FFI Definition

Simon Peyton-Jones simonpj at microsoft.com
Mon May 7 04:42:03 EDT 2001


[Welcome back, Sigbjorn.  Are you on the FFI mailing list?    
Now you are back online you should be!]

| Export dynamic introduces a name, export static exports an 
| existing name. For that reason putting this distinction in 
| extent seems strange for me.

This seems like a good point to me.

    foreign export foo :: Int -> IO Int
	exports a C-callable function foo
	*uses* a Haskell function  foo :: Int -> IO Int 
		(that is, foo must be in scope)

    foreign export dynamic baz :: (Int -> IO Int) -> IO Addr
	does not export anything to C
	*defines* a Haskell function baz with the type specified
		(that is, the foreign decl binds baz)

This is rather different to 'foreign import' vs 'foreign import dynamic'
both of which import a function, but the type of the function depends
on whether it's dynamic.


PRINCIPLE: it should be possible to look at a foreign decl, and 
*without looking at the extent string* say what Haskell function is
used or defined, and what its type is.   

CONCLUSION: we need to say outside the extent string whether
we are doing foreign export or foreign export dynamic.  I'm not
sure what the right syntax is

Simon




More information about the FFI mailing list