newForeignPtr

m v mivori at hotmail.com
Mon Feb 3 06:03:57 EST 2003


I do not understand the rational behind the type of, why the change from the 
previous definition:

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

suppose I have a function

  foreign import ccall fooalloc :: IO (Ptr Foo)

and

  foreign import ccall foofree :: Ptr Foo -> IO ()

now how do I create a foreign pointer without either using:

  foreign import ccall "wrapper" mkfoofree :: (Ptr Foo->IO())->IO (FunPtr 
(Ptr Foo->IO()))

or declaring


  foreign import ccall "&foofree" foofree :: FunPtr(Ptr Foo->IO())

after all why should I need to import and then re-export or suppose I want 
foofree as a function or for
that matter suppose Foo were a simple memory alloc which could be freed from 
haskell, why should we be forced to wrap a haskell function to create a 
foreign pointer, or am I missing something ?




_________________________________________________________________
MSN 8 with e-mail virus protection service: 2 months FREE*  
http://join.msn.com/?page=features/virus




More information about the FFI mailing list