Re: Custom generators for custom predicate functions

2016-12-08 Thread Dave Dixon
Thanks Alex. I agree it probably isn't "needed", was just a little 
surprised to discover the asymmetry. Mostly was curious if there was some 
deeper design decision, e.g. that you need to start with some set of 
primitive predicates upon which you can start building named specs.

On Thursday, December 8, 2016 at 9:23:11 AM UTC-8, Alex Miller wrote:
>
> In general, you shouldn't need to do this (it is better to attach the 
> generator to the spec). Generator mappings are provided for core Clojure 
> predicates so that many common predicates gen automatically and so that 
> they can be combined (via things like s/and) with other predicates that 
> filter but don't gen.
>
> I was not part of the design discussion, but I assume that it would open a 
> can of worms around conflicts, ordering, and function resolution that Rich 
> and Stu didn't want to open at this time. Nothing precludes this from being 
> expanded later if deemed useful.
>
> On Thursday, December 8, 2016 at 10:56:29 AM UTC-6, Dave Dixon wrote:
>>
>> Though one can obviously attach a custom generator to a keyword-named 
>> spec, it appears there is no way to do the same for a custom predicate 
>> function. I see that the generators for predicate functions testing for 
>> core primitives are hard-coded in the private 
>> clojure.spec.gen\gen-builtins. Curious why this isn't extensible, since it 
>> naively seems similar to the keyword case, but with the custom generator 
>> keyed by a symbol rather than a map.
>>
>> Dave
>>
>

-- 
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.


Re: Custom generators for custom predicate functions

2016-12-08 Thread Alex Miller
In general, you shouldn't need to do this (it is better to attach the 
generator to the spec). Generator mappings are provided for core Clojure 
predicates so that many common predicates gen automatically and so that 
they can be combined (via things like s/and) with other predicates that 
filter but don't gen.

I was not part of the design discussion, but I assume that it would open a 
can of worms around conflicts, ordering, and function resolution that Rich 
and Stu didn't want to open at this time. Nothing precludes this from being 
expanded later if deemed useful.

On Thursday, December 8, 2016 at 10:56:29 AM UTC-6, Dave Dixon wrote:
>
> Though one can obviously attach a custom generator to a keyword-named 
> spec, it appears there is no way to do the same for a custom predicate 
> function. I see that the generators for predicate functions testing for 
> core primitives are hard-coded in the private 
> clojure.spec.gen\gen-builtins. Curious why this isn't extensible, since it 
> naively seems similar to the keyword case, but with the custom generator 
> keyed by a symbol rather than a map.
>
> Dave
>

-- 
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.


Custom generators for custom predicate functions

2016-12-08 Thread Dave Dixon
Though one can obviously attach a custom generator to a keyword-named spec, 
it appears there is no way to do the same for a custom predicate function. 
I see that the generators for predicate functions testing for core 
primitives are hard-coded in the private clojure.spec.gen\gen-builtins. 
Curious why this isn't extensible, since it naively seems similar to the 
keyword case, but with the custom generator keyed by a symbol rather than a 
map.

Dave

-- 
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.