On 24 June 2016 at 11:41, Yuras Shumovich <shumovichy@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@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