[Haskell-cafe] Re: allocation for "pure" FFI functions

Johannes Waldmann waldmann at imn.htwk-leipzig.de
Fri Oct 15 05:24:08 EDT 2010


Duncan Coutts <duncan.coutts <at> googlemail.com> writes:

> It is exactly for this purpose that the Haskell FFI library includes
> unsafePerformIO. This is basically *the* legitimate use case for it, so
> you don't need to feel bad about it.

OK, thanks. Then this means my C type is a ForeignPtr,
and each time I use it (even read-only) it looks like
unsafePerformIO $ withForeignPtr $ \ p -> ...

Meanwhile I think I found a nice example and explanation here:
http://en.wikibooks.org/wiki/Haskell/FFI#Self-Deallocating_Pointers

J.W.




More information about the Haskell-Cafe mailing list