Re: (gen/sample (s/gen #{'nil})): Couldn't satisfy such-that predicate

2019-01-31 Thread Andy Fingerhut
Sometimes text in comments in ClojureDocs.org examples can be more useful than the examples. They are effectively longer (unofficial) doc strings. Andy On Thu, Jan 31, 2019 at 5:36 AM Alex Miller wrote: > Go for it. Not sure the type stuff is adding anything in the context of > quote examples

Re: (gen/sample (s/gen #{'nil})): Couldn't satisfy such-that predicate

2019-01-31 Thread Alex Miller
Go for it. Not sure the type stuff is adding anything in the context of quote examples here beyond the other explanation though. On Thu, Jan 31, 2019 at 6:50 AM Rostislav Svoboda < rostislav.svob...@gmail.com> wrote: > Hi Alex, > > > quote is a special form that returns the value you pass it, wit

Re: (gen/sample (s/gen #{'nil})): Couldn't satisfy such-that predicate

2019-01-31 Thread Rostislav Svoboda
Hi Alex, > quote is a special form that returns the value you pass it, without evaluation Aah! "without evaluation" is the key! Now it makes sense. Yea you mentioned it before already, but it takes twice the effort to undo and re-comprehend an acquired misconception. Thank you so much! Would you

Re: (gen/sample (s/gen #{'nil})): Couldn't satisfy such-that predicate

2019-01-30 Thread Alex Miller
On Wed, Jan 30, 2019 at 11:42 AM Rostislav Svoboda < rostislav.svob...@gmail.com> wrote: > Hi Alex, > > > You can see the special cases of nil, false, and true in the LispReader > here if you're curious: > > > https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/LispReader.java#L393

Re: (gen/sample (s/gen #{'nil})): Couldn't satisfy such-that predicate

2019-01-30 Thread Rostislav Svoboda
Hi Alex, > You can see the special cases of nil, false, and true in the LispReader here > if you're curious: > https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/LispReader.java#L393-L413 I think it's not the special case of nil, false and true what's causing me headache. I'm ha

Re: (gen/sample (s/gen #{'nil})): Couldn't satisfy such-that predicate

2019-01-29 Thread Alex Miller
You can see the special cases of nil, false, and true in the LispReader here if you're curious: https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/LispReader.java#L393-L413 On Tue, Jan 29, 2019 at 4:45 PM Alex Miller wrote: > > > On Tue, Jan 29, 2019 at 4:23 PM Rostislav Svobo

Re: (gen/sample (s/gen #{'nil})): Couldn't satisfy such-that predicate

2019-01-29 Thread Alex Miller
On Tue, Jan 29, 2019 at 4:23 PM Rostislav Svoboda < rostislav.svob...@gmail.com> wrote: > Hi Alex, > > > Sets are treated as predicate functions which are valid when they > produce a logically true value. > > So then my question boils down to: > Why is then (boolean (quote nil)) => false and (

Re: (gen/sample (s/gen #{'nil})): Couldn't satisfy such-that predicate

2019-01-29 Thread Rostislav Svoboda
Hi Alex, > Sets are treated as predicate functions which are valid when they produce a > logically true value. So then my question boils down to: Why is then (boolean (quote nil)) => false and (boolean (quote anything)) => true? And this boils down to: Why a type of quoted symbol (type (

Re: (gen/sample (s/gen #{'nil})): Couldn't satisfy such-that predicate

2019-01-29 Thread Alex Miller
Sets are treated as predicate functions which are valid when they produce a logically true value. Sets with logically false values nil or false will fail this check. This is not a spec thing, but a general thing to be aware of in Clojure when using sets as functions. If you want nils, use (s/ge

(gen/sample (s/gen #{'nil})): Couldn't satisfy such-that predicate

2019-01-29 Thread Rostislav Svoboda
Could anybody explain please why I can't get a sample of falses or quoted nils / falses here? foo.core> (clojure-version) "1.10.0" foo.core> (require '[clojure.spec.gen.alpha :as gen] '[clojure.spec.alpha :as s]) nil foo.core> (gen/sample (s/gen #{'nil})) Error printing return v