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

Bulat Ziganshin bulat.ziganshin at
Tue Mar 7 12:31:25 EST 2006

Hello Brian,

Tuesday, March 7, 2006, 7:35:27 PM, you wrote:

BH> foreign import ccall duma_init :: Int -> IO Int

int duma_init(int);

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

see official FFI documentation -
and excellent paper "Tackling the awkward squad: monadic input/output, concurrency,
exceptions, and foreign-language calls in Haskell"

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

void f(void);

foreign import ccall f :: IO ()

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

if you are sure what you do, you can even declare C function as pure:

foreign import ccall duma_init :: Int -> Int

Best regards,
 Bulat                            mailto:Bulat.Ziganshin at

More information about the Glasgow-haskell-users mailing list