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

Parsec returns additional, spurious error messages on parserFail #91

Open
ksvanhorn opened this issue Apr 17, 2018 · 2 comments
Open

Parsec returns additional, spurious error messages on parserFail #91

ksvanhorn opened this issue Apr 17, 2018 · 2 comments

Comments

@ksvanhorn
Copy link

Consider the following code entered in ghci:

Parsec.parse (Parsec.many1 Parsec.digit <* Parsec.parserFail "foo") "" "123"

Here is the result:

Left (line 1, column 4):
unexpected end of input
expecting digit
foo

The error messages "unexpected end of input" and "expecting digit" should not be there.

This is simplified from a more involved example in which the result of parsing a number is checked, and parserFail is called if the number is out of bounds.

@buggymcbugfix
Copy link

I'm running into the same issue :(

@nomeata
Copy link

nomeata commented Jun 16, 2020

Yes, also curious for a good idiom about reporting such error messages, e.g. for

  do n <- many1 digit
       when (n < 0) fail "must not be empty"
       return n

where I’d somehow like to attache the error to the span parsed by many1 digit.

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