I was wondering if there is any good documentation out there for integrating Haskell with the outside world (specifically .NET). I would like to be able to call Haskell functions from within my .NET code. I saw that there was a previously posed question that showed how to pass strings back开发者_高级运维 and forth, but I was wondering if there are more general references and the possibility of passing more complex type.
hs-dotnet: Pragmatic .NET interop for Haskell
You should probably read the stuff in that other question more clearly, because it does actually give links to relevant stuff. But here's a bullet-point version anyway:
You can call unmanaged native code from .NET using P/Invoke. See the end of the Wikipedia article for tutorials and documentation on this part.
You can export Haskell functions through Haskell's FFI. Make sure you export the functions with the correct calling convention (stdcall, not ccall). See also GHC's FFI documentation.
So basically what you want to do is export your Haskell functions as if you were going to use them from C, build a DLL with the functions you want, then use P/Invoke to call the Haskell functions. And definitely re-read the accepted answer to the other question, it mentions several pitfalls you'll need to avoid.
精彩评论