morning
Good morning lovely people
Good morning
You can try this with a longer exposure time, if your camera allows for it.
Going down?
@lsolbach maybe next time 🙂
morning
Good Morning!
Wonder if it would be possible to implement an https://www.archunit.org/use-cases-like thing for Clojure using clj-kondo. 🤔 Perhaps by looking at namespace segments. Things like "`app.persistence.*` must not require app.service.*". Or maybe something like this already exists and I don't know about it...?
it's possible to do this based on clj-kondo analysis, but there's also a dedicated tool for this https://github.com/fabiodomingues/clj-depend which is also available in clojure-lsp
Thank you! I’ll take a look at clj-depend. 👍🏻
morning
Is there a nice way to get namespaced maps printed with all keys fully qualified instead of the short form? Evaluating a map with namespaced keys like
{:person/name "Fred" :person/age 50}
in my repl prints the following return value
#:person{:name "Fred", :age 50}
And the latter is really annoying to me.
I know how to change the behaviour with (set! *print-namespace-maps* false) and was hoping to use a leiningen profile with
:my-cool-profile-name {:repl-options {:init (set! *print-namespace-maps* false)}}
or similar, and the code does execute, but it doesn't take effect once the REPL is fully initialised - at that point, (= true *print-namespace-maps*) ;=>> true
And I thought to myself; these cool folks will have solved this problem already 😄From the docstring: "It defaults to false, but the REPL binds to true." -- so it is getting bound after :init executes, I suspect? Looks like there's no way to globally override it.
This snippet handled all but one specific kind of CIDER evaluation on an old project, as I recall
(defmethod print-method clojure.lang.IPersistentMap [m, ^java.io.Writer w]
(#'clojure.core/print-meta m w)
(#'clojure.core/print-map m #'clojure.core/pr-on w))Hmm, looking at the code in clojure.main, (init) should be called inside the REPL bindings so... but I don't know how Leiningen handles :init in :repl-options...
@daveliepmann That's part of the application code then, right? I think we could do (set! *print-namespace-maps* false) somewhere in the application code that is loaded on REPL startup, and I suppose it would work as well.
@seancorfield I think we're stuck with leiningen for a while yet 🙂
Thanks both 🙂
have you tried (alter-var-root #'*print-namespace-maps* (constantly false)) ?
in the init
edit: false
although what Sean referenced from the doc might overwrite that too
@reefersleep we stick that print-method override in user.clj and it works as expected
Ah, completely forgot about user.clj! Will try that, thank you
@imre it seems like a slightly different way to achieve the same result, like you say, but I'll try
Just out of curiosity, why do you find printing namespaced maps in short form annoying?
I'd be curious about that. I checked our codebase at work and we have 58 map literals that use the #:namespace{:key value ..} format so seeing thing printed the same way seems natural to me.
We (regrettably) have deeply nested, wide maps as our central business objects, and it's easy to lose your place when scrolling vertically and horizontally. The maps are all namespaced with what they are, which helps - except when you can't see the namespace on your screen. Better tools should be used for prodding these data structures, of course, but often, a print is what you have at hand.
Also, copy/pasting parts of maps doesn't work as you'd like
or as I'd like. 🙂
> parts of maps this is a real pain with namespace maps, you cannot just copy-paste a key-value-pair from it