Personal tools

Common Language Runtime

From HaskellWiki

Revision as of 11:40, 14 February 2017 by Wizzup (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


Can I use Haskell with the Common Language Runtime (CLR). In other words .Net / Mono / CoreCLR?


If you're looking for a way to run Haskell on (aka target) the CLR, then the short answer is you can't. A resonable approach to hacking this up you're selves might be to work on GHC backend that outputs common intermediate language (aka MSIL), and perhaps via the LLVM backend? The GCH JS crew have made some good progress on creating a new target for GHC so it's doable at least.

If you're instead looking for a way to bridge between the Haskell & CLR eco systems, then reality for you isn't quite as grim.

There was the pragmatic hs-dotnet package. This might be considered dead by now, though experiment as you please and update the wiki with your results.

Another, not so dead alternative is Salsa. A common misconception is that: "Haskell's type system has no way to represent inheritance, overloading or method calls". This is false (if for practical reasons we consider GHC = Haskell), and Salsa is library that has proven that these can indeed be encoded with the current state of GHC's type features.

While Salsa is not quite dead, it also doesn't have an automated build system, and the copy on Hackage doesn't get updated. To give this spin, head over to github page, and follow the READMEs carefully. It it also the only Mono compatible solution (but again, may require manual steps - you'll likely need to pass in an "--extra-include-dirs=" param)

Future directions?

Surveys have shown that many people consider CLR support important or crucial for Haskell, but as far as I know few people are working on this.

I for one, am actually making a CLR <-> Haskell bridge the primary project of my free time, but my free time is rather limited. It would be great if others could help out in this space, by either contributing to Salsa, or my new 'clr-haskell' project (very early work in progress):

See also