12

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?

Andriy Drozdyuk
  • 58,435
  • 50
  • 171
  • 272
  • 1
    I just came across this when searching for ghcjs. There is a newer repo: https://github.com/ghcjs/ghcjs – Nathan Jun 27 '12 at 12:52
  • See also [What is the most production-level Haskell to JavaScript compiler, to write code running in the browser?](https://stackoverflow.com/questions/6272226/what-is-the-most-production-level-haskell-to-javascript-compiler-to-write-code) – Bergi Feb 14 '20 at 00:52

2 Answers2

9

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

Konstantin Solomatov
  • 10,252
  • 8
  • 58
  • 88
  • I have made a [very brief comparision of both](https://www.joachim-breitner.de/blog/archives/602-Running-Circle-Packing-in-the-Browser-using-Haste.html). – Joachim Breitner Jul 12 '13 at 08:47
7

Ji seems relevant, although it doesn't do any Haskell-to-JS compilation; it lets a Haskell server control a browser connected to it via AJAX.

It seems like UHC supports compiling to JavaScript and has some libraries along those lines, but I don't know what UHC's compatibility with GHC extensions is like, or how mature the support is.

I'm not convinced compiling full Haskell to JavaScript is a productive route; the overhead of implementing the likes of lazy evaluation on top of a high-level language is likely to be significant, and all the attempts so far (I haven't checked out UHC's generated code) seem to produce rather huge JavaScript (admittedly, HTTP compression mitigates this).

I don't think ghcjs is being actively developed, but it might be more stable than UHC's support. Yhc's support seems to be the furthest so far, but unfortunately Yhc is a dead project.

ehird
  • 40,602
  • 3
  • 180
  • 182