Fork me on GitHub

Hi, I'm having some issues with resolving dependencies. Maybe this is common? I have 2 Libraries, A and B, And 1 application, C. A is required by B, B is required by C. A's classpath doesn't get added to application C. Resulting in the following error: Could not locate A/core__init.class I can resolve this by adding A to C's project.clj dependencies. However C isn't using A directly, so it doesn't make sense to me that I have to add A. Any ideas?


Is A a "provided" dependency of B? Also lein deps :tree may give some hints as to what's going on.


It's not provided, it's a direct dependency. I tried to also include it in provided but both didn't work. Could be related to the fact that B is a private repo included through git


Hmm yeah I'm not familiar with git-down but a brief scan of docs suggests that it effectively means that B is being physically included in the source for C? If so, how are the dependencies for B being included?


i.e. is it possible that leiningen just isn't processing the project.clj for B at all? (In which case, none of the transitive dependencies - including those of A - would be loaded.)


Yeah that's what I'm suspecting. I'm pretty sure this is a git-down related issue. I'll have to look more into that. Thanks

👍 4

Are you using Leiningen? something else?


Is B published somewhere publicly, like Maven central or Clojars, or is it something private to you and/or your organization?


Reading again, you mention a project.clj file, so that means yes for your using Leiningen. Perhaps however B was published as a JAR file does not correctly define A as something that B depends upon?


A is public, B is private organization repo that we include through git-down. Maybe that's the problem.

Hiroyuki K.13:03:32

Hello, everyone. I'm looking for a mate who can help me on my business. I'm willing to pay monthly. Budget would be 500 ~ 2000USD. Please DM me. Thank you.


getting a dependency exception like this when trying to include clojupyter in my project

Caused by: clojure.lang.ExceptionInfo: Insufficient `com.taoensso/encore` version, you may have a dependency conflict: see  for solutions. {:min-version "2.105.0", :your-version "2.91.0"}
	at taoensso.encore$assert_min_encore_version.invokeStatic(encore.clj:1007)
	at taoensso.encore$assert_min_encore_version.invoke(encore.clj:998)
is there a standard way to resolve issues like this using clj deps? The naive solution of just adding com.taoensso/encore {:mvn/version 2.105.0} to deps.edn doesn't seem to be working

Alex Miller (Clojure team)15:03:35

you need quotes around 2.105.0


still doesn’t work

Alex Miller (Clojure team)16:03:25

can you share full deps.edn and your output

Alex Miller (Clojure team)16:03:48

"doesn't work" is not useful


see error message i put quotes when I tried it the first time

Alex Miller (Clojure team)17:03:26

is that commented line what you were trying? if so, that's not correct deps.edn syntax

Alex Miller (Clojure team)17:03:13

override-deps only go in aliases, but I think you actually want that in your normal deps so it overrides the transitive version

👍 4
Alex Miller (Clojure team)17:03:40

so just include com.taoensso/encore {:mvn/version "2.119.0"} in your :deps


in case anyone finds this via google the correct answer in exclude sente as it appears to be incompatible with clojupyter


Is the a good log analysis library in Clojure? I need to extract structured info from unstructured log lines. RegEx is helpful, but I also need to maintain context from previous line. For example, 1) Starting upgrade of node X 2) Container A upgraded successfully 3) Container B upgrade failed Now I need to output, {:node "X" :success ["A"] :failure ["B"]} What would be your approach to this?


is this a standard log format or something of your own?


Our own. But changing the logs now might break things elsewhere.


well I don't really have any good ideas sorry. if it were me I'd be tempted to look at instaparse

☝️ 4

My inclination would be to look into using Instaparse to write a parser that will convert each individual log entry into a useful hashmap, and then run some kind of aggregator function over all the hashmaps.

Grigory Shepelev16:03:41

Hello. I'm continuing digging deeper into Clojure and I don't quite understand definterface from official documentation. Could you give some more examples please?


Perhaps the examples from clojuredocs help?

Grigory Shepelev16:03:19

yeah. I saw. I don't understand them.


are you familiar with java and java interfaces?

Grigory Shepelev16:03:44

Nope. I came from Haskell. I'm looking for a way to specify function's return (type?). Spec is basiclly for checking the argument themself.

Grigory Shepelev16:03:26

It seems like definterface "acts" on Records

Grigory Shepelev16:03:01

Is there any way to to that?

Grigory Shepelev16:03:00

Like: saying what expected from function to be result. And if it's not what's exprcted — throw and error with an explanation.

Grigory Shepelev16:03:55

Or I can have the same by using spec inside the function's body? :thinking_face:


sorry got distracted. you'll need to read up on and understand java interfaces to understand definterface

Grigory Shepelev16:03:25

My patters of thinking are somewhat locked on static type systems...


interfaces are very much a static type system thing


I'm trying to remember my haskell to give you the right analogy but it's been so long


typeclass, that's it. an interface is java's equivalent of a typeclass. but of course much more limited/less static than haskell


Also called trait in some languages.


as an aside: in 10ish years of using clojure I don't think I've ever used definterface


It will be needed though when you want Java developers to also use your Clojure library.


Hey, I am playing around with datafy/nav and rebl.


(require '[clojure.datafy :as d])
(require '[clojure.core.protocols :as p])
(defrecord D [a b]
  (d/datafy [this]
    (-> (into {}
              (map (fn [[k v]] [k (if (instance? D v) '=> v)]))
        (assoc :type "D")))
  (d/nav [this k v]
    (get this k)))


I am wondering why the following doesn't let me see the nested D's in REBL. (D. 1 (D. 2 (D. 3 5)))


I mean why can't navigate into them.

David Pham17:03:47

Is it possible to require different namespace depending on your build? Like if I want to build :a with lein it will require namespace foo, but if I build :b it will require namespace bar?


it's possible, I can't think of a situation where I'd recommend it. what's brought this about?


my first reaction is "create a protocol/multimethod and inject the dependency instead" btw

David Pham20:03:08

In the case of CLJS with React Native and React. I would like to abstract the UI layer and have different implementations of component depending on the target.


yeah a protocol/multimethod/passed-in-function is the appropriate way to create an abstraction, not namespaces

David Pham06:03:13

In this case the build should be passed to all functions?

David Pham06:03:34

Or you would initiate the closures at the beginning of the programs?


I would build your protocol implementing or multimethod dispatching object at whatever time you first know which to choose (which is probably start up) and then pass it down through each function as a parameter

sol sarratea20:03:03

hey! I am trying to build an app with overtone + reagent+ figwheel + ajax , but I am having lots of troubles with dependencies. Is anybody interesting in maybe generating a template for building this kind of apps? or just wanna help me with this particular project 🙂 ?

Michael Thurmond20:03:31

what command did you run from the command line to create the project?

sol sarratea20:03:56

I tried to start building by myself, but have problems connecting my server with clojurescript/figwheel server

sol sarratea20:03:01

so i run lein new reagent-ajax ...

sol sarratea20:03:15

which has a nice template, but dependencies are killing me

sol sarratea20:03:23

i tried to fix it with lein tree :deps

sol sarratea20:03:35

but did not work

Michaël Salihi20:03:11

> which has a nice template, but dependencies are killing me @mssarratea Did you try with Shadow-CLJS instead Lein/Figwheel ? For me when I begin last year, it was more clear and simplier.

sol sarratea21:03:02

I did not figure out how to set the server port, so to connect it with my backend clojure app

sol sarratea21:03:28

have you been through the same? can I see your code 🙃

Michaël Salihi15:03:52

Do you tried to communicate with your Clojure backend with AJAX from CLJS Reagent right ? Any information about your backend ? REST API ? Another ?

Adrian Smith21:03:38

lein new re-frame is a nice template, might be worth doing that to get reagent/shadowcljs setup then remove re-frame if not needed


Say I want to return a value in a certain scenario, but just log an error and return nil (log function just returns nil) in another, is this weird?

(if good?
 (log-err "No good!))


imo fine

👍 4

How would you tranform

{:x [1 2 3]
 :y [4 5 6]}
[{:x 1 :y 4}
 {:x 2 :y 5}
 {:x 3 :y 6}]


Multi-arity map:

(let [old-data {:x [1 2 3]
                  :y [4 5 6]}]
    (map (fn [x y]
           {:x x :y y})
         (:x old-data)
         (:y old-data)))
  ;; => ({:x 1, :y 4} {:x 2, :y 5} {:x 3, :y 6})


erm, map is going to be better actually

Pavel Klavík23:03:22

ya, use map, it allows to take multiple sequences as arguments

Pavel Klavík23:03:19

something like

(let [{:keys [x y]} input]
  (into [] (map (fn [xval yval] {:x xval :y yval}) x y)))


Thanks, got stuck in reduce land


I'm trying to have this work for arbitrary keys, but guaranteed values have the same number of elements, I've got this far, missing

(def m {:x [1 2 3]
          :y [4 5 6]
          :z [7 8 9]
          :ab [10 11 12]})
  (let [ks (keys m)
        vs (vals m)]
    (map #(zipmap ks %) vs)


;=> ({:x 1, :y 2, :z 3} {:x 4, :y 5, :z 6} {:x 7, :y 8, :z 9} {:x 10, :y 11, :z 12})


(let [ks (keys m)] (into [] (apply map #(zipmap ks %) (vals m))))


you forgot the apply


it's a join


and I forgot the &

(let [ks (keys m)]
  (into [] (apply map #(zipmap ks %&) (vals m))))
[{:x 1, :y 4, :z 7, :ab 10} {:x 2, :y 5, :z 8, :ab 11} {:x 3, :y 6, :z 9, :ab 12}]


(let [m {:x [1 2 3]
         :y [4 5 6]
         :z [23 19 34]}]
   (fn [a b]
     (clojure.set/join a b {:nth :nth}))
   (for [k (keys m)]
      #(assoc %2 :nth %1)
      (for [item (k m)]
        {k item})))))

;;=> #{{:x 3, :nth 2, :y 6, :z 34} {:x 1, :nth 0, :y 4, :z 23} {:x 2, :nth 1, :y 5, :z 19}}

👍 4

I did want the nth next, so thanks!