8d07f345cedf4f151dee9f1fb252bf642312d975
[haskell-report.git] / haskell98-bugs.html
1 <html>
2 <head>
3 </head>
4 <HEAD>
5 <TITLE>Haskell 98: ERRATA</title></head>
6 </head>
7 </head>
8 </head>
9 </head>
10 </HEAD>
11 <BODY>
12 <div align=center>
13 <img src="h98.gif" alt="Haskell 98">
14 </div>
15
16 <h1>Errata in the
17 <a href="http://haskell.cs.yale.edu/definition/">Haskell 98 Language Report</a></h1>
18
19 <ul>
20 <p><li> <strong>Title page</strong>. Add the paragraph:
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."
31
32 <p><li> <strong>Page 10, Section 2.7, Layout.</strong>
33 In the middle of the third paragraph, just before the sentence beginning
34 "A close brace is also inserted...", add the following sentence:
35 <p>
36 "If the indentation of the non-brace lexeme immediately
37 following a <tt>where</tt>, <tt>let</tt>,
38 <tt>do</tt> or <tt>of</tt> is less than or equal to the <em>current</em> indentation level,
39 then instead of starting a layout, an empty list "<tt>{}</tt>" is inserted, and
40 layout processing occurs for the current level (i.e. insert a semicolon or close brace)."
41
42 <p><li> <strong>Page 11, Figures 1 and 2</strong>. In both figures the signature for <tt>size</tt>
43 should be
44 <pre>
45 size :: Stack a -> Int
46 </pre>
47
48 <p><li> <strong>Page 14, Section 3.1, Errors.</strong> In the first sentence of
49 the section, after "indistinguishable" add "by a Haskell program".
50
51 <p><li> <strong>Page 20, Section 3.10, Arithmetic sequences.</strong>
52 In the second paragraph, in the sentence "For the type <tt>Integer</tt>,
53 arithmetic sequences have the following meaning...", replace "<tt>Integer</tt>"
54 with "<tt>Int</tt>".
55
56 <p><li> <strong>Page 23, Section 3.14, Do Expressions;
57 and Page 128, Appendix B.4, Context Free Syntax.</strong>
58 <ul>
59 <li>
60 Change the production for <em>stmts</em> to read:
61 <pre>
62 stmts -> stmt1 ... stmtn exp [;] (n>=0)
63 </pre>
64 <li> Add "<tt>;</tt>" to the end of each of the four productions for <em>stmt</em>.
65 </ul>
66 That is, every list of statements must end in an expression, optionally
67 followed by a semicolon.
68
69 <p><li> <strong>Page 40, Section 4.2.1, Algebraic Datatype Declarations.</strong>
70 In the bottom paragraph on the page, before "The context in the data declaration
71 has no other effect whatsoever" add the following:
72 <p>
73 "Pattern matching against <tt>ConsSet</tt> also gives rise to an <tt>Eq a</tt>
74 constraint. For example:
75 <pre>
76 f (ConsSet a s) = a
77 </pre>
78 the function <tt>f</tt> has inferred type <tt>Eq a => Set a -> a</tt>."
79
80 <p><li> <strong>Page 41, Section 4.2.1, subsection Labelled Fields.</strong>
81 At the end of the subsection, add a new paragraph:
82 <p>
83 "The pattern "<tt>F {}</tt>" matches any value built with constructor <tt>F</tt>,
84 <em>whether or not <tt>F</tt> was declared with record syntax</em>."
85
86 <p><li> <strong>Page 49, Section 4.3.4, Ambiguous Types...</strong>
87 In the third paragraph from the end of Section 4.3.4, replace "...an ambiguous
88 type variable is defaultable if at least one of its classes is a numeric class..."
89 by "...an ambiguous type variable, v, is defaultable if v appears only in constraints
90 of the form (C v), where C is a class, and if at least one of its classes is
91 a numeric class...".
92 <p>
93 The new phrase is "if v appears only in constraints of the
94 form (C v) where C is a class". Without this condition the rest of the
95 sentence does not make sense.
96
97 <p><li><strong>Page 54, first translation scheme.</strong>
98 The <em>xn</em> should be <em>xk</em> (suitably subscripted in both cases!),
99 and all three <em>m</em> subscripts should be <em>n</em>.
100
101 <p><li> <strong>Page 57, Section 4.5.3, Context reduction errors.</strong>
102 The example
103 <pre>
104 f :: (Monad m, Eq (m a)) => a -> m a -> Bool
105 f x y = x == return y
106 </pre>
107 is wrong; it should read
108 <pre>
109 f x y = return x == y
110 </pre>
111
112 <p><li> <strong>Page 66, Section 5.3, Import Declarations, numbered item 2.</strong>
113 Start a new paragraph before the sentence "The hiding clause only applies to unqualified
114 names...".
115
116 <p><li><strong>Page 67, Section 5.3.2, Local aliases</strong>.
117 The the last example in the section should read:
118 <pre>
119 import Foo as A(f)
120 </pre>
121
122 <p><li> <strong>Page 69, Section 5.5.2, Name clashes.</strong>
123 At the very end of the section, add the following clarification:
124 <p>
125 "The name occurring in a type signature or fixity declarations is always
126 unqualified, and unambiguously refers to another declaration in the
127 same declaration list (except that the fixity declaration for a class method
128 can occur at top level --- Section 4.4.2). For example, the following
129 module is legal:
130 <pre>
131 module F where
132 sin :: Float -> Float
133 sin x = (x::Float)
134
135 f x = Prelude.sin (F.sin x)
136 </pre>
137 The local declaration for <tt>sin</tt> is legal, even though
138 the <tt>Prelude</tt> function <tt>sin</tt> is implicitly in scope.
139 The references to
140 <tt>Prelude.sin</tt> and <tt>F.sin</tt> must both be qualified to make
141 it unambigous which <tt>sin</tt> is meant.
142 However, the unqualified name "<tt>sin</tt>" in the type
143 signature in the first line of <tt>F</tt> unambiguously refers to the
144 local declaration for <tt>sin</tt>."
145
146 <p><li> <strong>Page 71, Section 5.6.2, Shadowing Prelude Names.</strong>
147 Replace the example at the beginning of the section, and the entire
148 following paragraph, with the following
149 <pre>
150 module A( null, nonNull ) where
151 import Prelude hiding( null )
152 null, nonNull :: Int -> Bool
153 null x = x == 0
154 nonNull x = not (null x)
155 </pre>
156 Module <tt>A</tt> redefines <tt>null</tt>, and contains an unqualified reference
157 to <tt>null</tt> on the right hand side of <tt>nonNull</tt>.
158 The latter would be ambiguous without the "<tt>hiding(null)</tt>" on the
159 "<tt>import Prelude</tt>" statement.
160 Every module that imports <tt>A</tt> unqualified, and then makes an unqualified
161 reference to <tt>null</tt> must also resolve the ambiguous use of <tt>null</tt>
162 just as <tt>A</tt> does. Thus there is little danger of accidentally shadowing
163 Prelude names.
164
165
166 <p><li> <strong>Page 76, Section 6.3, Standard Haskell classes.</strong>
167 There is a formatting error in the example. The sentence beginning "This declaration gives default
168 method declarations..." should start on a new line.
169
170 <p><li><strong>Page 80, Section 6.3.6, Class Monad.</strong>
171 Right at the bottom of the page, after "However, for IO, the fail
172 method invokes error." add the clarifying sentence "To raise
173 a user exception in the IO monad, use <tt>ioError</tt> (see
174 Section 7.3)."
175
176 <p><li> <strong>Page 84, Section 6.4, Fig 7; and bottom of page 86, Section 6.4.6.</strong>
177 <pre>
178 fromRealFrac :: (RealFrac a, Fractional b) => a -> b
179 </pre>
180 should be replaced by
181 <pre>
182 realToFrac :: (Real a, Fractional b) => a -> b
183 </pre>
184
185 <p><li><strong>Page 90, Section 7.3, Exception handling in the IO monad.</strong>
186 After the first paragraph give the following type signature:
187 <pre>
188 userError :: String -> IOError
189 </pre>
190 Also add an index entry for <tt>userError</tt> on this page.
191 (These changes are purely presentational.)
192
193 <p><li><strong>Page 94, Appendix A, Standard Prelude, class <tt>Enum</tt>.</strong>
194 After the default method for <tt>enumFromTo</tt> add
195 <pre>
196 enumFromThen x y = map toEnum [fromEnum x, fromEnum y ..]
197 </pre>
198
199 <p><li><strong>Page 102, Appendix A, comments immediately before
200 <tt>instance Enum Float</tt>.</strong>
201 Replace "<tt>1.0</tt>" by "<tt>0.95</tt>".
202
203 <p><li><strong>Page 105, Appendix A.1, line 11.</strong>
204 In the module header for <tt>PreludeList</tt> replace "<tt>Sum</tt>" by "<tt>sum</tt>".
205
206 <p><li><strong>Page 106, definition of <tt>(!!)</tt>.</strong>
207 Replace the definition of <tt>(!!)</tt> with the following:
208 <pre>
209 -- List index (subscript) operator, 0-origin
210 (!!) :: [a] -> Int -> a
211 xs !! n | n < 0 = error "Prelude.!!: negative index"
212 [] !! _ = error "Prelude.!!: index too large"
213 (x:_) !! 0 = x
214 (_:xs) !! n = xs !! (n-1)
215 </pre>
216 (The original version had the property that <tt>([] !! -100)</tt>
217 reported "index too large".)
218
219 <p><li> <strong>Page 141, Bibliograpy</strong>.
220 The library report citation [8] is out of date. It should read:
221 "Simon Peyton Jones and John Hughes (editors), Standard Libraries for the
222 Haskell 98 Programming Language, 1 February 1999".
223
224 <p><li><strong>Page 147, Index</strong>. Remove the entry for "monad comprehension".
225 </ul>
226
227 <hr>
228 <h1>Errata in the
229 <a href="http://haskell.cs.yale.edu/definition/">Haskell 98 Library Report</a></h1>
230
231 <ul>
232 <p><li> <strong>Title page</strong>. Add the paragraph:
233 <p>
234 "Copyright (c) Simon Peyton Jones and John Hughes.
235 <p>
236 The authors intend this Report to belong to the entire Haskell
237 community, and so we grant permission to copy and
238 distribute it for any purpose, provided that it is
239 reproduced in its entireity, including this Notice. Modified
240 versions of this Report may also be copied and distributed for any purpose,
241 provided that the modified version is clearly presented as such,
242 and that it does not claim to be a definition of the Haskell 98 libraries."
243
244 <p><li> <strong>Page 17, Section 5, first text line</strong>. Replace "continuous" by "contiguous".
245
246 <p><li> <strong>Page 22, Section 6.3; and Page 23, Fig 3</strong>:
247 Replace "<tt>map</tt>" by "<tt>fmap</tt>" (two occurrences in 6.3, one in Fig 3).
248
249 <p><li> <strong>Page 29, Section 7.2</strong>. Add a new bullet for <tt>nub</tt>.
250 Add an index entry for <tt>nub</tt>.
251
252 <p><li> <strong>Page 29, Section 7.2, second bullet</strong>.
253 Introduce a new bullet just before "<tt>union</tt> is list union".
254
255 <p><li><strong>Page 54, Section 11</strong>.
256 The signature for <tt>try</tt> should be
257 <pre>
258 try :: IO a -> IO (Either IOError a)
259 </pre>
260
261 <p><li><strong>Page 62, Section 11.7.2</strong>.
262 <ul>
263 <li>Add a new section heading "<strong>11.7.4 Reading the entire input</strong>"
264 just before the paragraph about <tt>hGetContents</tt>.
265 <li>
266 Add a new section heading "<strong>11.7.5 Text output</strong>" before the
267 paragraph about <tt>hPutChar</tt>.
268 </ul>
269 <p><li><strong>Page 63, definition of <tt>main</tt> in Section 11.8.1</strong>.
270 Replace the definition of "<tt>readNum</tt>" with
271 <pre>
272 where readNum :: IO Integer
273 -- Need a type signature for readLn to avoid ambiguity
274 readNum = readLn
275 </pre>
276 (This change merely advertises the generally useful function <tt>readLn</tt>.)
277
278
279 <p><li><strong>Page 64, Section 12, Directory functions.</strong>
280 (More an editor's blunder than a typo.)
281 <ul>
282 <li>
283 Replace the abstract definition of <tt>Permissions</tt>, and the four instances
284 of <tt>Permissions</tt> with
285 <pre>
286 data Permissions
287 = Permissions {
288 readable, writable, executable, searchable :: Bool
289 }
290 deriving ( Eq, Ord, Read, Show )
291 </pre>
292 <li> Remove <tt>readable, writable, executable, searchable</tt> both from
293 the module header, and from the module body.
294 <li> Change <tt>Permissions</tt> to <tt>Permissions(readable, writable, executable, searchable)</tt>
295 in the module header.
296 </ul>
297
298 <p><li><strong>Page 81, Section 17.1, The <tt>RandomGen</tt> class</strong>.
299 Bottom line on page 81: replace "<tt>show/Read</tt> instances" with
300 "<tt>Show/Read</tt> instances" (i.e. capitalise <tt>Show</tt>).
301
302 <p><li><strong>Page 83, Section 17.3, The global random number generator</strong>.
303 In the first paragraph, replace "kernal" by "kernel".
304
305 </ul>
306 <hr>
307 <address>Simon Peyton Jones, simonpj@microsoft.com</address>
308 </body>
309 </html>
310