The output of `spec/form` is helps a bit with this, as it namespaces vars, keywords and symbols correctly. I've had it on my list to write a translator for specs sometime in the near future, but I haven't done it yet. True the output of `form` isn't as uniform as I would like (sexprs instead of maps) but I don't think it would be too much work.
Timothy On Tue, May 24, 2016 at 6:26 PM, Leif <leif.poor...@gmail.com> wrote: > Hi, Alex, thanks for the responsiveness. > > The paths refer to tags in the schemas, not keys in the map. However, this >> has been asked about several times today and Rich has added support for a >> :in clause that will track the key paths to master and that will be in >> alpha2. >> > > Where is this discussion thread? I wouldn't want to ask duplicate > questions. > > >> Is there a recommended way to introspect specs for our own purposes >> (coercion, code generation)? An interpreter on the output of 'describe' >> might work (although it's a little complicated for fn specs), but I wanted >> to know if you all had any thoughts or plans for the future here. >> > > >> Could you give more details on what question you would like to ask? >> > > Better people to ask would be those that have a lot of experience writing > translators for specs, like the Schema devs. But I'll give my muddled > thoughts here: > > Right now, the internals of different instances of Spec are private. So, > to write a translator from a Spec to the approximate json or avro schema it > specifies, or translate from a Spec to a function that coerces a String to > a data structure that conforms, I would have to: > > 1. Parse the output of 'describe' back into a description of the Spec's > internals (if I can get at all of them) > 2. Interpret / translate the parsed tree > > In fact, the current Spec protocol, in my mind, is actually 4 protocols, > one for 4 different translators you all have written: > > (defprotocol Spec > ;; Spec->Conformer > (conform* [spec x]) > :: Spec->Explainer > (explain* [spec path via x]) > ;; Spec->Gen > (gen* [spec overrides path rmap]) > (with-gen* [spec gfn]) > ;; Spec->Describer > (describe* [spec])) > > But this implementation hiding dooms clojure/core to write *all* the > translators. This just seems weird given how most other Clojure features > are open and user-extensible. > > --Leif > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with > your first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en > --- > You received this message because you are subscribed to the Google Groups > "Clojure" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to clojure+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- “One of the main causes of the fall of the Roman Empire was that–lacking zero–they had no way to indicate successful termination of their C programs.” (Robert Firth) -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.