Project aims to provide solution to
- develop entire Ajax application in Haskell language
Previous version of project is located at vir.mskhug.ru.
Code builds as standard haskell package
$ runghc Setup configure $ runghc Setup build $ runghc Setup install
$ ghcjs Test.hs
This command is merely equivalent to the following
$ ghc --make Test.hs
See examples folder for an example of loading and running haskell code from browser.
The code is in alpha stage. Feel free to experiment with it as you wish.
Compiler is implemented as GHC backend using GHC API. And been tested with GHC 6.12.1.
To play with any Haskell code you'll need Haskell standard library. GHC implements standard library as a "base" package. You'll need to compile modules from base package.
Download ghc source distribution for the same version of ghc that you use to build ghcjs.
$ cd ghc-x.xx.x $ cd mk $ cp build.mk.sample build.mk
Add the following line to the top:
INTEGER_LIBRARY = integer-simple
Set build flower to the quikest: uncomment the line:
BuildFlavour = quickest
$ ./configure $ make
You should try to use BuildPackages.hs script. You can build ghc-prim, integer-simple and base packages in examples directory with the following command
$ cd examples $ ./BuildPackages.hs <path-to-ghc-directory>
You can build packages manually using instructions below.
=== Building ghc-prim
=== Building integer-simple
=== Building base
This last magic command line was guessed using
cabal build -v
to see what options are passed to GHC.
We should really use
option to get read of useless object files, but it seems to be a bug in ghc that cause GHC to rely on odir to be the same as hidir wich is mostly the case in "normal" GHC usage.
Differences from old version
vir.mskhug.ru contains the first implementation of the idea. This version is a rewrite that inherit little code from previous version. The differences are the following.
It is more modular.
But not enough. Generator.Core module needs some refactoring to separate some parts into stand alone modules.
Lazy module loading is implemented.
Modules are loaded (using XMLHttpRequest) on demand when they are needed.
Foreign function interface is not supported. Only minimum of primitive operations is supported.
Tail recursion optimization is off by default.
$ ghcjs --calling-convention=trampoline
To optimize tail recursion in resulting code.
Reading The Code
Many of the names used have been shortened to a single character to reduce the size of the java script. Here is a key so you can work out what they do.