Fork me on GitHub
Chris K06:10:49

trying to use compojure, hiccup, and cljs together but while I was able to make hiccup and clojure work together, I couldn't figure out how clojurescript would work with hiccup... I don't even know very much of how clojurescript works and can anyone forward me to some resource?


There's also #clojurescript which might be a good place to ask more specific questions related to ClojureScript

Jim Newton07:10:47

does anyone know of a clojure system named genus ? I need a clever and somewhat abstract name for a package which I intend to eventually publish. I dont want to take a name that already means something to someone. Naming is hard.

Chris K07:10:07

maybe u can search it on clojure toolbox?

Chris K07:10:32

@jimka.issy and no I couldn't find one named genus

Jim Newton07:10:36

I did a google search for clojure and genus and didn't find anything. I didn't specifically try clojure toolbox.

Jim Newton07:10:03

my other option is compositus not sure yet.


clojure libraries often follow naming convention taken from java (e.g. org.clojure/clojure) this is the way how to make your library name unique


most recent version of clojure cli even start warn developers about using unqualified lib names DEPRECATED: Libs must be qualified, change clj-http => clj-http/clj-http


I think if people want to be squeaky clean, and/or if you ask them how in Java and Clojure land to keep library/artifact names unique, they would agree that using reverse DNS names as a group, and a separate name as an artifact, is a good idea. There certainly are a heck of a lot of Clojure libraries that haven't bothered with the reverse DNS names, of course. I suspect that has more to do with expediency and/or lack of awareness than anyone advocating for the current state.

Jim Newton08:10:23

i suppose there are really two questions hidden in my question. 1) How do I conform to the correct semantics of naming so as to avoid name clashes? and 2) how to choose a name which is colloquially distinct? as per #2, i could certainly name my library spec with the appropriate reverse dns name. However, that would not be culturally compatible with clojure social community.

Jim Newton08:10:43

A part of DNS naming which I don't understand is where does the DNS path need to come from. If I use, for example, the name of my research institute, what should have if I change employer in the future? Would I need to fork and rename? Or do I really need to create a personal DNS independent from my location, employer etc?

Jim Newton08:10:26

a personal DNS is a bit hard to justify, being that I don't even have anything at the moment to publish


Yeah, spec would be a poor choice, even with the reverse DNS name as a group. Google searches for "clojure genus", or whatever project name you are interested in using, is certainly one good filter, as well as asking here if you are worried about it. Very rarely, things fall through the cracks, and someone renames a project as a result. At least, I've heard of that happening for libraries in other languages.


Personal DNS names are about $10/year, if I recall correctly.


At least, the uncontested ones are.


you do not need personal DNS to name your library


Agreed that it isn't a requirement, but neither is it a requirement to make a group id that is different than the name of the library.


for instance I can use me.delaguardo as a qualifier for my libs without actually paying for

Jim Newton07:10:18

that's also unfound in clojure toolbox

Chris K07:10:52

I don't no too much but I think u can change the name afterwards? not sure tho depends on how you develop it but if it is not on google or clojure-toolbox, then I think you should be fine

Chris K07:10:52

For compojure, I am trying to use jetty webserver as I've seen in practicalli's tutorial, and when I use the default compojure lein template, it uses ring server. I want to change it to jetty, can someone help me? like a code snippet would be greatly appreciated. (I tried code myself but none of them really worked)..


It’s for a Leiningen project, but apart from dependencies it works the same for Clojure CLI tools. Feel free to @ mention me or use the #practicalli channel for help

Chris K10:10:41

thanks a lot 😄


The compojure template does hide some details, I thought it did use jetty by default but the details are probably in one of the libraries its using.


I notice that when running lein ring uberjar to packing up a project created with lein new compojure todo-app it downloads the ring/ring-jetty-adapter library, so it seems that project its already using jetty, it just hides that fact under a few abstractions.

Chris K11:10:12

so I should basically be fine with the default condition the template is in?


Fine in that it is using jetty and you are happy using the lein ring xxx commands to run the server externally. I think the compojure template included wrap-reload as part of the wrap-defaults, so when running the server with lein ring server it should automatically reload any code changes that are called from the defroutes function and in the defroutes funciton itself. And if you want to package up the application, then ensure lein ring uberjar is used to generate the jar file, otherwise the jar file will not include the code that lein ring server automatically injects. I moved away from lein ring plugin a while ago, but its convenient for getting started.

Maurice Fingher08:10:40

I just installed lein, Clojure and Cursive on Windows 10 and was able to launch REPL. All right but what I'm looking for is Clojurescript with figwheel-main.

Maurice Fingher08:10:03

I tried using the template but could not install cli and lein doesn't understand "lein fig:build". Pretty sure that somebody had thesame problem, Am I right? Any clue ? Thanks.


This is a simple project that uses Leiningen and figwheel-main. The readme explains how the project was created and how to use it


Hi ! how can i optimize my clojure code for math operations or basically find out where type information can help ?


One good resource for Clojure performance in general is


If you are interested in arithmetic on Clojure on the JVM and want to use Java primitive types long and/or double wherever possible, this library might be helpful:


@U0CMVHBL2 ahh primitive math looks great. but this won’t work with clojurescript right ? i forgot mentioning a key detail, this code is intended to work with both clojure and clojurescript basically this is the library i intended to use it with quil (processing wrapper) on both clj and cljs, but the same algorithm when written in javascript is quite faster. is there a way to optimise for both clj and cljs @U04V15CAJ i’ll go through the link, thank you. (set! warn-on-reflection true)`` looks pretty useful and probably what i need


@U7W7M34UQ Also:

(set! *unchecked-math* :warn-on-boxed) 


I know almost nothing about trying to optimize ClojureScript or JavaScript. You could try asking in the #clojurescript channel.


I have a piece of code represented by class, not under my control and I want to give it a deref capability, similar to how Futures are treated in core. It seems that the only way to do it is write an adapter. There is no protocol to give it such capability adhoc. Is it a correct observation?


Correct, it needs to implement IDeref

👍 1

Hey folks! Need a little bit of beginner help with regads to sorting. I have the following structure {[2019 10] 21, [2020 9] 17} where format of each item is "[year month] amount". How best to sort this structure such that I have the latest "month" last?


BTW. This how I'm forming this if it helps.


(->> data (map #(assoc % :grouping [(:year %) (:month %)]))
       (group-by :grouping)
       (map (fn [[g t]]
              [g (->> t (map :amount) (reduce +))]))
       (into {})))


I'm currently looking at sorted-map for this. Am I on the right track?


(group-by (juxt :year :month)) is shorter 🙂


e.g. no need for the first map


Thanks @U47G49KHQ. Does that help with ensuring the order in the end?


what do you mean having latest month last?


sort by month, then by year?


you can use (into (sorted-map)) instead of (into {}) to sort by keys


By year then month. Sorry should have been more clear 🙂


so just (into (sorted-map)) then?


Cool tried that earlier. Didn't seem to work unfortunatly


user=> (->> data 
            (group-by (juxt :year :month)) 
            (map (juxt key #(->> % val (map :amount) (reduce +)))) 
            (into (sorted-map)))
{[2019 10] 21, [2020 9] 17}


hmm let me try again.


Ah that worked! Thanks @U47G49KHQ :) appreciate the assistance.


No problem :)


anyone know how to run codox from deps.edn clojure command line ?

Max Rothman16:10:20

What’s the idiomatic way to map a function into a nested collection? For example, in Haskell I’d do:

=> (map . map) (+ 1) [[1, 2], [3, 4]]
[[2, 3], [4, 5]]
The best I could come up with in clojure was:
user=> (((comp #(partial map %) #(partial map %)) inc) [[1 2][3 4]])
but that seems pretty ugly


I reach for Specter for these kind of things: (transform [ALL ALL] your-fn your-coll)


clojure.walk/post-replace is probably the best core option

Max Rothman17:10:22

How would you use that to apply a function to every element? AFAICT postwalk-replace only does value replacements


it walks every element


that's the whole point


oh, you might need postwalk if you're applying a function, sorry if that's what you were asking


like (clojure.walk/postwalk #(if (number? %) (inc %) %) the-data)

Max Rothman18:10:22

aha, that does it

Malik Kennedy19:10:22 I thought I knew how to load project-local .clj namespaces, but the errors tell me I'm missing something. (It was ~40 lines, IDK etiqutte about posting long posts vs pastebin)


what are you doing when hitting this error?

Malik Kennedy20:10:36

lein ring server

Malik Kennedy20:10:39

Weird part to me is in REPL evaluating (auth.views.login/login-view) gives me the map I want. But running as server it claims to not know where it is, either in a ns :require or as a fully qualified ns/fn


what's the entry of :source-paths in your project.clj?


(GET "/login" []
It is not good practice to reference namespaces without requiring them. Depending on the path through the code, you may end up trying to use that symbol reference before the ns it lives in has been loaded.


(I didn't see auth.views.login in the :require in auth.token -- although you did omit some of that from the paste)


your error message complained about looking for views/login.clj. How are you requiring that ns?

Malik Kennedy20:10:56

Required in ns declaration like so

   [auth.views.login :as login] ...) 
when I eval (ns ...) in repl I get
1. Unhandled
   Could not locate auth/views/login__init.class, auth/views/login.clj
   or auth/views/login.cljc on classpath.
whilst lein ring server errors out and points to line containing (auth.views.login/login) or (login/login)`
Syntax error (FileNotFoundException) compiling at (/tmp/form-init7302222187445651419.clj:1:73).
Could not locate auth/token__init.class, auth/token.clj or auth/token.cljc on classpath.


avoid lein ringer server for now and just start a repl. then at the repl try (require '[auth.views.login :as login]) this would keep it as simple as possible. if that works you should be good to go. if not, then lein ring server will be just more machinery obscuring what is going on


and can you tell me how you're starting the repl and from what directory?

Malik Kennedy20:10:33

$PROJECT_DIR/src/auth is where I'm running lein ring server and I start the repl from inside emacs daeomon with cider-jack-in


run it from the root directory


when using cider-jack-in did you try (at a fresh repl) (require '[auth.views.login :as login])?

Malik Kennedy20:10:16


(require '[auth.views.login :as login])            
1. Unhandled
   Could not locate auth/views/login__init.class, auth/views/login.clj
   or auth/views/login.cljc on classpath.

Malik Kennedy20:10:31

Run at $PROJECT_DIR has no difference afaict

Could not locate auth/token__init.class, auth/token.clj or auth/token.cljc on classpath.

Full report at:
Subprocess failed (exit code: 1)


the the login.clj file is located at PROJECT_ROOT/src/auth/views/login.clj?