This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-11-08
Channels
- # aws (3)
- # bangalore-clj (1)
- # beginners (47)
- # boot (137)
- # cider (1)
- # cljs-dev (67)
- # cljsrn (7)
- # clojure (122)
- # clojure-argentina (5)
- # clojure-berlin (4)
- # clojure-czech (12)
- # clojure-france (27)
- # clojure-italy (9)
- # clojure-russia (88)
- # clojure-spec (44)
- # clojure-uk (157)
- # clojurebridge (2)
- # clojurescript (236)
- # datomic (5)
- # devcards (3)
- # dirac (23)
- # emacs (13)
- # hoplon (29)
- # incanter (1)
- # leiningen (41)
- # microservices (1)
- # off-topic (78)
- # om (145)
- # onyx (13)
- # parinfer (8)
- # pedestal (4)
- # planck (15)
- # protorepl (1)
- # re-frame (72)
- # reagent (25)
- # ring (2)
- # specter (23)
- # test-check (9)
- # untangled (106)
- # vim (8)
- # yada (1)
@norton it's tricky... you have to make sure there's an fdef for the thing you're :replace
-ing
@drewr Thank you for the feedback. I posted this question (with more details) to the Google clojure mailing list with an example that is using :replace. Alex Miller responded and corrected my example. It works as expected!
s/keys question, I need to express key ::foo is optional, but if it's there ::bar key should be too, since there's no or/and in opt it's a bit tricky I think.
@alexmiller might know 🙂
Why not req (or foo (and foo bar))
I'd probably replace the #(or …
with another (s/keys …
so you get enforcement of the values for :foo
and :bar
.
@alexmiller because foo is required like this
I don't think merge helps at all here
But you could and a predicate that adds this constraint
it doesn't, I was mentioning it in the context of a solution with keys vs s/and + pred with contains?
Or or 2 keys specs - one with the pair, one without
that's what I am going to end up using, but I wish it was possible to use or/and in opt
Although that may not be very useful
Opt is all optional - it doesn't make sense to have and/or there
well it'd make this example way nicer at least, there are other situations like this where it would make sense
Note that this is or, not xor
to take the other example mentioned earlier: an option map that could have credentials (optionally), but if ::user is there there must be ::password too.
user=> (s/conform :clojure.core.specs/defn-args '(foo [{x :y}])) {:bs [:arity-1 {:args {:args [[:map {x :y}]]}}], :name foo}
user=> (s/conform :clojure.core.specs/defn-args '(foo [{x y}])) {:bs [:arity-1 {:args {:args [[:seq {:elems [[:seq {:elems [[:sym x] [:sym y]]}]]}]]}}], :name foo}
@alexmiller ^ is that a bug?
Is what a bug?
Not at a computer so hard for me to look at stuff
I guess the question is whether regex specs like cat should or do work on maps
If so, then seq-binding-form will happen to be satisfied by the map
Or dynamically generate a spec
ok - i’m reasonably sure that is a bug & that the fix is a simple s/spec - making a patch