How to find out the C type signature corresponding to a Haskell function type in FFI?

Brian Hulley brianh at
Tue Mar 7 11:35:27 EST 2006

Hi -
I've got a Haskell module with the following ffi import:

foreign import ccall duma_init :: Int -> IO Int

However my problem is that I've got no idea what the type signature for the 
corresponding C function should be, and when I compile the above module with 
ghc -fglasgow-exts -fffi --make it doesn't create any stubs either.

I've tried looking at the wiki but that only seems to give specific 
examples. I'm trying to find what the mapping is between Haskell function 
signatures and C signatures is in general. Any ideas?

Also, I really wanted to be able to use () -> IO () but () doesn't seem to 
be allowed in FFI...

A third point is, how would I pass an arbitrary monad instead of just using 

Thanks, Brian.

More information about the Glasgow-haskell-users mailing list