I’m working on a new release of Expound which will include better handling for cat specs and a description of any missing key specs:
(require '[expound.alpha :as expound])
(require '[clojure.spec.alpha :as s])
(require '[clojure.spec.test.alpha :as st])
(s/def :demo.loc/city string?)
(s/def :demo.loc/state string?)
(s/def :demo/loc (s/keys :req-un [:demo.loc/city :demo.loc/state]))
(s/fdef loc-str
:args (s/cat :loc :demo/loc))
(defn loc-str [loc]
(str (:city loc) ", " (:state loc)))
;; with no instrumentation
(loc-str) ;; Wrong number of args (0) passed to: alpha/loc-str
(loc-str {}) ;; ", "
;; with instrumentation
(st/instrument)
(set! s/*explain-out* expound/printer)
(loc-str)
;; -- Syntax error -------------------
;; Function arguments
;; nil
;; should have additional elements. The next element ":loc" should
;; satisfy
;; map?
(loc-str {})
;; -- Spec failed --------------------
;; Function arguments
;; ({})
;; ^^
;; should contain keys: `:city`, `:state`
;; | key | spec |
;; |--------+---------|
;; | :city | string? |
;; | :state | string? |
I realize the following part is not helpful:
;; Function arguments
;; nil
;; should have additional elements.
It should say something like Function arguments to (loc-str) should have additional elements
but right now, clojure.spec does not include enough information to display the original function name. If you’d like to see this feature in Expound, please vote for https://dev.clojure.org/jira/browse/CLJ-2166 