This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-02-05
Channels
- # arachne (7)
- # architecture (3)
- # beginners (106)
- # cider (22)
- # clara (2)
- # cljs-dev (14)
- # cljsrn (12)
- # clojure (121)
- # clojure-china (1)
- # clojure-italy (2)
- # clojure-spec (22)
- # clojure-uk (32)
- # clojurescript (38)
- # community-development (45)
- # cursive (15)
- # datascript (6)
- # datomic (12)
- # defnpodcast (2)
- # emacs (8)
- # events (1)
- # fulcro (14)
- # immutant (6)
- # jobs (3)
- # jobs-discuss (6)
- # jobs-rus (3)
- # keechma (4)
- # keyboards (4)
- # leiningen (8)
- # luminus (1)
- # off-topic (91)
- # onyx (13)
- # parinfer (36)
- # re-frame (12)
- # reagent (23)
- # remote-jobs (1)
- # ring-swagger (3)
- # shadow-cljs (57)
- # specter (11)
- # sql (9)
- # uncomplicate (4)
- # vim (2)
- # yada (15)
Is there a s/cat function which doesn't create a map? I essentially want a regex op which will consume exactly 2 predicates.
Use s/tuple
@U064X3EF3 That isn't a regex op, so it doesn't work for this:
(s/conform
(s/cat
:foo int?
:bar (s/tuple int? int?)
:baz int?)
[1 2 3 4])
(s/conform
(s/cat
:foo int?
:bar (s/cat :a int? :b int?)
:baz int?)
[1 2 3 4])
;; =>
;; {:foo 1, :bar {:a 2, :b 3}, :baz 4}
with the s/cat regex ops/+ then s/& with a size constraint?
@U064X3EF3 This works!
(s/conform
(s/cat
:foo int?
:bar (s/& (s/+ int?) #(= 2 (count %)))
:baz int?)
[1 2 3 4])
Rather cool.it’s like s/and but as a regex op
I've instrumented and stubbed out a function that thanks to the magic of spec can now generate results. The result is generated from a multispec though, is there a way of limiting a multispec to one of the methods [so I can only return certain types of results]?
What would cause clojure.spec.test.alpha/spec-checking-fn/conform!
to be applied to a function that has *not* been instrumented? :thinking_face:
Feels a bit circular having a mutlispec generate many cases only then to filter it again on the same logic each defmethod has.