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 </ul>

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

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

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

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

70 <ul>

71 <li>

73 <pre>

75 </pre>

77 </ul>

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

79 followed by a semicolon.

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

90 has no other effect whatsoever" add the following:

91 <p>

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

93 constraint. For example:

94 <pre>

95 f (ConsSet a s) = a

96 </pre>

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

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

101 <p>

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

107 the section.

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

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

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

114 a numeric class...".

115 <p>

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

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

118 sentence does not make sense.

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

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

122 <br>

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

124 <pre>

125 plus x y z = x+y+z

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

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

128 </pre>"

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

130 can have all of them on the LHS.)

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

138 The example

139 <pre>

141 f x y = x == return y

142 </pre>

143 is wrong; it should read

144 <pre>

145 f x y = return x == y

146 </pre>

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

150 names...".

153 The the last example in the section should read:

154 <pre>

155 import Foo as A(f)

156 </pre>

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

160 <p>

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

162 unqualified, and unambiguously refers to another declaration in the

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

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

165 module is legal:

166 <pre>

167 module F where

168 sin :: Float -> Float

169 sin x = (x::Float)

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

172 </pre>

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

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

175 The references to

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

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

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

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

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

184 following paragraph, with the following

185 "<pre>

186 module A( null, nonNull ) where

187 import Prelude hiding( null )

188 null, nonNull :: Int -> Bool

189 null x = x == 0

190 nonNull x = not (null x)

191 </pre>

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

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

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

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

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

199 Prelude names."

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

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

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

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

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

211 to and from strings." add the sentence:

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

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

214 (Clarification only.)

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

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

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

222 <pre>

224 </pre>

225 should be replaced by

226 <pre>

228 </pre>

231 After the first paragraph give the following type signature:

232 <pre>

233 userError :: String -> IOError

234 </pre>

236 (These changes are purely presentational.)

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

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

242 <pre>

243 instance Monad IO where

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

246 fail s = ioError (userError s)

247 </pre>"

251 <pre>

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

253 </pre>

257 <pre>

258 fail s = ioError (userError s)

259 </pre>

270 <pre>

272 </pre>

276 <pre>

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

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

281 (x:_) !! 0 = x

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

283 </pre>

285 reported "index too large".)

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

289 <pre>

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

292 [] -> []

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

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

297 scanl1 _ [] = []

300 scanr1 f [] = []

301 scanr1 f [x] = [x]

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

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

304 </pre>

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

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

310 <pre>

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

313 take _ [] = []

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

317 drop n xs | n <= 0 = xs

318 drop _ [] = []

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

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

323 </pre>

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

325 is a semantic change.

328 In numbered item 3, replace

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

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

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

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

338 Haskell 98 Programming Language, 1 February 1999".

343 <ul>

346 </ul>

347 </ul>

349 <hr>

350 <h1>Errata in the

353 <ul>

355 <p>

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

357 <p>

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

359 community, and so we grant permission to copy and

360 distribute it for any purpose, provided that it is

361 reproduced in its entireity, including this Notice. Modified

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

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

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

368 <pre>

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

370 </pre>

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

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

376 <p><li> [Apr 2001] <strong>Page 19, Section 5.2, comment on <tt>rangeSize</tt></strong>. Replace whole comment by

377 <pre>

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

381 -- but the range is nevertheless empty

383 </pre>

384 (This simply fixes a misleading comment.)

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

388 <pre>

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

390 </pre>

391 This documents an invariant that was previously only implicit.

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

396 Though these changes are

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

398 <ul>

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

401 <pre>

402 class Ix a where

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

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

407 </pre>

410 <pre>

411 class Ix a where

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

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

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

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

421 -- but the range is nevertheless empty

423 </pre>

424 </ul>

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

432 simply makes the definition recursive and hence divergent.)

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

442 <pre>

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

445 </pre>

450 <pre>

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

453 maximumBy cmp xs = foldl1 max xs

454 where

455 max x y = case cmp x y of

456 GT -> x

457 _ -> y

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

461 minimumBy cmp xs = foldl1 min xs

462 where

463 min x y = case cmp x y of

464 GT -> y

465 _ -> x

466 </pre>

472 <pre>

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

474 </pre>

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

478 <p>

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

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

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

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

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

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

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

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

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

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

489 example.

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

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

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

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

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

498 <ul>

501 <li>

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

504 </ul>

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

507 <pre>

508 where readNum :: IO Integer

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

510 readNum = readLn

511 </pre>

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

517 <ul>

518 <li>

521 <pre>

522 data Permissions

523 = Permissions {

524 readable, writable, executable, searchable :: Bool

525 }

526 deriving ( Eq, Ord, Read, Show )

527 </pre>

529 the module header, and from the module body.

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

531 in the module header.

532 </ul>

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

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

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

542 <ul>

547 </ul>

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

559 </ul>

560 <hr>

562 </body>

563 </html>