Skip to content

Casting ForeignPtr to pinned ByteArray

Regular ByteArray# is managed by GC, but pinned ByteArray looks totally compatible with ForeignPtr (mmapFileByteString).

I realized that casting Addr# to pinned array ByteArray# is not possible. isPinnedByteArray# returns false for the casted value.

Having such casting option would help to improve Parsec parser performance for Text type. I haven't found a way to turn a memory mapped ByteString into Text without copying and I have to rewrite parser to work with ByteString instead of Text.

Edited by Daniil Iaitskov
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information