Javascript Options - mathfur/yesod GitHub Wiki
Yesod by default gives you Shakespeare-Javascript, also known as Julius. It is just Javascript that you can insert haskell values into. Also Shakespeare-Coffee, which is Coffeescript you can insert haskell values into. Coffeescript is a thin veneer that papers over Javascript to make a convenient and consistent language, but there is still no type system. These solutions can easily be used with any existing javascript code.
There is prior art for Julius: jmacro has QQ value insertion, but also supports a haskell-ish version of javascript.
Using Javascript Frameworks
The most robust and portable approach is to use one of the above javascript template tools and integrate with an existing javascript framework.
Compile Haskell
Fay is a new alternative that we would love to hear some experience reports about.
- Fay, Haskell code translated to JS. Upside: produces a small amount of understandable javascript. Downside: only a subset of Haskell is supported.
- UHC js compiler. Downsides: alpha, not completely integrated with cabal, not GHC.
- ghcjs - example Yesod app - directly compile ghc core to javascript. Downside: produces large amounts of javascript.
Alternative experimental ways to compile Haskell
- Emscripten — compiles LLVM/Clang output to JavaScript. If you use features of the GHC runtime you also have to compile it, which nobody has made an effort to figure out.
- PNaCL - run native code on Google Chrome with NaCL. PNaCL is the next generation that will run LLVM byte code. Won't work on other browsers.
- JS Haskell interpreter
A Haskell-like language that only compiles to Javascript
We would really like to hear about your experience with Elm or Roy, which are 2 nice options with Yesod integration.
- Elm - Yesod integration available. Haskell inspired language that also offers an FRP GUI. Downside: not quite Haskell, not Javascript.
- Roy - Yesod integration (Roy templates) available. Javascripty semantics with Haskelly features. Project is starting to mature. Upside: should be easier to use with existing JS than many other alternatives. Downside: not Haskell.
- lambdascript
Haskell code that explicitly generates Javascript
- Reactive-banana - an FRP GUI framework can now output html/javascript
- Panther-Ajax Experimental library to write server side code that accesses the dom and uses continuations.
- Ji - experimental library not currently working with Yesod. Same as Panther-Ajax, but under active development.
- HJScript - javascript DSL.
- yesod-js - currently stalled while investigating Fay/Elm/ghc-js
Add better typing to Coffeescript
contracts.coffee not types, but contracts. Well maintained, easy to use. Uberscript requires Google Closure compiler for its type-checking. A great idea, but this is a fork of coffeescript that has now fallen behind coffeescript by almost a year.
Other strongly typed functional languages that compile to Javascript
- Ur/Web - A Haskell-like programming language tailored to web programming. Automatically generates FRP javascript code. Appropriate for taking the FRP plunge, but Heavyweight (large library and difficult to debug) if you just want some strongly-typed JS. Opa is a very similar concept.
- JS of OCaml - There is also an in-browser OCaml bytecode interpreter!