拥有描述规格形式的规格将非常有用,这样就可以从类似于 (s/keys :req [::a ::b] :opt [::c]) 的规格形式,到允许您获取其部分的规范版本进行转换,而无需解析 s 表达式。这可以通过创建规格实现,从而允许
user=> (require '[clojure.spec :as s] '[clojure.spec.specs])
user=> (s/def ::aspec (s/keys :req [::a ::b] :opt [::c]))
user=> (def aspec-data (s/conform :clojure.spec.specs/spec (s/form ::aspec)))
user=> (pr aspec-data)
[:form {:s clojure.spec/keys,
:args {:req [[:key :clojure.spec.specs/a] [:key :clojure.spec.specs/b]],
:opt [:clojure.spec.specs/c]}}]
user=> (map val (-> aspec-data val :args :req))
(:clojure.spec.specs/a :clojure.spec.specs/b)
**补丁:** spec-forms.patch (一个正在进行中的作品)