6
votes

I'm writing a haskell wrapper for a c++ library and as much as I can import functions from the library to my haskell program, I have no clue how to import c++ data types. For instance I have a function which takes as a parameter a video::E_DRIVER_TYPE EDT_OPENGL type defined in some.h file, and as I said before I know how to import the function with ffi using

foreign import ccall ...

with the appropriate compiler-mangled function name

but I'm not able to call the function from haskell because I can't figure out how to import/use this specific video driver data type.

Now, I know that you can create types in Haskell but still I need a starting point as to what to define the type to whatever the c++ representation is. (I'm confused at this point)

I would appreciate any kind of help! Thanks

1
May I ask the purpose of creating such a wrapper?Babra Cunningham

1 Answers

4
votes

Calling C++ from Haskell is quite difficult; Haskell Wiki / Cxx foreign function interface lists some options.