Feature request: allow C finalizers that can call back into Haskell
- Dominant language
- Haskell
- Stars
- 211
- Forks
- 52
- PR merge metrics
- No merged PRs in 30d
Description
I ran into the following error with my [libarchive](https://github.com/vmchale/libarchive) bindings:
```
error: a C finalizer called back into Haskell.
This was previously allowed, but is disallowed in GHC 6.10.2 and later.
To create finalizers that may call back into Haskell, use
Foreign.Concurrent.newForeignPtr instead of Foreign.newForeignPtr.
```
Looking at generated code, it looks like `c2hs` uses `Foreign.newForeignPtr` by default:
```
import qualified Foreign.C.String as C2HSImp
import qualified Foreign.C.Types as C2HSImp
import qualified Foreign.ForeignPtr as C2HSImp
import qualified Foreign.Marshal.Utils as C2HSImp
import qualified Foreign.Ptr as C2HSImp
```
(This is from
```
{#pointer *archive as ArchivePtr foreign finalizer archive_free #}
```
among other things)
Would it be possible to use `Foreign.Concurrent.newForeignPtr` with a new keyword?
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.