Programs from
Haskell: The Craft of Functional Programming, Second Edition
The Haskell code from this text can be downloaded from here. It is divided
into chapter-size scripts, except when this proves to be too unwieldy, when
they are further subdivided.
These scripts are supplied so that you can execute the programs in the book;
the comments that they contain are not intended to be a substitute for the
commentary which appears in the text itself.
Scripts are provided in both literate (Foo.lhs
) and
non-literate (Foo.hs
) forms.
In literate scripts all code occurs on lines like
> dummy = dummy
Sometimes, however, in literate scripts code appears which is just indented, without the
>
: this is when the code acts as a
comment on the script.
Dummy definitions like the one above are included in some of the scripts.
This happens when the definition is left as an exercise for the reader.
For these scripts to work properly you need to add the appropriate definitions to
the script.
All the scripts are contained in the files Code.tar.gz
(Unix) and Code.ZIP (PC).
Scripts chapter-by-chapter
- Chapter1.hs, Chapter1.lhs
- Materials from Chapter2.
- Chapter3.hs, Chapter3.lhs
- Chapter4.hs, Chapter4.lhs
- Chapter5.hs, Chapter5.lhs
- Chapter6.hs, Chapter6.lhs
- Chapter7.hs, Chapter7.lhs
- Chapter8.hs, Chapter8.lhs
- Chapter9.hs, Chapter9.lhs
- Chapter10.hs, Chapter10.lhs
- Chapter11.hs, Chapter11.lhs
- Chapter12.hs, Chapter12.lhs
- Chapter13.hs, Chapter13.lhs
- Chapter 14 is given in two parts.
- Chapter 15 is given in various parts. Here are
the introductory modules of the first part:
The Huffman coding example is given under case studies below.
- Chapter 16 contains a collection of abstract data types.
- Queues1.hs,
Queues1.lhs
- Queues2.hs,
Queues2.lhs
- Queues3.hs,
Queues3.lhs
- Relation.hs,
Relation.lhs
- Set.hs,
Set.lhs
- Store.hs,
Store.lhs
- StoreFun.hs,
StoreFun.lhs
- Tree.hs,
Tree.lhs
- UseStore.hs,
UseStore.lhs
- UseStoreFun.hs,
UseStoreFun.lhs
- UseTree.hs,
UseTree.lhs
- Chapter17.hs, Chapter17.lhs Parsing is given separately below.
- Chapter18.hs, Chapter18.lhs
- Chapter19.hs, Chapter19.lhs
- Chapter20.hs, Chapter20.lhs
Case studies
- Calculator
- Huffman coding
- Parsing
- Simulation
© Simon Thompson, 1999.
Last modified 31 January 2001.