snoyberg / mono-traversable

Type classes for mapping, folding, and traversing monomorphic containers
152 stars 61 forks source link

vectorBuilder does not stream data #189

Open axman6 opened 4 years ago

axman6 commented 4 years ago

I received a PR recently which used vectorBuilder to produce ByteStrings (via conversion from unboxed vectors). I was surprised when I looked at the source code that it does not produce vectors lazily, and instead produces the list of vectors and yields them all once the conduit has finished. Is this expected behaviour? It's certainly surprising to me given its type!

snoyberg commented 4 years ago

It's honestly been so long since I wrote this that I don't remember. From the code and comments, it looks like it's designed to handle a very specific kind of inefficiency we were running into at the time, and may in fact not stream the output as you're anticipating.

axman6 commented 4 years ago

It looks like I'm probably wrong about the behaviour of the function, I'd missed how yieldS interacted with onAwait.