Haskell
The Craft of Functional Programming
Second Edition

Errata


Third impression

This section contains the errors reported in the third impression (or printing) consists of copies of the text bought in spring 2000 or later, which are indicated by the line 10 9 8 7 6 5 4 3 close to the bottom of page iv. Errata for earlier impressions follow.

p29, Exercise 2.1. The Pictures module already contains a definition of rotate. To hide this definition when the module is imported, please import thus:

import Pictures hiding (rotate)

p31 The expression

4 `div` (3*2-6)
in fact generates the error message
Program error: {primQrmInteger 4 0}
rather than Program error: {primDivInt 4 0} in the latest version of Hugs.

p 42. In line 4 of the first paragraph, '\97' should read '\57'.

p 42. In line 5 of the first paragraph, replace 'fonts' by 'character sets'.

p 43. In line 8 of Section 3.6, replace 'not be always be' by 'not always be'.

p 44 makes reference to the fromInt function which has been superseded by fromIntegral. Thanks to Mark Skilbeck for pointing this out.

p 113. The type of makeDiscount could be BillType -> Price.

p 161-162. The definition of foldr1 on p 162 is different from that on p161. Calling them def161 and def162 they behave thus:

def161 (++) ["a", "b", "c"] = "abc"
def162 (++) ["a", "b", "c"] = "bca"

p 186. In line 13, delete 'will'.

p 236. Following the definition of expr, `The first occurrence of [] is at [Bool], whilst the second is at [Int].'.

p257. In line 11: replace 'bExpr' by 'bExp'.

p263. Second line: replace 'though' by 'through'.

p306. In the code at the bottom of the page, you might think that 'data' could be 'newtype'. Unfortunately, newtypes have to have a single type argument, so it would only be possible by pairing up the two lists, thus:

newtype Queue a = Qu ([a],[a])
and by making the corresponding modifications to the functions defined over Queue.

pp 347-8. Throughout this discussion of list permutations, the operator \\ for list difference comes from the List module.

p387. Line 10 should read: "The effect of return x ..." rather than "The effect of IO x ...".

p 406 In Exercise 18.25, the expression on the left hand sides of the equations should be joinM . return that is the composition of the two.

p 422. The information given here should be tightened up. It is possible using a variant of search trees called red-black trees to give linear complexity to subSet and inter. Red-black trees are a type of 'balanced' tree, in which the lengths of all the branches are (almost) the same.

p 427. Line -8 should begin "As in Section 19.4 ...".

Second impression

The errata for the third impression also apply to the second.

In the second impression, but not in the first, a number of diagrams on pp. 10, 10, 11, 34, 38, 39, 228, 229, 229, 232, 234, 234, have captions missing. Click on the page numbers to see GIFs of the figures.

p 38. In the diagram, small boxes appear at the end of lines in multiple-line pieces of text. These should be ignored.

p 41. In the boxed text, the declaration of max should contain a double colon as in

max :: Int -> Int -> Int
and not a triple colon, :::.

p 53, line 6. `We being by ...' should be `We begin by ...'.

p 220. The last line of the definition of compare at the foot of the page should read

x >  y		= compare x y == GT

p 233. The final type derived for the function h, which is given just above the second horizontal line on the page, should read

h :: (Int , [Char]) -> Int
as is plain from the surrounding discussion.

p 307. The second line on this page should be

remQ (Qu [] (y:ys)) = remQ (Qu (reverse (y:ys)) [])
That is, ys is replaced by (y:ys) in two places, and the multiple spaces before the equals sign are replaced by a single space.

p 391. In line 3 of the Summary, `Morevover' should be `Moreover'.

p 400. The type of (>>=) is stated incorrectly (it is too restricted as it stands). It should state

(>>=) :: IO a -> (a -> IO b) -> IO b
as the surrounding discussion makes clear.

First impression

The errata for later impressions also apply unless it is explicitly stated otherwise.

pp 2, 38, 157, 158, 162, 202. In the diagrams, small boxes appear at the end of lines in multiple-line pieces of text. They should be ignored. Their presence is a consequence of different `end of line' representations on PC/Unix/Mac; aargh!

p 57. In the first two lines `problem i' should be `problem is' and `examples appea' should be `examples appear'; it this typesetting? PostScript?

Thanks to Torsten Baden-Jensen, Frederik Juul Christiani, Joey Coleman, Jens Svalgaard Frederiksen, Stefan Gustafsson, Mark IJbema, Per Johansson, Frank Kruchio, Richard Kuhns, Lennart Ohlsson, Anders Lau Olsen, Cagdas Ozgenc, Rin Park, Kei Simon Pedersen, Ham Richards and Dietmar Roesner for spotting and reporting errors.


© Simon Thompson, 1999-2005.

Last modified 19 January 2005.