I'd say that's a bug in s/nilable (and I wrote it, so I'll take the blame :).
I created a ticket and a patch here: http://dev.clojure.org/jira/browse/CLJ-2100 On Thursday, January 19, 2017 at 11:35:47 AM UTC-6, marian.hor...@vacuumlabs.com wrote: > > Hi, > > this sequence of commands in Clojure 1.9.0-alpha14 suprised me: > > => (clojure.spec/def :test/name string?) > :test/name > > => (clojure.spec/form (clojure.spec/and :test/name)) > (clojure.spec/and :test/name) > > => (clojure.spec/form (clojure.spec/nilable :test/name)) > (clojure.spec/nilable clojure.core/string?) > > Is there any reason, why *clojure.spec/**nilable *resolves the keywords > in its form and *clojure.spec/and* does not? If I understand it > correctly, the keywords are resolved explicitly by the line (let [pf (res > pred)]. > > In the following paragraph I'll try to explain, why this bothers me. We > are developing the API that will be used by external applications. To > validate input data, we decided to use the clojure specs, that serves this > purpose perfectly. However, we would like to reuse our definitions to > generate specifications in other languages like Swagger or JSON Schema. > Using *clojure.spec/form* we were able to detructuralize the spec and > translate it. It is not a surprise that there were some specs that cannot > be translated automatically. The best solution is to associate the > registered keyword of the unsupported spec with the valid translation. The > occurence of *clojure.spec/**nilable* (or, for example, *clojure.spec/def*) > then looses the information about the keywords it was used on and therefore > the translation is incorrect. > > Do you think it is a good idea to translate the specs to the other data > specification languages? Is so, is there a better way to do it? > > Generally, I think that registering a spec to keyword gives some context > to it - at least the name. It is a shame to throw this information away. > > Thanks for your time, > Marián > > -- 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.