Allow for (unpinned) ByteArray# to be written directly to a Handle
Motivation
From what I understand, currently writing an (unpinned!!) Text
or ShortByteString
value to a Handle
always requires reallocation of the underlying payload.
My understanding is that there is currently no way to work around this as GHC.IO.Device.RawIO puts hard limits on what you can do with a handle.
Proposal
Add four new methods to RawIO
that work with ByteArray
instead of Ptr Word8
:
- readByteArray :: a -> MutableByteArray s -> Word64 -> Int -> IO Int
- readNonBlockingByteArray :: a -> MutableByteArray s -> Word64 -> Int -> IO (Maybe Int)
- writeByteArray :: a -> ByteArray -> Word64 -> Int -> IO ()
- writeNonBlockingByteArray :: a -> ByteArray -> Word64 -> Int -> IO Int
Edited by Simon Hengel