This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-08-17
Channels
- # arachne (1)
- # beginners (42)
- # boot (4)
- # cider (28)
- # clara (9)
- # cljs-dev (149)
- # cljsrn (5)
- # clojure (185)
- # clojure-austin (2)
- # clojure-dusseldorf (4)
- # clojure-italy (14)
- # clojure-norway (1)
- # clojure-russia (18)
- # clojure-spec (35)
- # clojure-uk (36)
- # clojurescript (78)
- # core-async (6)
- # data-science (20)
- # datomic (48)
- # emacs (1)
- # fulcro (2)
- # garden (4)
- # hoplon (47)
- # jobs (5)
- # jobs-rus (1)
- # leiningen (2)
- # lumo (12)
- # off-topic (8)
- # om (8)
- # onyx (39)
- # parinfer (19)
- # re-frame (100)
- # reagent (15)
- # ring-swagger (1)
- # sql (8)
- # vim (1)
- # yada (20)
Question: Is there a place on a spec you can add a doc-string, so that it is printed when the spec fails?
I would like to have literate english prose explain what the spec predicates are asserting.
I believe there's a JIRA issue open to consider docstrings for specs -- but it wouldn't be printed (by default) when a spec failed.
I think better third-party "explain" functions are the right way to go here.
(but I think that each application is going to need its own customization so I don't know how much generic goodness we're going to get here)
I think that "spec is about what you function can do. You shouldn't specify what your function cant do." (under quote cos it's about what I understand when I see the core team talking about spec)
I asked this a bit ago but I have yet to stumble upon a solution 🙂 - is there a way to specify a function of arity 1? If i have a function that takes another function as an argument - and that function argument is expected to take a single argument?
something like (fspec :args (s/cat any?))
(s/fspec :args (s/cat :x any?))
@gfredericks I’ll give that a whirl. Thank you!
Is there an equivalent to s/describe
for fdef
‘ed fns?
Oh, duh, I didn’t quote the fn name so it evaluated it. Thanks!
also note that (doc rules.core/rules-in-eid)
will print the function specs
as part of the docstring
doc
also knows about specs so (doc ::foo)
works for data specs
Oh awesome, didn’t know about that either. Thanks!
(s/cat :foo string? :bar (s/spec (s/cat :barbar string?)))
is it right? there is a shorter way? I'm not sure if s/spec + s/cat
is right
["foo string" ["barbar string"]]
<< sample
@souenzzo the second half could be (s/tuple string?) if you are specifically expecting a vector of length 1
But tuple is some kind of anonymous Thinking in docs (in my case, the main propose), give a name for the elements of the tuple is better...
(in the real case, it's a tuple 3 elements where each is a different tuple of 3 elements)