Given a Builder what's the most efficient way to determine if the serialized/reified data is greater than, say, 1kB?
. My best plan currently is using toLazyByteStringWith with a 1kB initial chunk size, and inspect just the first chunk to see if it's full.
But is there some way to do this without writing any data at all? (and preferably in a pure function?)
I got a bit lost trying to understand how running Builder directly on a socket works.
If efficiency is super important, you may want to write a small wrapper around a monoid that tracks the length explicitly:
There's already a suitable monoid instance for this type, but of course if you choose to use
newtypeinstead oftypeyou may want to add one withderiving.