What is the most production-level Haskell to JavaScript compiler, to write code running in the browser? [closed]
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this questionI 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 i开发者_开发问答s 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.
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
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.
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.
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.
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.
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)
精彩评论