This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-10-17
Channels
- # alda (5)
- # bangalore-clj (1)
- # beginners (9)
- # bigdata (1)
- # boot (51)
- # carry (1)
- # cider (9)
- # cljs-dev (22)
- # clojars (39)
- # clojure (118)
- # clojure-brasil (1)
- # clojure-czech (8)
- # clojure-france (2)
- # clojure-italy (5)
- # clojure-korea (9)
- # clojure-russia (9)
- # clojure-spec (17)
- # clojure-uk (42)
- # clojurescript (48)
- # core-async (1)
- # emacs (3)
- # figwheel (1)
- # funcool (3)
- # hoplon (39)
- # klipse (51)
- # lein-figwheel (4)
- # leiningen (2)
- # luminus (5)
- # off-topic (245)
- # om (18)
- # onyx (19)
- # parinfer (1)
- # pedestal (18)
- # re-frame (47)
- # reagent (19)
- # ring-swagger (1)
- # specter (18)
- # untangled (93)
- # vim (8)
- # yada (56)
Hi. Is there something like s/assert
which is executed every time? I like to reserve s/assert
for checks I want potentially disable in production. But I have some checks I like to execute in all cases.
How would one go about specing a function that takes a callback that may take any kind of argument? For ex:
(defn myfunc [k cb]
(do-something-async k (fn [res err]
(check-err err)
(cb res err))))
If do-something-async
in this example is an un-speced library function where I only care about specing functions in my project and not external ones
But if you know what cb should look like, it would be beneficial to fail fast at your function.
You can use fspec to spec a function arg and any? to spec an arg that takes any value
So something like
(s/fdef myfunc :args (s/cat :k keyword? :cb (s/fspec :args (s/cat :res any? :err any?))))
@alexmiller Thanks, that’s what I was looking for!
Should I be able to spec an infinite sequence as an argument to a function? I tried s/every
but it got stuck in an infinite loop.
s/every samples so that should be able to work. Would be interested in seeing more.
(s/valid? (s/every int?) (range)) ;; => true