HI Gracjan,

I would like to attach finalizer (written in Haskell) to some pointer. When the pointer won't be needed any more, finalizer should run. So here is the code:

import Foreign.ForeignPtr

I couldn't get finalisers to work either with the newForeignPtr from this module. I didn't know how to create a proper FunPtr. In Foreign.Concurrent there is a newForeignPtr that is easier to use:


newForeignPtr :: Ptr a -> IO () -> IO (ForeignPtr a)

This one worked beautifully for me. In your code something like:

import Foreign.ForeignPtr hiding (newForeignPtr)
import Foreign.Concurrent

   ... fptr <- newForeignPtr ptr (finDoIt ptr)

Hope this helps,
  Arjan

_______________________________________________
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

Reply via email to