I have a DSL specification, which is a sequence as usual ( cat). I want to use spectrum analysis (i.e. conforming) to get the AST for an expression that matches my DSL. For instance.
user> (s/def ::person (s/cat :person-sym '#{person} :name string? :age number?))
=> :user/person
user> (s/conform ::person '(person "Henry The Sloth" 55))
=> {:person-sym person, :name "Henry The Sloth", :age 55}
Now that he has figured out, and I have my AST, I would like to do interesting things with him, so I would like to check it and much more. So now I need to write a specification for this AST, and this basically duplicates everything. Actually, it’s worse because now I have specifications s/deffor predicates that I haven’t had to before, because the docs keyssay: “there is no support for the built-in specification of value by design” ./ “This is a (forced) view that a specification of the values associated with the namespaced keyword, for example: my.ns / k, must be registered under this keyword. ". Thus, duplication (with the lack of parts person-sym):
user> (s/def ::name string?)
=> :user/name
user> (s/def ::age number?)
=> :user/age
user> (s/def ::person-ast (s/keys :req-un [::name ::age]))
:user/person-ast
And now it seems compatible:
user> (s/conform ::person-ast (s/conform ::person '(person "Henry The Sloth" 55)))
=> {:person-sym person, :name "Henry The Sloth", :age 55}
, , , , ? AFAIK AST, ( , , ). ?