This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-10-03
Channels
- # aleph (5)
- # announcements (4)
- # babashka (2)
- # beginners (52)
- # calva (13)
- # cider (60)
- # clj-kondo (91)
- # cljsrn (6)
- # clojure (93)
- # clojure-brasil (2)
- # clojure-dev (37)
- # clojure-europe (5)
- # clojure-italy (7)
- # clojure-nl (8)
- # clojure-norway (1)
- # clojure-sg (1)
- # clojure-spec (115)
- # clojure-uk (31)
- # clojurescript (32)
- # cursive (35)
- # data-science (4)
- # datascript (3)
- # datomic (29)
- # emacs (8)
- # events (1)
- # figwheel (1)
- # funcool (2)
- # graalvm (2)
- # joker (12)
- # kaocha (4)
- # lein-figwheel (1)
- # leiningen (34)
- # malli (7)
- # off-topic (4)
- # overtone (1)
- # parinfer (2)
- # pathom (5)
- # quil (1)
- # re-frame (12)
- # reagent (2)
- # shadow-cljs (7)
- # spacemacs (6)
- # sql (8)
- # tools-deps (63)
- # vim (24)
I'm running into a problem where an implementation of a method that I expect to be found is not being found....
No implementation of method: :clj->avro of protocol:
#'jackdaw.serdes.avro/SchemaCoercion found for class:
jackdaw.serdes.avro.StringType
I expect the code below to provide that method but even when I evaluate it immediately before running a test that requires it, I run into the error above.
(defrecord StringType []
SchemaCoercion
(match-clj? [_ x] (string? x))
(match-avro? [_ x] (instance? CharSequence x))
(avro->clj [_ x] (str x))
(clj->avro [this x path]
(validate-clj! this x path "string")
x))
I've had this kind of problem before when dealing with code that uses multi-methods and it's always very difficult to debug. In the past it's been due to recompiling an upstream lib (e.g. with some additional logging), then trying to run some code that uses it, and needing to recompile some other code that I guess has been invalidated by recompiling the lib.
That might be the problem here but it's always difficult to identify exactly what needs to be recompiled and was wondered if anyone else had these kind of problems and had figured out a good way of debugging them.have you seen https://github.com/clojure/tools.namespace? It makes sure to reload all dependent namespaces when you change a namespace
Yeah I've been playing around with that this morning. It seems to introduce other problems (or more likely highlight tech debt in the code-base I'm working in) but it is helping.... Thanks for the link.
I’ve had this issue with protocols & records as well… it’s pretty frustrating. My understanding is that this happens when the protocol gets recompiled, but the record doesn’t, and so Clojure doesn’t see the record as implementing the “new” protocol, only the “old” one
I believe this JIRA issue is related - https://clojure.atlassian.net/browse/CLJ-2073#issue-tabs
That issue is related to AOT’d code, but I think results from the same underlying dynamics of protocols…
don’t quote me on that 😅
a common problem is for instances of the old record (which may for example be implementing the old protocol) to be left hanging around, you can have two Classes with the same name and package but unrelated implementations (and that's what you can get if you reload incompletely and leave old instances hanging around)
Yeah, that’s exactly what happens
Thanks for clarifying that
Is there a way to require a github project in leiningen project.clj ? I have a dependency of [gg4clj "0.1.0"] (a r wrapper) - this dependency is no longer working. And there is a fix out there but they didn't push a maven repo https://github.com/quan-nh/gg4clj What is the normal way of resolving this?
it's 0.1.0 in project.clj which is rather weird, so perhaps better to change that manually to 0.2.0-SNAPSHOT
or something like that?
the new version will just be the name of the jar installed in the local repo which you don't need to care about at all (usually)
Thanks @U06BE1L6T
@hoertlehner There are two alternative solutions: - https://lambdaisland.com/blog/2017-05-17-loading-clojure-libraries-directly-from-github - https://github.com/RickMoynihan/lein-tools-deps Not sure how well the latter works. I've used the first one a couple of times.
@U04V15CAJ Thanks! I will try this out also!
doesn't matter if you publish it under your org, for example com.github.andy27/gg4clj.
tools.deps is more geared towards using deps directly from git, so you could also consider using that
I get it that it does not fuck up other libraries; however I can only tell from my own experience that I spend A LOT of time to find out which fork is the best one to use. And by putting everything on clojars, it does not make it easier for a developer to find the best dependencies. What is missing really are "suggested dependencies"
as an aside this "I spend A LOT of time to find out which fork is the best one to use" is maybe an issue someone should file at clojars to think about. Might be useful to have someone think about this top-down.
Guys, i need to write user acess to certain views of my application. Do you know some library or how to create a acess level function in re-frame?
@UNZALKY4V https://github.com/cemerick/friend or https://funcool.github.io/buddy-core/latest/?
Thank you
Is there a way to configure printing of the full stack trace by default at the REPL in clojure 1.10?
i.e. to get the same printing as this clojure --report stderr -e '(throw (ex-info "foo" {}))'
but via clojure --report stderr -r
it seems there isn’t an option to do that
obvs can access *e
or use a different repl I suppose
Defining your own REPL interaction function is certainly one way -- I cannot think of another off hand. At least in one Stuart Halloway talk he demonstrated this, and it looked pretty straightforward.
His REPL-driven development talk has some info on the topic: https://github.com/matthiasn/talk-transcripts/blob/master/Halloway_Stuart/REPLDrivenDevelopment.md
the default repl has never done this (and personally I think you rarely want it)
but yes, you can start your own repl with whatever exception handler you want
i imported something :as d
and then realized i needed a different ns :as d
. What's the best way to override it?
the best way is to use clojure.tools.namespace.repl
which manages these for you 🙂
I just (refresh)
and the aliases are swapped cleanly
but if you look at the namespace related functions one of them is for removing aliases I believe
Is it possible to make mixed clojure java projects with a deps.edn? Similar to the java-source-paths in leiningen?
TL;DR: no.
Clojure can be run from source. Java requires a specific javac
compilation step. So you either need to manually compile the .java
files to .class
on your classpath, and then run clj
, or you need to put the (compiled) Java code in its own artifact to be depended on by deps.edn
.
(in theory you could use the clj -e
option to shell out to run javac
and then combine steps via aliases but that feels a bit of a hack)
How could I import the generated class in the target path in a clj namespace? Simple using the package name doesn't work.
@danielgrosse Is that "target path" on your classpath when you start clj
?
It needs to be included in :paths
(or :extra-paths
if you're only adding it via aliases you use when running clj
).
@danielgrosse Here's a quick example I just knocked up to illustrate this https://github.com/seancorfield/java-clojure-example
You only need -A:compile
when the Java code changes (or when you're starting off). clj -m my.main
will run the main program on subsequent runs.
Note that if you run clj -A:compile
on its own, it will "hang" for 60 seconds waiting for agents to shutdown -- that's expected but perhaps a bit annoying. If you run clj -A:compile -m my.main
then running the main program will shutdown the agents and it will exit immediately.
Hope it helps.
Thanks for the effort. I solved it already by adding the class path to the src file. Was just for a POC.
I have a map of vecs {:series-a [1 2 3] :series-b [4 5 6]}. In order to do pretty-print-table I need to convert it to a vec of maps [ {:series-a 1 :series-b 4} {:series-a 2 :series-b 5} {:series-a 3 :series-b 6} ]. I know that I can map simultaneously over multiple vecs, but I guess I have to apply the keys to that. Does someone know how to do that? I seem not to be able to do that.
Is it reasonable to assume that all values in the map are vectors, and they all have the same length as each other?
@andy.fingerhut you just got a shoutout for rrb vector on Apropos https://www.youtube.com/watch?v=PzyUpvTwu7I
Cool. I see from some comments that I am not the only one that hears choppy audio.
@hoertlehner Here is a function that gets part of the way there. Ask again if you would like help completing it from there:
(def m1 {:series-a [1 2 3] :series-b [4 5 6]})
(defn all-nths [m idx]
(into {} (for [[k vector-val] m]
[k (vector-val idx)])))
(all-nths m1 0)
;; {:series-a 1, :series-b 4}
(all-nths m1 1)
;; {:series-a 2, :series-b 5}
(defn pp-flip [m] (let [first-series (first (vals m)) size (count first-series) one-row (fn [i] (all-nths m i)) row-idx (range size) ] (vec (map one-row row-idx)) ))
Understood. Best to try taking it in small pieces, e.g. take that function all-nths and see if you understand exactly what it is doing, and why. There are things in there like for
to loop over all key/value pairs in a map, producing a different key/value pair as a vector of two elements, then sending the result to (into {} ...)
to create a map from that sequence of pairs, that are very generally useful in many situations.
It's I do understand your code. No problem with that. But when I try to do it myself, I read clojure docs, and find that the docuentation is very compact. One really has to know how things work in order to come up with an idea how to do it.
Thanks @andy.fingerhut
does anyone know of something in the clojure ecosystem like an interactive editor that error checks edn input and provides autocomplete according to a schema? (prismatic or spec). I have some complex declarative edn configuration and would love a tool that validates and suggests as someone is building up the config (like the way an IDE interacts with a developer as you write code or writing an xml file with a well defined xsd)
Maybe something implementing Language Server Protocol ?
I have no idea, but I wonder whether Hyperfiddle might be somewhere in the neighborhood of what you are asking about (and when I say neighborhood, I simply mean "may have some related functionality, but maybe not")
Thanks. I'll take a peek. Might fool around with edamame (https://github.com/borkdude/edamame) and lsp. I'll report back if I get something working
pathom
autocompletes queries based on it's indexes. You might wanna check that out for reference. Does it for codemirror though...
https://cljdoc.org/d/com.wsscode/pathom-viz/1.0.2/api/com.wsscode.pathom.viz.codemirror