Ross Paterson <[EMAIL PROTECTED]> wrote,

> On Thu, Sep 19, 2002 at 12:03:34AM +1000, Manuel M T Chakravarty wrote:
> > RC 7 of the FFI Addendum is now available from
> > 
> >   http://www.cse.unsw.edu.au/~chak/haskell/ffi/
> 
> Must it include unsafePerformIO?

Sometimes you have a C function that is pure (and hence, you
want to give it a pure type), but as C cannot return complex
structures as a function result, you need to allocate a
piece of memory, pass a pointer to the C function, and read
the result out of that memory area on return of the C
function.  All this marshaling business requires IO actions;
however, it doesn't change the pureness of the overall
function.  So, you typically want to unsafePerformIO the
marshaling business.

Cheers,
Manuel
_______________________________________________
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell

Reply via email to