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.
git clone https://github.com/the-real-blackh/ghc.git cd ghc ./sync-all -r https://github.com/ghc get ./sync-all -r https://github.com/ghc get ./sync-all -r https://github.com/ghc get ./sync-all -r https://github.com/ghc 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 https://github.com/the-real-blackh/packages-Cabal.git libraries/Cabal cp mk/build.mk.sample mk/build.mk perl boot ./configure --prefix=/home/hamish/ghcjs make make install
To use this compiler add /home/hamish/ghcjs to your path ahead of any other ghc.
You should be able to switch back to your main compiler at any point by simply not including this in you path.
User cabal packages are installed to something like
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 http://darcs.haskell.org/cabal-install 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 https://github.com/hamishmack/ghcjs-rts.git cd ghcjs-rts cabal install
Installing Yesod Slides
Almost there now
git clone https://github.com/hamishmack/yesod-slides.git cd yesod-slides cabal install --constraint='tagged==0.2' --ghc-options='-XFlexibleInstances' yesod-slides
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 http://127.0.0.1:3000
Click to advance from one slide to the next. The GHCJS slde is here the last one http://127.0.0.1:3000/ghcjs