This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-05-24
Channels
- # beginners (12)
- # cider (3)
- # clara (3)
- # cljs-dev (3)
- # cljsrn (19)
- # clojure (83)
- # clojure-android (1)
- # clojure-dev (15)
- # clojure-dusseldorf (1)
- # clojure-greece (30)
- # clojure-italy (10)
- # clojure-madison (1)
- # clojure-nl (6)
- # clojure-russia (274)
- # clojure-spec (51)
- # clojure-uk (31)
- # clojurescript (38)
- # core-async (7)
- # cursive (11)
- # datascript (1)
- # datomic (63)
- # emacs (10)
- # figwheel (1)
- # hoplon (27)
- # jobs (11)
- # klipse (4)
- # lein-figwheel (1)
- # lumo (6)
- # nyc (1)
- # off-topic (278)
- # om (12)
- # pedestal (10)
- # protorepl (31)
- # re-frame (13)
- # reagent (23)
- # remote-jobs (1)
- # spacemacs (9)
- # untangled (24)
- # yada (54)
Should instrument
report the name of the function that failed in the ex-data
?
It reports the function name in the exception message, but it’s missing from the exception’s data.
most likely yes
example would help, but feel free to file something about itk
@weavejester just looked at an example - definitely yes
Ah, I was just about to post one 🙂
Shall I add a JIRA report, @alexmiller ?
that would be great
if you patch it, I will screen it too :)
btw, enjoyed your defn podcast episode
Ah thanks 🙂
I assume this is obvious, but patch will be against the spec.alpha lib, not core clojure repo
Sorry, I couldn’t find the spec.alpha lib in the project list when I created the issue.
is there any support for string keys in s/keys
? or any plan to support them later?
no @stathissideris -- s/keys
needs things that are globally registered (keywords/specs)
@ghadi thanks
@weavejester you filed it in the right place - spec issues are being managed in CLJ, just meant that the patch would be on a different repo
Ah, cool.
What’s an idiomatic way to spec args for a multi-arity function where the longer arities only add new arguments to the shorter ones? Say the full args vector is [a b c ...]
but you have aritites with defaults that only take [a]
, or [a b]
etc?
@jfntn I think you either do (s/or :arity1 (s/cat ..) :arity2 (s/cat ...) :arity3 (s/cat))
or (s/cat x y (s/? w z))
not sure which is more idiomatic
actually it’s not s/?
yeah, but I think s/?
is for a single predicate
Seems to do what I expect: (s/explain (s/cat :a string? :b string? :c (s/? string?) :d (s/? string?)) ["a" "b" "c" :d])
@jfntn ok, but if for some reason you had arities 2 and 4, you’d say
(s/cat :a string? :b string? :rest (s/? (s/cat :c string? :d string?)))
which is valid for ["a" "b"]
and ["a" "b" "c" "d"]
but not for 3 strings
this works because the nested s/cat
does not imply a nested sequence
if you want nesting, you need to wrap it with a s/spec
:
(s/valid? (s/cat :a string? :b string? :rest (s/? (s/spec (s/cat :c string? :d string?)))) ["a" "b"])
(s/valid? (s/cat :a string? :b string? :rest (s/? (s/spec (s/cat :c string? :d string?)))) ["a" "b" ["c" "d"]])
thanks @stathissideris
Hi everybody, what’s the best way to use clojure.spec with Clojure 1.8?
Is there a clojar for that?
@seancorfield thank you!
is there any way to dynamically provide arguments from a collection to spec/or
? It's a macro so I can't use apply
mattly: I have used eval
for similar purposes:
(doseq [[spec-kw field-spec desc] fields]
(eval `(s/def ~spec-kw ~(build-internal-spec field-spec))))
yeah, the individual specs I haven't had problems with, what I need is to validate that a value in a map conforms to one of possibly 100 specs
Well, a way you could do that is to use eval
to build the s/or
form you want
Yeah, having a shorthand for this case is something I think would be useful
It comes up regularly