[Haskell-cafe] managing embedded structs

Alexey Khudyakov alexey.skladnoy at gmail.com
Sun Aug 28 15:39:54 UTC 2016

On 27 August 2016 at 13:23, Henning Thielemann
<lemming at henning-thielemann.de> wrote:
> I want to write a Haskell interface to a C library that provides two data
> structures A and B, where B is contained in A. That is, if A is freed, then
> B is automatically freed, too.
I don't quite understand. Do A and B live in the same buffer and problem in
keeping buffer alive as long as there're pointers to A or B. If so
it's easy problem
and vector solves exactly this problem for storable vectors. Check
of basicUnsafeSlice. Idea is to share finalizer between ForeignPtr

If they live in different buffers and B should not be collected as
long as A lives...
I don't know how to implement this.

More information about the Haskell-Cafe mailing list