I want to look at the data-structure which represents a Clojure Spec.
How can I get and have a look in it?
Eg. given
(s/def ::myspec (s/keys :opt-un [::x ::y]))
I want to pretty print the internal representation of myspec.
I want to look at the data-structure which represents a Clojure Spec.
How can I get and have a look in it?
Eg. given
(s/def ::myspec (s/keys :opt-un [::x ::y]))
I want to pretty print the internal representation of myspec.
You can use
s/form
which "return[s] the spec as data":Or
s/describe
for an abbreviated version of the same thing:Both these ultimately depend on the
describe*
method of theSpec
protocol:So each spec type is responsible for describing itself. For example the map spec implementation just rebuilds its literal definition from its initial inputs like this: