Fork me on GitHub
#clojure-spec
<
2016-12-16
>
noprompt00:12:40

i think there’s a bug with :clojure.core.specs/binding-form. it’s defined as

(spec/or :sym :clojure.core.specs/local-name
         :seq :clojure.core.specs/seq-binding-form
         :map :clojure.core.specs/map-binding-form)
but this is a problem if you actually want to use the data from conforming against it because
(spec/conform
 :clojure.core.specs/binding-form
 '{})
;; => [:seq {}]
which is the smallest example that demonstrates the problem (`{:as m}` conforms to a [:seq ,,,] value). in order to fix this problem the spec needs to be reorganized to place :map spec above the :seqspec.
(spec/or :sym :clojure.core.specs/local-name
         :map :clojure.core.specs/map-binding-form
         :seq :clojure.core.specs/seq-binding-form)
here’s an example of the updated behavior
(spec/conform
 (spec/or :sym :clojure.core.specs/local-name
          :map :clojure.core.specs/map-binding-form
          :seq :clojure.core.specs/seq-binding-form)
 '{})
;; => [:map {}]

(spec/conform
 (spec/or :sym :clojure.core.specs/local-name
          :map :clojure.core.specs/map-binding-form
          :seq :clojure.core.specs/seq-binding-form)
 '[])
;; => [:seq {}]

noprompt00:12:10

i guess this is another good case for specs for specs. 😉

Alex Miller (Clojure team)00:12:41

There's already a ticket and a patch for this I think

noprompt01:12:10

ah nice! yep, that’ll do it too! 🙂

noprompt01:12:26

(although my patch would have been smaller) 😛

noprompt01:12:20

(brandon’s is better though) 🙂

Alex Miller (Clojure team)01:12:04

We really need a vcat which would be better than either

devth15:12:39

where does spec store registered specs? can i list / inspect them?

Alex Miller (Clojure team)16:12:49

you might also find stest/instrumentable-syms or stest/checkable-syms of interest re functions

devth16:12:59

ah, very cool