Re: Recursive clojure.spec doesn't work

2016-10-06 Thread Yehonathan Sharvit
This recursive definition also works - the difference is that the inner :html/element is not wrapped in s/spec: (s/def :html/element (s/cat :tag keyword? :attrs map? :children (s/* (s/alt :element :html/element :string string? I'm a bit confused

Re: Recursive clojure.spec doesn't work

2016-10-06 Thread Aaron
Well I'm referring to the OP's original example: (s/def :html/element > (s/cat >:tag keyword? >:attrs map? >:children (s/* (s/alt :element (s/spec :html/element) > :string string? > > The exception says: "Unable to resolve spec: :html/element". > On

Re: Recursive clojure.spec doesn't work

2016-10-06 Thread Alex Miller
Can you share a specific case? -- 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

Re: Recursive clojure.spec doesn't work

2016-10-05 Thread Aaron
I was playing around with something similar to the OP and encountered this same problem using s/spec recursively. Yes, I get it that there are work-arounds, but it seems like this is a legitimate issue. s/spec as you say resolves at definition time, but the rest of the combinators (s/alt,

Re: Recursive clojure.spec doesn't work

2016-07-20 Thread Johan Jonasson
It works! Thanks! Seems like I have to learn more about s/spec. On Wednesday, July 20, 2016 at 5:46:20 PM UTC+2, Alex Miller wrote: > > s/spec is going to try to resolve that keyword during the definition. Does > this do what you want? > > (s/def :html/element > (s/spec (s/cat >

Re: Recursive clojure.spec doesn't work

2016-07-20 Thread Alex Miller
s/spec is going to try to resolve that keyword during the definition. Does this do what you want? (s/def :html/element (s/spec (s/cat :tag keyword? :attrs map? :children (s/* (s/alt :element :html/element

Recursive clojure.spec doesn't work

2016-07-20 Thread Johan Jonasson
I might have stumbled upon a bug in clojure.spec, while trying to define a spec. This doesn't compile: (s/def :html/element (s/cat :tag keyword? :attrs map? :children (s/* (s/alt :element (s/spec :html/element) :string string? The exception says: "Unable