ANNOUNCE: Salsa: A .NET Bridge for Haskell

I'd like to announce the first release of Salsa, an experimental Haskell library that allows Haskell programs to access .NET libraries. Here's a taste:
type Hello.hs import Foreign.Salsa import Bindings
main = withCLR $ do _Console # _writeLine ("Hello .NET World!")
type Hello.imports System.Console: WriteLine
msbuild .\hello Hello .NET World!
Salsa operates by loading the .NET runtime into your Haskell process and using the FFI (and run-time code generation) to marshall calls between the .NET and Haskell runtimes. It includes a code generator and a type-level library (which uses type families) to provide type-safe access to .NET libraries in Haskell with C#-style method overload resolution and implicit conversions. The adventurous can find version 0.1.0.1 of Salsa on Hackage [1], the darcs repository on code.haskell.org [2], and some (limited) documentation on the Haskell wiki [3]. The library is experimental and by no means complete (refer to the wiki page [3] for some of its limitations). Be prepared to end up with incomprehensible error messages and/or a broken compiler! :-) At the moment you'll need Windows, GHC 6.8, and version 3.5 of the .NET Framework to use it. Have fun! [1] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Salsa [2] http://code.haskell.org/Salsa [3] http://haskell.org/haskellwiki/Salsa -- Andrew

Great! Are there any chances of getting support for non-Win32
platforms with Mono?
On Fri, Oct 10, 2008 at 2:12 PM, Andrew Appleyard
I'd like to announce the first release of Salsa, an experimental Haskell library that allows Haskell programs to access .NET libraries.
Here's a taste:
type Hello.hs import Foreign.Salsa import Bindings
main = withCLR $ do _Console # _writeLine ("Hello .NET World!")
type Hello.imports System.Console: WriteLine
msbuild .\hello Hello .NET World!
Salsa operates by loading the .NET runtime into your Haskell process and using the FFI (and run-time code generation) to marshall calls between the .NET and Haskell runtimes. It includes a code generator and a type-level library (which uses type families) to provide type-safe access to .NET libraries in Haskell with C#-style method overload resolution and implicit conversions.
The adventurous can find version 0.1.0.1 of Salsa on Hackage [1], the darcs repository on code.haskell.org [2], and some (limited) documentation on the Haskell wiki [3].
The library is experimental and by no means complete (refer to the wiki page [3] for some of its limitations). Be prepared to end up with incomprehensible error messages and/or a broken compiler! :-)
At the moment you'll need Windows, GHC 6.8, and version 3.5 of the .NET Framework to use it.
Have fun!
[1] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Salsa [2] http://code.haskell.org/Salsa [3] http://haskell.org/haskellwiki/Salsa
-- Andrew _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Alfonso Acosta wrote:
Great! Are there any chances of getting support for non-Win32 platforms with Mono?
Yep, I believe it's possible. The interoperability layer is centered around two .NET methods: - Marshal.GetDelegateForFunctionPointer and - Marshal.GetFunctionPointerForDelegate As long as Mono correctly implements these methods (I haven't tested them, but Mono appears to implement them), it shouldn't be too difficult to get Salsa going. Most of the work involves extending the runtime hosting code to use the Mono API to load the Mono runtime and then load the driver assembly. Everything after that point is relatively platform independent. It'd be worth implementing this just to see how long it takes Don to get an Arch Linux port out for it... :-) Regards, Andrew

This could be a game changer. Great work Andrew!! -- Don andrew.appleyard:
I'd like to announce the first release of Salsa, an experimental Haskell library that allows Haskell programs to access .NET libraries.
Here's a taste:
type Hello.hs import Foreign.Salsa import Bindings
main = withCLR $ do _Console # _writeLine ("Hello .NET World!")
type Hello.imports System.Console: WriteLine
msbuild .\hello Hello .NET World!
Salsa operates by loading the .NET runtime into your Haskell process and using the FFI (and run-time code generation) to marshall calls between the .NET and Haskell runtimes. It includes a code generator and a type-level library (which uses type families) to provide type-safe access to .NET libraries in Haskell with C#-style method overload resolution and implicit conversions.
The adventurous can find version 0.1.0.1 of Salsa on Hackage [1], the darcs repository on code.haskell.org [2], and some (limited) documentation on the Haskell wiki [3].
The library is experimental and by no means complete (refer to the wiki page [3] for some of its limitations). Be prepared to end up with incomprehensible error messages and/or a broken compiler! :-)
At the moment you'll need Windows, GHC 6.8, and version 3.5 of the .NET Framework to use it.
Have fun!
[1] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Salsa [2] http://code.haskell.org/Salsa [3] http://haskell.org/haskellwiki/Salsa
-- Andrew _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Don Stewart wrote:
This could be a game changer.
In what way? As far as I'm aware, .NET never really caught on and has long since become obsolete. Or do you just mean the type system machinery that has been developed could be used for other projects?
Great work Andrew!!
Yes indeed. I'm looking at the thesis now. It looks rather interesting...

.NET never really caught on and has long since become obsolete.
Oh, if only this was the case. :( You wouldn't believe the things I have to
make .NET run on (but I can't talk about it... yay for NDAs).
/jve
On Fri, Oct 10, 2008 at 3:48 PM, Andrew Coppin
Don Stewart wrote:
This could be a game changer.
In what way? As far as I'm aware, .NET never really caught on and has long since become obsolete. Or do you just mean the type system machinery that has been developed could be used for other projects?
Great work Andrew!!
Yes indeed. I'm looking at the thesis now. It looks rather interesting...
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Andrew Coppin wrote:
Don Stewart wrote:
This could be a game changer.
In what way? As far as I'm aware, .NET never really caught on and has long since become obsolete.
Wha? Microsoft's programming languages all now depend on and compile to .NET runtime (the CLR), including C#, Managed C++, Visual BASIC, and even things like the Haskell competitor F#. Hence Don's comment. I've heard people at more than one company say that if they could access .NET well from Haskell, they wouldn't be as interested in F#. Anton

On 2008 Oct 10, at 15:48, Andrew Coppin wrote:
Don Stewart wrote:
This could be a game changer.
In what way? As far as I'm aware, .NET never really caught on and has long since become
News to me; lots of people installing VS.NET on campus... -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH

Hallo,
On Fri, Oct 10, 2008 at 5:48 PM, Andrew Coppin
Don Stewart wrote:
This could be a game changer.
In what way? As far as I'm aware, .NET never really caught on and has long since become obsolete. Or do you just mean the type system machinery that has been developed could be used for other projects?
In what alternate universe? -- -alex http://www.ventonegro.org/

On Mon, Oct 13, 2008 at 1:35 PM, Albert Y. C. Lai
Alex Queiroz wrote:
On Fri, Oct 10, 2008 at 5:48 PM, Andrew Coppin
In what way? As far as I'm aware, .NET never really caught on and has long since become obsolete.
In what alternate universe?
Anthropic Principle: Everyone is in a different bubble of observable reality.
Dude! Invoking the Anthropic Principle is the Physics equivalent of calling someone a Nazi: you automatically lose the discussion.

Alex Queiroz wrote:
Hallo,
On Fri, Oct 10, 2008 at 5:48 PM, Andrew Coppin
wrote: In what way? As far as I'm aware, .NET never really caught on and has long since become obsolete. Or do you just mean the type system machinery that has been developed could be used for other projects?
In what alternate universe?
One with a 3-day time dilation, apparently... [Sorry, couldn't resist. ;-) ]

Hallo, Andrew Coppin wrote:
In what alternate universe?
One with a 3-day time dilation, apparently...
[Sorry, couldn't resist. ;-) ]
No problem, I didn't get your point anyway. -alex http://www.ventonegro.org/

On Fri, Oct 10, 2008 at 5:12 AM, Andrew Appleyard < andrew.appleyard@gmail.com> wrote:
I'd like to announce the first release of Salsa, an experimental Haskell library that allows Haskell programs to access .NET libraries.
Wow, that's really great. I have a .NET friendly employer, so I'm happy to see a tool/library that 'bridges" the gap between my dream of using Haskell on the job and my reality of using .NET on the job. Thank you for releasing this! Salsa operates by loading the .NET runtime into your Haskell process and
using the FFI (and run-time code generation) to marshall calls between the .NET and Haskell runtimes. It includes a code generator and a type-level library (which uses type families) to provide type-safe access to .NET libraries in Haskell with C#-style method overload resolution and implicit conversions.
That's a very pragmatic approach. Nice. But, as I understand it the Haskell you write still lives in Haskell-land and the .NET code you interface with lives in .NET land. So this means, that if we tried this approach with other languagse, say Python and Java, our Haskell code would be a second class citizen there. For example, suppose you embed CPython into an application and then build a Haskell <--> Python bridge. Then my Haskell code I write must be recompiled for each platform and loaded by the python? Similarly for Java, I'm assuming that while the JVM bytecode might get loaded by the security module my Haskell is living in Haskell-land and the JVM can't provide the users with the same guarantees. So, what about translators? I was thinking, maybe a nice way to interoperate would to translate Haskell to language du jour? What if I could type, ghc --make Foo.hs -TPython, and I get Foo.py that can be run in the CPython implementation as just plain python? My understanding is that changing GHC backend is a lot of work. Take projects like lambdaVM, which I don't think has ever been completed, and you see that it involves writing a language specific run-time and some other work. There is yhccore, which has a translator for javascript. What is the way to go here? I like GHC in terms of performance, robustness and language extensions. Would I lose that with custom backends? I imagine the language extensions I'd get to keep and everything else would be subject to how well the backend is written. What do others think? Thanks! Jason

Jason Dagit wrote:
Thank you for releasing this!
No worries. I might never have got around to releasing it if it wasn't for the encouragement of Manuel Chakravarty, Don Stewart, and others. Thanks guys!
[...] as I understand it the Haskell you write still lives in Haskell-land and the .NET code you interface with lives in .NET land.
Yep, that's correct. Compiling Haskell to .NET IL is a significantly more adventurous project! I wouldn't have managed to acheive a practical result in the time I had for my thesis if I had taken that route. Salsa's approach to type system mapping could be useful in such a project though. Regards, Andrew
participants (14)
-
Albert Y. C. Lai
-
Alex Queiroz
-
Alex Sandro Queiroz e Silva
-
Alfonso Acosta
-
Andrew Appleyard
-
Andrew Coppin
-
Anton van Straaten
-
Brandon S. Allbery KF8NH
-
Creighton Hogg
-
Don Stewart
-
Jason Dagit
-
John Van Enk
-
Manuel M T Chakravarty
-
Niklas Broberg