ffihugs [option...] [-i
include...] file [cc-arg...]
Suppose you have some C functions in test.c
with some foreign import declarations for those
functions in Test.hs,
and that the code in test.c needs to be
compiled with -lm
.
To use these with Hugs, you must first use ffihugs
to generate Test.c, compile it and link it against
test.c with -lm
to produce
Test.so:
ffihugs Test.hs test.c -lmAny Hugs options should be placed before the module name, as in
ffihugs -98 Test.hs test.c -lmNow you can run Hugs as normal:
hugs -98 Test.hsWhen Test.hs is loaded, Hugs will load Test.so and then use the imported functions. (If Test.hs depends on other modules using foreign functions, you'll have to have compiled those modules too, but not necessarily before compiling Test.hs.)
In the standard FFI, each foreign import declaration should name a C header file containing the prototype of the function. Because this is often cumbersome, ffihugs provides the following additional option: