Fork me on GitHub
#clojure-spec
<
2021-06-11
>
vlaaad17:06:58

a bit surprising:

(s/valid? (s/map-of keyword? int? :kind vector?) [[:a 1]])
=> true

Alex Miller (Clojure team)17:06:12

what is that even supposed to mean?

Alex Miller (Clojure team)17:06:37

seems like it's doing exactly what the docstring says to me

vlaaad17:06:52

I don't know what that's supposed to mean, I'm trying to build a tool on top of spec and I have to support what it supports

vlaaad17:06:51

I'll probably ignore this particular thing... I just was trying to understand what kind of data shapes various variations of s/every support.

borkdude17:06:09

spec needs a spec? ;)

vlaaad17:06:44

less surprising:

(s/valid? (s/every-kv keyword? int?) #{[:a 1]})
=> true
every-kv docstring states it works on associative collections...

borkdude17:06:21

what kind of tool are you building, or is it secret?

vlaaad17:06:46

"spec forms"

borkdude17:06:05

something cljfx related?

vlaaad17:06:01

It's a reveal plugin that builds a UI form for a given spec. Then you can fill the form to get back the data in the shape that satisfies the spec.

clojure-spin 2
vlaaad18:06:07

...and the form resembles the data

borkdude18:06:31

so it's way to visualize a spec form?

vlaaad18:06:37

More than that. You can bind changes in form to custom code and custom views. For example, if you have spec for vega/vega-lite data format, you can have a UI form for creating vega chart input and a vega chart itself that updates on changes to the form. This allows learning and experimenting with data-driven APIs interactively

Alex Miller (Clojure team)18:06:49

every-kv is really about "seqs to map entries", but we have no way to say that in Clojure (yet)

Alex Miller (Clojure team)18:06:28

Rich and I have been talking about that gap for years, some day we'll figure it out :)

borkdude18:06:18

what's the 2-version of triple?

vlaaad18:06:44

map-entry?

Alex Miller (Clojure team)18:06:47

pair is commonly used though :)

borkdude18:06:11

duple-flock

Alex Miller (Clojure team)18:06:54

the "seqs to" part is the hard part :)

vlaaad18:06:02

btw I think every-kv is fine, I'd expect it to accept any coll

vlaaad18:06:36

but maybe the docstring shouldn't mention associative...

Alex Miller (Clojure team)18:06:01

I think that may be vestigial from earlier impls