clojure-spec

About: http://clojure.org/about/spec Guide: http://clojure.org/guides/spec API: https://clojure.github.io/spec.alpha/clojure.spec.alpha-api.html
2021-06-11T05:55:58.076200Z

Mongodb is storing data as json. So you probably need to have some sort of convention how to encode qualified keywords to/from json

vlaaad 2021-06-11T17:41:58.076900Z

a bit surprising:

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

alexmiller 2021-06-11T17:45:12.077300Z

what is that even supposed to mean?

alexmiller 2021-06-11T17:46:37.077800Z

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

vlaaad 2021-06-11T17:50:52.078500Z

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

vlaaad 2021-06-11T17:53:51.079700Z

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

borkdude 2021-06-11T17:54:09.080100Z

spec needs a spec? ;)

vlaaad 2021-06-11T17:55:44.081Z

less surprising:

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

borkdude 2021-06-11T17:56:21.081300Z

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

vlaaad 2021-06-11T17:56:46.081500Z

"spec forms"

borkdude 2021-06-11T17:57:05.082100Z

something cljfx related?

vlaaad 2021-06-11T17:58:01.083Z

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.

1
vlaaad 2021-06-11T18:01:07.083900Z

...and the form resembles the data

borkdude 2021-06-11T18:02:31.084200Z

so it's way to visualize a spec form?

vlaaad 2021-06-11T18:06:37.087700Z

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

alexmiller 2021-06-11T18:06:49.088Z

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

alexmiller 2021-06-11T18:07:28.088400Z

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

borkdude 2021-06-11T18:08:18.089200Z

what's the 2-version of triple?

alexmiller 2021-06-11T18:08:36.089400Z

duple?

vlaaad 2021-06-11T18:08:44.089900Z

map-entry?

alexmiller 2021-06-11T18:08:47.090100Z

pair is commonly used though :)

borkdude 2021-06-11T18:08:48.090200Z

duple-blob

borkdude 2021-06-11T18:09:11.090500Z

duple-flock

borkdude 2021-06-11T18:09:24.090800Z

solved? ;)

alexmiller 2021-06-11T18:09:54.091200Z

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

vlaaad 2021-06-11T18:10:02.091500Z

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

vlaaad 2021-06-11T18:10:36.092500Z

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

alexmiller 2021-06-11T18:11:01.093Z

I think that may be vestigial from earlier impls