Integrating Haskell with .Net?

笑着哭i 提交于 2019-12-10 19:02:03

问题


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.


回答1:


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.




回答2:


hs-dotnet: Pragmatic .NET interop for Haskell



来源:https://stackoverflow.com/questions/4111467/integrating-haskell-with-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!