Haskell
The Craft of Functional Programming

Errata


Many of the misprints listed here are corrected in the second 1997 reprint and in subsequent editions.

The book was written prior to the release of `Hugs0' the first Yale release of Hugs and also before the release of `Hugs1.3' and `Hugs1.4'. The version referred to in the text is the 1994-5 `Hugs1.01'. In fact this makes little difference to the text except that Hugs0 does in fact implement the Haskell module system; whilst Hugs1.3 does not at present.

p xiii On line 12 `spaced' should be `space'.

p 16 On line 4 the expression $$-1 should read $$ -1 to avoid causing a Gofer error.

p 20 In Exercise 1.9 the type of tester should be

Int -> Int -> Int -> Bool

Chapter 1 (and subsequently) In Haskell 1.3 and Hugs 1.3 the function putStr is needed to resolve the formatting of a string. For instance, evaluating "ant\nbee" results in "ant\nbee", whilst evaluating putStr "ant\nbee" results in
ant bee

p 24 In Haskell 1.3 maxInt needs to be replaced by maxBound. This has the same effect in giving the maximum bound on the Int type.

p 27 The first definition of maxSales has a missing argument n.

p 50 At the bottom of the page rjustify should be rJustify.

p 51 The two definitions of printAverage should have their equals signs (=) indented; otherwise they yield a layout error.

p 66 In the definition of header the final line should read

show c ++ " = 0.0" ++ "\n\nhas "

p 91 The second exercise should be numbered 4.2 (not 4.1!).

p 101 In Exercise 4.18 `evaluation' is used to mean `calculation' and not anything different.

p 106 In the definition of exampleBase the equality symbol should be indented (by at least one whitespace character).

p 109 In the definition of returnLoan2 the recursive calls should be to returnLoan2 and not to returnLoan.

p 113 The type of books given here should be

books::Database->Person->[Book]

p 156 In the second paragraph, `When an' should read `When a'.

p 161 The `see' on line 5 should be `seem'.

p 214 The third line of the default definitions in the class Ord should read

x > y = y < x

p 262 The `though' on line -8 should be `through'.

p 263 In the description of the evaluation of

trap (1+) 56 (lift (*3) (errDiv 9 0))
the dash before the 56 is not a minus sign.

Section 12.8 Note that the join function is implemented in such a way that it only guarantees that its result is a search tree if all elements of the first argument are smaller than all elements of the second.

p 326 The implementation of insert given in the book is incorrect. It should take account of whether the value val is a member of the tree (Node v n t1 t2) when calculating the size of the resulting tree. We therefore need to write

insert val (Node v n t1 t2) | v==val = Node v n t1 t2 | val > v = Node v (1 + size t1 + size nt2) t1 nt2 | val < v = Node v (1 + size nt1 + size t2) nt1 t2 where nt1 = insert val t1 nt2 = insert val t2

p 408 Note that putLine is pre-defined as the function putStrLn.

p 434 In Exercise 15.12 replace * with + three times.

p 475 Operator priority 7, replace % by *,. Also the operators *, /, `quot`,`rem`, `div`,`mod` are left associative.

p 488 In the function lines replace splitAt ('\n'==) by span ('\n'/=).

Generally. In some places composition has been written (f.g) which needs to be replaced by compostion with spaces around (f . g) in order to distinguish it from qualified naming.

I am very grateful to Johan Agat, Richard Bird, Luis Antonio Galan, Jim Hassett, Patrik Jansson, Johan Jeuring, Joyce McKeown, Sven Panne, Martin Pavier, Ham Richards and Andre Santos for sending errata for inclusion here.


Last modified 26 August 1997.