ANN: H98 FFI Addendum 1.0, Release Candidate 7

Manuel M T Chakravarty chak@cse.unsw.edu.au
Thu, 19 Sep 2002 22:28:36 +1000 (EST)


Ross Paterson <ross@soi.city.ac.uk> 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