Home
This is the Github project page for a version of GHC extended with a form of syntactic sugar for applicative functors in the ApplicativeFix type class. This type class has an observable effectful recursion primitive afix. The alet construct allows writing applicative terms with observable effectful recursion with a low syntactic overhead. All of this is the topic of a PEPM 2013 paper titled "Fixing Idioms - Choosing fixpoints in applicative DSLs".
To try out our modified version of GHC, we recommend you to follow these steps:
You will need to get both the augmented compiler and the standard libraries, based on the GHC branch ghc-7.4.
git clone git@github.com:ilyasergey/GHC-XAppFix.git
cd GHC-XAppFix
./sync-all --testsuite -r http://darcs.haskell.org get -o ghc-7.4
./sync-all --testsuite -r http://darcs.haskell.org checkout -t ghc-7.4/ghc-7.4
cd libraries/base
git remote add github git@github.com:ilyasergey/GHC-XAppFix-BaseLibrary.git
git fetch github appfix:appfix
git checkout appfix
cd ../..
To fetch the augmented testsuite:
cd testsuite
git remote add github git@github.com:ilyasergey/GHC-XAppFix-TestSuite.git
git fetch github appfix:appfix
git checkout appfix
cd ..
To build the compiler, follow the standard instructions from Haskell Wiki, duplicated here for quick reference:
perl boot
./configure
make
- top-level alets are not supported
- type signatures for alet-bound variables are not supported
We have prepared some known working examples. To try them out, you need to install some libraries from Hackage first. We recommend the following:
cabal update
cabal install --with-compiler=$PWD/inplace/bin/ghc-stage2 --with-hc-pkg=$PWD/inplace/bin/ghc-pkg uu-parsinglib
cabal install --with-compiler=$PWD/inplace/bin/ghc-stage2 --with-hc-pkg=$PWD/inplace/bin/ghc-pkg memoize
We have prepared a tarball containing known working examples, including those discussed in the paper. Starting points are the files Parser.hs, FRP.hs and Memoize.hs. The examples employ functions from other modules which are also included. If you save the tarball in /tmp, you can use it as follows.
GHCDIR=<the directory where you built GHC>
cd /tmp
tar xzf demo.tar.gz
cd demo
$GHCDIR/inplace/bin/ghc-stage2 --interactive Parser.hs
The last command can be similarly used on the other files in the demo dir. Note that our current prototype compiler still generates a lot of debug output, which we recommend you to ignore...
If you want to look at the implementation of the arity-generic nafix function, which we do not discuss in our ICFP submission, it is defined in the file libraries/base/Control/Applicative/GeneriFix.hs if you correctly followed the installation steps outlined below. You can also find the file online.
Our compiler changes are isolated in the parser, renamer, type-checker and desugarer. If you want to get a view of our changes, you are probably best to do a git diff
of our branch against the GHC-7.4 branch.