1 <html>

2 <head>

3 </head>

4 <HEAD>

6 </head>

7 </head>

8 </head>

9 </head>

10 </HEAD>

11 <BODY>

14 </div>

16 <h1>Errata in the

21 <ul>

25 <p>

26 "Copyright (c) Simon Peyton Jones.

27 <p>

28 The authors intend this Report to belong to the entire Haskell

29 community, and so we grant permission to copy and

30 distribute it for any purpose, provided that it is

31 reproduced in its entireity, including this Notice. Modified

32 versions of this Report may also be copied and distributed for any purpose,

33 provided that the modified version is clearly presented as such,

34 and that it does not claim to be a definition of the language Haskell 98."

37 Replace the entire section with the following:

38 <p>

39 "Haskell has adopted many of the convenient syntactic structures

40 that have become popular

41 in functional programming. In this Report, the meaning of such

42 syntactic sugar is given by translation into simpler constructs.

43 If these translations are applied exhaustively, the result is a program

44 written in a small subset of Haskell that we call the Haskell <em>kernel</em>.

45 <p>

46 "Though the kernel is not formally specified, it is essentially a

47 slightly sugared variant of the lambda calculus with a straightforward

48 denotational semantics. The translation of each syntactic structure

49 into the kernel is given as the syntax is introduced. This modular

50 design facilitates reasoning about Haskell programs and provides

51 useful guidelines for implementors of the language."

52 <p>

53 (The intent here is to avoid the common misconception that the kernel

54 is a formally specified thing.)

56 <p><li> [Sept 2001] <strong>Page 2, Section 1.4, Namespaces; and

57 Page 7, Section 2.4, Identifiers and operators; and

58 Page 15, Section 3.2, Variables, Constructors, Operators, and Literals.</strong>

59 Remove the first paragraph (about operators), which does not really belong

60 here, and item 2 of the list (which is related).

61 Instead, amplify the remarks in Section 2.4 and 3.2. This is a presentational

62 change only.

64 <p><li> <strong>Page 5, Section 2.2, Lexical program structure; and Appendix B.2, p120.</strong>

65 Change the production for <em>uniDigit</em> to

66 <pre>

67 uniDigit -> any Unicode decimal digit

68 </pre>

70 <p><li> <strong>Page 5, Section 2.2, Lexical program structure; and Appendix B.2, p120.</strong>

71 Change the production for <em>symbol</em> to:

72 <pre>

73 symbol -> ascSymbol | uniSymbol< special | _ | : | " | ' >

74 </pre>

77 <ul>

78 <li> Add <em>return</em>, <em>linefeed</em>, and <em>uniWhite</em> to the production for <em>ANY</em>.

80 <pre>

81 lexeme -> qvarid | qconid | qop | literal | special | reservedop | reservedid

82 </pre>

83 </ul>

84 (These changes, and the next one, justify the productions for <em>program</em> which claims that a program is

85 a sequence of lexemes and white space.)

90 "<tt>---</tt>" are not legal lexemes.

92 <p><li> <strong>Page 9, Section 2.4, Identifiers and operators; and Page 68, Section 5.5.1, Qualified names.</strong>

93 Move the first paragraph of 5.5.1, and the following table, and the paragraph starting "The qualifier does not change...",

94 to the end of Section 2.4. (These paragraphs deal with lexical matters, which do not belong in Chapter 5.)

100 In the middle of the third paragraph, just before the sentence beginning

101 "A close brace is also inserted...", add the following sentence:

102 <p>

103 "If the indentation of the non-brace lexeme immediately

104 following a <tt>where</tt>, <tt>let</tt>,

105 <tt>do</tt> or <tt>of</tt> is less than or equal to the <em>current</em> indentation level,

107 layout processing occurs for the current level (i.e. insert a semicolon or close brace)."

109 <p><li> <strong>Page 11, Figures 1 and 2</strong>. In both figures the signature for <tt>size</tt>

110 should be

111 <pre>

112 size :: Stack a -> Int

113 </pre>

116 Replace the last two sentences of the first paragrah of the section by:

117 <p>

118 "Free variables and constructors used in these translations always

119 refer to entities defined by the <tt>Prelude</tt>. For example,

120 ``<tt>concatMap</tt>'' used in the translation of list comprehensions

121 (Section 3.11) means the <tt>concatMap</tt> defined by the

122 <tt>Prelude</tt>, regardless of what is in scope where the list

123 comprehension is used."

124 <p>

125 (Clarification only.)

129 understanding...". (The table causes more confusion than it clears up.)

134 <p><li> [Apr 2001] <strong>Page 15, Section 3.2, Variables, Constructors, Operators, and Literals.</strong>

135 Remove the paragraph starting "Qualified names may only ...", and the following example, and the

136 concluding paragraph starting "incorrectly uses a qualifier". (This is all covered in 2.4 and 5.5.1.)

139 In the second paragraph, in the sentence "For the type <tt>Integer</tt>,

142 list in the paragraph following the bulletted list.

146 <li> Remove the production for (empty qualifier)

147 <li> In the translation box lower down the page, rewrite the translation so

148 that it does not involve and empty list of qualifiers. (Unchanged semantics.)

149 </ul>

150 This change ensures that there is at least one qualifier in list comprehension,

151 and no qualifier is empty. The translation lower down page 23 is then

152 not utterly rigorous, because Q can be empty, and when it is there is no preceding

153 comma, but I reckon it would make matters worse to "fix" it.

157 <ul>

158 <li>

160 <pre>

162 </pre>

164 </ul>

165 That is, every list of statements must end in an expression, optionally

166 followed by a semicolon.

169 Add an example to illustrate the final point in para 2.

172 In the translation box:

173 <ul>

177 </ul>

180 Give an example to illustrate an illegal non-linear pattern.

182 <p><li> [Aug 2001] <strong>Page 31, Section 3.17.2, Informal Semantics of Case Expressions.</strong>

184 with the following:

185 <pre>

187 f ~(x,y,z) [a] | (a == y) = 1

188 </pre>

189 (The previous example use boolean and, which is non-strict in its second argument!)

199 First paragraph, last sentence. After "infix type constructors are not allowed",

200 add "(other than <tt>(->)</tt>)".

202 <p><li> [Late Sept 2001] <strong>Page 38, Section 4.1.2, Algebraic Datatype Declarations.</strong>

203 Replace the sentence

204 "Although the tuple, list, and function types have special syntax, they

205 are not different from user-defined types with equivalent

206 functionality."

207 with

208 <p>

209 "These special syntactic forms always denote the built-in type constructors

210 for functions, tuples, and lists, regardless of what is in scope.

211 In a similar way, the prefix type constructors <tt>(->),</tt>, <tt>[]</tt>, <tt>()</tt>, <tt>(,)</tt>,

212 and so on, always denote the built-in type constructors; they

213 cannot be qualified, nor mentioned in import or export lists (Section 5).

214 (Hence the special production, <em>gtycon</em>, above.)

215 <p>

216 "Although the tuple and list types have special syntax, their semantics

217 is the same as the equivalent user-defined algebraic data types."

218 <p>

219 (This stuff is clarification only.)

221 <p><li> <strong>Page 40, Section 4.2.1, Algebraic Datatype Declarations.</strong>

222 In the bottom paragraph on the page, before "The context in the data declaration

223 has no other effect whatsoever" add the following:

224 <p>

226 constraint. For example:

227 <pre>

228 f (ConsSet a s) = a

229 </pre>

232 <p><li> <strong>Page 41, Section 4.2.1, subsection Labelled Fields.</strong>

233 At the end of the subsection, add a new paragraph:

234 <p>

238 <p><li> [Apr 2001] <strong>Page 42, Section 4.2.1, subsection Labelled Fields.</strong>

240 the section.

242 <p><li> <strong>Page 49, Section 4.3.4, Ambiguous Types...</strong>

243 In the third paragraph from the end of Section 4.3.4, replace "...an ambiguous

244 type variable is defaultable if at least one of its classes is a numeric class..."

245 by "...an ambiguous type variable, v, is defaultable if v appears only in constraints

246 of the form (C v), where C is a class, and if at least one of its classes is

247 a numeric class...".

248 <p>

249 The new phrase is "if v appears only in constraints of the

250 form (C v) where C is a class". Without this condition the rest of the

251 sentence does not make sense.

253 <p><li> [Aug 2001] <strong>Page 51, Section 4.4.2, Fixity Declarations.</strong>

254 <ul>

255 <li> In the prodution for <em>gendecl</em> change <em>digit</em> to <em>integer</em>.

256 <li> Make the same change in the syntax at the start of Section 4 and in Appendix B.

257 <li> After "A fixity declaration gives the fixity and binding

258 precedence of one or more operators." add the sentence "The <em>integer</em> in a fixity declaration

260 </ul>

263 <p><li> [Apr 2001] <strong>Page 53, Section 4.4.3.</strong> Replace "For example, these two function

264 definitions are equivalent:", and the two lines of code that follow by:

265 <br>

266 "For example, these three function definitions are all equivalent:

267 <pre>

268 plus x y z = x+y+z

269 x `plus` y = \ z -> x+y+z

270 (x `plus` y) z = x+y+z

272 (This change makes explicit that an infix operator with more than two arguments

273 can have all of them on the LHS.)

275 <p><li> [Apr 2001] <strong>Page 54, Section 4.4.3, subsection Function Bindings.</strong>

277 the <em>xn</em> should be <em>xk</em> (suitably subscripted in both cases!),

278 and all three <em>m</em> subscripts should be <em>n</em>.

280 <p><li> <strong>Page 57, Section 4.5.3, Context reduction errors.</strong>

281 The example

282 <pre>

283 f :: (Monad m, Eq (m a)) => a -> m a -> Bool

284 f x y = x == return y

285 </pre>

286 is wrong; it should read

287 <pre>

288 f x y = return x == y

289 </pre>

291 <p><li> [Sept 2001] <strong>Page 58, Section 4.5.5, Momomorphism.</strong>

293 "The usual Hindley-Milner restriction on polymorphism is that only

294 type variables free in the environment may be generalized" by

295 <p>

296 "The usual Hindley-Milner restriction on polymorphism is that only

297 type variables that do not occur free in the environment may be generalized."

298 <p>

299 (The sense was backward before.)

301 <p><li> [May 2001] <strong>Page 62, Section 5, Modules.</strong>

302 In paragraph 4, add a footnote to the sentence "A multi-module Haskell

303 program can be converted into a single-module program by ...", namely:

304 <p>

305 "There are two minor exceptions to this statement.

308 is affected by module boundaries."

309 <p>

310 This footnote qualifies the otherwise over-strong statement.

312 <p><li> [Aug 2001] <strong>Page 64, Section 5.2, Export declarations, numbered item 5.</strong>

313 Replace the first paragrah of this item with:

314 <p>

317 of the form "<tt>import</tt> M [impspec]" or "<tt>import</tt> A <tt>as</tt> M [impspec]". This set may be empty.

318 For example:"

320 <p><li> [Aug 2001] <strong>Page 64, Section 5.2, Export declarations.</strong>

321 After the numbered items, add:

322 <p>

324 module bearing the export list, or M is imported

327 <p><li> [July 2001] <strong>Page 65, Section 5.2, Export declarations.</strong>

328 Replace the two paragraphs and code fragment that the numbered list with the following:

329 <p>

330 "It makes no difference to an importing module how an entity was

331 exported. For example, a field name <tt>f</tt> from data type <tt>T</tt> may be exported individually

332 (<tt>f</tt>, item (1) above); or as an explicitly-named member of its data type (<tt>T(f)</tt>, item (2));

335 <p>

336 Exports lists are cumulative: the set of entities exported by an export

337 list is the union of the entities exported by the individual items of the list.

338 <p>

340 (within their respective namespace). For example

341 <pre>

342 module A ( module B, C.f, g ) where -- an invalid module

343 import qualified B(f,g)

344 import qualified C(f)

345 g = True

346 </pre>

351 <p><li> [July 2001] <strong>Page 65, Section 5.3, Import Declarations, last line.</strong>

353 be imported...".

355 <p><li> [July 2001] <strong>Page 66, Section 5.3, Import Declarations, numbered item 2.</strong>

356 Delete the two sentences "The hiding clause only applies to unqualified

357 names... A hiding clause has no effect....".

359 <p><li> [Late Sept 2001] <strong>Page 66, Section 5.3, Import Declarations, numbered item 2.</strong>

360 Add "It is an error to hide an entity that is not, in fact, exported by

361 the imported module."

363 <p><li> [July 2001] <strong>Page 66, Section 5.3.1, Qualified Import.</strong> [This section

364 becomes 5.3.2.] Replace the first sentence with:

367 the top-level environment is extended. If the import declaration used

370 qualified and unqualified name of the entity is brought into scope.

374 <p><li><strong>Page 67, Section 5.3.2, Local aliases</strong>.

375 The last example in the section should read:

376 <pre>

377 import Foo as A(f)

378 </pre>

380 <p><li> [Aug 2001] <strong>Page 68, Section 5.5.1, Qualified names.</strong>

381 Replace the second example in the first bullet by:

382 <pre>

383 module M where

384 M.f x = ... -- ILLEGAL

385 g x = let M.y = x+1 in ... -- ILLEGAL

386 </pre>

387 (This just clarifies that qualifiers aren't legal in local decls either.)

389 <p><li> <strong>Page 69, Section 5.5.2, Name clashes.</strong>

390 At the very end of the section, add the following clarification:

391 <p>

392 "The name occurring in a type signature or fixity declarations is always

393 unqualified, and unambiguously refers to another declaration in the

394 same declaration list (except that the fixity declaration for a class method

395 can occur at top level --- Section 4.4.2). For example, the following

396 module is legal:

397 <pre>

398 module F where

399 sin :: Float -> Float

400 sin x = (x::Float)

402 f x = Prelude.sin (F.sin x)

403 </pre>

406 The references to

409 However, the unqualified name "<tt>sin</tt>" in the type

413 <p><li> <strong>Page 71, Section 5.6.2, Shadowing Prelude Names.</strong>

414 Replace the example at the beginning of the section, and the entire

415 following paragraph, with the following

417 module A( null, nonNull ) where

418 import Prelude hiding( null )

419 null, nonNull :: Int -> Bool

420 null x = x == 0

421 nonNull x = not (null x)

422 </pre>

425 The latter would be ambiguous without the "<tt>hiding(null)</tt>" on the

426 "<tt>import Prelude</tt>" statement.

430 Prelude names."

432 <p><li> [Aug 2001] <strong>Page 74, Section 6.1.3, Lists.</strong> In the last sentence,

433 after "<tt>Monad</tt>" add ", <tt>Functor</tt>". (The list type is an instance of <tt>Functor</tt>.)

435 <p><li> [May 2001] <strong>Page 74, Section 6.1.4, Tuples.</strong>

436 Replace the first paragraph of this section with:

437 <p>

438 "Tuples are algebraic datatypes with special syntax, as defined

439 in Section 3.8. Each tuple type has a single constructor.

442 <p>

443 There is no upper bound on the size of a tuple, but some Haskell

444 implementations may restrict the size of tuples, and limit the

445 instances associated with larger tuples. However, every Haskell

446 implementation must support tuples up to size 15, together with their instances

452 <p><li> [Apr 2001] <strong>Page 74, Section 6.1.6, Function Types.</strong>

453 Delete the sentence "Functions are an instance of the <tt>Show</tt> class but not <tt>Read</tt>".

455 <p><li> [Aug 2001] <strong>Page 75, Section 6.1.7, The IO and IOError Types.</strong>

457 (<tt>IO</tt> is an instance of <tt>Functor</tt>, but not <tt>Show</tt>.)

459 <p><li> [Apr 2001] <strong>Page 76, Section 6.3, Standard Haskell classes.</strong>

460 There is a formatting error in the example. There should be a new line

464 <p><li> [July 2001] <strong>Page 78, Section 6.3.2, The Ord Class.</strong>

465 Redefine the default methods for <tt>max</tt> and <tt>min</tt> as follows:

466 <pre>

467 max x y | x <= y = y

468 | otherwise = x

469 min x y | x <= y = x

470 | otherwise = y

471 </pre>

472 (This change aligns the report with the code given in the Appendix.)

474 <p><li> [Apr 2001] <strong>Page 78, Section 6.3.3, The Read and Show Classes.</strong>

476 to and from strings." add the sentence:

479 (Clarification only.)

481 <p><li><strong>Page 80, Section 6.3.6, Class Monad.</strong>

482 Right at the bottom of the page, replace "However, for IO, the fail

483 method invokes error." by "For IO, the fail method raises a user

486 <p><li> [Aug 2001] <strong>Page 82, Section 6.4, Numbers.</strong>In paragraph 2 of 6.4, replace "Rational library"

489 <p><li> [July 2001] <strong>Page 83, Section 6.4.2, Arithmetic and number-theoretic operations.</strong>

490 After "The quod, rem, div, and mod class methods satisfy these laws" add "if <tt>y</tt> is non-zero".

492 <p><li> [Apr 2001] <strong>Page 84, Section 6.4, Fig 7; and bottom of page 86, Section 6.4.6.</strong>

493 <pre>

494 fromRealFrac :: (RealFrac a, Fractional b) => a -> b

495 </pre>

496 should be replaced by

497 <pre>

498 realToFrac :: (Real a, Fractional b) => a -> b

499 </pre>

501 <p><li><strong>Page 88, Section 7.1, Standard I/O functions.</strong>

506 <p><li><strong>Page 90, Section 7.3, Exception handling in the IO monad.</strong>

507 After the first paragraph give the following type signature:

508 <pre>

509 userError :: String -> IOError

510 </pre>

511 Also add an index entry for <tt>userError</tt> on this page.

512 (These changes are purely presentational.)

514 <p><li> [Apr 2001] <strong>Page 90, Section 7.3, Exception handling in the IO monad.</strong>

515 After the above signature for <tt>userError</tt>, add the following:

516 "The <tt>fail</tt> method of the <tt>IO</tt> instance of the <tt>Monad</tt> class (Section 6.3.6) raises a

518 <pre>

519 instance Monad IO where

522 fail s = ioError (userError s)

525 <p><li> [Late Sept 2001] <strong>Page 93, Appendix A, Standard Prelude.</strong>

526 Replace the fixity declaration for <tt>(:)</tt> by the following comments:

527 <pre>

528 -- The (:) operator is built-in syntax, and cannot legally be given

529 -- a fixtity declaration; but its fixity is given by:

530 -- infixr 5 :

531 </pre>

534 <p><li><strong>Page 94, Appendix A, Standard Prelude, class <tt>Enum</tt>.</strong>

535 After the default method for <tt>enumFromTo</tt> add

536 <pre>

537 enumFromThen x y = map toEnum [fromEnum x, fromEnum y ..]

538 </pre>

540 <p><li><strong>Page 95, Appendix A, Standard Prelude, class <tt>Floating</tt>.</strong>

541 Add <tt>asin, acos, atan</tt> to the comment giving the list of minimal complete definitions.

543 <p><li> [Apr 2001] <strong>Page 101, Appendix A, <tt>instance Monad IO</tt>.</strong>

544 Replace the definition of <tt>fail</tt> in <tt>instance Monad IO</tt> by

545 <pre>

546 fail s = ioError (userError s)

547 </pre>

549 <p><li><strong>Page 102, Appendix A, comments immediately before

550 <tt>instance Enum Float</tt>.</strong>

553 <p><li> [Aug 2001] <strong>Page 101, Appendix A, instance of <tt>Monad IO</tt>.</strong>

554 Delete defintion for <tt> >> </tt>. (The default definition will do.)

556 <p> <li> [Apr 2001] <strong>Page 105, Appendix A.1, line 11.</strong>

559 <p><li><strong>Page 105, Appendix A.1 (PreludeList), line 19.</strong>

560 Correct the type of <tt>map</tt> to

561 <pre>

562 map :: (a -> b) -> [a] -> [b]

563 </pre>

565 <p><li><strong>Page 106, definition of <tt>(!!)</tt>.</strong>

566 Replace the definition of <tt>(!!)</tt> with the following:

567 <pre>

568 -- List index (subscript) operator, 0-origin

569 (!!) :: [a] -> Int -> a

572 (x:_) !! 0 = x

573 (_:xs) !! n = xs !! (n-1)

574 </pre>

575 (The original version had the property that <tt>([] !! -100)</tt>

578 <p><li> [Apr 2001] <strong>Page 107, definition of <tt>scanl1</tt> and <tt>scanr1</tt>.</strong>

579 Replace the definitions of <tt>scanl1</tt> and <tt>scanr1</tt> with these:

580 <pre>

581 scanl :: (a -> b -> a) -> a -> [b] -> [a]

582 scanl f q xs = q : (case xs of

583 [] -> []

584 x:xs -> scanl f (f q x) xs)

586 scanl1 :: (a -> a -> a) -> [a] -> [a]

587 scanl1 f (x:xs) = scanl f x xs

588 scanl1 _ [] = []

590 scanr1 :: (a -> a -> a) -> [a] -> [a]

591 scanr1 f [] = []

592 scanr1 f [x] = [x]

593 scanr1 f (x:xs) = f x q : qs

594 where qs@(q:_) = scanr1 f xs

595 </pre>

596 The effect is to make both functions defined on the empty list.

599 <p><li> [Apr 2001] <strong>Page 108, definition of <tt>take</tt>, <tt>drop</tt>, and <tt>splitAt</tt>.</strong>

600 Replace the definitions of <tt>take</tt>, <tt>drop</tt>, and <tt>splitAt</tt> with these:

601 <pre>

602 take :: Int -> [a] -> [a]

603 take n _ | n <= 0 = []

604 take _ [] = []

605 take n (x:xs) = x : take (n-1) xs

607 drop :: Int -> [a] -> [a]

608 drop n xs | n <= 0 = xs

609 drop _ [] = []

610 drop n (_:xs) = drop (n-1) xs

612 splitAt :: Int -> [a] -> ([a],[a])

613 splitAt n xs = (take n xs, drop n xs)

614 </pre>

615 The effect is that all three functions are defined on negative arguments. This

616 is a semantic change.

618 <p><li> [May 2001; showsPrec corrected Sept 2001]

619 <strong>Page 115, instances <tt>Show Int</tt> and <tt>Read Int</tt></strong>.

620 Replace the instances for <tt>Show Int</tt> and <tt>Read Int</tt> with

621 <pre>

622 instance Show Int where

623 showsPrec n = showsPrec n . toInteger

624 -- Converting to Integer avoids

625 -- possible difficulty with minInt

627 instance Read Int where

628 readsPrec p r = [(fromInteger i, t) | (i,t) <- readsPrec p r]

629 -- Reading at the Integer type avoids

630 -- possible difficulty with minInt

631 </pre>

632 The previous definitions (which are simply specifications, remember) failed on minInt.

634 <p><li> [Aug 2001] <strong>Page 124, Appendix B.3, Layout</strong>.

636 sub-section. (Note 5 covers the top-level case.)

638 <p><li> [May 2001] <strong>Page 132, Appendix D, Specification of Derived Instances</strong>.

639 In numbered item 3, replace

640 ``(all constructors must by nullary)'' with

641 ``(all constructors must be nullary)''.

643 <p><li> [June 2001] <strong>Page 134, Appendix D.4, Derived instances of Read and Show</strong>.

645 the empty string, resulting in the following:

646 <pre>

648 </pre>

649 (The old, stronger, equation is simply false.)

651 <p><li> [Aug 2001] <strong>Page 138, Appendix E, Compiler pragmas</strong>.

652 <ul>

653 <li> Change <tt>inline</tt> to <tt>INLINE</tt>.

654 <li> Change <tt>notInline</tt> to <tt>NOINLINE</tt>.

655 <li> Change <tt>specialize</tt> to <tt>SPECIALIZE</tt>.

656 <li> Remove the optional digit from the <tt>INLINE</tt> pragma, and replace the first para of E.1 by:

657 <p>

659 at their use sites.

660 Compilers will often automatically inline simple expressions. This

662 <p> <li> Delete the whole of E.3.

663 </ul>

664 (These changes simplify the pramga story, and bring it into line with what

665 is usually implemented.)

668 <p><li> [Apr 2001] <strong>Page 141, Bibliograpy</strong>.

671 <p><li> <strong>Page 141, Bibliograpy</strong>.

672 The library report citation [8] is out of date. It should read:

673 "Simon Peyton Jones and John Hughes (editors), Standard Libraries for the

678 <p><li> [Apr 2001] <strong>Index of the Haskell 98 Prelude (HTML version only)</strong>

679 <ul>

680 <li> Remove <tt>Eval</tt> as a superclass of <tt>Num</tt>

681 <li> Correct type of <tt>seq</tt> to <tt>seq :: a -> b -> b</tt>.

682 <li> Correct type of <tt>getLine</tt> to <tt>IO String</tt>

683 </ul>

684 </ul>

686 <hr>

687 <h1>Errata in the

690 <ul>

693 <p><li> <strong>Title page</strong>. Add the paragraph:

694 <p>

695 "Copyright (c) Simon Peyton Jones.

696 <p>

697 The authors intend this Report to belong to the entire Haskell

698 community, and so we grant permission to copy and

699 distribute it for any purpose, provided that it is

700 reproduced in its entireity, including this Notice. Modified

701 versions of this Report may also be copied and distributed for any purpose,

702 provided that the modified version is clearly presented as such,

705 <p><li> [Apr 2001] <strong>Page 5, Section 2.1, Library <tt>Ratio</tt></strong>.

706 Replace the definition of <tt>recip</tt> on line 3 by the following

707 <pre>

708 recip (x:%y) = y % x

709 </pre>

711 doing it by hand. In particular, an error will be raised if y is zero.

713 <p><li> [Sept 2001] <strong>Page 13, Section 4.1, Numeric library</strong>.

714 <ul>

715 <li> Add specifications for the functions exported by the Numeric library.

717 <p><li>In <tt>formatRealFloat</tt>, add the following local definitions:

718 <pre>

720 mk0 s = s -- and 0.34 not .34

723 mkdot0 s = '.' : s

724 </pre>

726 <li> In the definition of <tt>formatRealFloat</tt>,

727 <ul>

728 <li> in the definition of <tt>doFmt</tt>,

732 <pre>

733 Nothing | e >= 0 -> take e (ds ++ repeat '0') ++ mkdot0 (drop e ds)

734 | otherwise -> '0' : mkdot0 (replicate (-e) '0' ++ ds)

735 </pre>

736 <li> in the <tt>Just dec</tt> branch, replace "<tt>(if null ls then "0" else ls) ++ (if null rs then "" else '.' : rs)</tt>"

739 <li> also in the <tt>Just dec</tt> branch, replace "<tt>d : '.' : ds</tt>" by "<tt>d : mkdot0 ds</tt>".

740 </ul>

742 <p><li>In the definition of <tt>k</tt> in <tt>floatToDigits</tt> replace "<tt>fromInt e</tt>" by "<tt>fromIntegral e</tt>".

743 (<tt>fromInt</tt> no longer exists.)

744 <li> Last line of code for <tt>floatToDigits</tt>, replace "<tt>toInt</tt>" by "<tt>fromIntegral</tt>".

745 (<tt>toInt</tt> no longer exists.)

746 </ul>

749 <p><li> [Sept 2001] <strong>Page 16, Section 4, Numeric library</strong>. In the definition

751 <pre>

754 </pre>

755 (This makes <tt>readFloat</tt> able to read "Infinity" and "NaN", which <tt>formatRealFloat</tt>

756 can produce.)

758 <p><li> <strong>Page 17, Section 5, first text line</strong>. Replace "continuous" by "contiguous".

760 <p><li> [May 2001] <strong>Page 17, Section 5, Indexing operations</strong>.

761 Add the following equation to the laws listed just before Section 5.1:

762 <pre>

763 map index (range (l,u)) == [0..rangeSize (l,u)]

764 </pre>

765 This documents an invariant that was previously only implicit.

767 <p><li> [Late Sept 2001] <strong>Page 17, Section 5, Indexing operations</strong>.

768 This significant item makes <tt>rangeSize</tt> into a method of

769 <tt>Ix</tt> rather than a free-standing declaration. Though this

770 change is visible to the programmer, all existing Haskell 98

771 programs will continue to work.

773 <ul>

774 <li> <strong>Page 17, Section 5, Indexing operations, boxed text</strong>. Replace the <tt>Ix</tt>

775 change the class declaration, and the type signature for <tt>rangeSize</tt> with:

776 <pre>

777 class Ord a => Ix a where

778 range :: (a,a) -> [a]

779 index :: (a,a) -> a -> Int

780 inRange :: (a,a) -> a -> Bool

781 rangeSize :: (a,a) -> Int

782 </pre>

783 <li> <strong>Section 5.2, pages 19, line 3</strong>. Replace the <tt>Ix</tt>

784 class declaration, and the <tt>rangeSize</tt> declaration, with:

785 <pre>

786 class Ord a => Ix a where

787 range :: (a,a) -> [a]

788 index :: (a,a) -> a -> Int

789 inRange :: (a,a) -> a -> Bool

790 rangeSize :: (a,a) -> Int

792 rangeSize b@(l,h) | null (range b) = 0

793 | otherwise = index b h + 1

795 -- fails if the bounds are tuples. For example,

796 -- (1,2) <= (2,1)

797 -- but the range is nevertheless empty

798 -- range ((1,2),(2,1)) = []

799 </pre>

800 (Note: the comment has changed too; it was misleading before.)

801 </ul>

803 <p><li> [July 2001] <strong>Page 17, Section 5.1, Derived instances of <tt>Ix</tt></strong>.

804 Replace the first paragraph with the following:

805 <p>

808 of the Language Report).

810 for enumerations (i.e. datatypes having

811 only nullary constructors) and single-constructor datatypes,

814 <p>

816 Section 6.1.6 of the Language Report.]

818 <p><li> <strong>Page 22, Section 6.3; and Page 23, Fig 3</strong>:

821 <p><li> [May 2001] <strong>Page 23, Figure 3</strong>.

822 In the definition of <tt>diag</tt>, delete the guard ``<tt>| l==l' && u==u'</tt>''.

823 (The original intent was presumably to check for a square array, but

824 simply makes the definition recursive and hence divergent.)

826 <p><li> <strong>Page 29, Section 7.2</strong>. Add a new bullet for <tt>nub</tt>.

827 Add an index entry for <tt>nub</tt>.

829 <p><li> <strong>Page 29, Section 7.2, second bullet</strong>.

832 <p><li> [May 2001] <strong>Page 30, Section 7.4, unfoldr</strong>.

833 Replace the first line-and-a-half paragraph with:

834 <p>

835 "The <tt>unfoldr</tt> function is a `dual' to <tt>foldr</tt>: while <tt>foldr</tt> reduces a list

837 example:

838 <pre>

839 iterate f == unfoldr (\x -> Just (x, f x))

840 </pre>

842 <p>

843 (Followed by the existing displayed equation.)

845 <p><li> [Apr 2001] <strong>Page 34, Section 7.8, Library List</strong>.

846 Replace the definition of <tt>partition</tt> by

847 <pre>

848 partition :: (a -> Bool) -> [a] -> ([a],[a])

849 partition p xs = (filter p xs, filter (not . p) xs)

850 </pre>

851 This simply makes it agree with the definition on page 30 (Section 7.3).

853 <p><li> [Apr 2001] <strong>Page 35, Section 7.8</strong>.

854 Replace the definitions of <tt>maximumBy</tt> and <tt>minimumBy</tt> by the following

855 <pre>

856 maximumBy :: (a -> a -> Ordering) -> [a] -> a

858 maximumBy cmp xs = foldl1 max xs

859 where

860 max x y = case cmp x y of

861 GT -> x

862 _ -> y

864 minimumBy :: (a -> a -> Ordering) -> [a] -> a

866 minimumBy cmp xs = foldl1 min xs

867 where

868 min x y = case cmp x y of

869 GT -> y

870 _ -> x

871 </pre>

872 <strong>NOTE:</strong> this is a semantic change, but it makes the definitions

875 <p><li><strong>Page 54, Sections 11, 12, 13</strong>.

877 Namely:

878 <ul>

879 <li> Section 11.1, second para after bullets (two occurrences).

880 <li> Section 12, para 2 (two occurrences).

881 <li> Section 13, para 2 (two occurrences).

882 </ul>

883 (It was inconsistent before.)

885 <p><li><strong>Page 54, Section 11</strong>.

886 The signature for <tt>try</tt> should be

887 <pre>

888 try :: IO a -> IO (Either IOError a)

889 </pre>

891 <p><li> [May 2001] <strong>Page 57, Section 11.2.1 Semi-closed handles</strong>.

893 "Once a semi-closed handle becomes closed, the contents of the

894 associated list becomes fixed. The contents of this final list is

895 only partially specified: it will contain at least all the items of

896 the stream that were evalutated prior to the handle becoming closed."

897 <p>

898 This change attempts to clarify the (murky) meaning of <tt>hGetContents</tt> followed by

899 <tt>hClose</tt>.

901 <p><li> [Apr 2001] <strong>Page 56-58, Section 11.2, Files and Handles</strong>.

902 Add a section 11.2.3 to clarify the file-locking issue. It says:

903 <p>

904 "Implementations should enforce as far as possible, at least locally to the

905 Haskell process, multiple-reader single-writer locking on files.

906 That is, there may either be many handles on the same file which manage

907 input, or just one handle on the file which manages output. If any

908 open or semi-closed handle is managing a file for output, no new

909 handle can be allocated for that file. If any open or semi-closed

910 handle is managing a file for input, new handles can only be allocated

911 if they do not manage output. Whether two files are the same is

912 implementation-dependent, but they should normally be the same if they

913 have the same absolute path name and neither has been renamed, for

914 example.

917 holds a semi-closed handle on the file until the entire contents of the file have been

922 <p><li> [May 2001] <strong>Page 59, Section 11.4.2</strong>.

924 "An implementation is free to flush the buffer more frequently, but not

925 less frequently, than

926 specified above." (Clarification only.)

928 <p><li> [May 2001] <strong>Page 59, Section 11.4.2</strong>.

929 In the second no-buffering bullet (sixth bullet in the sub-section) add the

931 even a no-buffered handle may require a one-character buffer. " (Clarification only.)

933 <p><li><strong>Page 62, Section 11.7.2</strong>.

934 <ul>

936 just before the paragraph about <tt>hGetContents</tt>.

937 <li>

939 paragraph about <tt>hPutChar</tt>.

940 </ul>

941 <p><li><strong>Page 63, definition of <tt>main</tt> in Section 11.8.1</strong>.

943 <pre>

944 where readNum :: IO Integer

945 -- Need a type signature for readLn to avoid ambiguity

946 readNum = readLn

947 </pre>

948 (This change merely advertises the generally useful function <tt>readLn</tt>.)

951 <p><li><strong>Page 64, Section 12, Directory functions.</strong>

952 (More an editor's blunder than a typo.)

953 <ul>

954 <li>

955 Replace the abstract definition of <tt>Permissions</tt>, and the four instances

956 of <tt>Permissions</tt> with

957 <pre>

958 data Permissions

959 = Permissions {

960 readable, writable, executable, searchable :: Bool

961 }

962 deriving ( Eq, Ord, Read, Show )

963 </pre>

964 <li> Remove <tt>readable, writable, executable, searchable</tt> both from

965 the module header, and from the module body.

966 <li> Change <tt>Permissions</tt> to <tt>Permissions(Permissions, readable, writable, executable, searchable)</tt>

967 in the module header.

968 </ul>

970 <p><li> [Apr 2001] <strong>Page 78, Section 16, The <tt>CPUTime</tt> library</strong>.

971 Add <tt>cpuTimePrecision</tt> to the export list.

973 <p><li>[Apr 2001] <strong>Page 81, Section 17.1, The <tt>RandomGen</tt> class</strong>.

974 This sigificant semantic change adds a method <tt>genRange</tt> to the <tt>RandomGen</tt>

975 class. (Extensive discussion on the Haskell mailing list made it clear that this change

976 is essential to make the RandomGen class useful.) The following summarises the changes

977 but not in the detailed line-by-line form used for the rest of the errata.

978 <ul>

979 <li> Add a method <tt>genRange :: g -> (Int,Int)</tt> to class <tt>RandomGen</tt>.

980 <li> Give it the default method <tt>genRange g = (minBound,maxBound)</tt>

981 <li> Add a specification of <tt>genRange</tt>

982 <li> Change the header on page 80 to match.

983 </ul>

985 <p><li>[Apr 2001] <strong>Page 81, Section 17.1, The <tt>RandomGen</tt> class</strong>.

986 Specify more precisely that <tt>split</tt> must deliver <strong>independent</strong> generators.

988 <p><li><strong>Page 81, Section 17.1, The <tt>RandomGen</tt> class</strong>.

992 <p><li><strong>Page 83, Section 17.3, The global random number generator</strong>.

995 </ul>

996 <hr>

997 <address>Simon Peyton Jones, simonpj@microsoft.com</address>

998 </body>

999 </html>