Skip to content
The Haskell Phrasebook: a quick intro to Haskell via small annotated example programs
Haskell Nix
Branch: master
Clone or download
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Create FUNDING.yml Jul 26, 2019
outputs add branching.hs output Jul 31, 2019
tools add branching.hs output Jul 31, 2019
common-types.hs init Jul 23, 2019
for-loops.hs add for-loops.hs Jul 24, 2019
hashing.hs add hashing.hs Jul 23, 2019
hello-world.hs init Jul 23, 2019
if-else.hs add branching, if-else files; add time to nix shell Jul 30, 2019
mutable-references.hs add a loop in the mutable-references example Jul 27, 2019 update readme, no longer using stderr Jul 30, 2019
threads.hs threads: print to stdout Jul 30, 2019
timeouts.hs timeouts: remove module declaration Jul 27, 2019
transactions.hs transactions: use stdout, increase thread count Jul 30, 2019
variables.hs add variables.hs Jul 23, 2019

The Haskell Phrasebook

The Haskell Phrasebook is a free quick-start Haskell guide comprised of a sequence of small annotated programs. It provides a cursory overview of selected Haskell features, jumping-off points for further reading, and recommendations to help get you writing programs as soon as possible.

This repository contains only the code files; you may find them useful if you want to follow along while reading the Phrasebook, which can be found at

Using Nix shell

You do not have to use Nix to run these Haskell programs, but you may find it convenient.

  1. Install Nix

  2. Enter a Nix shell:

    $ nix-shell tools/shell.nix
  3. Within the Nix shell, you have all of the dependencies required by the examples in the Phrasebook. For example, you can run commands like runhaskell and ghcid:

    $ runhaskell hello-world.hs
    hello world
    $ ghcid --command 'ghci hello-world.hs'


In addition to the code examples themselves, the results from running the examples are also included in this repository, in the outputs directory. An example's output is typically given the same name as its source file, with the extension changed; for example, the output of hello-world.hs is given by the file outputs/hello-world.txt.

When any source code or dependency versions change, run ./tools/generate-outputs. This script runs all of the examples and updates the output files.

Any examples that include nondeterministic behavior (such as threads.hs) have the nondeterministic portion of their output redacted as "..." to avoid including non-repeatable results in the output files.

Nix dependency versions

All of the Nix tools are configured to use a specific version of the Nix package set to ensure that the code works the same in all environments. This version is specified in tools/versions.json.

You can run ./tools/update-versions to update the dependency hashes in tools/versions.json to their latest commits. The JSON data is then used by tools/versions.nix. This system is described in Vaibhav Sagar's blog post, Quick and Easy Nixpkgs Pinning.

You can’t perform that action at this time.