Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Haskell
prime
Commits
0a55db15
Commit
0a55db15
authored
May 29, 2001
by
Simon Peyton Jones
Browse files
Towards the revised Reports
parent
8da89af8
Changes
36
Hide whitespace changes
Inline
Sidebyside
haskell98bugs.html
View file @
0a55db15
...
...
@@ 29,6 +29,9 @@ 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>
<strong>
Page 9, Section 2.6, Character and String Literals.
</strong>
In the production for "cntrl" replace "ASClarge" by "ascLarge".
<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:
...
...
@@ 45,15 +48,24 @@ should be
size :: Stack a > Int
</pre>
<p><li>
<strong>
Page 14, Section 3.1, Errors.
</strong>
In the first sentence of
<p><li>
[Apr 20001]
<strong>
Page 14, Section 3.1, Errors.
</strong>
In the first sentence of
the section, after "indistinguishable" add "by a Haskell program".
<p><li>
<strong>
Page 20, Section 3.10, Arithmetic sequences.
</strong>
<p><li>
[Apr 20001]
<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 "
<tt>
Integer
</tt>
"
with "
<tt>
Int
</tt>
".
<p><li>
<strong>
Page 23, Section 3.14, Do Expressions;
<p><li>
[Apr 20001]
<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)
</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>
[Apr 20001]
<strong>
Page 23, Section 3.14, Do Expressions;
and Page 128, Appendix B.4, Context Free Syntax.
</strong>
<ul>
<li>
...
...
@@ 66,6 +78,13 @@ Change the production for <em>stmts</em> to read:
That is, every list of statements must end in an expression, optionally
followed by a semicolon.
<p><li>
[Apr 20001]
<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 20001]
<strong>
Page 33, Figure 4, Semantics of Case Expressions Part 2.
</strong>
In clause (r) replace "e0" by "v" throughout.
<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:
...
...
@@ 83,6 +102,10 @@ At the end of the subsection, add a new paragraph:
"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>
[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>
<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..."
...
...
@@ 94,8 +117,21 @@ 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><strong>
Page 54, first translation scheme.
</strong>
The
<em>
xn
</em>
should be
<em>
xk
</em>
(suitably subscripted in both cases!),
<p><li>
[Apr 20001]
<strong>
Page 53, Section 4.3.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 20001]
<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>
...
...
@@ 146,7 +182,7 @@ local declaration for <tt>sin</tt>."
<p><li>
<strong>
Page 71, Section 5.6.2, Shadowing Prelude Names.
</strong>
Replace the example at the beginning of the section, and the entire
following paragraph, with the following
<pre>
"
<pre>
module A( null, nonNull ) where
import Prelude hiding( null )
null, nonNull :: Int > Bool
...
...
@@ 160,20 +196,29 @@ The latter would be ambiguous without the "<tt>hiding(null)</tt>" on the
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.
Prelude names."
<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>
[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>
<strong>
Page 76, Section 6.3, Standard Haskell classes.
</strong>
There is a formatting error in the example. The sentence beginning "This declaration gives default
method declarations..." should start on a new line.
<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><strong>
Page 80, Section 6.3.6, Class Monad.
</strong>
Right at the bottom of the page, after "However, for IO, the fail
method invokes error." add the clarifying sentence "To raise
a user exception in the IO monad, use
<tt>
ioError
</tt>
(see
Section 7.3)."
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>
<strong>
Page 84, Section 6.4, Fig 7; and bottom of page 86, Section 6.4.6.
</strong>
<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>
...
...
@@ 190,19 +235,42 @@ After the first paragraph give the following type signature:
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><strong>
Page 94, Appendix A, Standard Prelude, class
<tt>
Enum
</tt>
.
</strong>
After the default method for
<tt>
enumFromTo
</tt>
add
<pre>
enumFromThen x y = map toEnum [fromEnum x, fromEnum y ..]
</pre>
<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><strong>
Page 105, Appendix A.1, line 11.
</strong>
<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>
...
...
@@ 216,17 +284,66 @@ Replace the definition of <tt>(!!)</tt> with the following:
(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
(
n1
)
xs
drop
::
Int

>
[a] > [a]
drop n xs  n
<
=
0
=
xs
drop
_
[] =
[]
drop
n
(_:xs) =
drop
(
n1
)
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>
[May 2000.]
<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>
[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>
.
</ul>
</ul>
<hr>
...
...
@@ 246,8 +363,26 @@ 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>
<strong>
Page 17, Section 5, first text line
</strong>
. Replace "continuous" by "contiguous".
<p><li>
[Apr 2001]
<strong>
Page 19, Section 5.2, comment on
<tt>
rangeSize
</tt></strong>
. Replace whole comment by
<pre>
 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
>
(This simply fixes a misleading comment.)
<p><li>
[May 2000]
<strong>
Page 17, Section 5, Indexing operations
</strong>
.
Add the following equation to the laws listed just before Section 5.1:
<pre>
...
...
@@ 302,18 +437,69 @@ 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>
[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><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>
[Apr 2001]
<strong>
Page 5658, Section 11.2, Files and Handles
</strong>
.
Add a section 11.2.3 to clarify the filelocking issue. It says:
<p>
"Implementations should enforce as far as possible, locally to the
Haskell process, multiplereader singlewriter 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 semiclosed handle is managing a file for output, no new
handle can be allocated for that file. If any open or semiclosed
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
implementationdependent, 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 semiclosed 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><strong>
Page 62, Section 11.7.2
</strong>
.
<ul>
<li>
Add a new section heading "
<strong>
11.7.
4
Reading the entire input
</strong>
"
<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.
5
Text output
</strong>
" before the
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>
.
...
...
@@ 345,6 +531,24 @@ the module header, and from the module body.
in the module header.
</ul>
<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 linebyline 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>
).
...
...
libraries/Makefile
View file @
0a55db15
...
...
@@ 5,7 +5,7 @@
# Begin by saying
# touch library.idx
default
:
library.ps html
default
:
library.ps
.gz
html
#########################################
...
...
@@ 38,6 +38,8 @@ EXPAND = expand
# I've been having problems with that damn NT messing up filenames in the html
# generator so I'm changing the .verb files to lower case  jcp
RELEASE_DIR
=
../haskell98revised
PARTS
=
library.tex introduction.tex ratio.tex complex.tex ix.tex
\
numeric.tex
\
array.tex io.tex char.tex monad.tex list.tex
\
...
...
@@ 129,11 +131,10 @@ verbs: $(CODEV) $(HEADERSV)
library.ps
:
library.dvi
dvips library.dvi
o
library.ps
publish
:
library.ps html
gzip
< library.ps
>
y:Haskell/haskell98library/library.ps.gz
cp
haskell98libraryhtml/
*
y:Haskell/haskell98library
tar
cvf  haskell98libraryhtml 
gzip
>
y:Haskell/haskell98library/haskell98libraryhtml.tar.gz
release
:
library.ps html
gzip
< library.ps
>
$(RELEASE_DIR)
/library.ps.gz
cp
r
haskell98libraryhtml
$(RELEASE_DIR)
tar
cvf  haskell98libraryhtml 
gzip
>
$(RELEASE_DIR)
/haskell98libraryhtml.tar.gz
publishpdf
:
library.pdf
gzip
< library.pdf
>
y:Haskell/haskell98library/library.pdf.gz
...
...
@@ 143,7 +144,7 @@ publishpdf: library.pdf
# Suffix rules
#########################################
.SUFFIXES
:
.hs .verb .tex .dvi
.SUFFIXES
:
.hs .verb .tex .dvi
.gz .ps
.verb.tex
:
expand
<
$<

$(VERBATIM)
>
$@
...
...
@@ 157,3 +158,4 @@ publishpdf: library.pdf
.tex.dvi
:
$(LATEX)
$<
libraries/array.verb
View file @
0a55db15
...
...
@@ 143,11 +143,11 @@ accumArray f z b = accum f (array b [(i, z)  i < range b])
\subsection{Derived Arrays}
\index{array!derived}
The two functions @map@\indextt{map} and @ixmap@\indextt{ixmap}
The two functions @
f
map@\indextt{
f
map} and @ixmap@\indextt{ixmap}
derive new arrays from existing ones; they may be
thought of as providing function composition on the left and right,
respectively, with the mapping that the original array embodies.
The @map@ function transforms the array values while
The @
f
map@ function transforms the array values while
@ixmap@ allows for transformations on array indices.
Figure~\ref{derivedarrayexamples} shows some examples.
...
...
@@ 169,7 +169,7 @@ diag x = ixmap (l,u) (\i>(i,i)) x
 Projection of first components of an array of pairs
firstArray :: (Ix a) => Array a (b,c) > Array a b
firstArray = map (\(x,y)>x)
firstArray =
f
map (\(x,y)>x)
@
}
\ecaption{Derived array examples}
...
...
libraries/code/Ix.hs
View file @
0a55db15
...
...
@@ 8,12 +8,11 @@ class Ix a where
rangeSize
b
@
(
l
,
h
)

null
(
range
b
)
=
0

otherwise
=
index
b
h
+
1
 NB: replacing "null (range b)" by "l > h" fails if
 the bounds are tuples. For example,
 (2,1) > (1,2),
 but
 range ((2,1),(1,2)) = []
 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)) = []
instance
Ix
Char
where
range
(
m
,
n
)
=
[
m
..
n
]
...
...
libraries/code/List.hs
View file @
0a55db15
...
...
@@ 94,9 +94,7 @@ transpose ((x:xs) : xss) = (x : [h  (h:t) < xss]) :
transpose
(
xs
:
[
t

(
h
:
t
)
<
xss
])
partition
::
(
a
>
Bool
)
>
[
a
]
>
([
a
],[
a
])
partition
p
xs
=
foldr
select
(
[]
,
[]
)
xs
where
select
x
(
ts
,
fs
)

p
x
=
(
x
:
ts
,
fs
)

otherwise
=
(
ts
,
x
:
fs
)
partition
p
xs
=
(
filter
p
xs
,
filter
(
not
.
p
)
xs
)
 group splits its list argument into a list of lists of equal, adjacent
 elements. e.g.,
...
...
@@ 162,13 +160,21 @@ insertBy cmp x ys@(y:ys')
GT
>
y
:
insertBy
cmp
x
ys'
_
>
x
:
ys
maximumBy
::
(
a
>
a
>
a
)
>
[
a
]
>
a
maximumBy
max
[]
=
error
"List.maximumBy: empty list"
maximumBy
max
xs
=
foldl1
max
xs
minimumBy
::
(
a
>
a
>
a
)
>
[
a
]
>
a
minimumBy
min
[]
=
error
"List.minimumBy: empty list"
minimumBy
min
xs
=
foldl1
min
xs
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
genericLength
::
(
Integral
a
)
=>
[
b
]
>
a
genericLength
[]
=
0
...
...
libraries/code/Random.hs
View file @
0a55db15
module
Random
(
RandomGen
(
next
,
split
),
RandomGen
(
next
,
split
,
genRange
),
StdGen
,
mkStdGen
,
Random
(
random
,
randomR
,
...
...
@@ 13,8 +13,9 @@ module Random (
 The RandomGen class 
class
RandomGen
g
where
next
::
g
>
(
Int
,
g
)
split
::
g
>
(
g
,
g
)
 May not exist for all RandomGens
genRange
::
g
>
(
Int
,
Int
)
next
::
g
>
(
Int
,
g
)
split
::
g
>
(
g
,
g
)
 May not exist for all RandomGens
 A standard instance of RandomGen 
...
...
libraries/code/Ratio.hs
View file @
0a55db15
...
...
@@ 50,7 +50,7 @@ instance (Integral a) => Real (Ratio a) where
instance
(
Integral
a
)
=>
Fractional
(
Ratio
a
)
where
(
x
:%
y
)
/
(
x'
:%
y'
)
=
(
x
*
y'
)
%
(
y
*
x'
)
recip
(
x
:%
y
)
=
if
x
<
0
then
(

y
)
:%
(

x
)
else
y
:
%
x
recip
(
x
:%
y
)
=
y
%
x
fromRational
(
x
:%
y
)
=
fromInteger
x
:%
fromInteger
y
instance
(
Integral
a
)
=>
RealFrac
(
Ratio
a
)
where
...
...
libraries/headers/CPUTime.hs
View file @
0a55db15
module
CPUTime
(
getCPUTime
)
where
module
CPUTime
(
getCPUTime
,
cpuTimePrecision
)
where
getCPUTime
::
IO
Integer
cpuTimePrecision
::
Integer
libraries/headers/Directory.hs
View file @
0a55db15
module
Directory
(
Permissions
,
readable
,
writable
,
executable
,
searchable
,
Permissions
(
readable
,
writable
,
executable
,
searchable
),
createDirectory
,
removeDirectory
,
removeFile
,
renameDirectory
,
renameFile
,
getDirectoryContents
,
getCurrentDirectory
,
setCurrentDirectory
,
...
...
@@ 10,14 +9,17 @@ module Directory (
import
Time
(
ClockTime
)
data
Permissions
=
...
 Abstract
data
Permissions
=
Permissions
{
readable
,
writable
,
executable
,
searchable
::
Bool
}
instance
Eq
Permissions
where
...
instance
Ord
Permissions
where
...
instance
Read
Permissions
where
...
instance
Show
Permissions
where
...
readable
,
writable
,
executable
,
searchable
::
Permissions
>
Bool
createDirectory
::
FilePath
>
IO
()
removeDirectory
::
FilePath
>
IO
()
...
...
libraries/headers/IO1.hs
View file @
0a55db15
...
...
@@ 41,6 +41,6 @@ ioeGetErrorString :: IOError > String
ioeGetHandle
::
IOError
>
Maybe
Handle
ioeGetFileName
::
IOError
>
Maybe
FilePath
try
::
IO
a
>
Either
IOError
a
try
::
IO
a
>
IO
(
Either
IOError
a
)
bracket
::
IO
a
>
(
a
>
IO
b
)
>
(
a
>
IO
c
)
>
IO
c
bracket_
::
IO
a
>
(
a
>
IO
b
)
>
IO
c
>
IO
c
libraries/headers/Random.hs
View file @
0a55db15
module
Random
(
RandomGen
(
next
,
split
),
RandomGen
(
next
,
split
,
genRange
),
StdGen
,
mkStdGen
,
Random
(
random
,
randomR
,
randoms
,
randomRs
,
...
...
@@ 10,8 +10,9 @@ module Random (
 The RandomGen class 
class
RandomGen
g
where
next
::
g
>
(
Int
,
g
)
split
::
g
>
(
g
,
g
)
genRange
::
g
>
(
Int
,
Int
)
next
::
g
>
(
Int
,
g
)
split
::
g
>
(
g
,
g
)
 A standard instance of RandomGen 
data
StdGen
=
...
 Abstract
...
...
libraries/index.html
View file @
0a55db15
...
...
@@ 7,7 +7,7 @@
<img
src=
"h98libs.gif"
alt=
"Haskell 98 Libraries"
>
<h3
align=
"center"
>
Standard Libraries for Haskell 98
</h3>
<h3
align=
"center"
>
1 February 1999
</h3>
<h3
align=
"center"
>
Revised: FIX THIS DATE
</h3>
<hr>
<a
href=
"http://research.microsoft.com/Users/simonpj"
>
Simon Peyton Jones
</a>
[editor], Microsoft Research, Cambridge
<br>
...
...
@@ 49,6 +49,7 @@ Philip Wadler</a>, University of Glasgow <br>
<hr>
Contents:
<ul>
<li><a
href=
"libindex.html"
>
Full Table of Contents
</a>
<li><a
href=
"introduction.html"
>
Introduction
</a>
<li><a
href=
"ratio.html"
>
Ratio
</a>
<li><a
href=
"complex.html"
>
Complex
</a>
...
...
@@ 68,8 +69,15 @@ Contents:
<li><a
href=
"random.html"
>
Random
</a>
</ul>
<p>
There is also a
<a
href=
"libindex.html"
>
complete index
</a>
.
Copyright (c) Simon Peyton Jones and John Hughes.
<br>
<em>
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 entirity,
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.
</em>
<p>
The master version of the Haskell Library Report is at
<a
href=
"http://haskell.org/library"
>
haskell.org
</a>
. Any corrections or
...
...
libraries/introduction.verb
View file @
0a55db15
...
...
@@ 18,6 +18,15 @@ which are not a recognized part of the \Haskell{} standard.
The latest version of this report, as well many other available libraries,
can be found on the web at @http://haskell.org@.
\subsection*{The April 2001 Revision}
Both Haskell 98 Reports were revised in April 2001, to incorporate
dozens of typographical errors and presentational improvements. A
complete list of all changes can be found at @http:://haskell.org@.
\subsection*{Acknowledgements}
We would like to express our thanks to those who have contributed