Open michaeljklein opened 8 years ago
Since pipes are no longer being used (except maybe for compilation alone), I'm not sure how relevant this is.
For one, the Haskell FFI supports returning a function pointer and the (non-recompiled) C code is well-integrated into Haskell.
See Parse.Templates
for the current template, which, at the moment, is:
data CFunctionTemplate = CFunTempl {returnType :: T.Text, functionName :: T.Text, inputVars :: [(T.Text, T.Text)], functionBody :: T.Text } deriving (Eq, Ord, Show)
Suppose we have the following C code:
int add(int a, int b){ return a + b; }
Then, on the Haskell end we'll have something like:
cAdd :: Fix CInt -> Fix CInt -> (CInt -> CInt -> CInt)
cAddTemplate CInt "add" [("int", "a"), ("int", "b")] "return a + b;"
But this is not enough to compile/run/call from Haskell. We need something like:
int main(){ int (*add_ptr)(int, int) = add; send_to_haskell( fun_ptr ); pause_indefinately(); ...
Thus this issue will be solved when an interface generator for C to Haskell is written.