[Haskell-cafe] Anonymous FFI calls

Francesco Mazzoli f at mazzo.li
Wed Feb 11 10:26:17 UTC 2015


Hi,

I am in a situation where it would be very useful to call C functions
without an explicit FFI import.  For example, I'd like to be able to do

    (foreign import ccall "cadd" :: CInt -> CInt -> CInt) 1 2

instead of declaring the foreign import explicitely at the top level.

Is there a way to do this or to achieve similar results in some other
way?

If not, I imagine it would be easy to implement such a facility in GHC,
given that the code implementing calling to C functions must already be
present to implement "proper" FFI imports.  I think such an addition
would be useful in many cases.

Thanks,
Francesco


More information about the Haskell-Cafe mailing list