Fork me on GitHub
#clojure-spec
<
2019-04-11
>
vemv14:04:21

Is there something like (describe-spec :my/spec) that will print what :my/spec is about? Maybe recursively. Loosely analog to macroexpand/`macroexpand-all`

vemv15:04:41

(for now I use Emacs niceties but I'm interested in editor-agnostic tooling)

Alex Miller (Clojure team)15:04:52

doc works on registered specs

✌️ 4
❤️ 8
Alex Miller (Clojure team)15:04:18

it is, however, not deep/recursive

fedreg16:04:01

Hi all, can someone help me with spec’ing a higher-order fn? One of the arguments to a fdef is a higher order fn that I’ve defined as:

(s/def ::foo-fn (s/fspec :args any? :ret ::foo)) 
This works except running something like test.check on the fn that takes foo-fn as an arg is super slow. …If I just pass ::foo in instead of ::foo-fn everything generates as quickly as usual so I’m guessing I’m doing something wrong… 😞 . Any thoughts? thx!! …oh… and ::foo has no args but not sure how to express that.. :args nil doesn’t work

Alex Miller (Clojure team)17:04:24

:args (s/cat) is prob best

Alex Miller (Clojure team)17:04:15

fspecs are instrumented by generating args and invoking the passed function a bunch of times

Alex Miller (Clojure team)17:04:30

this is sometimes surprising and/or bad for people

Alex Miller (Clojure team)17:04:52

an alternate option to using an s/fspec here is to just spec it as ifn?

fedreg17:04:48

@alexmiller Will try those out! Thanks!!

fedreg17:04:21

…Using :args (s/cat) instead of any? definitely sped things up.. Can’t use ifn? for my specific use case but still generating / running through my system about 5 results per second which is pretty fast. …just spoiled by how fast test.check usually runs data!

Alex Miller (Clojure team)17:04:13

any? can generate very large nested colls

Alex Miller (Clojure team)17:04:21

(s/cat) can only generate one thing, ()

fedreg17:04:42

yes.. I knew that any was slowing things down but couldn’t figure out how to do no args… Didn’t think to try (s/cat) so thanks for that!