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.
Source code
To follow along and run the code examples, get the source files from github.com/typeclasses/haskell-phrasebook.
We welcome requests and contributions, and we’re grateful to all who have submitted example code. If you have ideas for the Phrasebook, please see the contributor guide.
The code may be modified and redistributed for any non-commercial purpose with attribution.
Libraries
Here is the complete list of libraries utilized by the example programs:
baseis the standard library, required by every Haskell program.We use
Seqwhenever we will need to retrieve a value from a particular position in a list, andMapwhen we need to lookup values by an associated key. These come from thecontainerspackage.hashableprovides theHashableclass for types that can be used as keys in hash maps.We use
stm(“software transactional memory”) for all mutable references and inter-thread communication.For concurrency we use either the primitives provided by
baseor the somewhat higher-level tools in theasynclibrary.We use
timefor holding time in the palm of our hands.We use
mwc-randomto generate pseudo-random numbers (MWC stands for “multiply-with-carry”).cryptoniteserves all of our cryptography needs.We represent byte arrays using the
ByteStringtype from thebytestringlibrary.We use some utilities from the
memorylibrary for working with byte arrays.We use the
utf8-stringlibrary for conversions betweenByteStringandStringusing the UTF-8 character encoding.The
generic-derivinglibrary gives us some extensions to GHC’s code-generation features, such as the ability to get an automatic list of all values of a type.We use the
safe-exceptionslibrary for handling I/O exceptions.The
processpackage lets our programs start other programs.When we write a program that runs indefinitely, we use the
signallibrary to listen for a termination signal.The
directorypackage lets us enumerate the contents of a directory, move files, and remove files.

