Re: Spec of conform of spec

2016-12-10 Thread James Laver
This is exactly my use case as well. I want to provide the user a nice DSL but make it easy to automatically generate input. The idea I had was the user could write things in the DSL and for automatic generation you could just generate the conformed structure. The other thing it's made me notic

Re: Spec of conform of spec

2016-12-09 Thread Leon Grapenthin
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

Re: Spec of conform of spec

2016-09-01 Thread Alex Miller
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 fu

Re: Spec of conform of spec

2016-09-01 Thread l0st3d
I was asking how you would conform a value to a falsey value. If the interface for the function is that returning nil or false means that the input is not valid (which is what I understood from the discussion) then how can you conform to nil or false? However, on reading the docs for conformer

Re: Spec of conform of spec

2016-08-31 Thread Alex Miller
user=> (doc s/conformer) - clojure.spec/conformer ([f] [f unf]) Macro takes a predicate function with the semantics of conform i.e. it should return either a (possibly converted) value or :clojure.spec/invalid, and returns a spec that uses it as a predicate/conformer.

Re: Spec of conform of spec

2016-08-31 Thread Alex Miller
I don't understand the question. What are you trying to do? On Wednesday, August 31, 2016 at 4:08:00 PM UTC-5, l0st3d wrote: > > So how would you conform something to nil or false? For example: > > (s/conform (s/conformer read-string) "nil") > > ? > > -- You received this message because you are

Re: Spec of conform of spec

2016-08-31 Thread l0st3d
So how would you conform something to nil or false? For example: (s/conform (s/conformer read-string) "nil") ? -- 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 mem

Re: Spec of conform of spec

2016-06-20 Thread Beau Fabry
I think Alex's point was given any arbitrary function can be used as the conform part of the spec, this wouldn't be possible. Ie boot.user=> (s/conform (s/conformer inc) 1) 2 On Saturday, June 18, 2016 at 10:35:10 AM UTC-7, Leon Grapenthin wrote: > > I am not sure whether I understand what you m

Re: Spec of conform of spec

2016-06-18 Thread Leon Grapenthin
Yes I have tried that. As soon as you use things like `or` or `alt` it becomes quite the tedious manual effort and you don't get away with s/keys anymore. On Saturday, June 18, 2016 at 8:35:20 PM UTC+2, Josh Tilles wrote: > > Have you considered choosing labels that are themselves qualified > k

Re: Spec of conform of spec

2016-06-18 Thread Josh Tilles
I just realized that in my example, I probably should have used `s/get-spec` instead of `s/spec` when defining the labels. Oh well. On Saturday, June 18, 2016, Josh Tilles wrote: > Have you considered choosing labels that are themselves qualified > keywords with registered specs? That might feel

Re: Spec of conform of spec

2016-06-18 Thread Josh Tilles
Have you considered choosing labels that are themselves qualified keywords with registered specs? That might feel like a workaround, but I think it could get you most of what you’re looking for. For example: ``` (s/def ::even-spec even?) ;= :user/even-spec (s/def ::odd-spec odd?) ;= :user/odd-spe

Re: Spec of conform of spec

2016-06-18 Thread Leon Grapenthin
I am not sure whether I understand what you mean. Behavior of conform for predicates is to return its return value if it is logically true, ::s/invalid otherwise. Thus the predicate itself is the spec to its conform*. s/conformer is only limiting as much as it is to unform, a user would have

Re: Spec of conform of spec

2016-06-18 Thread Alex Miller
Given that conform takes an arbitrary (opaque) function, I don't think that's generically possible. On Saturday, June 18, 2016 at 7:37:33 AM UTC-5, Leon Grapenthin wrote: > > Assume I parse with conform. > > Then I have functions that operate on the value returned by conform. I > want to spec

Spec of conform of spec

2016-06-18 Thread Leon Grapenthin
Assume I parse with conform. Then I have functions that operate on the value returned by conform. I want to spec them. But I can't get a spec for the value returned by conform (so that I can spec said functions) automatically. Imagine `(s/conform-spec ::my-spec)` would return the spec of the