haskell / haskell/parsec

Bad error handling: unhelpful "unexpected" error message when parsing set of strings

Open
#52 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Haskell
Stars
892
Forks
99
PR merge metrics
No merged PRs in 30d

Description

A parser like

```
parser :: GenParser Char st String
parser = choice $ fmap (try . string) ["head", "tail", "tales"]
```

with malformed input "ta " will produce an error message like `unexpected "t"` and point to the first position of the input. Better output would be `unexpected " "` (and possibly a list of expected outputs, `["tails", "tales"]` in this case).

Please see this much more detailed [StackOverflow answer/analysis](http://stackoverflow.com/a/34358623/1260229) written by _CR Drost_ (starting with the second headline).

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.