[spec] Add specs for spec forms


It would be useful to have specs that described spec forms, such that it was possible to go from a spec form like (s/keys :req [::a ::b] :opt [::c]) to a conformed version that allowed you to grab the parts without parsing the s-expression. This can be done by creating specs, thus allowing:

Patch: spec-forms.patch (a work in progress)




Alexander Kiel
June 28, 2018, 1:33 PM

Thanks. I see. The documentation in clojure.core defines that (clojure.core/and) returns true and (clojure.core/or) returns nil.

Alex Miller
June 27, 2018, 4:54 PM

There is a clear semantic definition for these - they are the same as clojure.core/and and clojure.core/or. As far as I'm concerned, this is all correct.

Alexander Kiel
June 27, 2018, 4:45 PM

Another observation: Currently s/and and s/or are allowed to contain no preds:

there should be either a clear semantic definition what an empty form will mean or we should just use s/+ here and require at least one pred. For the and-form, we could define that (s/and) is the same as (s/and any?) and the same as just any?. For the or-form it is difficult, because s/conform returns tagged results. So conforming any value with (s/or) will result in ::s/invalid which renders an empty or-form useless.

Alex Miller
June 27, 2018, 2:07 PM

Yeah, that would probably be good.

Alexander Kiel
June 27, 2018, 1:34 PM

In the current patch, keywords referencing specs are missing except for keys in `s/keys`. What would the right way to model the keywords? One way would be to add `qualified-keyword?` as fourth option to the or-spec of `::spec`. Than `::spec` could be used as spec for the spec arg in `s/valid?`, `s/conform`, `s/form` and others.

Your pinned fields
Click on the next to a field label to start pinning.


Alex Miller


Alex Miller








Affects versions