[Haskell-cafe] Propagating Parsec errors

Tomasz Zielonka tomasz.zielonka at gmail.com
Sun Dec 5 12:38:31 EST 2004


On Thu, Dec 02, 2004 at 02:48:07PM +0000, Mark Carroll wrote:
> Is there a way in Parsec to, within a parser, throw an error generated 
> by another parser? For instance, something of type
> 
> 	ParseError -> GenParser tok st a
> 
> or whatever.

I guess no. I tried hard to find this about a month ago, but my best
approximation was something like this:

    do  setPosition (errorPos err)
        fail (messageString (head (errorMessages err)))

which is very, very unsatisfying.

It would be nice, if there were explicit functions in Parsec for this and
also:

    instance Control.Monad.Error.MonadError ParseError (GenParser tok st) ...

Best regards,
Tomasz


More information about the Haskell-Cafe mailing list