1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head><title>Haskell 98 (Revised Report): ERRATA</title></head>
<BODY>
<div align=center>
<img src="h98.gif" alt="Haskell 98">
</div>
<h2>Errata in the
<a href="http://haskell.org/definition/">Revised Haskell 98 Language Report (2003)</a></h2>
The list below gives all known errors in "Haskell 98 Language and
Libraries: the Revised Report", published by Cambridge University Press
as a book, and also in the Journal of Functional Programming 13(1)
(Jan 2003). All page references are to these texts, which may differ
slightly from the online versions.
<ul>
<li> [Dec 2005] <strong>Page 8, Section 2.2, Lexical Program Structure</strong>
The production for end-of-line <em>comment</em> appears to permit
the character sequence <tt>--:</tt> to introduce a comment, although
it should properly be permissible as a <em>varsym</em>.
The production can be fixed by changing it thus:
<p>
<em>comment</em> -> <em>dashes</em> [ <em>any</em><sub><<em>symbol</em> | : ></sub> {<em>any</em>} ] <em>newline</em>
<li> [July 2004] <strong>Page 32, Section 3.17.2, Informal Semantics of
Pattern-Matching, case #6.</strong>
Case 6 says: "Matching against a constructor using labeled fields is
the same as matching ordinary constructor patterns except that the
fields are matched in the order they are named in the field list. All
fields listed must be declared by the constructor; fields may not
be named more than once. Fields not named by the pattern are ignored
(matched against _)."
<p>
You could interpret 'field list' to mean the order the fields appear
in the pattern, OR, the order in which the fields were declared.
The choice of interpretation affects termination behaviour.
<p>
The intention of the Report writers was to use the field order of the
pattern, not the declaration. Thus, the Report can be clarified by
changing the end of the first sentence above to read "the order they
are named in the pattern field list".
<p><li> [Jan 2005] <strong>Page 32, Section 3.17.2, Informal Semantics of
Pattern-Matching, case #6.</strong>
Case 6 begins: "Matching against a constructor using labeled fields is
..." To some readers, this could appear to invert the sense of
matching, which in all other places is used consistently to mean
matching a pattern against a value, not a value against a pattern.
<p>The proposed fix is to change the start of the sentence to read:
"Matching a constructor pattern using labeled fields is ..."
<p><li> [Mar 2008] <strong>Page 32, Section 3.17.2, Informal Semantics of
Pattern-Matching, case #8.</strong>
Case 8 says: "Matching ... against a value <em>v</em> succeeds if
<em>x >= k</em>,
resulting in the binding of <em>n</em> to <em>x - k</em>, and fails otherwise."
The variable <em>x</em> should of course be <em>v</em>.
<p><li> [July 2004] <strong>Page 55, Section 4.4.2, Fixity
Declarations.</strong> The operator <tt>=<<</tt> defined
in the Prelude is missing from Table 4.1 - it has precedence 1,
right-associative. Also, in the HTML version (but not the printed
versions), Table 4.1 is numbered in its caption as Table 2, although
it continues to be referred to as Table 4.1 in the text.
<p><li> [May 2003] <strong>Page 86, Section 6.3.4, The Enum Class.</strong>
Section 6.3.4 states: "For all four of these Prelude numeric types,
all of the <tt>enumFrom</tt> family of functions are strict in all
their arguments".
<p>
Alas, this contradicts the code for the Prelude in Chapter 8 for
<tt>Float</tt> and <tt>Double</tt>. In particular, the instances for
<tt>enumFrom</tt> and <tt>enumFromThen</tt> for <tt>Float</tt> and
<tt>Double</tt> are defined in terms of <tt>numericEnumFrom</tt>,
<tt>numericEnumFromThen</tt>, which are not strict (see p113).
They both deliver an infinite list even if their argument is undefined.
<p>
The fix is presumably to add a <tt>seq</tt> to the instances for
<tt>Float</tt> and <tt>Double</tt>.
<p><li> [June 2003] <strong>Page 93, Section 6.4.6, Coercions
and Component Extraction.</strong> The specification for
<tt>properFraction</tt> does not deal properly with the case where
<em>x</em> is zero. Here is a suggested rewording:
<p>
"The function <tt>properFraction</tt> takes a real fractional number
x and returns a pair <em>(n,f)</em> such that <em>x = n+f</em>, and:
<em>n</em> is an integral number; <em>f</em> is a fraction with the
same type as <em>x</em> and with absolute value less than 1; either
<em>n</em> is zero or <em>n</em> has the same sign as <em>x</em>;
and either <em>f</em> is zero or <em>f</em> has the same sign as
<em>x</em>."
<p><li> [Feb 2008] <strong>Page 98, Chapter 7.2, Sequencing I/O
Operations.</strong> The example using explicit <em>do</em> notation
gives unexpected interactive behaviour, due to buffering issues. Either
replace uses of <tt>putStr</tt> with <tt>putStrLn</tt>, or insert a
first line <tt>IO.hSetBuffering IO.stdout IO.NoBuffering</tt>.
<p><li> [Feb 2003] <strong>Page 123, Section 8.2, PreludeText.</strong>
In the definition of <tt>lex</tt> make the following changes:
<ul>
<li> Replace <tt>isAlpha</tt> in the third guard by <tt>isIdInit</tt>.
<li> In the definition of <tt>isSingle</tt>, remove the underscore
'_' from the quoted list.
<li> Add the following local definition:
<pre>
isIdInit c = isAlpha c || c == '_'
</pre>
</ul>
[These changes reflect the fact that an identifier can start with
an underscore.]
<p><li> [Sept 2004] <strong>Page 136, Chapter 9.5, Context-Free
Syntax.</strong> The third production for <em>export</em> does
not match the production and explanation given earlier in Section 5.2.
Replace the <em>qvar</em> in parentheses after <em>qtycls</em> with
<em>var</em>.
<p><li> [Aug 2005] <strong>Page 152, Chapter 12, Rational
Numbers.</strong> The function <tt>approxRational</tt> actually
returns the simplest rational number within the given <em>closed</em>
interval, not the open interval.
<p><li> [March 2003] <strong>Page 170, Chapter 15, Indexing
operations.</strong> Replace the (bogus) law
<pre>
map index (range (l,u)) = [0..rangeSize (l,u)]
</pre>
by
<pre>
map (index (l,u)) (range (l,u)) = [0 .. rangeSize (l,u) - 1]
</pre>
<p><li> [September 2008] <strong>Page 187-188, Chapter 17, List
utilities.</strong> The "<code>generic</code>" functions should behave
the same way as the <tt>Prelude</tt> functions for negative
arguments. The ones listed in the report call <tt>error</tt>,
while the <tt>Prelude</tt> versions simply treat negative numbers
as 0. The implementations are replaced by:
<pre>
genericTake :: (Integral a) => a -> [b] -> [b]
genericTake n _ | n <= 0 = []
genericTake _ [] = []
genericTake n (x:xs) = x : genericTake (n-1) xs
genericDrop :: (Integral a) => a -> [b] -> [b]
genericDrop n xs | n <= 0 = xs
genericDrop _ [] = []
genericDrop n (_:xs) = genericDrop (n-1) xs
genericSplitAt :: (Integral a) => a -> [b] -> ([b],[b])
genericSplitAt n xs | n <= 0 = ([],xs)
genericSplitAt _ [] = ([],[])
genericSplitAt n (x:xs) = (x:xs',xs'') where
(xs',xs'') = genericSplitAt (n-1) xs
</pre>
<p><li> [March 2003] <strong>Page 194, line -9, Chapter 19, Character
utilities.</strong> Replace "converts the to the character it
encodes" by "converts the string to the character it encodes".
<p><li> [Nov 2006] <strong>Page 215, Chapter 21.3.2, Closing
Files.</strong> In "doing so not an error", insert the verb "is":
"doing so is not an error".
<p><li> [July 2003] <strong>Index to the online version (only).</strong>
<ul>
<li>The type for <tt>either</tt> is missing.
<li>
The type for <tt>print</tt> should be
<pre>
print :: Show a => a -> IO ()
</pre>
<li>[Oct 2006] The example usage of <tt>break</tt> is wrong. A correct
example might be
<pre>
break (>2) [1,2,3] == ([1,2],[3])
</pre>
</ul>
<p><li> [June 2005] <strong>Index to the printed version (only).</strong>
<ul>
<li>There is no entry for <em>keywords</em> of the language, which should
cross-refer to <em>reservedid</em>.
<li>There is no index entry for the <tt>where</tt> keyword.
Relevant page numbers are 10, 13, 56, and 58.
</ul>
</ul>
<hr>
<address><strong>maintainer:</strong> Malcolm Wallace,
<a href="mailto:Malcolm.Wallace@cs.york.ac.uk">
Malcolm.Wallace@cs.york.ac.uk</a></address>
</body>
</html>
|