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