What is the most production-level Haskell to JavaScript compiler, to write code running in the browser?

JavascriptHaskellCode Translation

Javascript Problem Overview


I am not looking for a necessarily super-robust solution with a 10-year track record, but for something that can be used in a real applications, and goes beyond just being able to run an Hello World example.

My preference is to run the compiler on the server, so I can compile Haskell code ahead of time. Of course, the solution would need to be more than just a compiler, and enable Haskell code to access the API available on the browser (DOM, XHR…).

Footnote: the projects I have seen so far don't seem to be actively maintained, or to go beyond being able to run "Hello world", or in some case even to go beyond a project description.

Javascript Solutions


Solution 1 - Javascript

There is a more complete list here:

http://www.haskell.org/haskellwiki/The_JavaScript_Problem

and there is also Fay (although it is only a subset of haskell)

https://github.com/faylang/fay

Solution 2 - Javascript

You may find this List useful: https://github.com/jashkenas/coffee-script/wiki/List-of-languages-that-compile-to-JS

From the List:

* UHC (Utrecht Haskell Compiler) backend converts UHC core to JavaScript, allowing the compiling of Haskell code to JS.
* YHC (York Haskell Compiler) backend, as above but with YHC core language.
* jshaskell

I know its not Haskell but Coffee script is expression based and rather elegant IMHO.

Solution 3 - Javascript

I have stumbled upon this project called ghcjs

It seems promising!

Quote from the README:

> Haskell to Javascript translator > ================================ > > Project aims to provide solution to

> * compile modern Haskell libraries to Javascript files and use > them in Ajax applications or > * develop entire Ajax application in Haskell language

> Previous version of project is located at vir.mskhug.ru.

Solution 4 - Javascript

While GHCJS does not seem to be actively maintained, Emscripten seems to be quite current.

  • Emscripten compiles LLVM bitcode to JavaScript.
  • GHC's LLVM backend appears to be actively developed.
  • Intuitively, to answer the question, the following pipeline might not be very far from "production quality": Haskell lexemes (-> GHC ->) LLVM lexemes (-> Emscripten ->) JavaScript lexemes

I'll admit that this is a speculative post.

Solution 5 - Javascript

This language, Roy, is perhaps not really Haskell (?), but it seems very similar:

http://roy.brianmckenna.org/

Roy seems to be alive; there are many forks in the GitHub repo: https://github.com/pufuwozu/roy
and it seems to be alive: https://github.com/pufuwozu/roy/graphs


If you're using Play Framework 2.0, then there's a plugin, Ray, to run Roy on Play Framework 2.0:

http://brianmckenna.org/blog/ray
https://github.com/pufuwozu/ray

The last commit was four months ago, which is rather long ago keeping in mind that Play Framework 2 was released perhaps 4 or 5 months ago.

Solution 6 - Javascript

There is a list of "most production level" candidates from Yesod: https://github.com/yesodweb/yesod/wiki/Javascript-Options (Yesod is a very popular Haskell webframework so they may know what they are talking about)

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionavernetView Question on Stackoverflow
Solution 1 - JavascriptDavidView Answer on Stackoverflow
Solution 2 - JavascriptAdam GentView Answer on Stackoverflow
Solution 3 - JavascriptRotsorView Answer on Stackoverflow
Solution 4 - JavascriptjerngView Answer on Stackoverflow
Solution 5 - JavascriptKajMagnusView Answer on Stackoverflow
Solution 6 - JavascriptGerold MeisingerView Answer on Stackoverflow