Fork me on GitHub
#clojure-spec
<
2018-08-20
>
alexmiller00:08:54

per the s/fdef doc string, ” :args A regex spec for the function arguments as they were a list to be passed to apply - in this way, a single spec can handle functions with multiple arities”

alexmiller00:08:35

or I guess maybe the confusing thing is that regex ops nested inside each other are combined to describe the same sequential collection

alexmiller00:08:21

so you have an effective foo args spec of (s/cat :aa (s/cat :name keyword?)), however nested s/cats like this combine to form a spec for a single sequential collection (the args list)

alexmiller00:08:49

what you’re wanting is that ::any-args described a new nested collection

alexmiller00:08:54

you can do that with (s/fdef foo :args (s/cat :aa (s/spec ::any-args)))

alexmiller00:08:09

the s/spec wrapper here forces a new (non-combined) collection level

jeaye01:08:10

Thanks, Alex. Got it.

jeaye01:08:28

@alexmiller Is there any issue with using (s/spec ...), or unintended side effects? I'm thinking about defn-spec, within Orchestra, which provides fn specs inline. It seems like defn-spec should expand every arg spec to be wrapped in s/spec, based on your explanation.

djtango17:08:15

I've run into issues with regex flattening in arg-specs so I think you're right here

djtango17:08:32

(w.r.t. using s/spec how you've described)

jeaye01:08:18

Since none of them should ever flatten to affect the outer s/cat for the :args.

alexmiller02:08:08

I can’t speak to what Orchestra or defn-spec does, sorry. There are possible use cases for wanting the flattening here, although I agree that’s probably unusual.

richiardiandrea21:08:25

We were discussing a bit on #clojurescript about having the possibility to specify a custom printer (a la *explain-out*) for check results.

richiardiandrea21:08:43

Is it something worth working on, or at least opening a JIRA about?