Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

phrasing error in recursive s/cat #6

Open
ioRekz opened this issue Jan 22, 2018 · 3 comments
Open

phrasing error in recursive s/cat #6

ioRekz opened this issue Jan 22, 2018 · 3 comments

Comments

@ioRekz
Copy link

ioRekz commented Jan 22, 2018

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

@alexanderkiel
Copy link
Owner

I see your point. Please give me some time to work through your gist.

@marco-m
Copy link

marco-m commented Jul 11, 2018

@alexanderkiel did you have any chance to think about this ? I am facing the same problem. Thanks!

@alexanderkiel
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants