Open jberryman opened 10 years ago
(is there a class for types convertable to ByteString?)
So what this is almost just Builder
, where we could use a BufferWriter to write the buffer to our array, for an interface like:
writeChan :: ChanBytesString -> Builder -> IO ()
The only issue though is that we want (an O(1), preferably) function:
builderLength :: Builder -> Int
i.e. the amount of allocation needs to be statically known (so we know how much to increment our counters).
I think this requires a new library, but buffer-builder seems to be almost there already, and would at least be a good place to start a fork if the required changes aren't possible.
Unagi.Unboxed
could be modified fairly easily to use a payload that matches the internals of eitherText
orByteString
. I'm a little bit sketchy on details but this could accommodate some pretty interesting and very efficient functions, like:a concurrent builder for
Text
, something like:ByteString
(is there a class for types convertable to ByteString?)concurrent Text and/or ByteString readers, something like:
Text
. This case would involve efficient memory copies into the unagi array; I'm not sure if this makes more or less sense than functions describes above which would convert and write directly into the unagi array.Please comment with your particular use case if you need something like these.