Fork me on GitHub
#clojure
<
2023-01-05
>
emccue00:01:45

stupid question, but is "the algorithm" for tools.deps documented explicitly anywhere? I honestly don't remember if ive asked that before

andy.fingerhut00:01:02

You mean, in English prose as opposed to open source code?

andy.fingerhut00:01:20

Because I believe the code is open.

Alex Miller (Clojure team)00:01:25

Yes, there’s a page for it

emccue00:01:11

> You mean, in English prose as opposed to open source code? > Because I believe the code is open. Yep - been reading this file for a bit today https://github.com/clojure/tools.deps/blob/master/src/main/clojure/clojure/tools/deps.clj

Alex Miller (Clojure team)00:01:27

Assuming that’s what you’re asking about

Alex Miller (Clojure team)00:01:30

Looking at trace output can be pretty illuminating too in tandem with that page

skylize01:01:00

Alex also talks through the same in this talk. https://youtu.be/7CM7Ef-dPWQ

grav14:01:32

Anyone here using clj-yaml? I'm trying to get non-ordered maps out, but I'm not sure if it's at all possible using the API, or whether I need to do the conversion myself

grav14:01:08

There's not much mentioning about ordering in the docs, except for this doc-string: https://github.com/clj-commons/clj-yaml/blob/master/src/clojure/clj_yaml/core.clj#L27

lread17:01:32

Glad you sorted it out, there is also #C042XAQFCCU if you have more clj-yaml questions/thoughts.

🙏 2
Jordan Robinson14:01:16

Hey all, can anyone recommend a good library that does something similar to https://github.com/awaitility/awaitility does in Java/Scala?

grav14:01:17

A follow-up to my question about ordered maps would be: Is there a way to get unordered (regular) maps from a nested flatland-ordered map (https://github.com/clj-commons/ordered)?

grav14:01:26

Seems this does it

(->> (flatland.ordered.map/ordered-map 
       {:foo 42 
        :bar (flatland.ordered.map/ordered-map {:baz 43})})
     (clojure.walk/prewalk
       #(if (map? %) (into {} %) %)))

moe15:01:42

Live a little! throw a cond->> in there

grav15:01:55

@U04HK53G7SQ You mean #(cond->> % map? (into {}))?

moe15:01:04

I always thought there should be a condp->> which worked like that, but it'd have to be

#(cond->> % (map? %) (into {}))

👍 2
grav15:01:12

True! It definitely looks better with cond->>

grav15:01:55

There's a fif in our utils that's even neater: (prewalk (fif map? (partial into {})) m)

moe15:01:11

that looks scary!

moe15:01:34

function in function?

grav15:01:35

took some getting used to. now i love it

grav15:01:58

i think it's function-if, so "apply the function if predicate is true, else just return input"

moe15:01:00

function if function, i guess

grav15:01:13

would love to show the source, but it's probably copyrighted - it is however 4 lines only 😄

moe15:01:45

I'm sure I can reverse engineer it

🧑‍🔬 2
dpsutton23:01:51

Apparently we’ve had a namespace that required itself with an alias in https://github.com/metabase/metabase/blob/master/test/metabase/test/util.clj#L55 and that somehow wasn’t a problem. Kinda surprising. Apparently someone finally hit an issue with it when trying to reload all namespaces >

Circular dependency between metabase.test.util and metabase.test.util
Surprised this kind of thing makes sense in the first place.

dpsutton23:01:04

lol so is this perhaps a bug in tools.reload?

hiredman23:01:14

clojure's cyclic load checking isn't very complete or very strict, so its not uncommon for it to allow things that it shouldn't

dpsutton23:01:41

ah ok. i was thinking if the language doesn’t care, a library doesn’t get to complain, but that makes sense

hiredman23:01:02

in theory the cyclic load check allows self requiring to support the internals of how aot compilation works, but that loophole is large enough that any self require is allowed

dpsutton23:01:39

ok this explains it:

❯ clj
Clojure 1.11.1
user=> (ns foo (:require [foo :as f]))
Execution error (FileNotFoundException) at foo/eval138$loading (REPL:1).
Could not locate foo__init.class, foo.clj or foo.cljc on classpath.
foo=>
it loads from disk as a dep

dpsutton23:01:12

that makes me think this is indeed a bug in the reloading code? One no one will fix

hiredman23:01:31

it is slightly different if the ns starts as a file being loaded

dpsutton23:01:40

nah this is undefined behavior 100% i’m sure

dpsutton23:01:50

yeah. cool. thanks