-
Notifications
You must be signed in to change notification settings - Fork 1
Description
First of all, thanks for this nice little library! I am experimenting with doing batch file writes, but I found the shape of IOOpWrite quite inconvenient for the usual things I might want to write (e.g. ByteString), the use of MutableByteArray being the main issue. Looking at the source code, the MutableByteArray is immediately fed to mutableByteArrayContents to access the Ptr Word8 underneath. Therefore, my question is: would it be possible for IOOp (specifically IOOpWrite, but it should probably be fine for IOOpRead too) to take Ptr Word8 directly? That way, it would be possible to, say, write ByteStrings by extracting the ForeignPtr Word8, and in turn the Ptr Word8 within, and creating an IOOp out of that.
I have actually applied this change locally and it seems to be working fine. One thing worth mentioning is that it is not possible to use isMutableByteArrayPinned to guard against unpinned buffers since we would have a plain Ptr Word8. I don't know if there is a way to infer "pinnedness" from a Ptr, but I would guess not.