[Haskell-cafe] data.binary get reading beyond end of input bytestring?

Bryan O'Sullivan bos at serpentine.com
Thu Jul 29 14:16:30 EDT 2010


On Thu, Jul 29, 2010 at 10:55 AM, Jason Dagit <dagit at codersbase.com> wrote:

> Given those constructors for Result, how will you decode a sequence lazily?
>

I deliberately left incremental results out of the attoparsec API, because
it's a burrito-filled spacesuit of worms.

The problem is that parsers can nest and fail and backtrack and be, in
general, arbitrarily perverse. For instance, if there was a "yield" action,
I could yield you a 1, backtrack, then yield you a 10 from some completely
different branch of the parser that neither I nor you could foresee.

Now, lazily parsing a sequence of data is a very common need, and it's also
highly constrained, and hence easy to predict. It's also something that's
easy to write without any access to the attoparsec internals. It would take
just a few moments to write this:

parseSequence :: Parser a -> Lazy.ByteString -> [a]

I haven't added this to attoparsec because it's (a) trivial and (b) just one
possible approach. Using iteratees would be another; running with a monadic
action that can refill the parser on a Partial result would be yet another.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100729/0def3ff3/attachment.html


More information about the Haskell-Cafe mailing list