[jhc] some FFI questions

Samuel Bronson naesten at gmail.com
Sat Jul 7 14:20:49 EDT 2007

First of all, I'm wondering what the intended uses of the lookupCType
and lookupCType' functions are. It seems like lookupCType tells you
the type that should be used in marshalling a type, and lookupCType
tells you the primitive type that is used in the representation of a
type as well as how to extract the value from it. I'm not sure how to
go from there to actually converting to/from the correct primitive
type to use in interfacing with C code...

Another question is: what sort of E type should an imperative foreign
export use? Consider:

foreign export hello :: Int -> IO ()
hello n = putStrLn ("Hello, "++show n)

foreign export foo :: IO Int
foo :: Num a => IO a
foo = return 1

Should they just use IO? I guess that's what main does...

More information about the jhc mailing list