clojure-spec

misha 2021-12-26T13:09:51.289200Z

@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) 2021-12-26T13:30:23.290Z

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

misha 2021-12-26T13:32:08.290600Z

good point!

Alex Miller (Clojure team) 2021-12-26T13:32:38.291400Z

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

misha 2021-12-26T13:37:20.293100Z

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) 2021-12-26T13:45:39.293600Z

The path is the whole point

👍 1
bortexz 2021-12-26T22:46:52.295400Z

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

bortexz 2021-12-27T09:14:15.295800Z

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

2021-12-27T01:27:18.295500Z

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).