3

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.

3
  • 1
    Dupe: stackoverflow.com/questions/1494478/… Commented Nov 6, 2010 at 2:08
  • I read that thread an it showed one specific example of calling a string function. I am looking for more general documentation on how to export functions out of Haskell. Commented Nov 6, 2010 at 2:10
  • Possible duplicate of Call a Haskell function in .NET Commented Aug 16, 2017 at 3:55

2 Answers 2

4

hs-dotnet: Pragmatic .NET interop for Haskell

Sign up to request clarification or add additional context in comments.

Comments

3

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.

1 Comment

I guess this seems to be the best resource I've found as well. I also found this thread stackoverflow.com/questions/3338940/…

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.