下面的例子显示了在unform之后并未统一任何形式的情况。我期望您可以通过不断地重复conform -> unform -> conform来获得相同的结果。
(require '[clojure.core.specs])
(require '[clojure.spec :as s])
(s/def ::defn-macro (s/cat :type #{'defn} :definition :clojure.core.specs/defn-args))
(let [form '(defn foo "bar" ([a & b] a a c) ([a b] a))]
(-> form
(->> (s/conform ::defn-macro))) ;;=> {:type defn, :definition {:name foo, :docstring "bar", :bs [:arity-n {:bodies [{:args {:args [[:sym a]], :varargs {:amp &, :form [:sym b]}}, :body [a a c]} {:args {:args [[:sym a] [:sym b]]}, :body [a]}]}]}}
;; Unforming返回函数定义,但以列表形式而不是向量形式表示参数
(->> form
(s/conform ::defn-macro)
(s/unform ::defn-macro)) ;;=> (defn foo "bar" ((a (& b)) a a c) ((a b) a)))
;; Unform之后再次conform不再有效
(->> form
(s/conform ::defn-macro)
(s/unform ::defn-macro)
(s/conform ::defn-macro)) ;;=> :clojure.spec/invalid
)