什么是最生产级的 Haskell 到 JavaScript 编译器,编写在浏览器中运行的代码?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6272226/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is the most production-level Haskell to JavaScript compiler, to write code running in the browser?
提问by avernet
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.
我不是在寻找具有 10 年业绩记录的必然超级健壮的解决方案,而是寻找可以在实际应用程序中使用的东西,而不仅仅是能够运行 Hello World 示例。
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…).
我的偏好是在服务器上运行编译器,这样我就可以提前编译 Haskell 代码。当然,解决方案不仅需要编译器,还需要使 Haskell 代码能够访问浏览器上可用的 API(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.
脚注:到目前为止,我看到的项目似乎没有得到积极维护,或者超出了能够运行“Hello world”的能力,或者在某些情况下甚至超出了项目描述。
采纳答案by Dve
There is a more complete list here:
这里有一个更完整的列表:
http://www.haskell.org/haskellwiki/The_JavaScript_Problem
http://www.haskell.org/haskellwiki/The_JavaScript_Problem
and there is also Fay (although it is only a subset of haskell)
还有 Fay(虽然它只是 haskell 的一个子集)
回答by Adam Gent
You may find this List useful: https://github.com/jashkenas/coffee-script/wiki/List-of-languages-that-compile-to-JS
您可能会发现此列表很有用: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.
我知道它不是 Haskell,但 Coffee 脚本是基于表达式且相当优雅的恕我直言。
回答by Rotsor
I have stumbled upon this project called ghcjs
我偶然发现了这个名为ghcjs 的项目
It seems promising!
看起来很有希望!
Quote from the README
:
引自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.
Haskell 到 Javascript 翻译器
项目旨在提供解决方案
- 将现代 Haskell 库编译为 Javascript 文件并在 Ajax 应用程序中使用它们或
- 用 Haskell 语言开发整个 Ajax 应用程序
项目的先前版本位于vir.mskhug.ru。
回答by jerng
While GHCJS does not seem to be actively maintained, Emscriptenseems to be quite current.
虽然 GHCJS 似乎没有得到积极维护,但Emscripten似乎很流行。
- Emscripten compiles LLVMbitcode to JavaScript.
- GHC's LLVM backendappears 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
- Emscripten 将LLVM 位码编译为 JavaScript。
- GHC 的 LLVM 后端似乎正在积极开发中。
- 直观地,为了回答这个问题,以下管道可能离“生产质量”不远:Haskell lexemes (-> GHC ->) LLVM lexemes (-> Emscripten ->) JavaScript lexemes
I'll admit that this is a speculative post.
我承认这是一篇投机性的帖子。
回答by KajMagnus
This language, Roy, is perhaps not really Haskell (?), but it seems very similar:
这种语言Roy可能不是真正的 Haskell (?),但它看起来非常相似:
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
罗伊似乎还活着;GitHub repo 中有很多分支:https: //github.com/pufuwozu/roy
并且它似乎还活着: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:
如果您使用的是 Play Framework 2.0,那么有一个插件Ray可以在 Play Framework 2.0 上运行 Roy:
http://brianmckenna.org/blog/ray
https://github.com/pufuwozu/ray
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.
最后一次提交是在四个月前,这是很久以前的事了,记住 Play Framework 2 可能是在 4 或 5 个月前发布的。
回答by Gerold Meisinger
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)
Yesod 有一份“最具生产水平”的候选名单:https: //github.com/yesodweb/yesod/wiki/Javascript-Options(Yesod 是一个非常流行的 Haskell 网络框架,所以他们可能知道他们在说什么)