Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Haskell to Javascript compilers?

Tags:

haskell

I've recently came across ghcjs haskell-to-javascript compiler, but I am not sure how "ready" it is. It seems to have little activity over the last year.

Is there an equivalent to GWT in Haskell?

Also, more of a discussion question:do you think there will be a gwt haskell equivalent? Why or why not?

like image 247
Andriy Drozdyuk Avatar asked Jan 09 '12 19:01

Andriy Drozdyuk


People also ask

Does Haskell compile to JavaScript?

You can use GHCJS to compile Haskell code to JavaScript. It is a fork of GHC and supports pretty much everything GHC supports including TemplateHaskell. Most libraries on hackage work just fine as long as they do not have dependencies on C libraries. The compile times are slow and the resulting .

What is Ghcjs?

GHCJS is a Haskell to JavaScript compiler that uses the GHC API.

Does Haskell have a compiler?

The compiler (written in Haskell), translates Haskell to C, assembly, LLVM bitcode and other formats. The strategy it uses is described best here: Implementing lazy functional languages on stock hardware:the Spineless Tagless G-machine.


1 Answers

There are several such compilers which can be used right away.

  • Fay (formerly at http://fay-lang.org/, now on https://github.com/faylang/fay) The most popular and the most developed Haskell -> JS compiler. AFAIU, it implements Haskell from scratch and compiles it to JavaScript. It doesn't implement many of GHC's features, especially language extensions.
  • Haste (https://github.com/valderman/haste-compiler) It uses the backend of GHC to compile to javascript. As a result you can use it to compile extension containing code.
like image 91
Konstantin Solomatov Avatar answered Oct 08 '22 10:10

Konstantin Solomatov