[Haskell-cafe] Parsing of bytestrings with non-String errors?

Bryan O'Sullivan bos at serpentine.com
Mon Feb 22 19:39:59 EST 2010

On Mon, Feb 22, 2010 at 2:38 PM, Magnus Therning <magnus at therning.org>wrote:

> My thoughts went more like a parser type like
>    data Parser e a = ...

Yes, I knew that's where you were going :-)

The trouble is, you'd still have to deal with
fail :: Monad m => String -> m a
which would require your failure type to somehow accept a string. Plumbing
that in would be a little more awkward than your initial exporations suggest

You have two problems. The first is how to construct a value of your failure
type that accepts a String parameter so that you can support users of
"fail". The second is that you might need to pass extra information to
construct your failure value when naïve code uses fail or mzero, otherwise
you will only get useful error values out quite infrequently.

> I still haven't convinced myself that this will work though.  Also, I had a
> look at attoparsec on bitbucket, and there are some major changes between
> 0.7
> and 0.8.

Even though those changes represent a major modification to the internals of
attoparsec, they shouldn't really affect what you want to do, or anything
interesting about how to do it.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100222/f78eee1c/attachment.html

More information about the Haskell-Cafe mailing list