You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 13, 2024. It is now read-only.
Is your feature request related to a problem? Please describe.
I would like to use ForeignPtr to deal with the disposal of a Module. Currently, I can't pass Binaryen.Module.dispose as a finalizer to newForeignPtr as it's not a FunPtr.
Additionally, newForeignPtr and withForeignPtr want to deal with Ptr Module values rather than Module ones.
Describe the solution you'd like + Describe alternatives you've considered
To enable using Binaryen.Module.dispose as a finalizer, I believe the import would need to look like:
However, to make using the API with withForeignPtr nice, I can think of three options:
Have the user of haskell-binaryen implement wrappers such as newModuleForeignPtr :: FunPtr (Module -> IO ()) -> Module -> IO (ForeignPtr Module) and withModuleForeignPtr :: ForeignPtr Module -> (Module -> IO a) -> IO a.
Change haskell-binaryen to make all the FFI imports return or take a Ptr Module rather than a Module.
Change haskell-binaryen to export a Module type which wraps a ForeignPtr, have Module.create/Module.allocateAndWriteText set up finalizers, and have the exposed API use withForeignPtr internally.
I'm okay with any solution.
Additional context
I might be able to make a pull request once I know if/how you would like this to be done.
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Is your feature request related to a problem? Please describe.
I would like to use
ForeignPtr
to deal with the disposal of aModule
. Currently, I can't passBinaryen.Module.dispose
as a finalizer tonewForeignPtr
as it's not aFunPtr
.Additionally,
newForeignPtr
andwithForeignPtr
want to deal withPtr Module
values rather thanModule
ones.Describe the solution you'd like + Describe alternatives you've considered
To enable using
Binaryen.Module.dispose
as a finalizer, I believe the import would need to look like:However, to make using the API with
withForeignPtr
nice, I can think of three options:newModuleForeignPtr :: FunPtr (Module -> IO ()) -> Module -> IO (ForeignPtr Module)
andwithModuleForeignPtr :: ForeignPtr Module -> (Module -> IO a) -> IO a
.Ptr Module
rather than aModule
.Module
type which wraps aForeignPtr
, haveModule.create
/Module.allocateAndWriteText
set up finalizers, and have the exposed API usewithForeignPtr
internally.I'm okay with any solution.
Additional context
I might be able to make a pull request once I know if/how you would like this to be done.
The text was updated successfully, but these errors were encountered: