-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add withForeignPtrST
, touchForeignPtrST
#294
Comments
I originally had to write these myself in order to consume |
To save a click, Ben says that
I like the proposal, although I'm not proficient in the area. |
withForeignPtrST :: ForeignPtr a -> (Ptr a -> ST s b) -> ST s b is doubtful interface, as there isn't really anything you can do with EDIT: you can build a morally pure ( |
Thanks. This surprises me, purely based off primop type signatures: I can |
withForeignPtr :: ForeignPtr a -> (Ptr a -> IO b) -> IO b
is a key utility for consumingForeignPtr
s safely. It is expectably common when consumingByteString
s.It and its related utilities use the primops
But
withForeignPtr
is stuck inIO
, preventing its use inST
contexts.(This is probably due to the relevant primops being stuck in the
RealWorld
until #152 , implemented in GHC 9.8.)I propose the following new functions:
These would be defined in
ghc-internal
atGHC.Internal.ForeignPtr
, together with theirIO
versions.My draft implementation below is boring, copied from the existing
IO
versions withST
swapped in.No breaking changes.
The text was updated successfully, but these errors were encountered: