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

Jason Dagit dagit at codersbase.com
Thu Jul 29 13:35:07 EDT 2010


On Thu, Jul 29, 2010 at 6:15 AM, Duncan Coutts <duncan.coutts at googlemail.com
> wrote:

>
>
> No idea what WrappedByteString is.
>

WrappedByteString is a newtype wrapper around ByteString that has a phantom
type.  This allows instances of to be written such that ByteString can be
used with the iteratee library.  You can see the source here if you're
interested:
http://hackage.haskell.org/packages/archive/iteratee/0.3.5/doc/html/src/Data-Iteratee-WrappedByteString.html



>
> It would look like attoparsec's resumable parser:
>
> data Result a = Fail !ByteString
>              | Partial (ByteString -> Result a)
>              | Done !ByteString a
>
> runGet :: Get a -> ByteString -> Result a
>
> Point is you feed it strict bytestring chunks. Then decoding a lazy
> bytestring can be implemented on top easily, as can decoding a sequence
> lazily.
>

Like attoparsec you'll probably want to write some other utility functions
for working with Results.  Attoparsec defines feed, parseWith, maybeResult,
and eitherResult.  I think you'll want something similar here.


> I imagine you could fairly easily interface it with iteratee too.
>

Yes that should be easy given the above API.  See for example the
attoparsec-iteratee package.

Once that work is done how will binary differ from cereal?  How will I know
which one to pick?

Thanks,
Jason
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100729/539d8301/attachment.html


More information about the Haskell-Cafe mailing list