[Haskell-cafe] ByteString and ByteString.Builder questions

Viktor Dukhovni ietf-dane at dukhovni.org
Thu Nov 30 08:07:25 UTC 2023

On Thu, Nov 30, 2023 at 06:58:32AM +0000, Zoran BoĆĄnjak wrote:

> Thanks for your answer. That makes sense. In particular the fact that
> there should be no need to read own output.
> However, one problem remains. Data format I am working with contains a
> total-length prefix. That is: 2 bytes of total length somewhere in the
> header of the message (header is of the fixed length). But the builder
> does not directly provide length.

I knew you'd eventually ask this question.

> So, how do I suppose to effectively encode the message in the form:
> msg = header <> chunk1 <> chunk2 <> ...

Take a look at my DNS Stub resolver codec:


and its "passLen" function:



More information about the Haskell-Cafe mailing list