I'm creating Haskell bindings for a C library. However, I want to adapt the calling conventions of the library to something more appropriate for Haskell so I've created a template class which has a static method that invokes the correct method when you use it the following way:
Wrap<decltype(&libraryFunction), &libraryFunction>::call(...);
Where ...
denotes the arguments. This is great, the compiler has generated the wrapper code for me apparently. I can even take the address of this function using the &
operator so it's apparently just a regular function.
However, Haskell cannot use C++ templates so what I'd like to do is to explicitly instantiate this template for the required functions and export them as regular C function which I can reference from Haskell. I know I could just make stubs that manually invoke this static member function but let's say I don't really feel like it.
Any ideas on how to do this? Portable or non-portable, I'd like to know if it's possible.