This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-09-05
Channels
- # beginners (45)
- # boot (2)
- # cider (2)
- # cljs-experience (1)
- # cljsrn (6)
- # clojure (67)
- # clojure-brasil (1)
- # clojure-dusseldorf (47)
- # clojure-finland (7)
- # clojure-italy (81)
- # clojure-portugal (2)
- # clojure-russia (12)
- # clojure-sanfrancisco (1)
- # clojure-serbia (1)
- # clojure-spec (22)
- # clojure-uk (27)
- # clojurescript (49)
- # clojurewerkz (3)
- # code-reviews (3)
- # component (19)
- # core-async (3)
- # cursive (16)
- # events (7)
- # fulcro (20)
- # graphql (7)
- # immutant (1)
- # jobs (2)
- # juxt (44)
- # leiningen (7)
- # lumo (35)
- # onyx (31)
- # portkey (31)
- # portland-or (8)
- # random (1)
- # re-frame (82)
- # reagent (35)
- # sfcljs (1)
- # spacemacs (5)
- # specter (7)
- # unrepl (4)
- # yada (2)
Hello,
I am trying to spec some higher order functions using fdef
and fspec
For eg:
(s/fdef adder
:args (s/cat :x number?)
:ret (s/fspec :args (s/cat :y number?)
:ret number?)
:fn #(= (-> % :args :x) ((:ret %) 0)))
is it possible to get the value of argument x
inside the spec of the inner function which is returned ?Hello there! Quick question: is it possible to create an "inline" s/keys
inside a s/cat
in fdef
s? Like:
(s/fdef something :args (s/cat :first-argument (s/keys :req-un [::a ::b ::c])))
😞 Ok, thank you!
or wait, maybe? what are you trying to do?
you might want s/keys*
if you’re matching varargs in a function
Hmmm, I'll check that out 😃
and even my prior answer is wrong - you can use s/keys there (I just don’t think it’s what you want)
are you taking a map or a series of key/value options in something?
Odd; I tried that way before and my generative test exploded
I'm taking a map
oh, then you should be fine with the above
if you want to test it, run (s/exercise (s/cat :first-argument (s/keys :req-un [::a ::b ::c])) 1000)
- that’s basically what you’re getting with a generative test on something
Nice catch, I'll inspect this way
often pushing that out to 1000 samples reveals more :)
if a/b/c are big colls, that can provoke some problematic samples - bounding their size often helps
with :gen-max
Actually that's not the case, in my scenario ::a
, ::b
and ::c
are just very specific definitions, but I got your point
we will eventually get around to implementing it in spec, just kinda far down the list atm