[Haskell-cafe] Parsing workflow

Vo Minh Thu noteed at gmail.com
Sun Oct 31 11:53:16 EDT 2010

2010/10/31 Nils Schweinsberg <ml at n-sch.de>:
> Hi!
> I'm having a really hard time to write a correct parser for a small language
> I've developed. I have been trying to write a parser using parsec, but
> always get a lot of error messages like "unexpected "\n", expected ...,
> new-line or..." when trying to run the parser.
> [snip]


I can't really tell from your description, but maybe this is because
of the way Parsec works when it deals with alternatives. When you
combine several parsers with e.g. '<|>' or 'choice', an alternative
that can consume some input but fails will make the whole combined
parser fail too. So you have to either factorize you parsers or use
the 'try'. See the documentation for 'try' at


More information about the Haskell-Cafe mailing list