clojure-spec

vlaaad 2021-08-15T19:28:48.047300Z

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]]]]

dgb23 2021-08-15T19:43:58.047400Z

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])

vlaaad 2021-08-15T20:05:26.047700Z

fixed formatting

Alex Miller (Clojure team) 2021-08-15T21:28:01.049100Z

I'm not seeing what's unexpected here, can you describe?

vlaaad 2021-08-16T05:02:30.050Z

Second element of second result unnecessary wrapped in a vector

vlaaad 2021-08-15T21:06:04.048500Z

given (s/def ::foo (s/* any?)) , shouldn't (s/regex? ::foo) also return true?

seancorfield 2021-08-15T21:26:41.049Z

That operates on the (internal) spec form I believe, not on spec names.

seancorfield 2021-08-15T21:29:11.049600Z

Use (s/regex? (s/get-spec ::foo)) @vlaaad

seancorfield 2021-08-15T21:30:17.049800Z

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}