Fork me on GitHub
#clojure-spec
<
2021-12-26
>
misha13:12:51

@alexmiller greetings! https://github.com/clojure/core.specs.alpha/commit/938c0a9725a284095baa2387dff1a29c3f1e26ac I wonder, why not just do?

(s/or ::local-name       ::local-name
        ::seq-binding-form ::seq-binding-form
        ::map-binding-form ::map-binding-form
Had to port some code leveraging core.specs from 1.10 to 1.9 due to these. I get the "alpha" status and all. But the question above is a general one. I'd assume dispatch keywords are as part of a spec as the spec name itself, since it is not wild to assume there would be a bunch of code dependent on conformed values, eventually. Why not use the same qualified keys where available (sans e.g. inline specs)? Is there any specific reason or unobvious consequence? Thanks!

Alex Miller (Clojure team)13:12:23

We wanted to make path names better as they show up in error messages

misha13:12:08

good point!

Alex Miller (Clojure team)13:12:38

Generally we don't use qualified names for paths as they are contextual in the parent spec

misha13:12:20

I can see how it often applies to regex specs. For most or specs I found :: way more suitable. Sans the ugly unreadable path, ofc.

Alex Miller (Clojure team)13:12:39

The path is the whole point

👍 1
bortexz22:12:52

I would like to spec a coll-of maps that is sorted on a specific keyword, is there a simple way to do this?

colinkahn01:12:18

Something like (s/and (s/coll-of map?) #(apply <= (map :some-kw %))) perhaps (tested using CLJS so not sure if Java can compare using <= on strings).

bortexz09:12:15

I was trying to avoid the custom predicate, but I guess there’s no other way, thanks!