Is there an effort to write specs for Clojure's core namespaces? Apologies if this has already been addressed.
I've been tinkering with trivial (and probably wrong) fdefs on clojure.core/map and clojure.core/identity. It seems that the spec exception messages are way better than what we have now. Code is here: https://gist.github.com/ryfow/69a64e966d48258dfa9dcb5aa74005eb ========================================================= Before instrumenting clojure.core/map ========================================================= Form: (into [] (map nil [1 2 3] [1 2 3])) Exception Class: java.lang.NullPointerException Message: nil Form: (into [] (map 1 [1 2 3] [1 2 3])) Exception Class: java.lang.ClassCastException Message: java.lang.Long cannot be cast to clojure.lang.IFn Form: (into [] (map identity 4)) Exception Class: java.lang.IllegalArgumentException Message: Don't know how to create ISeq from: java.lang.Long ========================================================= After instrumenting clojure.core/map ========================================================= Form: (into [] (map nil [1 2 3] [1 2 3])) Exception Class: clojure.lang.ExceptionInfo Message: Call to #'clojure.core/map did not conform to spec: In: [0] val: nil fails at: [:args :fn] predicate: ifn? :clojure.spec/args (nil [1 2 3] [1 2 3]) Form: (into [] (map 1 [1 2 3] [1 2 3])) Exception Class: clojure.lang.ExceptionInfo Message: Call to #'clojure.core/map did not conform to spec: In: [0] val: 1 fails at: [:args :fn] predicate: ifn? :clojure.spec/args (1 [1 2 3] [1 2 3]) Form: (into [] (map identity 4)) Exception Class: clojure.lang.ExceptionInfo Message: Call to #'clojure.core/map did not conform to spec: In: [1] val: 4 fails at: [:args :seq] predicate: sequential? :clojure.spec/args (#object[clojure.core$identity 0x15a04efb "clojure.core$identity@15a04efb"] 4) ========================================================= Before instrumenting clojure.core/identity ========================================================= Form: (into [] (map identity [1 2 3] [1 2 3])) Exception Class: clojure.lang.ArityException Message: Wrong number of args (2) passed to: core/identity ========================================================= After instrumenting clojure.core/identity ========================================================= Form: (into [] (map identity [1 2 3] [4 5 6])) Exception Class: clojure.lang.ExceptionInfo Message: Call to #'clojure.core/identity did not conform to spec: In: [1] val: (4) fails at: [:args] predicate: (cat :one-argument identity), Extra input :clojure.spec/args (1 4) -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.