Is it normal for exercise-fn to return examples that don't conform?

2017-03-29 Thread Didier
If you look at this example: (defn wtv [in] (if (= 0 in) 0 10)) (s/fdef wtv :args (s/cat :in int?) :ret (s/and int? #(not= 0 %))) (s/exercise-fn `wtv) (s/conform `wtv (wtv 0)) You'll see that exercise gives you most of the time the following sample: [(0) 0] But this fails to

Re: Protocol support with spec?

2017-03-29 Thread Didier
> > multi-spec doesn't require you to use a key of a map - it's an arbitrary > function on arbitrary data, so it could leverage satisfies? or other > protocol functionality. > Oh, that's good to know, but I'm talking other way around. Where I can dispatch based on what the spec is for a given

Re: escape characters to make a string literal

2017-03-29 Thread Didier
| Also interesting, clojure's print methods will handle some escapes, but not others I think that's just that \t is printed as \t. Like a tab shows up as \t. Whereas say a Unicode like \u1234 will show the character of it. You can seek that here: (print (pr-str "foo\u0009bar"))

Re: Protocol support with spec?

2017-03-29 Thread Alex Miller
multi-spec doesn't require you to use a key of a map - it's an arbitrary function on arbitrary data, so it could leverage satisfies? or other protocol functionality. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email

Re: Protocol support with spec?

2017-03-29 Thread Didier
| I don't understand what this one is. I think I might be wishing specs were also types. In my head, I see as say, if I spec a vector as ::cart-items, I'd like to implement a protocol for ::cart-items which will dispatch to the function handling ::cart-items, and if that didn't exist, it

Re: escape characters to make a string literal

2017-03-29 Thread Brian Craft
A funny hole in the meta-programming story. I don't think the String or Character classes have methods that do this. Also interesting, clojure's print methods will handle some escapes, but not others: cavm.core=> (println (pr-str "foo\tbar")) "foo\tbar" nil cavm.core=> (println (pr-str

escape characters to make a string literal

2017-03-29 Thread Alex Miller
Clojure leans on Java to read that literal. There is no Clojure function to forcibly print it that way again, but you can probably use the Java methods on String or Character to get the String representation of a character somehow. -- You received this message because you are subscribed to

escape characters to make a string literal

2017-03-29 Thread Brian Craft
Is there an easy way to display a string as a string literal that can be read by clojure? E.g. > (let [x "\001"] (what-goes-here x)) "\001" -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to

Re: Protocol support with spec?

2017-03-29 Thread Alex Miller
On Tuesday, March 28, 2017 at 11:52:11 AM UTC-5, Didier wrote: > > I was wondering if protocols do or will be extended to support specs? I think that's undetermined at this point. > I'm thinking in the two following ways: > > 1) I can spec a protocol's functions so that whoever implements