Haskell recipes

December 28, 2016

This is an index of simple Haskell recipes for handy reference.

To run each recipe, the following script uses Nix to set up a ghc environment with specified packages, and uses codedown to extract the source code to run.

if [ $# -lt 1 ]
then
  echo "Usage: sh -s <recipe> [package1] [package2] [package3] ..."
  echo "Example: sh -s scotty.md scotty"
  exit 1
fi
nix-shell \
  -p "haskellPackages.ghcWithPackages (pkgs: with pkgs; [ ${@:2} ])" \
  --run "curl -sL earldouglas.com/notes/haskell-recipes/$1 |
         codedown haskell |
         runhaskell"