/usr/share/doc/haskell98-report/html/haskell98-bugs.html is in haskell98-report 20080907-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 | <html>
<head>
</head>
<HEAD>
<TITLE>Haskell 98: ERRATA</title></head>
</head>
</head>
</head>
</head>
</HEAD>
<BODY>
<div align=center>
<img src="h98.gif" alt="Haskell 98">
</div>
<center>
<hr>
<font size=+2>
No further changes should be made in this Errata.
<p>
Future changes are in <a href="haskell98-revised-bugs.html">The Revised Report bug list</a>.
</font>
<hr>
</center>
<h1>Errata in the
<a href="http://haskell.cs.yale.edu/definition/">Haskell 98 Language Report</a></h1>
All references are to the original Haskell 98 Report, dated 1 Feburary 1999.
<ul>
<p><li> <strong>Title page</strong>. Remove "[editor]" from after John Hughes.
<p><li> <strong>Title page</strong>. Add the paragraph:
<p>
"Copyright (c) Simon Peyton Jones.
<p>
The authors intend this Report to belong to the entire Haskell
community, and so we grant permission to copy and
distribute it for any purpose, provided that it is
reproduced in its entireity, including this Notice. Modified
versions of this Report may also be copied and distributed for any purpose,
provided that the modified version is clearly presented as such,
and that it does not claim to be a definition of the language Haskell 98."
<p><li> [Aug 2001] <strong>Page 2, The Haskell Kernel.</strong>
Replace the entire section with the following:
<p>
"Haskell has adopted many of the convenient syntactic structures
that have become popular
in functional programming. In this Report, the meaning of such
syntactic sugar is given by translation into simpler constructs.
If these translations are applied exhaustively, the result is a program
written in a small subset of Haskell that we call the Haskell <em>kernel</em>."
<p>
"Although the kernel is not formally specified, it is essentially a
slightly sugared variant of the lambda calculus with a straightforward
denotational semantics. The translation of each syntactic structure
into the kernel is given as the syntax is introduced. This modular
design facilitates reasoning about Haskell programs and provides
useful guidelines for implementors of the language."
<p>
(The intent here is to avoid the common misconception that the kernel
is a formally specified thing.)
<p><li> [Sept 2001] <strong>Page 2, Section 1.4, Namespaces; and
Page 7, Section 2.4, Identifiers and operators; and
Page 15, Section 3.2, Variables, Constructors, Operators, and Literals.</strong>
Remove the first paragraph (about operators), which does not really belong
here, and item 2 of the list (which is related).
Instead, amplify the remarks in Section 2.4 and 3.2. This is a presentational
change only.
<p><li> [Sept 2002] <strong>Page 4, Section 2.1, Notational conventions.</strong>
Remove the second-last paragraph altogether, which begins "Haskell uses a pre-processor...".
(No implementation does this, and the reference to escapes in identifiers is inconsistent
with the lexical syntax.)
<p><li> [Late Dec 2001] <strong>Page 5, Section 2.2, Lexical program structure; and Appendix B.2, p120.</strong>
Replace the production for "comment" with:
<pre>
comment -> dashes [ any_<symbol> { any } \] newline
</pre>
(This ensures that "--+", for example, does not start a comment.)
<p><li> [Dec 2001] <strong>Page 5, Section 2.2, Lexical program structure; and Appendix B.2, p120.</strong>
<ul>
<li> Change the production for <em>lexeme</em> to
<pre>
lexeme -> qvarid | qconid | qvarsym | qconsym | literal | special | reservedop | reservedid
</pre>
<p> <li> [March 02] Change the productions for <em>whitechar</em> and <em>newline</em> to:
<pre>
whitechar -> newline | vertab | space | tab | uniWhite
newline -> return linefeed | return | linefeed | formfeed
</pre>
(This means that CR, LF, or CRLF (remember maximal munch), are all valid 'newline' separators,
and the same sequence of characters should therefore work on any
Haskell implementation.)
<p> <li> [March 02] Change the production for <em>ANY</em> to
<pre>
ANY -> graphic | whitechar
</pre>
(This is nicely similar to the production for "any".)
<p> <li> Change the production for <em>uniDigit</em> to
<pre>
uniDigit -> any Unicode decimal digit
</pre>
<p> <li> Change the production for <em>symbol</em> to:
<pre>
symbol -> ascSymbol | uniSymbol< special | _ | : | " | ' >
</pre>
<p> <li> Add <em>return</em>, <em>linefeed</em>, and <em>uniWhite</em> to the production for <em>ANY</em>.
</ul>
(These changes, and the next one, justify the productions for <em>program</em> which claims that a program is
a sequence of lexemes and white space.)
<p><li> [Feb 2002] <strong>Page 6, Section 2.2, Lexical program structure.</strong>
In the first paragraph, delete the phrase ", using a context-independent
deterministic lexical analysis (i.e.~no lookahead beyond the current character is
required)".
<p>
(The maximal munch rule is correct, but it's not true that it only takes one character
of lookahead. Consider
"F. 9. 0o 0x 9.0e+f", which
should lex as "F . 9 . 0 o 0 x 9.0 e + f" but that needs up to two additional characters
of lookahead.)
<p><li> <strong>Page 7, Section 2.4, Identifiers and operators; and Appendix B.2, p121.</strong>
Add <em>dashes</em> to <em>reservedop</em> in the exclusion set of the
production for <em>varsym</em>. (This ensures that "<tt>--</tt>" and
"<tt>---</tt>" are not legal lexemes.
<p><li> [Nov 2001] <strong>Page 7, Section 2.4, Identifiers and operators; and Appendix B.2, p121.</strong>
<ul>
<li> Remove the productions for <em>specialid</em> and <em>specialop</em>
<li> Delete the paragraph about specialid and specialop near the bottom of page 7
("A few identifiers and operators..").
</ul>
<p><li> [Nov 2001] <strong>Page 8, Section 2.5, Numeric literals; and Appendix B.2, p121.</strong>
Replace the production for "float" with:
<pre>
float -> decimal . decimal [exponent]
| decimal exponent
exponent -> (e | E) [+ | -] decimal
</pre>
(This change means that 20e3 is a floating-point literal. There is a corresponding change
to the lexer on p114.)
<p><li> <strong>Page 9, Section 2.4, Identifiers and operators; and Page 68, Section 5.5.1, Qualified names.</strong>
Move the first paragraph of 5.5.1, and the following table, and the paragraph starting "The qualifier does not change...",
to the end of Section 2.4. (These paragraphs deal with lexical matters, which do not belong in Chapter 5.)
<p><li> <strong>Page 9, Section 2.6, Character and String Literals.</strong>
In the production for "cntrl" replace "ASClarge" by "ascLarge".
<p><li> [Nov 2001] <strong>Page 9, Section 2.6, Characters and String Literals; and
Page 73, Section 6.1.2, Characters and strings</strong>
<ul>
<li> In Section 2.6, delete the last sentence of the third paragraph "Numeric escapes
that are out of range...".
<p>
<li> In Section 6.1.2, replace the first sentence of the section by
<p>
"The character type <tt>Char</tt>
is an enumeration whose values represent Unicode characters [10]." Similarly,
remove the final clause "...in the range [0..2^16 - 1]".
</ul>
<p>
(This change removes the commitment to 16-bit Unicode. The result is that the Report
is even vaguer than before about the range of Unicode that a compiler is obliged to
accept, but this confusion is in large part Unicode's fault, and is not readily fixed
in a revision of this nature.)
<p><li> <strong>Page 10, Section 2.7, Layout.</strong>
In the middle of the third paragraph, just before the sentence beginning
"A close brace is also inserted...", add the following sentence:
<p>
"If the indentation of the non-brace lexeme immediately
following a <tt>where</tt>, <tt>let</tt>,
<tt>do</tt> or <tt>of</tt> is less than or equal to the <em>current</em> indentation level,
then instead of starting a layout, an empty list "<tt>{}</tt>" is inserted, and
layout processing occurs for the current level (i.e. insert a semicolon or close brace)."
<p><li> <strong>Page 11, Figures 1 and 2</strong>. In both figures the signature for <tt>size</tt>
should be
<pre>
size :: Stack a -> Int
</pre>
<p><li> [July 2001] <strong>Page 12, Section 3, Expressions.</strong>
Replace the last two sentences of the first paragrah of the section by:
<p>
"Free variables and constructors used in these translations always
refer to entities defined by the <tt>Prelude</tt>. For example,
``<tt>concatMap</tt>'' used in the translation of list comprehensions
(Section 3.11) means the <tt>concatMap</tt> defined by the
<tt>Prelude</tt>, regardless of what is in scope where the list
comprehension is used."
<p>
(Clarification only.)
<p><li> [May 2002] <strong>Page 12, Section 3, Expressions; also Page 17, Section 3.5;
also Page 128, Appendix B, Syntax.</strong>
Add the following two extra productions for <em>aexp</em>:
<pre>
| '(' lexp(i) qop(l,i) ')' left section
| '(' qop(r,i)<sub><<tt>-</tt>></sub> rexp(i) ')' right section
</pre>
and change the othe right-section production to:
<pre>
| '(' qop(a,i)<sub><<tt>-</tt>></sub> exp(i+1) ')' right section
</pre>
(This brings the formal syntax into line with the
words in Section 3.5. The grammar now follows the way that qfunlhs is defined.
There is no ambiguity, because an exp(i+1) is not an lexp(i).)
<p>
The exclusion of "<tt>-</tt>" from right sections is also new [May 2002]; it is necessary
to prevent overlap with the unary-minus syntax.
<p><li> [Aug 2001] <strong>Page 13, Section 3, Expressions.</strong>
Remove Table 1, and the associated paragraph beginning "As an aid to
understanding...". (The table causes more confusion than it clears up.)
<p><li> [March 2002] <strong>Page 14, Section 3, Expressions.</strong>
After the sample parses, add the following paragraphs:
<p>
<em>A note about parsing.</em> Expressions that involve the interaction
of fixities with the let/lambda meta-rule
may be hard to parse. For example, the expression
<pre>
let x = True in x == x == True
</pre>
cannot possibly mean
<pre>
let x = True in (x == x == True)
</pre>
because <tt>(==)</tt> is a non-associative operator; so the expression must parse thus:
<pre>
(let x = True in (x == x)) == True
</pre>
However, implementations may well use a post-parsing pass to deal with fixities,
so they may well incorrectly deliver the former parse. Programmers are advised
to avoid constructs whose parsing involves an interaction of (lack of) associativity
with the let/lambda meta-rule.
<p><li> [Nov 2001] <strong>Page 13, Section 3 Expressions.</strong>
Replace the curly braces by angle brackets, in the subscript of "aexp" in the last production of "aexp".
Similarly, on Page 26, Section 3.15.3; and Page 128, Appendix B.4.
<p><li> [Apr 2001] <strong>Page 14, Section 3.1, Errors.</strong> In the first sentence of
the section, after "indistinguishable" add "by a Haskell program".
<p><li> [Apr 2001] <strong>Page 15, Section 3.2, Variables, Constructors, Operators, and Literals.</strong>
Remove the paragraph starting "Qualified names may only ...", and the following example, and the
concluding paragraph starting "incorrectly uses a qualifier". (This is all covered in 2.4 and 5.5.1.)
<p><li> [May 2002] <strong>Page 17, Section 3.5, Sections.</strong>
Append the following to the paragraph beginning "Syntactic precedence rules apply to sections as follows."
<p>
"As another example, the expression
<pre>
(let x = 10 in x +)
</pre>
is invalid because, by the let/lambda meta-rule (Section 3)
the expression
<pre>
(let n = 10 in n + x)
</pre>
parses as
<pre>
(let n = 10 in (n + x))
</pre>
rather than
<pre>
((let n = 10 in n) + x)
</pre>
"
<p><li> [Oct 2001] <strong>Page 18, Section 3.7, Lists.</strong>
After the sentence starting "The constructor ":" is reserved solely for list construction...",
add the new sentence:
<p>
"It is a right-associative operator, with precedence level 5 (Section 4.4.2)."
<p>
(Otherwise this information is found only in the Prelude.)
<p><li> [July 2001] <strong>Page 20, Section 3.10, Arithmetic sequences.</strong>
In the second paragraph, in the sentence "For the type <tt>Integer</tt>,
arithmetic sequences have the following meaning...", replace "type <tt>Integer</tt>"
with "types <tt>Int</tt> and <tt>Integer</tt>". Remove <tt>Integer</tt> from the
list in the paragraph following the bulletted list.
<p><li> [Apr 2001] <strong>Page 21, Section 3.11, List Comprehensions; and Page 128.</strong>
<ul> <li> In the production for "aexp", change the "n >= 0" to "n >= 1".
<li> Remove the production for (empty qualifier)
<li> In the translation box lower down the page, rewrite the translation so
that it does not involve and empty list of qualifiers. (Unchanged semantics.)
</ul>
This change ensures that there is at least one qualifier in list comprehension,
and no qualifier is empty. The translation lower down page 23 is then
not utterly rigorous, because Q can be empty, and when it is there is no preceding
comma, but I reckon it would make matters worse to "fix" it.
<p><li> [March 2002] <strong>Page 22, Section 3.13, Case Expressions</strong>.
To the end of the section, add the following paragraphs:
<p>
<em>A note about parsing</em>. The (type-incorrect) expression
<pre>
case x of { (a,_) | let b = not a in b :: Bool -> a }
</pre>
is tricky to parse correctly. It has a single unambiguous parse, namely
<pre>
case x of { (a,b) | (let b = not a in b :: Bool) -> a }
</pre>
However, the phrase <tt>Bool -> a</tt> is syntactically valid as a type, and
parsers with limited lookahead may incorrectly commit to this choice, and hence
reject the program. Programmers are advised, therefore, to avoid guards that
end with a type signature --- indeed that is why a "gd" contains
an "exp^0" not an "exp".
<p><li> [Apr 2001] <strong>Page 23, Section 3.14, Do Expressions;
and Page 128, Appendix B.4, Context Free Syntax.</strong>
<ul>
<li>
Change the production for <em>stmts</em> to read:
<pre>
stmts -> stmt1 ... stmtn exp [;] (n>=0)
</pre>
<li> Add "<tt>;</tt>" to the end of each of the four productions for <em>stmt</em>.
</ul>
That is, every list of statements must end in an expression, optionally
followed by a semicolon.
<p><li> [Aug 2001] <strong>Page 24, Section 3.15, Datatypes with Field Labels.</strong>.
Add an example to illustrate the final point in para 2.
<p><li> [Feb 2002] <strong>Page 25, Section 3.15.2, Construction Using Field Labels</strong>.
At the end of the section add the sentence:
<p>
The expression <tt>F {}</tt>, where <tt>F</tt> is a data constructor, is legal
<I>whether or not </I><tt>F</tt><I> was declared with record syntax</I>, provided
<tt>F</tt> has no strict fields; it denotes
<tt>F</tt><I> _|_</I><sub><I>1</I></sub><I> ... _|_</I><sub><I>n</I></sub>,
where <I>n</I> is the arity of <tt>F</tt>.
<p>
(This matches the dual for pattern matching, in Section 4.2.1.)
<p><li> [Aug 2001] <strong>Page 26, Section 3.15.3, Updates Using Field Labels</strong>.
In the translation box:
<ul>
<li> replace the first un-subscripted "C" by "C1", and the second by "Cj".
(The "1" and "j" should be subscripts of course!)
<li> Change "b" to "bs" in the "where..." part.
</ul>
<p><li> [Aug 2001] <strong>Page 28, Section 3.17.1, Patterns.</strong>.
Give an example to illustrate an illegal non-linear pattern.
<p><li> [Jan 2002] <strong>Page 29, Section 3.17.2, Informal Semantics of Case Expressions.</strong>
Reword the entire numbered list giving the informal semantics, so that:
<ul>
<li> It is clearly classified by pattern.
<li> The semantics of matching a newtype pattern against bottom is given.
<li> A literal and n+k pattern may not diverge even if the value matched is bottom; it
depends on the definition of <tt>==</tt> and <tt>>=</tt> respectively.
</ul>
<p><li> [Aug 2001] <strong>Page 31, Section 3.17.2, Informal Semantics of Case Expressions.</strong>
Replace the example at the foot of Page 31, following the paragraph "The guard semantics...",
with the following:
<pre>
f :: (Int,Int,Int) -> [Int] -> Int
f ~(x,y,z) [a] | (a == y) = 1
</pre>
(The previous example use boolean and, which is non-strict in its second argument!)
<p><li> [Apr 2001] <strong>Page 31,33, Figures 3 and 4, Semantics of Case Expressions.</strong>
Replace "completely new variable" by "new variable" in these two figures. (Some clauses
said "new" and some "completely new" which is misleadingly inconsistent.)
<p><li> [Apr 2001] <strong>Page 33, Figure 4, Semantics of Case Expressions Part 2.</strong>
In clause (r) replace "e0" by "v" throughout.
<p><li> [Jan 2002] <strong>Page 33, Figure 4, Semantics of Case Expressions Part 2.</strong>
<ul>
<li> Insert new clause (r):
<pre>
case _|_ of { K x1 ... xn -> e; _ -> e' } = _|_
where K is a data constructor of arity n
</pre>
<li> Rename old clause (r) as clause (s).
<li> Use lambda instead of let in the new clause (s), so as to avoid the suggestion
of polymorphism (just as in other clauses).
<li> In the accompanying text, final paragaph, add clause (s) to the list of
clauses that use lambda to avoid suggesting polymorphism.
</ul>
<p><li> [May 2002] <strong>Page 34, Section 4, Declarations and Bindings;
and Page 44, Section 4.3.1, Class Declarations.</strong>
In the production for <tt>class</tt>, replace
<pre>
class [scontext =>] simpleclass [where decls]
</pre>
by
<pre>
class [scontext =>] tycls tyvar [where decls]
</pre>
<p><li> [Sept 2001] <strong>Page 36, Section 4.1.2, Syntax of Types.</strong>
First paragraph, last sentence. After "infix type constructors are not allowed",
add "(other than <tt>(->)</tt>)".
<p><li> [Oct 2001] <strong>Page 38, Section 4.1.2, Algebraic Datatype Declarations.</strong>
Replace the sentence
"Although the tuple, list, and function types have special syntax, they
are not different from user-defined types with equivalent
functionality."
with
<p>
"These special syntactic forms always denote the built-in type constructors
for functions, tuples, and lists, regardless of what is in scope.
In a similar way, the prefix type constructors <tt>(->),</tt>, <tt>[]</tt>, <tt>()</tt>, <tt>(,)</tt>,
and so on, always denote the built-in type constructors; they
cannot be qualified, nor mentioned in import or export lists (Section 5).
(Hence the special production, <em>gtycon</em>, above.)
<p>
"Although the tuple and list types have special syntax, their semantics
is the same as the equivalent user-defined algebraic data types."
<p>
(This stuff is clarification only.)
<p><li> <strong>Page 40, Section 4.2.1, Algebraic Datatype Declarations.</strong>
In the bottom paragraph on the page, before "The context in the data declaration
has no other effect whatsoever" add the following:
<p>
"Pattern matching against <tt>ConsSet</tt> also gives rise to an <tt>Eq a</tt>
constraint. For example:
<pre>
f (ConsSet a s) = a
</pre>
the function <tt>f</tt> has inferred type <tt>Eq a => Set a -> a</tt>."
<p><li> <strong>Page 41, Section 4.2.1, subsection Labelled Fields.</strong>
At the end of the subsection, add a new paragraph:
<p>
"The pattern "<tt>F {}</tt>" matches any value built with constructor <tt>F</tt>,
<em>whether or not <tt>F</tt> was declared with record syntax</em>."
<p><li> [Nov 2001] <strong>Page 41, Section 4.2.1, subsection Strictness Flags.</strong>
Add the following sentence at the end of the pargraph:
<p>
"Lexically, "<tt>!</tt>" is an ordinary varsym not a reservedop;
it has special significance only in the context of the argument types of
a data declaration."
<p><li> [Apr 2001] <strong>Page 42, Section 4.2.1, subsection Labelled Fields.</strong>
Change "occurance" to "occurrence" in the translation box at the very end of
the section.
<p><li> [Late Dec 2001] <strong>Page 46, Section 4.3.2, Instance Declarations.</strong>
<ul>
<li> Remove the production for "qfunlhs".
<li> Replace the first production for "idecl" by:
<pre>
idecl -> (funlhs | var) rhs
</pre>
(i.e. omitting the alternatives for "qvar" and "qfunlhs").
<li> In the third paragraph from the bottom, delete the text starting "However, unlike
other declarations, the name of the bound variable may be qualified..." and ending at
"Hence the need for the qfunlhs and qvar left hand sides for an idecl.".
<li> In place of the deleted sentences, add the following:
<p>
"It is illegal to give a
binding for a class method that is not in scope, but the name under
which it is in scope is immaterial; in particular, it may be a qualified
name. (This rule is identical to that used for subordinate names in
export lists --- Section 5.2.)
For example, this is legal, even though <tt>return</tt> is in scope only
with the qualified name <tt>Monad.return</tt>.
<pre>
module A where
import qualified Monad
instance Monad.Monad T where
return = ...
(>>=) = ...
</pre>
"
<li> Make the same syntactic changes to the syntax in Appendix B.4.
</ul>
(This signficant change removes a wart from the language. Instead of requiring a qualified
name on the LHS of an instance declaration if the method name is in scope in more than
one way, the context is now used to disambiguate. This is compatible with the story
for type signatures, Section 4.4.1.)
<p><li> [Late Dec 2001] <strong>Page 49, Section 4.3.4, Ambiguous Types...</strong> In the third paragraph
from the end of 4.3.4, replace "monotype" by "type".
<p><li> <strong>Page 49, Section 4.3.4, Ambiguous Types...</strong>
In the third paragraph from the end of Section 4.3.4, replace "...an ambiguous
type variable is defaultable if at least one of its classes is a numeric class..."
by "...an ambiguous type variable, v, is defaultable if v appears only in constraints
of the form (C v), where C is a class, and if at least one of its classes is
a numeric class...".
<p>
The new phrase is "if v appears only in constraints of the
form (C v) where C is a class". Without this condition the rest of the
sentence does not make sense.
<p><li> [Aug 2001] <strong>Page 51, Section 4.4.2, Fixity Declarations.</strong>
<ul>
<li> In the prodution for <em>gendecl</em> change <em>digit</em> to <em>integer</em>.
<li> Make the same change in the syntax at the start of Section 4 and in Appendix B.
<li> After "A fixity declaration gives the fixity and binding
precedence of one or more operators." add the sentence "The <em>integer</em> in a fixity declaration
must be in the range 0 to 9."
</ul>
(Previously, "digit" was used, and it isn't a lexeme.)
<p><li> [Apr 2001] <strong>Page 53, Section 4.4.3.</strong> Replace "For example, these two function
definitions are equivalent:", and the two lines of code that follow by:
<br>
"For example, these three function definitions are all equivalent:
<pre>
plus x y z = x+y+z
x `plus` y = \ z -> x+y+z
(x `plus` y) z = x+y+z
</pre>"
(This change makes explicit that an infix operator with more than two arguments
can have all of them on the LHS.)
<p><li> [Apr 2001] <strong>Page 54, Section 4.4.3, subsection Function Bindings.</strong>
In the first translation scheme ("The general binding form for functions..."),
the <em>xn</em> should be <em>xk</em> (suitably subscripted in both cases!),
and all three <em>m</em> subscripts should be <em>n</em>.
<p><li> <strong>Page 57, Section 4.5.3, Context reduction errors.</strong>
The example
<pre>
f :: (Monad m, Eq (m a)) => a -> m a -> Bool
f x y = x == return y
</pre>
is wrong; it should read
<pre>
f x y = return x == y
</pre>
<p><li> [Sept 2001] <strong>Page 58, Section 4.5.5, Momomorphism.</strong>
In the boxed text entitled "The monomorphism restriction", replace
"The usual Hindley-Milner restriction on polymorphism is that only
type variables free in the environment may be generalized" by
<p>
"The usual Hindley-Milner restriction on polymorphism is that only
type variables that do not occur free in the environment may be generalized."
<p>
(The sense was backward before.)
<p><li> [May 2001] <strong>Page 62, Section 5, Modules.</strong>
In paragraph 4, add a footnote to the sentence "A multi-module Haskell
program can be converted into a single-module program by ...", namely:
<p>
"There are two minor exceptions to this statement.
First, <tt>default</tt> declarations scope over a single module (Section 4.3.4).
Second, Rule 2 of the monomorphism restriction (Section 4.5.5)
is affected by module boundaries."
<p>
This footnote qualifies the otherwise over-strong statement.
<p><li> [Late Dec 2001] <strong>Page 63,64, Section 5.2, Export lists</strong>.
<ul>
<li> In the production for "export", replace "qcname" by "cname" (and similarly in Appendix B.4).
<li> In the production for "qcname", replace "qcname" by "cname", "qvar" by "var", and "qcon" by "con".
In Appendix B.4 delete the production for "qcname".
<li> In the second bulleted item under point (2) of the numbered items, replace "qcname" by "c", throughout.
<li> In point (2) of the numbered items, add the following:
<p>
"In all cases, the (possibly-qualified) type constructor T must be in scope.
The constructor and field names c_i in the second form are unqualified;
one of these subordinate names is legal if and only if (a) it names a constructor
or field of T, and (b) the constructor or field
is in scope in the module body <em>regardless of whether it is in scope
under a qualified or unqualified name</em>. For example, the following is
legal
<pre>
module A( Mb.Maybe( Nothing, Just ) ) where
import qualified Maybe as Mb
</pre>
"
<li> Make a similar change to point (4).
<li> In points (1)-(4), make it clear that the variable, type constructor, or class must be in scope.
</ul>
(These changes clarify the scope rules for export lists. Much email discussion during Dec 2001.)
<p>
<li> [March 02] In point (2) delete the sentence "The qcnamei must not conatin duplications.".
Make a similar change in point (4).
<p><li> [Oct 2001, modified Nov 2002] <strong>Page 64, Section 5.2, Export declarations, numbered items 5 and 6.</strong>
Replace both items with the following:
<p>
The form "<tt>module M</tt>" names the set of all entities that are in
scope with both an unqualified name "<tt>e</tt>" and a qualified name
"<tt>M.e</tt>".
This set
may be empty.
For example:
<pre>
module Queue( module Stack, enqueue, dequeue ) where
import Stack
...
</pre>
"Here the module <tt>Queue</tt> uses the module name <tt>Stack</tt> in its export
list to abbreviate all the entities imported from <tt>Stack</tt>.
<P>
"A module can name its own local definitions in its export
list using its own name in the `<tt>module M</tt>'' syntax, because a local
declaration brings into scope both a qualified and unqualified name.
For example:
<pre>
module Mod1( module Mod1, module Mod2 ) where
import Mod2
import Mod3
</pre>
"Here module <tt>Mod1</tt> exports all local definitions as well as those
imported from <tt>Mod2</tt> but not those imported from <tt>Mod3</tt>."
It is an error to use <tt>module M</tt> in an export list unless <tt>M</tt> is
the module bearing the export list, or <tt>M</tt> is imported by at
least one import declaration (qualified or unqualified).
<p><li> [July 2001] <strong>Page 65, Section 5.2, Export declarations.</strong>
Replace the two paragraphs and code fragment that the numbered list with the following:
<p>
"It makes no difference to an importing module how an entity was
exported. For example, a field name <tt>f</tt> from data type <tt>T</tt> may be exported individually
(<tt>f</tt>, item (1) above); or as an explicitly-named member of its data type (<tt>T(f)</tt>, item (2));
or as an implicitly-named member (<tt>T(..)</tt> item(2)); or by exporting an entire
module (<tt>module M</tt>, item (5)).
<p>
Exports lists are cumulative: the set of entities exported by an export
list is the union of the entities exported by the individual items of the list.
<p>
The <em>unqualified</em> names of the entities exported by a module must all be distinct
(within their respective namespace). For example
<pre>
module A ( C.f, C.g, g, module B ) where -- an invalid module
import B(f)
import qualified C(f,g)
g = f True
</pre>
There are name clashes in the export list
between <tt>C.g</tt> and <tt>g</tt>,
and between <tt>module B</tt> and <tt>C.f</tt> (assuming <tt>B.f</tt> and <tt>C.f</tt> are different entities),
even though there are no name clashes within module <tt>A</tt> itself.
<p><li> [Feb 2002] <strong>Page 65, Section 5.3, Import Declarations, syntax; also page 125, Appendix B.4.</strong>
In the second production for "import", namely "tycon [ [(..)] | (cname1, ..., cnamen)]"
replace "n>=1" by "n>=0". (There is no need to require one or more constructors, and
in <tt>hiding</tt> clauses it may be useful to hide the type constructor only.)
<p><li> [Nov 2001] <strong>Page 65, Section 5.3, Import Declarations, last line.</strong>
Before "Exactly which entities are to be imported..." add a new paragraph:
<p>
"Lexically speaking, the terminal symbols "<tt>as</tt>", "<tt>qualified</tt>" and
"<tt>hiding</tt>" are each a "varid" rather than a "reservedid". They have
special significance only in the context of an <tt>import</tt> declaration;
they may also be used as variables."
<p><li> [July 2001] <strong>Page 65, Section 5.3, Import Declarations, last line.</strong>
Start a new subsection "5.3.1 What is imported" before "Exactly which entities are to
be imported...".
<p><li> [July 2001] <strong>Page 66, Section 5.3, Import Declarations, numbered item 2.</strong>
Delete the two sentences "The hiding clause only applies to unqualified
names... A hiding clause has no effect....".
<p><li> [Oct 2001] <strong>Page 66, Section 5.3, Import Declarations, numbered item 2.</strong>
Add "It is an error to hide an entity that is not, in fact, exported by
the imported module."
<p><li> [July 2001] <strong>Page 66, Section 5.3.1, Qualified Import.</strong> [This section
becomes 5.3.2.] Replace the first sentence with:
"For each entity imported under the rules of Section 5.3.1
the top-level environment is extended. If the import declaration used
the <tt>qualified</tt> keyword, only the qualified name of the entity is
brought into scope. If the <tt>qualified</tt> keyword is omitted, then both the
qualified and unqualified name of the entity is brought into scope.
Section 5.5.1 describes qualified names in more detail."
<p><li><strong>Page 67, Section 5.3.2, Local aliases</strong>.
The last example in the section should read:
<pre>
import Foo as A(f)
</pre>
<p><li> [Aug 2001] <strong>Page 68, Section 5.5.1, Qualified names.</strong>
Replace the second example in the first bullet by:
<pre>
module M where
M.f x = ... -- ILLEGAL
g x = let M.y = x+1 in ... -- ILLEGAL
</pre>
(This just clarifies that qualifiers aren't legal in local decls either.)
<p><li> <strong>Page 69, Section 5.5.2, Name clashes.</strong>
At the very end of the section, add the following clarification:
<p>
"The name occurring in a type signature or fixity declarations is always
unqualified, and unambiguously refers to another declaration in the
same declaration list (except that the fixity declaration for a class method
can occur at top level --- Section 4.4.2). For example, the following
module is legal:
<pre>
module F where
sin :: Float -> Float
sin x = (x::Float)
f x = Prelude.sin (F.sin x)
</pre>
The local declaration for <tt>sin</tt> is legal, even though
the <tt>Prelude</tt> function <tt>sin</tt> is implicitly in scope.
The references to
<tt>Prelude.sin</tt> and <tt>F.sin</tt> must both be qualified to make
it unambigous which <tt>sin</tt> is meant.
However, the unqualified name "<tt>sin</tt>" in the type
signature in the first line of <tt>F</tt> unambiguously refers to the
local declaration for <tt>sin</tt>."
<p><li> [Nov 2001] <strong>Page 71, Section 5.6.1, The Prelude module.</strong>
Replace the entire first paragraph of the section with:
<p>
"The <tt>Prelude</tt> module is imported automatically into all modules as if
by the statement `<tt>import Prelude</tt>', if and only if it is not imported
with an explicit <tt>import</tt> declaration. This provision for explicit
import allows entities defined in the Prelude to be selectively imported,
just like those from any other module."
<p><li> [May 2002] <strong>Page 71, Section 5.6.2, Shadowing Prelude Names.</strong>
Replace the entire section with the following, which clarifies matters considerably
compared to the original Haskell 98 Report.
"<pre>
module A( null, nonNull ) where
import Prelude hiding( null )
null, nonNull :: Int -> Bool
null x = x == 0
nonNull x = not (null x)
</pre>
Module <tt>A</tt> redefines <tt>null</tt>, and contains an unqualified reference
to <tt>null</tt> on the right hand side of <tt>nonNull</tt>.
The latter would be ambiguous without the "<tt>hiding(null)</tt>" on the
"<tt>import Prelude</tt>" statement.
Every module that imports <tt>A</tt> unqualified, and then makes an unqualified
reference to <tt>null</tt> must also resolve the ambiguous use of <tt>null</tt>
just as <tt>A</tt> does. Thus there is little danger of accidentally shadowing
Prelude names.
<p>
"It is possible to construct and use a different module to serve in
place of the Prelude. Other than the fact that it is implicitly
imported, the Prelude is an ordinary Haskell module; it is special
only in that some objects in the Prelude are referenced by special
syntactic constructs. Redefining names used by the Prelude does not
affect the meaning of these special constructs. For example, in
<pre>
module B where
import Prelude()
import MyPrelude
f x = (x,x)
g x = (,) x x
h x = [x] ++ []
</pre>
the explicit <tt>import Prelude()</tt> declaration prevents the automatic
import of <tt>Prelude</tt>, while the declaration <tt>import MyPrelude</tt> brings the
non-standard prelude into scope.
The special syntax for tuples (such as <tt>(x,x)</tt> and <tt>(,)</tt>) and lists
(such as <tt>[x]</tt> and <tt>[]</tt>) continues to refer to the tuples and lists
defined by the standard <tt>Prelude</tt>;
there is no way to redefine the meaning of <tt>[x]</tt>, for example, in terms of a
different implementation of lists.
On the other hand, the use of <tt>++</tt> is not special syntax, so it refers
to <tt>++</tt> imported from <tt>MyPrelude</tt>.
<p>
"It is not possible, however, to hide <tt>instance</tt> declarations in the
<tt>Prelude</tt>. For example, one cannot define a new instance for <tt>Show Char</tt>."
<p><li> [Aug 2001] <strong>Page 74, Section 6.1.3, Lists.</strong> In the last sentence,
after "<tt>Monad</tt>" add ", <tt>Functor</tt>". (The list type is an instance of <tt>Functor</tt>.)
<p><li> [May 2001] <strong>Page 74, Section 6.1.4, Tuples.</strong>
Replace the first paragraph of this section with:
<p>
"Tuples are algebraic datatypes with special syntax, as defined
in Section 3.8. Each tuple type has a single constructor.
All tuples are instances of <tt>Eq</tt>, <tt>Ord</tt>, <tt>Bounded</tt>, <tt>Read</tt>,
<tt>Show</tt> (provided, of course, that all their component types are).
<p>
There is no upper bound on the size of a tuple, but some Haskell
implementations may restrict the size of tuples, and limit the
instances associated with larger tuples. However, every Haskell
implementation must support tuples up to size 15, together with their instances
for <tt>Eq</tt>, <tt>Ord</tt>, <tt>Bounded</tt>, <tt>Read</tt>,
and <tt>Show</tt>. The Prelude and
libraries define tuple functions such as <tt>zip</tt> for tuples up to a size
of 7."
<p><li> [Apr 2001] <strong>Page 74, Section 6.1.6, Function Types.</strong>
Delete the sentence "Functions are an instance of the <tt>Show</tt> class but not <tt>Read</tt>".
<p><li> [Aug 2001] <strong>Page 75, Section 6.1.7, The IO and IOError Types.</strong>
In the second sentence, replace "<tt>Show</tt>" by "<tt>Functor</tt>".
(<tt>IO</tt> is an instance of <tt>Functor</tt>, but not <tt>Show</tt>.)
<p><li> [Apr 2001] <strong>Page 76, Section 6.3, Standard Haskell classes.</strong>
There is a formatting error in the example. There should be a new line
after "the declaration of Class Eq is:", and before the sentence beginning
"This declaration gives default method declarations...".
<p><li> [July 2001] <strong>Page 78, Section 6.3.2, The Ord Class.</strong>
Redefine the default methods for <tt>max</tt> and <tt>min</tt> as follows:
<pre>
max x y | x <= y = y
| otherwise = x
min x y | x <= y = x
| otherwise = y
</pre>
(This change aligns the report with the code given in the Appendix.)
<p><li> [Apr 2001] <strong>Page 78, Section 6.3.3, The Read and Show Classes.</strong>
After "The <tt>Read</tt> and <tt>Show</tt> classes are used to convert values
to and from strings." add the sentence:
"The <tt>Int</tt> argument to <tt>showsPrec</tt> and <tt>readsPrec</tt> gives the operator
precedence of the enclosing context (see Appendix D.4)."
(Clarification only.)
<p><li> [May 2002] <strong> Page 79, Section 6.3.3, The Read and Show Classes.</strong>
Add documentation for the function <tt>lex</tt>:
<p>
"The function <tt>lex :: ReadS String</tt>, used by <tt>read</tt>, is also part of the Prelude.
It reads a single lexeme from the input, discarding initial white space, and
returning the characters that constitute the lexeme. If the input string contains
only white space, <tt>lex</tt> returns a single successful ``lexeme'' consisting of the
empty string. (Thus <tt>lex ""</tt> = <tt>[("","")]</tt>.) If there is no legal lexeme at the
beginning of the input string, <tt>lex</tt> fails (i.e. returns <tt>[]</tt>)."
<p><li> [Nov 2001] <strong> Page 79, Section 6.3.4, Class Enum;
Page 19, Section 3.10 Arithmetic Sequences; and Appendix D.2, Derived instances of Enum.</strong>
<ul>
<li> Move the specification of the <tt>Int</tt> and <tt>Integer</tt> instances of
<tt>Enum</tt> from 3.10 to 6.3.4.
<li> Specify that, for bounded types, <tt>succ</tt> and <tt>pred</tt> should fail
when applied to <tt>maxBound</tt> and <tt>minBound</tt> resp.
<li> Specify that the <tt>enum</tt> functions on numeric types are strict.
<li> Remove material from D.2 so that it describes only the derived instances.
</ul>
This change amounts to a fairly complete rewrite of 6.3.4, with a slightly tighter
specification than before.
<p><li><strong>Page 80, Section 6.3.6, Class Monad.</strong>
Right at the bottom of the page, replace "However, for IO, the fail
method invokes error." by "For IO, the fail method raises a user
exception in the IO monad (see Section 7.3)."
<p><li> [Aug 2001] <strong>Page 82, Section 6.4, Numbers.</strong>In paragraph 2 of 6.4, replace "Rational library"
with "Ratio library".
<p><li> [July 2001] <strong>Page 83, Section 6.4.2, Arithmetic and number-theoretic operations.</strong>
After "The quod, rem, div, and mod class methods satisfy these laws" add "if <tt>y</tt> is non-zero".
<p><li> [Apr 2001] <strong>Page 84, Section 6.4, Fig 7; and bottom of page 86, Section 6.4.6.</strong>
<pre>
fromRealFrac :: (RealFrac a, Fractional b) => a -> b
</pre>
should be replaced by
<pre>
realToFrac :: (Real a, Fractional b) => a -> b
</pre>
<p><li> [Late Dec 2001] <strong>Page 84, Section 6.4.2, <tt>gcd</tt></strong>.
In the final paragraph of 6.4.2, replace "<tt>gcd</tt> x y is the greatest integer
that divides both x and y" by "<tt>gcd</tt> x y is the greatest (positive) integer
that divides both x and y. <tt>gcd 0 0</tt> raises a runtime error".
<p>
(The "(positive)" clarifies a slightly ambiguous point, while the specification for
<tt>gcd 0 0</tt> remains controversial.
There was a lot of email on the Haskell mailing list in Dec 2001 about the latter point.)
<p><li><strong>Page 88, Section 7.1, Standard I/O functions.</strong>
In the section "Input functions" replace "the <tt>IOError</tt> value associated
with end-of-file is defined in a library" by "a predicate <tt>isEOFError</tt> that
identifies this exception is defined in the <tt>IO</tt> library".
<p><li> [May 2002] <strong>Page 88, Section 7.1, Standard I/O functions.</strong>
In the section "Input functions",
<ul>
<li> Change "Both <tt>getChar</tt> and <tt>getLine</tt> raise an exception on end-of-file;" to
"The <tt>getChar</tt> operation raises an exception on end-of-file;".
<li> After that sentence, add the further sentence "The <tt>getLine</tt> operation raises
an exception under the same circumstances as <tt>hGetLine</tt>, defined the <tt>IO</tt> library."
</ul>
(This change goes along with a more precise description of the behaviour of hGetLine.)
<p><li> [Sept 2002] <strong>Page 88, Section 7.1, Standard I/O functions.</strong>
Remove the paragraph "By default, these input functions echo to standard output."
(There was a lot of discussion on the Haskell mailing list on this point, in Sept 2002.
The conclusion was that the sentence should go, though it would have been better
to craft something more detailed.)
<p><li><strong>Page 90, Section 7.3, Exception handling in the IO monad.</strong>
After the first paragraph give the following type signature:
<pre>
userError :: String -> IOError
</pre>
Also add an index entry for <tt>userError</tt> on this page.
(These changes are purely presentational.)
<p><li> [Apr 2001] <strong>Page 90, Section 7.3, Exception handling in the IO monad.</strong>
After the above signature for <tt>userError</tt>, add the following:
"The <tt>fail</tt> method of the <tt>IO</tt> instance of the <tt>Monad</tt> class (Section 6.3.6) raises a
<tt>userError</tt>, thus:
<pre>
instance Monad IO where
...bindings for return, (>>=), (>>)
fail s = ioError (userError s)
</pre>"
<p><li> [Dec 2001] <strong>Page 91, Appendix A, Standard Prelude.</strong>
<ul>
<li>
Add the following paragraph to clarify the status of the default-method definitions.
<p>
"The default method definitions, given with <tt>class</tt> declarations, constitute
a specification <em>only</em> of the default method. They do <em>not</em> constitute a
specification of the meaning of the method in all instances. To take
one particular example, the default method for <tt>enumFrom</tt> in class <tt>Enum</tt>
will not work properly for types whose range exceeds that of <tt>Int</tt> (because
<tt>fromEnum</tt> cannot map all values in the type to distinct <tt>Int</tt> values)."
<p>
<li> Add the following paragraph, to say why some functions have an unexpectedly
restricted type:
<p>
"To reduce the occurrence of unexpected ambiguity errors, and to
improve efficiency, a number of commonly-used functions over lists use
the <tt>Int</tt> type rather than using a more general numeric type, such as
<tt>Integral a</tt> or <tt>Num a</tt>. These functions are: <tt>take</tt>, <tt>drop</tt>,
<tt>index</tt>, <tt>length</tt>, <tt>splitAt</tt>, and <tt>replicate</tt>. The more general
versions are given in the <tt>List</tt> library, with the prefix
"<tt>generic</tt>"; for example <tt>genericLength</tt>."
</ul>
<p><li> [Oct 2001] <strong>Page 93, Appendix A, Standard Prelude.</strong>
Replace the fixity declaration for <tt>(:)</tt> by the following comments:
<pre>
-- The (:) operator is built-in syntax, and cannot legally be given
-- a fixtity declaration; but its fixity is given by:
-- infixr 5 :
</pre>
<p><li> [Nov 2001] <strong>Page 94, Appendix A, Standard Prelude, class <tt>Enum</tt>.</strong>
<ul>
<li> Before the default methods add:
<pre>
-- NOTE: these default methods only make sense for types
-- that map injectively into Int using fromEnum
-- and toEnum.
</pre>
<li>
After the default method for <tt>enumFromTo</tt> add
<pre>
enumFromThen x y = map toEnum [fromEnum x, fromEnum y ..]
</pre>
</ul>
<p><li><strong>Page 95, Appendix A, Standard Prelude, class <tt>Floating</tt>.</strong>
Add <tt>asin, acos, atan</tt> to the comment giving the list of minimal complete definitions.
<p><li> [Dec 2001] <strong>Page 100, Appendix A, <tt>instance Bounded Char</tt>.</strong>
<ul>
<li> Replace the definition of <tt>maxBound</tt> by
<pre>
maxBound = primUnicodeMaxChar
</pre>
<li> Import <tt>UnicodePrims( primUnicodeMaxChar )</tt> at the top of the module.
</ul>
(This avoids making explicit what the largest character is.)
<p><li> [Apr 2001] <strong>Page 101, Appendix A, <tt>instance Monad IO</tt>.</strong>
Replace the definition of <tt>fail</tt> in <tt>instance Monad IO</tt> by
<pre>
fail s = ioError (userError s)
</pre>
<p><li><strong>Page 102, Appendix A, comments immediately before
<tt>instance Enum Float</tt>.</strong>
Replace "<tt>1.0</tt>" by "<tt>0.95</tt>".
<p><li> [Aug 2001] <strong>Page 101, Appendix A, instance of <tt>Monad IO</tt>.</strong>
Delete defintion for <tt> >> </tt>. (The default definition will do.)
<p> <li> [Oct 2002] <strong>Page 103, Appendix A.1, line 19.</strong>
In the definition of <tt>numericFromThenTo</tt> replace "<tt>n' > n</tt>" by
"<tt>n' >= n</tt>". So the definition now reads:
<pre>
numericEnumFromThenTo n n' m = takeWhile p (numericEnumFromThen n n')
where
p | n' >= n = (<= m + (n'-n)/2)
| otherwise = (>= m + (n'-n)/2)
</pre>
(This change makes the code agree with the last bullet in (the revised version of) 6.3.4.)
<p> <li> [Apr 2001] <strong>Page 105, Appendix A.1, line 11.</strong>
In the module header for <tt>PreludeList</tt> replace "<tt>Sum</tt>" by "<tt>sum</tt>".
<p><li><strong>Page 105, Appendix A.1 (PreludeList), line 19.</strong>
Correct the type of <tt>map</tt> to
<pre>
map :: (a -> b) -> [a] -> [b]
</pre>
<p><li><strong>Page 106, definition of <tt>(!!)</tt>.</strong>
Replace the definition of <tt>(!!)</tt> with the following:
<pre>
-- List index (subscript) operator, 0-origin
(!!) :: [a] -> Int -> a
xs !! n | n < 0 = error "Prelude.!!: negative index"
[] !! _ = error "Prelude.!!: index too large"
(x:_) !! 0 = x
(_:xs) !! n = xs !! (n-1)
</pre>
(The original version had the property that <tt>([] !! -100)</tt>
reported "index too large".)
<p><li> [Apr 2001] <strong>Page 107, definition of <tt>scanl1</tt> and <tt>scanr1</tt>.</strong>
Replace the definitions of <tt>scanl1</tt> and <tt>scanr1</tt> with these:
<pre>
scanl :: (a -> b -> a) -> a -> [b] -> [a]
scanl f q xs = q : (case xs of
[] -> []
x:xs -> scanl f (f q x) xs)
scanl1 :: (a -> a -> a) -> [a] -> [a]
scanl1 f (x:xs) = scanl f x xs
scanl1 _ [] = []
scanr1 :: (a -> a -> a) -> [a] -> [a]
scanr1 f [] = []
scanr1 f [x] = [x]
scanr1 f (x:xs) = f x q : qs
where qs@(q:_) = scanr1 f xs
</pre>
The effect is to make both functions defined on the empty list.
<p><li> [Apr 2001] <strong>Page 108, definition of <tt>take</tt>, <tt>drop</tt>, and <tt>splitAt</tt>.</strong>
Replace the definitions of <tt>take</tt>, <tt>drop</tt>, and <tt>splitAt</tt> with these:
<pre>
take :: Int -> [a] -> [a]
take n _ | n <= 0 = []
take _ [] = []
take n (x:xs) = x : take (n-1) xs
drop :: Int -> [a] -> [a]
drop n xs | n <= 0 = xs
drop _ [] = []
drop n (_:xs) = drop (n-1) xs
splitAt :: Int -> [a] -> ([a],[a])
splitAt n xs = (take n xs, drop n xs)
</pre>
The effect is that all three functions are defined on negative arguments. This
is a semantic change.
<p><li> [Jan 2002] <strong>Page 112, header for PreludeText</strong>.
Remove <tt>show</tt> from the export list, and re-insert it as an exported
operation of class <tt>Show</tt>.
<p><li> [Nov 2001] <strong>Page 114, definition of lex</strong>.
Change the line that currently reads
<pre>
lexFracExp s = [("",s)]
</pre>
to read instead
<pre>
lexFracExp s = lexExp s
</pre>
(This change allows 10e3 to be a single lexeme; c.f. the lexical change on page 7.)
<p><li> [May 2001; showsPrec corrected Sept 2001]
<strong>Page 115, instances <tt>Show Int</tt> and <tt>Read Int</tt></strong>.
Replace the instances for <tt>Show Int</tt> and <tt>Read Int</tt> with
<pre>
instance Show Int where
showsPrec n = showsPrec n . toInteger
-- Converting to Integer avoids
-- possible difficulty with minInt
instance Read Int where
readsPrec p r = [(fromInteger i, t) | (i,t) <- readsPrec p r]
-- Reading at the Integer type avoids
-- possible difficulty with minInt
</pre>
The previous definitions (which are simply specifications, remember) failed on minInt.
<p><li> [July 2002]
<strong>Page 115, instances <tt>Read Float</tt> and <tt>Read Double</tt></strong>.
These two instance declarations should read:
<pre>
instance Read Float where
readsPrec p = readSigned readFloat
instance Read Double where
readsPrec p = readSigned readFloat
</pre>
(Adding the 'readSigned' call.)
<p><li> [Late Dec 2001] <strong>Page 118, defn of <tt>interact</tt></strong>.
Replace the definition of <tt>interact</tt> with the following.
<pre>
interact :: (String -> String) -> IO ()
-- The hSetBuffering ensures the expected interactive behaviour
interact f = do hSetBuffering stdin NoBuffering
hSetBuffering stdout NoBuffering
s <- getContents
putStr (f s)
</pre>
<p><li> [Dec 2001] <strong>Page 122, Appendix B.3, Layout</strong>.
<ul>
<p><li>Replace the first dashed item in the first bullet item by:
<p>
"If a <tt>let</tt>, <tt>where</tt>, <tt>do,</tt>, or <tt>of</tt> keyword is not followed by the lexeme <tt>{</tt>,
the token "<tt>{n}</tt>" is inserted after the keyword, where "n" is the indentation of the
next lexeme if there is one, or "0" if the end of file has been reached."
<p>
(This addresses the question of end of file just after a <tt>where</tt>.)
<p><li>Replace the third dashed item in the first bullet item by:
<p>
"Where the start of a token is preceded only by white space on
same line, this token is preceded by "<n>" where "n"
is the indentation of the token, provided that it is not,
as a consequence of the first two rules, preceded by "{n}".
<p>
(This addresses the question of empty lines (no layout token) and string-gap tokens
(no layout token in the middle of them). I have added a clarifying example as well.)
</ul>
<p><li> [Nov 2001] <strong>Page 122, Appendix B.3, Layout</strong>.
In the paragraph following the bullets, add the sentence:
"The characters "newline", "return", "linefeed", and "formfeed", all start a new line."
<p><li> [Sept 2002] <strong>Page 122, Appendix B.3, Layout</strong>.
After the sentence "For the purposes of the layout rule, Unicode characters in a source program
are considered to be of the same, fixed, width as an ASCII character." add the clarifying sentence
<p>
"However, to avoid visual confusion, programmers should avoid writing programs in which
the meaning of implicit layout depends on the width of non-space characters."
<p><li> [Oct 2001] <strong>Page 123, Appendix B.3, Layout</strong>.
In the first line of the definition of L, replace "if parse-error(t)" by
"if m /= 0 and parse-error(t)". This checks that the implicitly-added close
brace matches an implicit open brace.
<p><li> [Late Dec 2001] <strong>Page 122,123, Appendix B.3, Layout</strong>.
<ul>
<li>
On p122, replace "L tokens [0]" by "L tokens []".
<p><li>
Replace the layout equations on p123 with the following:
<div align=center><p>
<table >
<tr><td>
L (<n>:ts) (m:ms) </td><td align=center> = </td><td> <tt>;</tt> : (L ts (m:ms)) </td><td>if m = n </td></tr><tr><td></td><td align=center> = </td><td> <tt>}</tt> : (L (<n>:ts) ms) </td><td> if n < m </td></tr><tr><td>L (<n>:ts) ms </td><td align=center> = </td><td> L ts ms </td></tr><tr></tr><tr><td>L ({n}:ts) (m:ms) </td><td align=center> = </td><td> <tt>{</tt> : (L ts (n:m:ms)) </td><td> if n > m (Note 1)</td></tr><tr><td>L ({n}:ts) [] </td><td align=center> = </td><td> <tt>{</tt> : (L ts [n]) </td><td> if n > 0 (Note 1)</td></tr><tr><td>L ({n}:ts) ms </td><td align=center> = </td><td> <tt>{</tt> : <tt>}</tt> : (L (<n>:ts) ms) </td><td> (Note 2)</td></tr><tr></tr><tr><td>L (<tt>}</tt>:ts) (0:ms) </td><td align=center> = </td><td> <tt>}</tt> : (L ts ms) </td><td> (Note 3) </td></tr><tr><td>L (<tt>}</tt>:ts) ms </td><td align=center> = </td><td> parse-error </td><td> (Note 3) </td></tr><tr></tr><tr><td>L (<tt>{</tt>:ts) ms </td><td align=center> = </td><td> <tt>{</tt> : (L ts (0:ms)) </td><td> (Note 4)</td></tr><tr></tr><tr><td>L (t:ts) (m:ms) </td><td align=center> = </td><td> <tt>}</tt> : (L (t:ts) ms) </td><td> if m /= 0 and parse-error(t) </td></tr><tr><td></td><td align=center></td><td></td><td> (Note 5) </td></tr><tr><td>L (t:ts) ms </td><td align=center> = </td><td> t : (L ts ms)</td></tr><tr></tr><tr><td>L [] [] </td><td align=center> = </td><td> []</td></tr><tr><td>L [] (m:ms) </td><td align=center> = </td><td> <tt>}</tt> : L [] ms </td><td> if m /=0 (Note 6)
</td></tr></table>
<p>
</div>
<p><li> Renumber the notes correspondingly.
</ul>
(These changes deal with various corner cases, such as empty <tt>where</tt> clauses;
order the equations so that they clearly deal completely with the tokens
"<n>", "{n}", "(", and "}" before dealing with the general case;
and ensure
that the tokens "<n>" and "{n}" are never passed to "parse-error".)
<p><li> [Aug 2001] <strong>Page 124, Appendix B.3, Layout</strong>.
Near the end of the sub-section, delete from "Another place where..." to the end of the
sub-section. (Note 5 covers the top-level case.)
<p><li> [May 2002] <strong>Page 124, Appendix B.3, Layout</strong>
To the very end of B.3, append the following:
<p>
"The parse-error rule is hard to implement in its full generality, because
doing so involves fixities. For example, the expression
<pre>
do a == b == c
</pre>
has a single unambiguous (albeit probably type-incorrect) parse, namely
<pre>
(do { a == b }) == c
</pre>
because <tt>(==)</tt> is non-associative. Programmers are therefore advised to avoid
writing code that requires the parser to insert a closing brace in such
situations."
<p><li> [Sept 2002] <strong>Page 130, Appendix C, Literate comments</strong>.
Move Appendix C (Literate comments) into Appendix B (Syntax), just after the section on Layout.
(This structure makes more sense when the report appears as a book.)
<p><li> [Oct 2001] <strong>Page 130, Appendix C, Literate comments</strong>.
In paragraph 2, replace
"The program text is recovered
by taking only those lines beginning with "<tt>></tt>",
and deleting the first character of each of those lines"
with
<p>
"The program text is recovered
by taking only those lines beginning with "<tt>></tt>",
and replacing the leading "<tt>></tt>" with a space."
<p><li> [Late Dec 2001] <strong>Page 130, Appendix C, Literate comments</strong>.
Final paragraph. After the phrase "all other lines are comment." add the sentence:
<p>
"More precisely:
<ul>
<li> Program code begins on the first line following a line that begins <tt>\begin{code}</tt>.
<li> Program code ends just before a subsequent line that begins <tt>\end{code}</tt> (ignoring
string literals, of course)."
</ul>
<p><li> [May 2001] <strong>Page 132, Appendix D, Specification of Derived Instances</strong>.
In numbered item 3, replace
``(all constructors must by nullary)'' with
``(all constructors must be nullary)''.
<p><li> [Jan 2002] <strong>Page 132, Appendix D, Specification of Derived Instances</strong>.
Mention that computing the context for the derived instance declaration may involve
a fixpoint calculation.
<p><li> [Feb 2002, modified Oct 2002] <strong>Page 133, Appendix D.1, Derived Instances of Eq and Ord</strong>.
Add the final sentence:
<p>
All derived operations of class <tt>Eq</tt> and <tt>Ord</tt> are strict in both arguments.
For example, <tt>False <=</tt> _|_ is _|_ , even though <tt>False</tt> is the first constructor
of the <tt>Bool</tt> type.
<p><li> [Oct 2002] <strong>Page 134, Appendix D.4, Derived instances of Read and Show</strong>.
<ul>
<li> In para 2, replace "10" by "11". Thus "(a number from 0 to 11)".
<li> In para 3 replace "...if <tt>d</tt> is 10 it is always surrounded
in parentheses, unless it is an atomic expression." by:
"if <tt>d</tt> is 11 it is always surrounded in parentheses, unless it is an
atomic expression (recall that function application has precedence 10)."
</ul>
<p><li> [June 2001] <strong>Page 134, Appendix D.4, Derived instances of Read and Show</strong>.
In the displayed equation starting <tt>fst (head (...)) == x</tt>, replace "<tt>r</tt>" by
the empty string, resulting in the following:
<p>
<center>
<tt>(x,"")</tt> is an element of <tt>(readsPrec d (showsPrec d x ""))</tt>
</center>
<p>
(The old, stronger, equation is simply false.)
<p><li> [Oct 2002] <strong>Page 135, Appendix D.4, Derived instances of Read and Show</strong>.
In para 1, replace "<tt>readsPrec</tt> will parse any valid representation of the standard types
apart from lists, for
which only the bracketed form [...] is accepted." by:
<p>
"<tt>readsPrec</tt> will parse any valid representation of the standard types
apart from strings, for which only quoted strings are accepted, and other lists,
for which only the bracketed form [...] is accepted."
<p><li> [May 2002] <strong>Page 135, Appendix D.4, Derived instances of Read and Show</strong>.
Replace the paragraph starting "A precise description of the derived...", and all the following
bullets, with the following
(the main change is to make Show ignore associativity, so that
a simple derived parser will terminate even on left-recursive inputs):
<p>
The result of <tt>show</tt> is a syntactically correct Haskell expression
containing only constants, given the fixity declarations in force at
the point where the type is declared. It contains only the
constructor names defined in the data type, parentheses, and
spaces. When labelled constructor fields are used, braces, commas,
field names, and equal signs are also used. Parentheses
are only added where needed, ignoring associativity. No line breaks
are added. The result of <tt>show</tt> is readable by <tt>read</tt> if all component
types are readable. (This is true for all instances defined in the
Prelude but may not be true for user-defined instances.)
<p>
Derived instances of <tt>Read</tt> make the following assumptions,
which derived instances of <tt>Show</tt> obey:
<ul>
<li> If the constructor is defined to be an infix operator, then
the derived <tt>Read</tt> instance will parse only infix applications of the
constructor (not the prefix form).
<li> Associativity is not used to reduce the occurrence of
parentheses, although precedence may be. For example, given
<pre>
infixr :$
data T = Int :$ T | NT
</pre>
then:
<ul>
<li> <tt>show (1 :$ 2 :$ NT)</tt> produces the string <tt>"1 :$ (2 :$ NT)"</tt>.
<li> <tt>read "1 :$ (2 :$ NT)"</tt> succeeds, with the obvious result.
<li> <tt>read "1 :$ 2 :$ NT"</tt> fails.
</ul>
<li>
If the constructor is defined using record syntax, the derived <tt>Read</tt>
will parse only the record-syntax form, and furthermore, the fields must be
given in the same order as the original declaration.
<li> The derived <tt>Read</tt> instance allows arbitrary Haskell whitespace between
tokens of the input string. Extra parenthese are also allowed."
</ul>
<p><li> [Aug 2001] <strong>Page 138, Appendix E, Compiler pragmas</strong>.
<ul>
<li> Change <tt>inline</tt> to <tt>INLINE</tt>.
<li> Change <tt>notInline</tt> to <tt>NOINLINE</tt>.
<li> Change <tt>specialize</tt> to <tt>SPECIALIZE</tt>.
<li> Remove the optional digit from the <tt>INLINE</tt> pragma, and replace the first para of E.1 by:
<p>
"The <tt>INLINE</tt> pragma instructs the compiler to inline the specified variables
at their use sites.
Compilers will often automatically inline simple expressions. This
may be prevented by the <tt>NOINLINE</tt> pragma."
<p> <li> Delete the whole of E.3.
</ul>
(These changes simplify the pramga story, and bring it into line with what
is usually implemented.)
<p><li> [Apr 2001] <strong>Page 141, Bibliograpy</strong>.
Citation [4] should read "JR Hindley".
<p><li> <strong>Page 141, Bibliograpy</strong>.
The library report citation [8] is out of date. It should read:
"Simon Peyton Jones and John Hughes (editors), Standard Libraries for the
Haskell 98 Programming Language, 1 February 1999".
<p><li><strong>Page 147, Index</strong>. Remove the entry for "monad comprehension".
<p><li> [Apr 2001] <strong>Index of the Haskell 98 Prelude (HTML version only)</strong>
<ul>
<li> Remove <tt>Eval</tt> as a superclass of <tt>Num</tt>
<li> Correct type of <tt>seq</tt> to <tt>seq :: a -> b -> b</tt>.
<li> Correct type of <tt>getLine</tt> to <tt>IO String</tt>
<li> [Jan 2002] Correct type of <tt>map</tt> and add entry for <tt>fmap</tt>.
<li> [Jan 2002] Add entry for <tt>filter</tt>
<li> [Feb 2002] The equations given for foldl and foldr were wrong. They
should be
<pre>
foldl (+) 0 [a,b,c] = ((0+a)+b)+c
foldr (+) 0 [a,b,c] = a+(b+(c+0))
</pre>
Furthermore, the function name was misspelled in the equation for foldr1.
</ul>
</ul>
<hr>
<h1>Errata in the
<a href="http://haskell.cs.yale.edu/definition/">Haskell 98 Library Report</a></h1>
<ul>
<p><li> <strong>Title page</strong>. Remove "[editor]" from after John Hughes.
<p><li> <strong>Title page</strong>. Add the paragraph:
<p>
"Copyright (c) Simon Peyton Jones.
<p>
The authors intend this Report to belong to the entire Haskell
community, and so we grant permission to copy and
distribute it for any purpose, provided that it is
reproduced in its entireity, including this Notice. Modified
versions of this Report may also be copied and distributed for any purpose,
provided that the modified version is clearly presented as such,
and that it does not claim to be a definition of the Haskell 98 libraries."
<p><li> [Apr 2001] <strong>Page 5, Section 2.1, Library <tt>Ratio</tt></strong>.
Replace the definition of <tt>recip</tt> on line 3 by the following
<pre>
recip (x:%y) = y % x
</pre>
The effect of this change is to use the "smart constructor", <tt>%</tt>, instead
doing it by hand. In particular, an error will be raised if y is zero.
<p><li> [Oct 2002] <strong>Page 5, Section 2.1, Library <tt>Ratio</tt></strong>.
Add the following definitions to the instance for <tt>Enum</tt>.
<pre>
succ x = x+1
pred x = x-1
</pre>
(This makes succ/pred behave in the same way for Ratio as they do for Float and Double.
Of course, it is still highly dubious having these fractional types in Enum at all,
but that is another matter.)
<p><li> [July 2002] <strong>Page 5, Section 2.1, Library <tt>Ratio</tt></strong>.
Modify the <tt>Read</tt> and <tt>Show</tt> instances of <tt>Ratio</tt> as follows:
<pre>
instance (Read a, Integral a) => Read (Ratio a) where
readsPrec p = readParen (p > prec)
(\r -> [(x%y,u) | (x,s) <- readsPrec (prec+1) r,
("%",t) <- lex s,
(y,u) <- readsPrec (prec+1) t ])
instance (Integral a) => Show (Ratio a) where
showsPrec p (x:%y) = showParen (p > prec)
(showsPrec (prec+1) x .
showString " % " .
showsPrec (prec+1) y)
</pre>
(It is important that the recursive calls carry the appropriate precedence.)
<p><li> [Nov 2001] <strong>Page 9, Numeric library</strong>.
<ul>
<li> Add <tt>showIntAtBase</tt>, <tt>showHex</tt>, and <tt>showOct</tt> to the export list.
<li> Add documentation for these functions.
<li> In the body of the module, replace the definition of <tt>showInt</tt> with the following:
<pre>
showSigned :: Real a => (a -> ShowS) -> Int -> a -> ShowS
showSigned showPos p x
| x < 0 = showParen (p > 6) (showChar '-' . showPos (-x))
| otherwise = showPos x
-- showInt, showOct, showHex are used for positive numbers only
showInt, showOct, showHex :: Integral a => a -> ShowS
showOct = showIntAtBase 8 intToDigit
showInt = showIntAtBase 10 intToDigit
showHex = showIntAtBase 16 intToDigit
showIntAtBase :: Integral a
=> a -- base
-> (Int -> Char) -- digit to char
-> a -- number to show
-> ShowS
showIntAtBase base intToDig n rest
| n < 0 = error "Numeric.showIntAtBase: can't show negative numbers"
| n' == 0 = rest'
| otherwise = showIntAtBase base intToDig n' rest'
where
(n',d) = quotRem n base
rest' = intToDig (fromIntegral d) : rest
</pre>
(This siginficant change extends the Numeric library so that it can show
octal and hexadecimal numbers, just as it can already read them.)
</ul>
<p><li> [Nov 2001] <strong>Page 13, Section 4.1, Numeric library</strong>.
<ul>
<li> Add specifications for the functions exported by the Numeric library.
<p><li>In <tt>formatRealFloat</tt>, replace the entire case alternative
starting <tt>FFFixed</tt> with the following:
<pre>
FFFixed ->
case decs of
Nothing -- Always prints a decimal point
| e > 0 -> take e (ds ++ repeat '0')
++ '.' : mk0 (drop e ds)
| otherwise -> "0." ++ mk0 (replicate (-e) '0' ++ ds)
Just dec -> -- Print decimal point iff dec > 0
let dec' = max dec 0 in
if e >= 0 then
let (ei, is') = roundTo base (dec' + e) is
(ls, rs) = splitAt (e+ei)
(map intToDigit is')
in mk0 ls ++ mkdot0 rs
else
let (ei, is') = roundTo base dec'
(replicate (-e) 0 ++ is)
d : ds = map intToDigit
(if ei > 0 then is' else 0:is')
in d : mkdot0 ds
where
mk0 "" = "0" -- Print 0.34, not .34
mk0 s = s
mkdot0 "" = "" -- Print 34, not 34.
mkdot0 s = '.' : s -- when the format specifies no
-- digits after the decimal point
</pre>
(This fixes an infinite loop.)
<p><li>In the definition of <tt>k</tt> in <tt>floatToDigits</tt> replace "<tt>fromInt e</tt>" by "<tt>fromIntegral e</tt>".
(<tt>fromInt</tt> no longer exists.)
<li> Last line of code for <tt>floatToDigits</tt>, replace "<tt>toInt</tt>" by "<tt>fromIntegral</tt>".
(<tt>toInt</tt> no longer exists.)
</ul>
<p><li> [Sept 2001] <strong>Page 16, Section 4, Numeric library</strong>. In the definition
of <tt>readFloat</tt>, after "... <tt>(k,t) <- readExp s]</tt>" add
<pre>
++ [ (0/0, t) | ("NaN",t) <- lex r]
++ [ (1/0, t) | ("Infinity",t) <- lex r]
</pre>
(This makes <tt>readFloat</tt> able to read "Infinity" and "NaN", which <tt>formatRealFloat</tt>
can produce.)
<p><li> [May 2002] <strong>Page 9, Section 4, Numeric library</strong>. In the type for
<tt>readFloat</tt> replace "<tt>(RealFloat a)</tt>" by "<tt>(RealFrace a)</tt>".
(This makes it possible to read a Rational number using readFloat.)
<p><li> <strong>Page 17, Section 5, first text line</strong>. Replace "continuous" by "contiguous".
<p><li> [May 2001] <strong>Page 17, Section 5, Indexing operations</strong>.
Add the following equation to the laws listed just before Section 5.1:
<pre>
map index (range (l,u)) == [0..rangeSize (l,u)]
</pre>
This documents an invariant that was previously only implicit.
<p><li> [Oct 2001] <strong>Page 17, Section 5, Indexing operations</strong>.
This significant item makes <tt>rangeSize</tt> into a method of
<tt>Ix</tt> rather than a free-standing declaration. Though this
change is visible to the programmer, all existing Haskell 98
programs will continue to work.
<ul>
<li> <strong>Page 17, Section 5, Indexing operations, boxed text</strong>.
Replace the <tt>Ix</tt>
class declaration, and the type signature for <tt>rangeSize</tt> with:
<pre>
class Ord a => Ix a where
range :: (a,a) -> [a]
index :: (a,a) -> a -> Int
inRange :: (a,a) -> a -> Bool
rangeSize :: (a,a) -> Int
</pre>
<li> <strong>Section 5.2, pages 19, line 3</strong>. Replace the <tt>Ix</tt>
class declaration, and the <tt>rangeSize</tt> declaration, with:
<pre>
class Ord a => Ix a where
range :: (a,a) -> [a]
index :: (a,a) -> a -> Int
inRange :: (a,a) -> a -> Bool
rangeSize :: (a,a) -> Int
rangeSize b@(l,h) | null (range b) = 0
| otherwise = index b h + 1
-- NB: replacing "null (range b)" by "not (l <= h)"
-- fails if the bounds are tuples. For example,
-- (1,2) <= (2,1)
-- but the range is nevertheless empty
-- range ((1,2),(2,1)) = []
</pre>
(Note: the comment has changed too; it was misleading before.)
</ul>
(Note: an earlier proposal to remove the Ord superclass was rejected.)
<p><li> [July 2001] <strong>Page 17, Section 5.1, Derived instances of <tt>Ix</tt></strong>.
Replace the first paragraph with the following:
<p>
"It is possible to derive an instance of <tt>Ix</tt> automatically, using
a <tt>deriving</tt> clause on a <tt>data</tt> declaration (Section 4.3.3
of the Language Report).
Such derived instance declarations for the class <tt>Ix</tt> are only possible
for enumerations (i.e. datatypes having
only nullary constructors) and single-constructor datatypes,
whose constituent types are instances of <tt>Ix</tt>. A Haskell implementation
must provide <tt>Ix</tt> instances for tuples up to at least size 15."
<p>
[This change just clarifies, and propagates the "instances up to size 15" change from
Section 6.1.6 of the Language Report.]
<p><li> <strong>Page 22, Section 6.3; and Page 23, Fig 3</strong>:
Replace "<tt>map</tt>" by "<tt>fmap</tt>" (two occurrences in 6.3, one in Fig 3).
<p><li> [Dec 2001] <strong>Page 23, Figure 3</strong>.
In the definition of <tt>diag</tt>, delete the guard ``<tt>| l==l' && u==u'</tt>''.
(The original intent was presumably to check for a square array, but
simply makes the definition recursive and hence divergent.)
<p><li> [July 2002] <strong>Page 24, Section 6.4, Library <tt>Array</tt></strong>.
Use the following <tt>Read</tt> and <tt>Show</tt> instances for <tt>Array</tt>:
<pre>
instance (Ix a, Show a, Show b) => Show (Array a b) where
showsPrec p a = showParen (p > arrPrec) (
showString "array " .
showsPrec (arrPrec+1) (bounds a) . showChar ' ' .
showsPrec (arrPrec+1) (assocs a) )
instance (Ix a, Read a, Read b) => Read (Array a b) where
readsPrec p = readParen (p > arrPrec)
(\r -> [ (array b as, u)
| ("array",s) <- lex r,
(b,t) <- readsPrec (arrPrec+1) s,
(as,u) <- readsPrec (arrPrec+1) t ])
-- Precedence of the 'array' function is that of application itself
arrPrec = 10
</pre>
(It is important that the recursive calls use the appropriate precedence.)
<p><li> <strong>Page 29, Section 7.2</strong>. Add a new bullet for <tt>nub</tt>.
Add an index entry for <tt>nub</tt>.
<p><li> <strong>Page 29, Section 7.2, second bullet</strong>.
Introduce a new bullet just before "<tt>union</tt> is list union".
<p><li> [July 2002] <strong>Page 29, Section 7.2, third bullet</strong>.
Remove the first <tt>intersect</tt> in the displayed equation.
<p><li> <strong>Page 30, Section 7.3</strong>. Add a bullet for <tt>insert</tt>.
<p><li> [May 2001] <strong>Page 30, Section 7.4, unfoldr</strong>.
Replace the first line-and-a-half paragraph with:
<p>
"The <tt>unfoldr</tt> function is a `dual' to <tt>foldr</tt>: while <tt>foldr</tt> reduces a list
to a summary value, <tt>unfoldr</tt> builds a list from a seed value. For
example:
<pre>
iterate f == unfoldr (\x -> Just (x, f x))
</pre>
In some cases, <tt>unfoldr</tt> can undo a <tt>foldr</tt> operation:"
<p>
(Followed by the existing displayed equation.)
<p><li> [Feb 2002] <strong>Page 31, Section 7.6, The "By" operations</strong>.
Change the defintion of <tt>nub</tt> to:
<pre>
nub :: (Eq a) => [a] -> [a]
nub [] = []
nub (x:xs) = x : nub (filter (\y -> not (x == y)) xs)
</pre>
(This eliminates a conflict with the definition in Section 7.8.)
<p><li> [Apr 2001] <strong>Page 31, Section 7.7, Library List</strong>.
Add a new subsection "The zip operations" to document zip4, zip5, etc.
<p><li> [Dec 2001] <strong>Page 33, Section 7.8, Library List</strong>.
Replace the definition of <tt>unionBy</tt> by the following:
<pre>
unionBy eq xs ys = xs ++ deleteFirstsBy eq (nubBy eq ys) xs
</pre>
(This is a simpler definition to understand.)
<p><li> [Apr 2001] <strong>Page 34, Section 7.8, Library List</strong>.
Replace the definition of <tt>partition</tt> by
<pre>
partition :: (a -> Bool) -> [a] -> ([a],[a])
partition p xs = (filter p xs, filter (not . p) xs)
</pre>
This simply makes it agree with the definition on page 30 (Section 7.3).
<p><li> [Apr 2001] <strong>Page 35, Section 7.8</strong>.
Replace the definitions of <tt>maximumBy</tt> and <tt>minimumBy</tt> by the following
<pre>
maximumBy :: (a -> a -> Ordering) -> [a] -> a
maximumBy cmp [] = error "List.maximumBy: empty list"
maximumBy cmp xs = foldl1 max xs
where
max x y = case cmp x y of
GT -> x
_ -> y
minimumBy :: (a -> a -> Ordering) -> [a] -> a
minimumBy cmp [] = error "List.minimumBy: empty list"
minimumBy cmp xs = foldl1 min xs
where
min x y = case cmp x y of
GT -> y
_ -> x
</pre>
<strong>NOTE:</strong> this is a semantic change, but it makes the definitions
consistent with the other "By" functions, and with the signatures given on page 28.
<p><li> [Dec 2001] <strong>Page 41, Sections 9, Character utilities</strong>.
Add an explanation of <tt>lexLitChar</tt>, and an example.
<p><li> [Jan 2002] <strong>Page 43, Sections 9.1, Library Char</strong>.
Add <tt>isLatin1</tt> to the list of variables in the type signature
for "character-testing operations".
<p><li> [May 2002] <strong>Page 45, Sections 9.1, Library Char</strong>.
Replace the first equation for <tt>lexLitChar</tt> with the following
<pre>
lexLitChar ('\\':s) = map (prefix '\\') (lexEsc s)
where
lexEsc (c:s) | c `elem` "abfnrtv\\\"'" = [([c],s)]
lexEsc ('^':c:s) | c >= '@' && c <= '_' = [(['^',c],s)]
-- Numeric escapes
lexEsc ('o':s) = [prefix 'o' (span isOctDigit s)]
lexEsc ('x':s) = [prefix 'x' (span isHexDigit s)]
lexEsc s@(d:_) | isDigit d = [span isDigit s]
-- Very crude approximation to \XYZ.
lexEsc s@(c:_) | isUpper c = [span isCharName s]
lexEsc _ = []
isCharName c = isUpper c || isDigit c
prefix c (t,s) = (c:t, s)
</pre>
(The effect is to allow octal and hexadecimal escapes in lexLitChar, just
as in readLitChar.)
<p><li><strong>Page 48, Sections 10.3, Monads</strong>.
In the definition of <tt>listFile</tt> replace "<tt>openFile</tt>" by "<tt>readFile</tt>".
<p><li><strong>Page 54, Sections 11, 12, 13</strong>.
Replace "<tt>isIllegalOperationError</tt>" with "<tt>isIllegalOperation</tt>" throughout.
Namely:
<ul>
<li> Section 11.1, second para after bullets (two occurrences).
<li> Section 12, para 2 (two occurrences).
<li> Section 13, para 2 (two occurrences).
</ul>
(It was inconsistent before.)
<p><li><strong>Page 54, Section 11</strong>.
The signature for <tt>try</tt> should be
<pre>
try :: IO a -> IO (Either IOError a)
</pre>
<p><li> [May 2001] <strong>Page 57, Section 11.2.1 Semi-closed handles</strong>.
Replace the sentence "Once a semi-closed handle becomes closed..." with
"Once a semi-closed handle becomes closed, the contents of the
associated list becomes fixed. The contents of this final list is
only partially specified: it will contain at least all the items of
the stream that were evalutated prior to the handle becoming closed."
<p>
This change attempts to clarify the (murky) meaning of <tt>hGetContents</tt> followed by
<tt>hClose</tt>.
<p><li> [Apr 2001] <strong>Page 56-58, Section 11.2, Files and Handles</strong>.
Add a section 11.2.3 to clarify the file-locking issue. It says:
<p>
"Implementations should enforce as far as possible, at least locally to the
Haskell process, multiple-reader single-writer locking on files.
That is, there may either be many handles on the same file which manage
input, or just one handle on the file which manages output. If any
open or semi-closed handle is managing a file for output, no new
handle can be allocated for that file. If any open or semi-closed
handle is managing a file for input, new handles can only be allocated
if they do not manage output. Whether two files are the same is
implementation-dependent, but they should normally be the same if they
have the same absolute path name and neither has been renamed, for
example.
Warning: the <tt>readFile</tt> operation (Section 7.1 of the Haskell Language Report)
holds a semi-closed handle on the file until the entire contents of the file have been
consumed. It follows that an attempt to write to a file (using <tt>writeFile</tt>, for example)
that was earlier opened by <tt>readFile</tt> will usually result in
failure with <tt>isAlreadyInUseError</tt>."
<p><li> [Sept 2002] <strong>Page 58, Section 11.3.2 Closing Files</strong>.
Replace the sentence "If the operation fails for any reason ... successfully closed."
by
<p>
"Performing <tt>hClose</tt> on a handle that has already been closed has no effect;
doing so not an error. All other operations on a closed handle will fail.
If <tt>hClose</tt> fails for any reason, any further operations (apart from <tt>hClose</tt>) on the
handle will still fail as if "hdl" had been successfully closed."
<p>
(The significant change here is that it is not an error to hClose a handle twice.)
<p><li> [May 2001] <strong>Page 59, Section 11.4.2</strong>.
Before "The buffer is emptied as soon as it has been written out." add:
"An implementation is free to flush the buffer more frequently, but not
less frequently, than
specified above." (Clarification only.)
<p><li> [May 2001] <strong>Page 59, Section 11.4.2</strong>.
In the second no-buffering bullet (sixth bullet in the sub-section) add the
sentence: "The <tt>hLookAhead</tt> operation implies that
even a no-buffered handle may require a one-character buffer. " (Clarification only.)
<p><li>[May 2002] <strong>Page 60, Section 11.7.1, Checking for input</strong>.
<ul>
<li> Split this section into two: 11.7.1 Checking for input (describing
<tt>hWaitForInput</tt> and <tt>hReady</tt>), and 11.7.2 Reading input (describing
<tt>hGetChar</tt> and <tt>hGetLine</tt>).
<p>
<li> To the new section 11.7.2, add the following description of <tt>hGetLine</tt>
exception behaviour:
<p>
"The <tt>hGetLine</tt> fails with <tt>isEOFError</tt> if the end of file is encountered
when reading the <em>first</em> character of the line. If <tt>hGetLine</tt> encounters
end-of-file at any other point while reading in a line, it is treated as
a line terminator and the (partial) line is returned."
</ul>
<p><li><strong>Page 62, Section 11.7.2</strong>.
<ul>
<li>Add a new section heading "<strong>11.7.3 Reading the entire input</strong>"
just before the paragraph about <tt>hGetContents</tt>.
<li>
Add a new section heading "<strong>11.7.4 Text output</strong>" before the
paragraph about <tt>hPutChar</tt>.
</ul>
<p><li><strong>Page 63, definition of <tt>main</tt> in Section 11.8.1</strong>.
Replace the definition of "<tt>readNum</tt>" with
<pre>
where readNum :: IO Integer
-- Need a type signature for readLn to avoid ambiguity
readNum = readLn
</pre>
(This change merely advertises the generally useful function <tt>readLn</tt>.)
<p><li><strong>Page 64, Section 12, Directory functions.</strong>
(More an editor's blunder than a typo.)
<ul>
<li>
Replace the abstract definition of <tt>Permissions</tt>, and the four instances
of <tt>Permissions</tt> with
<pre>
data Permissions
= Permissions {
readable, writable, executable, searchable :: Bool
}
deriving ( Eq, Ord, Read, Show )
</pre>
<li> Remove <tt>readable, writable, executable, searchable</tt> both from
the module header, and from the module body.
<li> Change <tt>Permissions</tt> to <tt>Permissions(Permissions, readable, writable, executable, searchable)</tt>
in the module header.
</ul>
<p><li> [Dec 2001] <strong>Page 65, Directory functions.</strong>
To paragraph 4, the "Error reporting" paragraph for <tt>createDirectory</tt>, append the
final clause "; or <tt>isDoesNotExistError</tt> if the new directory's parent does not exist".
<p><li> [Nov 2001] <strong>Page 66, Directory functions.</strong>
Add to the paragraph "Computation <tt>getDirectoryContents</tt> dir returns a list of all entries
in dir." the following extra sentence:
<p>
"Each entry in the returned list is named relative to the directory dir, not as an absolute path."
<p><li> [Dec 2002] <strong>Page 70, Section 14, The <tt>Time</tt> library; and page 72, section 14.1</strong>.
Add <tt>ctSec</tt> to the export list for Time (in two places).
<p><li> [Apr 2001] <strong>Page 78, Section 16, The <tt>CPUTime</tt> library</strong>.
Add <tt>cpuTimePrecision</tt> to the export list.
<p><li>[Apr 2001] <strong>Page 81, Section 17.1, The <tt>RandomGen</tt> class</strong>.
This sigificant semantic change adds a method <tt>genRange</tt> to the <tt>RandomGen</tt>
class. (Extensive discussion on the Haskell mailing list made it clear that this change
is essential to make the RandomGen class useful.) The following summarises the changes
but not in the detailed line-by-line form used for the rest of the errata.
<ul>
<li> Add a method <tt>genRange :: g -> (Int,Int)</tt> to class <tt>RandomGen</tt>.
<li> Give it the default method <tt>genRange g = (minBound,maxBound)</tt>
<li> Add a specification of <tt>genRange</tt>
<li> Change the header on page 80 to match.
</ul>
<p><li>[Apr 2001] <strong>Page 81, Section 17.1, The <tt>RandomGen</tt> class</strong>.
Specify more precisely that <tt>split</tt> must deliver <strong>independent</strong> generators.
<p><li><strong>Page 81, Section 17.1, The <tt>RandomGen</tt> class</strong>.
Bottom line on page 81: replace "<tt>show/Read</tt> instances" with
"<tt>Show/Read</tt> instances" (i.e. capitalise <tt>Show</tt>).
<p><li><strong>Page 83, Section 17.3, The global random number generator</strong>.
In the first paragraph, replace "kernal" by "kernel".
</ul>
<hr>
<address>Simon Peyton Jones, simonpj@microsoft.com</address>
</body>
</html>
|