Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

haskell generate FFI export wrapper code

Tags:

haskell

ffi

I am writing some code in haskell that has to be callable from C. Is there a tool or library in Haskell that simplifies writing FFI wrapper code for haskell functions that needs to be exported.

For example the tool given a haskell function to be exported would take care(generate the wrapper code) of mapping haskell types to the correct Foreign.C types etc. as required. It would also take care of generating the correct pointers when mapping [Int] types etc. Like what the questioner is attempting here Automatic conversion of types for FFI calls in Haskell. But only is it available like a library?

like image 406
Pradeep Avatar asked Mar 15 '12 14:03

Pradeep


1 Answers

I wrote a tool called Hs2lib to do this. If you're on windows you're in luck, it'll do everything including compiling the code to a dll and generating c/c++ or c# wrappers. If you're on linux, I'm afraid I haven't gotten the compilation step to work yet, but it still produces the required marshalling information and stubs. You can tell it to keep those by using the -T flag.

like image 177
Phyx Avatar answered Oct 24 '22 16:10

Phyx