在这次线程中讨论后打开了这个问题:
https://groups.google.com/forum/#!topic/clojure/r8WO24rHsi0
实质上,当使用 s/merge 与 s/or 时,s/conform 返回一个无法进行 s/unform'的 结构。
重现步骤(无耻地复制自线程)
(require '[clojure.spec.alpha :as s])
(s/def ::a (s/or :even even? :odd odd?))
(s/def ::b (s/or :even even? :odd odd?))
(s/def ::m1 (s/keys :req-un [::a]))
(s/def ::m2 (s/keys :req-un [::b]))
(s/def ::mm (s/merge ::m1 ::m2))
(s/valid? ::mm {:a 1 :b 2}) ;;; true
(s/conform ::mm {:a 1 :b 2})
;;=> {:a 1, :b [:even 2]}
(s/unform ::mm {:a [:odd 1] :b [:even 2]})
;;=> {:a 1, :b [:even 2]}
(s/unform ::mm (s/conform ::mm {:a 1 :b 2}))