I just spent the last week or so figuring out how to execute C ++ code with C # as part of my day job. It took us endlessly to figure this out, but the final solution is pretty simple.
Now I'm curious ... How hard would it be to name Haskell with C #? (Note: this is a Haskell call from C #, not the other way around. Therefore, C # is the main executable.)
If it is really difficult, I will not worry. But if it is easy enough, I may have to play with him ...
Basically, we wrote C ++ code. On Windows, it compiles to a DLL, and on Linux it compiles to a shared object ( *.so ). Then on the C # side, you do DllImport and write some manual memory management code if you are trying to pass something non-trivial. (E.g. arrays, strings, etc.)
I know that the GHC should support the creation of shared libraries on both platforms, but I'm not sure about the technical details. What is the syntax for exporting material, and the caller must do something special to initialize the DLL first?
Specifically: suppose that there is a function foobar :: FilePath -> IO Int32 . Can someone throw together a small sketch drawing:
- What Haskell ads I need to write to expose this to the outside world.
- How to tell GHC to create a separate standalone DLL / SO file.
- All the caller has to do, besides the usual binding process of the
foobar itself.
I'm not too worried about the actual syntax for the C # side; I think I was more or less puzzled by this.
PS I looked briefly at hs-dotnet , but it looks like Windows. (Ie, it wonβt work with Mono, so it wonβt work on Linux.)
c # haskell ffi
MathematicalOrchid May 17 '13 at 18:27 2013-05-17 18:27
source share