This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-08-15
Channels
- # announcements (9)
- # babashka (1)
- # beginners (1)
- # calva (7)
- # cider (13)
- # clj-kondo (2)
- # cljsrn (1)
- # clojure (40)
- # clojure-europe (2)
- # clojure-spec (9)
- # clojure-uk (1)
- # cursive (4)
- # datomic (2)
- # etaoin (1)
- # fulcro (4)
- # honeysql (3)
- # lsp (43)
- # malli (7)
- # music (1)
- # nbb (6)
- # off-topic (5)
- # polylith (8)
- # protojure (1)
- # re-frame (6)
- # react (17)
- # reagent (63)
- # releases (1)
- # shadow-cljs (8)
- # testing (8)
- # tools-deps (1)
- # vim (8)
s/* wrapping s/alt conform gives a vector of tuples (expected):
(s/conform (s/* (s/alt :strs (s/+ string?)
:ints (s/+ int?)))
["a" "x" 1 2])
=> [[:strs
["a" "x"]]
[:ints
[1 2]]]
s/+ wrapping s/alt conform gives a vector with tuple and a vector of tuples (unexpected):
(s/conform (s/+ (s/alt :strs (s/+ string?)
:ints (s/+ int?)))
["a" "x" 1 2])
=> [[:strs
["a" "x"]]
[[:ints
[1 2]]]]
so weird when you look at:
(s/conform (s/+ (s/alt :strs (s/+ string?)
:ints (s/+ int?)))
["a" "x" 1 2 "b" "c" 4 5])
I'm not seeing what's unexpected here, can you describe?
That operates on the (internal) spec form I believe, not on spec names.
Use (s/regex? (s/get-spec ::foo))
@vlaaad
dev=> (s/def ::bar string?)
:dev/bar
dev=> (s/def ::foo (s/* any?))
:dev/foo
dev=> (s/regex? (s/get-spec ::bar))
nil
dev=> (s/regex? (s/get-spec ::foo))
{:clojure.spec.alpha/op :clojure.spec.alpha/rep, :p2 #object[clojure.core$any_QMARK_ 0x18d396eb "clojure.core$any_QMARK_@18d396eb"], :splice false, :forms clojure.core/any?, :id #uuid "9d09bd34-f6f5-4ee6-a69f-4e84a312b5d0", :p1 #object[clojure.core$any_QMARK_ 0x18d396eb "clojure.core$any_QMARK_@18d396eb"], :ret [], :clojure.spec.alpha/name :dev/foo}