[Haskell-cafe] Re: Proving my point

Philippa Cowderoy flippa at flippac.org
Fri May 16 17:46:38 EDT 2008

On Fri, 16 May 2008, Achim Schneider wrote:

> My problem is that realTopLevel = expr, and that I get into an infinite
> recursion, never "closing" enough parens, never hitting eof.

Have you run into the left-recursion trap, by any chance?

This doesn't work:

expr = do expr; ...

You can cover common cases with combinators like many* and chain* though.

> Btw: Is there any way to make Parsec return a tree of things it tried?
> The end-user error messages are quite often just not informative enough
> while debugging the parser itself.

If you're willing to accept a little pain, you can write a few helper 
functions akin to <?> that keep a log in Parsec's state and extract it 
from there.

flippa at flippac.org

Society does not owe people jobs.
Society owes it to itself to find people jobs.

More information about the Haskell-Cafe mailing list