[Haskell-cafe] FFI Newbie: c functions that want pointers to objects

Mauricio briqueabraque at yahoo.com
Thu Oct 16 08:28:21 EDT 2008


Some functions in C changes data using pointers,
like this example:

void change_int (int *n)
   *n ++;

What is the proper way to handle that? I
guess I should wrap it like this:

foreign ccall "change_int" change_int
  :: Ptr CInt -> IO ()

Can I use that on a CInt in Haskell code?
Like this obviously wrong code, but that
probably shows what I want:

   let myN = 5
   change_int myN


More information about the Haskell-Cafe mailing list