Fork me on GitHub
#clojure-spec
<
2017-01-08
>
luxbock12:01:44

I'm a bit surprised that :clojure.core.specs/seq-binding-form doesn't restrict itself to only acceting vectors, i.e. you can attempt to destructure {(foo) :something} and it fails on because of an assert in clojure.core/destructuring rather than doing so at the spec level

stathissideris13:01:16

@alexmiller in your recent article on the destructuring spec you mention > Rather than recursively parsing the binding form, we could simply conform it to receive a more regular structure described in terms of the parts we've defined in the spec. …but that’s not entirely true because the use of every would prevent conform to recur to deeper levels to find the ::binding-form used within ::map-binding for example. Right?

mpenet14:01:18

Seems great on paper.

lmergen15:01:33

so, i was under the impression that fdef instruments a function and ensures that its args and return values conform to the spec on all invocations, but i think i’m wrong

lmergen15:01:58

i think i still need to manually ensure conform somewhere, right ?

lmergen15:01:51

for what it’s worth, i’m porting a schema-based codebase to spec, and want something similar to schema’s ^:always-validate

lmergen15:01:39

of course i could always use :pre and :post

mpenet15:01:26

instrument is a dev time thing really (it can trigger gen). To get ret validation you need to call check

mpenet15:01:20

and yeah, pre/post assertions is the closest to what you want i think

lmergen15:01:36

yeah but i am one of those people who runs its assertions in production 🙂

lmergen15:01:31

that’s probably it, eh ?

mpenet15:01:23

No, it s not a production usable thing. It ll trigger gen and be super slow/heavy. It doesnt just wrap args with simple validators

lmergen15:01:40

thanks, saves me some headaches 🙂

mpenet15:01:28

I wish we had another instrument for that personally, but now you have to roll your own basically

lmergen15:01:18

well, something like schema’s defn overload would be great

lmergen15:01:28

is anyone aware of some utility that does this ? basically all i want is to call s/explain whenever some pre or post condition is not matched

lmergen15:01:35

i might make it myself

lmergen15:01:07

it would make sense to me to have a function like this that has the same signature as fdef

brabster16:01:39

@lmergen something to make :pre/:post call s/explain sounds useful