You need to create a C-exported shell for the C ++ api and a Haskell shell for FFI in the C-exported shell.
Marshaling between C # and Haskell is described here: Haskell call with C #
but it is very similar to marshaling between C ++ and Haskell
For example, create a C ++ export function:
extern "C" __declspec(dllexport) int __cdecl addFive(int number); extern "C" __declspec(dllexport) int __cdecl addFive(int number) { return number + 5; }
In Haskell, you need an import code:
foreign import ccall "addFive" addFive :: Int -> Int
Then you can use addFive in Haskell as a typical Haskell function
For composite data types (classes and structures) you need to create an analogue of the C ++ data type in Haskell. Then you need to describe how the marshal's data types are from C ++ to Haskell and from Haskell to C ++.
In Haskell, this means that you need to create a Storable instance for your data types.
Bet Jul 15 '16 at 15:04 2016-07-15 15:04
source share