Using higher-order Haskell types in C#

Viewed 2094

How can I use and call Haskell functions with higher-order type signatures from C# (DLLImport), like...

double :: (Int -> Int) -> Int -> Int -- higher order function

typeClassFunc :: ... -> Maybe Int    -- type classes

data MyData = Foo | Bar              -- user data type
dataFunc :: ... -> MyData

What are the corresponding type signature in C#?

[DllImport ("libHSDLLTest")]
private static extern ??? foo( ??? );

Additionally (because it may be easier): How can I use "unknown" Haskell types within C#, so I can at least pass them around, without C# knowing any specific type? The most important functionality I need right know is to pass around a type class (like Monad or Arrow).

I already know how to compile a Haskell library to DLL and use within C#, but only for first-order functions. I'm also aware of Stackoverflow - Call a Haskell function in .NET, Why isn't GHC available for .NET and hs-dotnet, where I didn't find ANY documentation and samples (for the C# to Haskell direction).

3 Answers
Related