composewell / streamly

High performance, concurrent functional programming abstractions
https://streamly.composewell.com
Other
867 stars 66 forks source link

Add array conversion to and from foreignptr #2788

Closed harendra-kumar closed 1 month ago

harendra-kumar commented 4 months ago

Introduce something like toForeignPtr and fromForeignPtr so that we can implement the toArray and fromArray in streamly-bytestring.

adithyaov commented 3 months ago

toForeignPtr does not make sense when bounds aren't involved. We pass in the whole MutableByteArray# to the ForeignPtr which has the information of arrayCapacity but not arrayLength. (ForeignPtr, Int) will have all the information of Array without loss. We can however introduce asForeignPtr passing the length as well.

adithyaov commented 2 months ago

We have introduced unsafeAsForeignPtr