This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-10-17
Channels
- # announcements (3)
- # babashka (3)
- # beginners (53)
- # biff (2)
- # calva (16)
- # cider (1)
- # clj-commons (1)
- # clj-kondo (97)
- # clj-on-windows (137)
- # clojure (49)
- # clojure-europe (63)
- # clojure-gamedev (1)
- # clojure-nl (2)
- # clojure-norway (50)
- # clojure-uk (4)
- # clojurescript (36)
- # core-async (28)
- # datomic (32)
- # emacs (22)
- # events (1)
- # graalvm (8)
- # honeysql (6)
- # jobs (2)
- # lambdaisland (5)
- # malli (6)
- # nbb (31)
- # off-topic (171)
- # pathom (14)
- # rdf (2)
- # reitit (4)
- # releases (2)
- # scittle (19)
- # shadow-cljs (46)
- # sql (6)
- # squint (6)
Is there a tool to collect all license notices from dependencies in deps.edn
?
I vaguely recall a recent discussion around that, but this is the closest I can find: https://github.com/metabase/metabase/blob/master/bin/build-mb/src/build/licenses.clj
Thanks!
clj -X:deps list
will give you a list of libs and licenses in the path
but not the actual licenses themselves, depending what you need
Amazing, did not know this exists! Thanks for the hint, I will use the license-info
function in my custom tooling
For those who adopted line-associative? true
, how do you reason about differences in maps and let bindings from github diff?
For example, changing from
{ :a "a"
:b "b"}
to
{ :a "a"
:b "b"
:complicated-stuff "abcdefg"}
and applying the line-associative? true
rule renders below, taking the unchanged values a and b into the diff content.
{ :a "a"
:b "b"
:complicated-stuff "abcdefg"}
Yeah, I wish there was a way to enable it by default without a user-script that just redirects you to a URL with w=1
. :)
Also, for local compares, I find https://github.com/Wilfred/difftastic pretty sweet.
Is there a way to avoid getting the "whitespace" commas when printing a map:
(pr-str {:a "a" :b "B"})
=> "{:a \"a\", :b \"B\"}"
;; ^ this
Thanks for the link... so would you recommend something like:
(defn print-prefix-map-without-commas
...
(with-redef [clojure.core/print-prefix-map print-prefix-map-without-commas]
(do-my-stuff-that-doesn't-like-commas
with-redefs
is not thread-safe. If that's alright for you, then sure.
But zprint
should work in either case, although I haven't used it myself.
Thread safety is not going to be an issue for me... I might look into zprint later, since it seems to be supporting cljs just fine
Hi, we’re seeing some slightly surprising behaviour out of into
in Clojure 1.11.x:
We’re trying to create a vector by using (into [] xf coll)
, in Clojure 1.10.3 this returned a vector as expected, in Clojure 1.11.x this is returning an ITransientVector
- seemingly because persistent!
is now never being called by into
(the single arity call to rf
is never called).
This seems due to this change to support halt-when
in Clojure 1.11.0:
https://clojure.atlassian.net/browse/CLJ-2556
I was wondering if we’re now expected to call persistent!
in user-land code, or are we doing something wrong here with this call?
It works fine when calling (transduce xf conj coll)
so we’ve just switched to that call instead, but wanted to understand the change from a users perspective
When reporting a problem like this, a full repro would help. E.g. I can't reproduce your problem by trying a bunch of things:
Clojure 1.11.0
user=> (into [] (map identity) [1 2 3])
[1 2 3]
user=> (into [] (map identity) (list 1 2 3))
[1 2 3]
OK thanks, I was reporting for a colleague - I’ll get the transducer code to share
(defn chunks-xf [max-chunk-size]
(fn [xf]
(let [chunk (volatile! ::none)]
(fn
([] (xf))
([result]
;; flush what ever is left in chunk
(let [final @chunk]
(if (not= final ::none)
(xf result final)
(xf result))))
([result input]
(cond
(= @chunk ::none)
(do (vreset! chunk input)
result)
(<= (+ (count @chunk) (count input)) max-chunk-size)
(do
(vreset! chunk (str @chunk input))
result)
:else
(let [prev @chunk]
(vreset! chunk input)
(xf result prev))))))))
(into [] (chunks-xf 100) ["sentence 1", "sentence 2"])]
#object[clojure.lang.PersistentVector$TransientVector 0x149b4f84 "clojure.lang.PersistentVector$TransientVector@149b4f84"]
hmm, looks like we should probably be calling (xf result)
in all terminal cases, so this is probably a bug in our existing code
bug on our side,
needed to call (rf (rf result final)
in our reducing function or we missed the last element, and didn’t call the reducing function with 1 arity
thanks for looking!
unrelated but why not use (comp (partition-all 100) (map clojure.string/join))
? you're bulding a lot of intermediate strings there
Yer I'm aware of this - came across this when upgrading an existing project and haven't seen the code before
I have a question about conditional reader macros. When I run this code it runs on babashka fine but I get an error when I run it with JVM Clojure:
(ns my-ns
#?(:bb (:import java.util.Date)
:clj (:import java.time.ZoneId
java.util.Date
java.time.temporal.WeekFields)))
The error is not about the classes but it's about that I can't use the conditional reader:
Conditional read not allowed
What does it mean? I can't use the reader macros anymore? 😮Oh riiiight
I needed WeekFields via JVM but I wasn't going to use this code in babashka. It simply was part of the namespace that was included. So I wanted to exclude it. Edit: I wanted to exclude it because it was crashing.
I have namespaced data I'm passing to a function, such as
{:a/something :value b/something :value}
How would I go about getting each of the namespaces a
and b
as vars?
Something like:
(defn my-fn [{:keys [a b}])
doesn't work, clearly, but when googling all I find is :a/keys [something ...]
which requires me to manually specify the names, but I'd like to get whatever is assigned to that namespace.you can call namespace
on the keys themselves to get the namespace portion:
(comment
(namespace :a/my)
(let [val {:a/my-a-val "hi" :b/some-key "bye"}
ks (keys val)]
(map namespace ks)))
Yeah, there's no shortcut for it, you gotta type it all out:
(defn f [args]
(let [by-ns (fn [ns]
(into {}
(filter #(= (name ns) (namespace (key %))))
args))
a-args (by-ns :a)
b-args (by-ns :b)]
...))
I'd be concerned about why you'd be passing data to a function that didn't know what keys it needed to pull out...?
Hmm. It's unfortunate then that there's no straight forward way. I'm using this to sort-of "categorize" my data, thinking that's exactly what namespaces are for, so that I could pass the whole of a
to one place, and b
to another, with those places then having to care about specific destructuring, while my "middle man" would not.
Unless that "middle man" cares about all the kvs, I'd probably go with {:a {...}, :b {...}}
instead.
if you're wanting different fns to handle things differently depending on which key namespaces are being passed, perhaps use a defmulti
where the selector does something like (fn [m] (-> m keys first namespace))
, then each defmethod
would handle the the implementation for that keyspace
of course that's super naive, may be entirely not what you're looking for, just a thought
Let the “middle man” just pass the whole map as an opaque data structure, and let the downstream functions pick out (destructure) the values they need from the map.
Hey folks! I was wondering if anyone has a OpenApi 3 -> clojure HTTP client converter to recommend.
The https://github.com/OpenAPITools/openapi-generator/blob/master/docs/generators/clojure.md is lacking some features and I haven't found others (yet). Bonus points if it is compatible with httpkit
(and babashka)
You might want to look at https://github.com/oliyh/martian
Yep, thanks I saw that but unfortunately I don't think it supports OpenApi 3
I am not sure that martian
supports all of OpenAPI 3, but I am using it currently with OpenAPI 3.0.2 specs.
@U0AT6MBUL oh cool, that's good news, I'll try it out then