FFI with ABI instead of C declaration

Maurício CA mauricio.antunes at gmail.com
Fri Mar 11 15:17:54 CET 2011

Hi, all,

I wonder: why, in Haskell and also in other languages like ML, FFI is
done with C type and code as references? Since, ultimately, compiled
code goes to, say, ELF files or (in Windows) DLLs, shouldn't foreign
interfaces be consistent with those?

I believe this could simplify writing foreign interfaces. Say, we could
write something like this:

	foreign haskell_name1 binary_name1 :: T1 -> T2 -> IO T1
	foreign haskell_name2 binary_name2 :: T1 -> T3 -> IO T4

Our FFI tool would take a set of binary libraries where to look for
binary_name[i], and match haskell_name[i] with those.  T[i] would be
made synonyms of types which would offer all capabilities consistent
with the corresponding types in those libraries ABIs. Inconsistency,
of course, would be an error (like if, in the example above, the first
parameter of both functions would not be the same).

Thanks for your thoughts,

More information about the Libraries mailing list