phrase
phrase copied to clipboard
phrasing error in recursive s/cat
I think this is as much a question on spec that it is on phrase but I need the right :problem
in order to display the message I want.
Here is a gist https://gist.github.com/ioRekz/5b9ae3f1b424eaf1a6256e082d1ad904
I'm close to achieve what I want but the last bit at the bottom is preventing me to achieve the goals
I see your point. Please give me some time to work through your gist.
@alexanderkiel did you have any chance to think about this ? I am facing the same problem. Thanks!
I suppose that this is an equivalent minimal example:
(s/def ::hiccup-exp
(s/spec
(s/cat
:tag #{:div}
:attrs (s/? map?)
:content (s/* (s/alt :exp ::hiccup-exp :text string?)))))
(s/explain-data ::hiccup-exp [:div "a"])
;;=> nil
(s/explain-data ::hiccup-exp [:a "a"])
;;=> ... :pred #{:div} ...
(s/explain-data ::hiccup-exp [:div [:a "a"]])
;;=> ... :reason "Extra input", :pred (clojure.spec.alpha/cat ...
I have no idea why spec works this way. Phrase depends on "nice" pred's in spec problems. I'll leave the issue open and would be happy if someone could debug spec in for this example.