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
danm 2021-04-23T10:29:24.095500Z

Yeah, that's what we've ended up doing. Ta 🙂

Alex Whitt 2021-04-23T15:48:02.096800Z

in spec-alpha-2, will selects be composable? Assuming the answer is "yes," what does that look like?

👀 1
alexmiller 2021-04-23T16:22:53.097800Z

I think the answer will be no, actually, but it depends what you mean. which part are you looking to compose?

Aron 2021-04-23T16:24:54.099100Z

Personally, on the frontend the concept of static views that can define a select from the global state of the UI, then combining all of these into a single one for the whole of the UI?

Alex Whitt 2021-04-23T16:29:26.101700Z

We have a data structure that is going to accumulate keys as it moves through our system. To model that, it would make sense to have a selection for "phase 1," then a "phase 2" that takes phase 1 and adds a few keys, and a phase 3 that builds on phase 2, and so on. It would be nice to keep that DRY. (Actually we have a data model DSL that generates our specs, so we could always do the composition at that layer, but I wanted to know what spec-2 was planning on supporting.)

Alex Whitt 2021-04-23T16:32:29.102100Z

I guess I should've phrased my question as "are selections mergeable"

alexmiller 2021-04-23T16:46:52.102700Z

I think that's a very interesting and unresolved question

alexmiller 2021-04-23T16:48:40.104700Z

it depends somewhat on whether you see merge as an operation that produces an intersectional spec or whether it acts as parallel filters through which a value must pass (which is closer to how it's implemented)

Alex Whitt 2021-04-23T16:49:14.105400Z

Wouldn't the first option be better for generation?

alexmiller 2021-04-23T16:49:16.105500Z

certainly the latter seems doable

borkdude 2021-04-23T16:49:21.105700Z

are the args to select dynamic, i.e. can you merge those programmatically?

alexmiller 2021-04-23T16:49:57.106600Z

for generation, this is not that different than s/and in that you need to generate something that "passes" both specs but it's probably more challenging here

Aron 2021-04-23T16:50:22.107400Z

I remember having serious issues with json-schema based validation because json-schema can be async, that is remotely resolved, and circular

alexmiller 2021-04-23T16:50:29.107600Z

in spec 2, all of the spec can be passed as data which makes it amenable to merging the specification as data

👍 1
Aron 2021-04-23T16:50:49.108200Z

So merging there was only possible with serious limitations and strict conventions

alexmiller 2021-04-23T16:53:54.110600Z

there are a couple different ways data-based specs can be created in spec 2, so you actually have several choices - custom ops with s/defop (think spec template with holes), symbolic forms as data, and specs represented as maps. all of those are implemented now (with some caveats that the map form is kind of a hack in a few spots that are likely to change)

Alex Whitt 2021-04-23T17:29:16.112800Z

I was wondering if selection merging would be a first-class feature, but it sounds like I'll probably want to do the composition at the data model DSL layer. That will generate our specs, schemas, and selections. The implementation will be a lot cleaner with spec 2.