Slides from my Wellington FP Users Group presentation on Yesod
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Quick Tour to Yesod

These are the slides I used in my presentation to the Wellington FP Users group. After each slide I showed the code for the slide and discussed how it works.

The talk covered the parts of Yesod that were of particular interest to me.

I have now extended the slides to include an example of using GHCJS to run Haskell in the web browser.

Building GHC with JavaScript output

This version of GHC makes a .js file whenever it outputs an object file. It also "links" the javascript by copying all the files .js files into a .jsexe directory. It has its own version of cabal so that .js files and .jsexe directories are installed properly.

git clone
cd ghc
./sync-all -r get
./sync-all -r get
./sync-all -r get
./sync-all -r get

(You may need to rerun sync-all a few times if like me you get network errors part way through)

rm -rf libraries/Cabal
git clone libraries/Cabal
cp mk/ mk/
perl boot
./configure --prefix=/home/hamish/ghcjs
make install

To use this compiler add /home/hamish/ghcjs to your path ahead of any other ghc.

export PATH=/home/hamish/ghcjs/bin:$PATH

You should be able to switch back to your main compiler at any point by simply not including this in you path.

The global packages (including JavaScript) will be installed to something like

  • ~/ghcjs/lib/ghc-7.1.20110508

User cabal packages are installed to something like

  • ~/.ghc/i386-darwin-7.1.20110508
  • ~/.cabal/lib/*/ghc-7.1.20110508

Installing cabal-install with GHCJS

You need to make a version of cabal-install that uses the new Cabal package. So that which you run "cabal install" it will copy .js files and .jsexe directories to the install location.

darcs get --lazy
cd cabal-install

Change build-depends in cabal-install.cabal so it has Cabal >= 1.10.1 && < 1.12

cabal install --ghc-options='-XFlexibleInstances'

There is a catch. Because your old cabal install installed the dependancies the .js files for these libraries will not have been installed. So you shoule unregister then so they will be installed again with the new cabal-install.

ghc-pkg unregister HTTP
ghc-pkg unregister network
ghc-pkg unregister parsec
ghc-pkg unregister mtl
ghc-pkg unregister transformers
ghc-pkg unregister zlib

Installing GHCJS RTS

The runtime system js files need by GHCJS are in a package. To install this do

git clone
cd ghcjs-rts
cabal install

Installing Yesod Slides

Almost there now

git clone
cd yesod-slides
cabal install --constraint='tagged==0.2' --ghc-options='-XFlexibleInstances'

You need the -XFlixibleInstances because some of the packages on which we depend do not build with this dev version of ghc without it.

Point your web browser at

Click to advance from one slide to the next. The GHCJS slde is here the last one