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.
=========================================================
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)