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

19 <ul>

21 <p>

22 "Copyright (c) Simon Peyton Jones and John Hughes.

23 <p>

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

25 community, and so we grant permission to copy and

26 distribute it for any purpose, provided that it is

27 reproduced in its entireity, including this Notice. Modified

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

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

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

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

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

38 <p>

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

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

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

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

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

46 should be

47 <pre>

48 size :: Stack a -> Int

49 </pre>

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

57 with "<tt>Int</tt>".

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

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

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

64 </ul>

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

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

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

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

72 <ul>

73 <li>

75 <pre>

77 </pre>

79 </ul>

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

81 followed by a semicolon.

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

92 has no other effect whatsoever" add the following:

93 <p>

94 "Pattern matching against <tt>ConsSet</tt> also gives rise to an <tt>Eq a</tt>

95 constraint. For example:

96 <pre>

97 f (ConsSet a s) = a

98 </pre>

99 the function <tt>f</tt> has inferred type <tt>Eq a => Set a -> a</tt>."

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

103 <p>

105 <em>whether or not <tt>F</tt> was declared with record syntax</em>."

109 the section.

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

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

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

116 a numeric class...".

117 <p>

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

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

120 sentence does not make sense.

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

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

124 <br>

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

126 <pre>

127 plus x y z = x+y+z

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

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

130 </pre>"

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

132 can have all of them on the LHS.)

135 In the first translation scheme ("The general binding form for functions..."),

140 The example

141 <pre>

143 f x y = x == return y

144 </pre>

145 is wrong; it should read

146 <pre>

147 f x y = return x == y

148 </pre>

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

153 <p>

154 "There are two minor exceptions to this statement.

155 First, <tt>default</tt> declarations scope over a single module (Section 4.3.4).

156 Second, Rule 2 of the monomorphism restriction (Section 4.5.5)

157 is affected by module boundaries."

158 <p>

159 This footnote qualifies the otherwise over-strong statement.

162 Start a new paragraph before the sentence "The hiding clause only applies to unqualified

163 names...".

166 The the last example in the section should read:

167 <pre>

168 import Foo as A(f)

169 </pre>

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

173 <p>

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

175 unqualified, and unambiguously refers to another declaration in the

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

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

178 module is legal:

179 <pre>

180 module F where

181 sin :: Float -> Float

182 sin x = (x::Float)

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

185 </pre>

186 The local declaration for <tt>sin</tt> is legal, even though

187 the <tt>Prelude</tt> function <tt>sin</tt> is implicitly in scope.

188 The references to

189 <tt>Prelude.sin</tt> and <tt>F.sin</tt> must both be qualified to make

190 it unambigous which <tt>sin</tt> is meant.

192 signature in the first line of <tt>F</tt> unambiguously refers to the

193 local declaration for <tt>sin</tt>."

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

197 following paragraph, with the following

198 "<pre>

199 module A( null, nonNull ) where

200 import Prelude hiding( null )

201 null, nonNull :: Int -> Bool

202 null x = x == 0

203 nonNull x = not (null x)

204 </pre>

205 Module <tt>A</tt> redefines <tt>null</tt>, and contains an unqualified reference

206 to <tt>null</tt> on the right hand side of <tt>nonNull</tt>.

209 Every module that imports <tt>A</tt> unqualified, and then makes an unqualified

210 reference to <tt>null</tt> must also resolve the ambiguous use of <tt>null</tt>

211 just as <tt>A</tt> does. Thus there is little danger of accidentally shadowing

212 Prelude names."

215 Replace the first paragraph of this section with:

216 <p>

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

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

219 All tuples are instances of <tt>Eq</tt>, <tt>Ord</tt>, <tt>Bounded</tt>, <tt>Read</tt>,

220 <tt>Show</tt>, and <tt>Ix</tt> (provided, of course, that all their component types are).

221 <p>

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

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

224 instances associated with larger tuples. However, every Haskell

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

226 for <tt>Eq</tt>, <tt>Ord</tt>, <tt>Bounded</tt>, <tt>Read</tt>,

227 <tt>Show</tt>, and <tt>Ix</tt>. The Prelude and

228 libraries define tuple functions such as <tt>zip</tt> for tuples up to a size

229 of 7."

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

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

237 after "the declaration of Class Eq is:", and before the sentence beginning

238 "This declaration gives default method declarations...".

241 After "The <tt>Read</tt> and <tt>Show</tt> classes are used to convert values

242 to and from strings." add the sentence:

243 "The <tt>Int</tt> argument to <tt>showsPrec</tt> and <tt>readsPrec</tt> gives the operator

244 precedence of the enclosing context (see Appendix D.4)."

245 (Clarification only.)

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

250 exception in the IO monad (see Section 7.3)."

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

253 <pre>

255 </pre>

256 should be replaced by

257 <pre>

259 </pre>

262 After the first paragraph give the following type signature:

263 <pre>

264 userError :: String -> IOError

265 </pre>

267 (These changes are purely presentational.)

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

272 <tt>userError</tt>, thus:

273 <pre>

274 instance Monad IO where

275 ...bindings for return, (>>=), (>>)

277 fail s = ioError (userError s)

278 </pre>"

282 <pre>

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

284 </pre>

288 <pre>

289 fail s = ioError (userError s)

290 </pre>

301 <pre>

303 </pre>

307 <pre>

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

311 [] !! _ = error "Prelude.!!: index too large"

312 (x:_) !! 0 = x

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

314 </pre>

316 reported "index too large".)

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

320 <pre>

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

323 [] -> []

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

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

328 scanl1 _ [] = []

331 scanr1 f [] = []

332 scanr1 f [x] = [x]

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

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

335 </pre>

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

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

341 <pre>

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

344 take _ [] = []

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

348 drop n xs | n <= 0 = xs

349 drop _ [] = []

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

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

354 </pre>

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

356 is a semantic change.

358 <p><li> [May 2001] <strong>Page 115, instances <tt>Show Int</tt> and <tt>Read Int</tt></strong>.

360 <pre>

361 instance Show Int where

362 showsPrec = showsPrec . toInteger

363 -- Converting to Integer avoids

364 -- possible difficulty with minInt

366 instance Read Int where

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

368 -- Reading at the Integer type avoids

369 -- possible difficulty with minInt

370 </pre>

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

374 In numbered item 3, replace

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

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

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

380 the empty string, resulting in the following:

381 <pre>

382 fst (head (readsPrec d (showsPrec d x ""))) == x

383 </pre>

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

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

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

392 Haskell 98 Programming Language, 1 February 1999".

397 <ul>

400 </ul>

401 </ul>

403 <hr>

404 <h1>Errata in the

407 <ul>

409 <p>

410 "Copyright (c) Simon Peyton Jones and John Hughes.

411 <p>

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

413 community, and so we grant permission to copy and

414 distribute it for any purpose, provided that it is

415 reproduced in its entireity, including this Notice. Modified

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

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

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

422 <pre>

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

424 </pre>

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

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

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

432 <pre>

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

434 </pre>

435 This documents an invariant that was previously only implicit.

439 (b) make <tt>rangeSize</tt> into a method of <tt>Ix</tt> rather than a free-standing declaration.

440 Though these changes are

441 visible to the programmer, all existing Haskell 98 programs will continue to work.

442 <ul>

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

445 <pre>

446 class Ix a where

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

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

451 </pre>

454 <pre>

455 class Ix a where

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

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

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

462 | otherwise = index b h + 1

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

466 -- but the range is nevertheless empty

468 </pre>

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

470 </ul>

474 <pre>

475 instance (Ix a, Eq a, Eq b) => Eq (Array a b) ...

476 </pre>

478 <pre>

479 instance (Ix a, Ord a, Ord b) => Ord (Array a b) ...

480 </pre>

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

489 simply makes the definition recursive and hence divergent.)

495 Introduce a new bullet just before "<tt>union</tt> is list union".

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

499 <p>

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

501 to a summary value, <tt>unfoldr</tt> builds a list from a seed value. For

502 example:

503 <pre>

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

505 </pre>

506 In some cases, <tt>unfoldr</tt> can undo a <tt>foldr</tt> operation:"

507 <p>

508 (Followed by the existing displayed equation.)

512 <pre>

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

515 </pre>

520 <pre>

522 maximumBy cmp [] = error "List.maximumBy: empty list"

523 maximumBy cmp xs = foldl1 max xs

524 where

525 max x y = case cmp x y of

526 GT -> x

527 _ -> y

530 minimumBy cmp [] = error "List.minimumBy: empty list"

531 minimumBy cmp xs = foldl1 min xs

532 where

533 min x y = case cmp x y of

534 GT -> y

535 _ -> x

536 </pre>

542 <pre>

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

544 </pre>

547 Replace the sentence "Once a semi-closed handle becomes closed..." with

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

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

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

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

552 <p>

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

558 <p>

559 "Implementations should enforce as far as possible, locally to the

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

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

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

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

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

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

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

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

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

569 example.

571 Warning: the <tt>readFile</tt> operation (Section 7.1 of the Haskell Language Report)

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

573 consumed. It follows that an attempt to write to a file (using <tt>writeFile</tt>, for example)

574 that was earlier opened by <tt>readFile</tt> will usually result in

575 failure with <tt>isAlreadyInUseError</tt>."

578 Before "The buffer is emptied as soon as it has been written out." add:

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

580 less frequently, than

581 specified above." (Clarification only.)

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

585 sentence: "The <tt>hLookAhead</tt> operation implies that

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

589 <ul>

592 <li>

593 Add a new section heading "<strong>11.7.4 Text output</strong>" before the

595 </ul>

597 Replace the definition of "<tt>readNum</tt>" with

598 <pre>

599 where readNum :: IO Integer

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

601 readNum = readLn

602 </pre>

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

608 <ul>

609 <li>

612 <pre>

613 data Permissions

614 = Permissions {

615 readable, writable, executable, searchable :: Bool

616 }

617 deriving ( Eq, Ord, Read, Show )

618 </pre>

620 the module header, and from the module body.

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

622 in the module header.

623 </ul>

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

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

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

633 <ul>

638 </ul>

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

650 </ul>

651 <hr>

653 </body>

654 </html>