[EMAIL PROTECTED] writes:
>
...
>
> I know how to call C from Haskell, how to call Perl from C and I
> am beginning to know how to call C from Perl. The missing part is
> Haskell from C...
>
Here's a simple example demonstrating how to call into Haskell
from C
foo% ghc --version
The Glorious Glasgow Haskell Compilation System, version 4.04, patchlevel 0
foo% cat For.hs
module For where
foreign export "putChar" putChar :: Char -> IO ()
foo% ghc -c For.hs -fglasgow-exts
ghc: module version changed to 1; reason: no old .hi file
foo% cat test.c
#include "For_stub.h"
int
main(int argc, char *argv[])
{
char msg[] = "Hello, world\n";
startupHaskell(argc,argv);
for (i=0; i < sizeof(msg) - 1; i++) {
putChar(msg[i]);
}
shutdownHaskell();
}
foo% ghc -c test.c
foo% ghc -no-hs-main -o testApp test.o For.o For_stub.o
foo% ./testApp
Hello, world
foo%
Have a look at the HDirect www pages for more info regarding
FFI work, http://www.dcs.gla.ac.uk/fp/software/hdirect/
hth
--sigbjorn