This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-08-21
Channels
- # aleph (2)
- # beginners (22)
- # boot (7)
- # chestnut (8)
- # cider (4)
- # clara (3)
- # cljs-dev (3)
- # cljs-experience (19)
- # clojure (69)
- # clojure-italy (8)
- # clojure-nl (1)
- # clojure-spec (11)
- # clojure-uk (17)
- # clojurescript (77)
- # cursive (22)
- # datomic (14)
- # events (1)
- # fulcro (78)
- # hoplon (51)
- # jobs (3)
- # keechma (1)
- # lambdaisland (1)
- # lumo (30)
- # off-topic (42)
- # om (22)
- # onyx (5)
- # parinfer (4)
- # portkey (1)
- # re-frame (15)
- # reagent (2)
- # ring (4)
- # spacemacs (1)
- # specter (23)
- # testing (1)
- # unrepl (60)
- # yada (8)
@souenzzo multimethods are not currently support with spec fdef
@alexmiller Does ☝️ also hold for protocols? currently trying to spec a protocol fn that dispatches on type with s/or
and not succeeding...
functions that can’t be instrumented right now include: multimethods, protocols, inline functions, and primitive type hinted functions
some of those are fixable, some aren’t (easily)
attempting to spec a fn that has one argument, but can accept either a string or keyword, my attempt:
(s/fdef species->ident
:args (s/or :string-val string? :keyword-val keyword?)
:ret keyword?)
(defn species->ident [s-or-kw]
(-species->ident s-or-kw))
(clojure.spec.test.alpha/check 'species->ident)
gives the error (snipped):
:failure #error {
:cause "Don't know how to create ISeq from: clojure.lang.Keyword"
:via
[{:type java.lang.IllegalArgumentException
:message "Don't know how to create ISeq from: clojure.lang.Keyword"
:at [clojure.lang.RT seqFrom "RT.java" 547]}]
I think I'm probably using the wrong spec for args; any pointers please?You'll need something like
(s/fdef species->ident
:args (s/cat :arg1 (s/or :string-val string? :keyword-val keyword?))
:ret keyword?)
:args
will always be a sequence