[Haskell-cafe] Backtracking when building a bytestring

David Turner dct25-561bs at mythic-beasts.com
Fri Jun 24 13:28:47 UTC 2016


On 24 June 2016 at 11:41, Yuras Shumovich <shumovichy at gmail.com> wrote:

>
> I think it is possible (and easy) to implement with
> Data.ByteString.Builder. Just use the low-level interface: http://hacka
> ge.haskell.org/package/bytestring-0.10.8.1/docs/Data-ByteString-
> Builder-Extra.html#v:runBuilder
>
> BufferWriter takes a buffer to write to and returns a continuation to
> be called in case the buffer is too small. The idea is to allocate a
> buffer, but reserve necessary space for length and checksum. Then run
> the builder, get the resulting ByteString (or work directly with `Ptr
> Word8`), calculate length and check sum and write then into the
> reserved space.
>
> Just be careful when using the low level API, and read the docs
> carefully.
>


Aha, thanks, that looks like just what I'm after! Great.


On 24 June 2016 at 10:39, Axel Mannhardt <axel.mannhardt at freiheit.com>
 wrote:

>
> this might be of interest to you - the explanation is in German though:
>
> http://nfa.imn.htwk-leipzig.de/HAL2015/programm/slides/breitner.pdf
>
> Cheers,
> Axel


My German is nonexistent but fortunately the code is English enough to
read, thanks. Unfortunately,

> type ByteString = [Word8]

This is not the ByteString I'm looking for!

Cheers,

David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20160624/c8f987cd/attachment.html>


More information about the Haskell-Cafe mailing list