new ForeignPtr without finalizers

Ashley Yakeley ashley at semantic.org
Mon Jun 9 19:25:37 EDT 2003


In article <200306091626.18920.alastair at reid-consulting-uk.ltd.uk>,
 Alastair Reid <alastair at reid-consulting-uk.ltd.uk> wrote:

> I'm not convinced that merging them into a single function is desirable, but, 
> if we wanted to, I think a better FPish solution is to use 
> 
>   Maybe (FinalizerPtr a)

I think the most FPish solution would be this:

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

That gives you an empty finalizers function and an add finalizers 
function, like [] and (:).

I don't really care, actually, as long as I can obtain the same 
functionality.

-- 
Ashley Yakeley, Seattle WA




More information about the FFI mailing list