Alex, I thought about this and it appears to be a convenience problem. Spec is e. g. excellent to parse a e. g. a Query DSL (which is my current side project) via conform. But then you have that large data structure that you want to break down and operate on in several functions. So you need to have the specs for the conformed structure built by spec.
I found a surprisingly easy way to do so: (defmacro conformed "Takes a spec conformable and unformable spec. Returns a spec that validates and generates conformed values per spec." [spec] `(s/with-gen (fn [v#] (try (= v# (s/conform ~spec (s/unform ~spec v#))) (catch Throwable _# false))) (fn [] (gen/fmap (fn [v#] (s/conform ~spec v#)) (s/gen ~spec))))) Do you think it's a good idea to pursue this way? Kind regards, Leon. On Thursday, September 1, 2016 at 2:33:17 PM UTC+2, Alex Miller wrote: > > I think you may be confusing the return value of a predicate value (acting > as a spec) with the return value of the function passed to conformer. > > In the former case a predicate function's return value is a logically > truthy value and a return of nil or false indicates the value is invalid. > > The function passed to a conformer is expected to return either a > conformed value or ::s/invalid. > > -- 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.