Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Haskell
prime
Commits
b91dee4e
Commit
b91dee4e
authored
Aug 20, 2001
by
Simon Peyton Jones
Browse files
Done while away at c workshop
parent
cfbb1671
Changes
28
Expand all
Hide whitespace changes
Inline
Sidebyside
haskell98bugs.html
View file @
b91dee4e
...
...
@@ 29,6 +29,27 @@ 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>
"Though 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>
<strong>
Page 9, Section 2.6, Character and String Literals.
</strong>
In the production for "cntrl" replace "ASClarge" by "ascLarge".
...
...
@@ 48,6 +69,10 @@ should be
size :: Stack a > Int
</pre>
<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>
[July 2001]
<strong>
Page 12, Section 3, Expressions.
</strong>
Replace the last two sentences of the first paragrah of the section by:
<p>
...
...
@@ 93,6 +118,9 @@ 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>
[Aug 2001]
<strong>
Page ???, Section 3.15, Datatypes with Field Labels.
</strong>
.
Add an example to illustrate the final point in para 2.
<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.)
...
...
@@ 100,6 +128,9 @@ 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>
[Aug 2001]
<strong>
Page ???, Section 3.17.1, Patterns.
</strong>
.
Give an example to illustrate an illegal nonlinear pattern.
<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:
...
...
@@ 144,6 +175,15 @@ definitions are equivalent:", and the two lines of code that follow by:
(This change makes explicit that an infix operator with more than two arguments
can have all of them on the LHS.)
<p><li>
[Aug 2001]
<strong>
Page ???, 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>
<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!),
...
...
@@ 260,6 +300,9 @@ 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><li>
[Aug 2001]
<strong>
Page ???, Section 6.1.3, Lists.
</strong>
In the last sentence,
after "@Monad@" add ", @Functor@". (The list type is an instance of @Functor@.)
<p><li>
[May 2001]
<strong>
Page 74, Section 6.1.6, Tuples.
</strong>
Replace the first paragraph of this section with:
<p>
...
...
@@ 277,10 +320,13 @@ 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 ???, Section 6.1.7, The IO and IOError Types.
</strong>
In the second sentence, replace "
<tt>
Show
</tt>
" by "
<tt>
Functor
</tt>
".
(@IO@ is an instance of @Functor@, but not @Show@.)
<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
...
...
@@ 363,6 +409,9 @@ Replace the definition of <tt>fail</tt> in <tt>instance Monad IO</tt> by
<tt>
instance Enum Float
</tt>
.
</strong>
Replace "
<tt>
1.0
</tt>
" by "
<tt>
0.95
</tt>
".
<p><li>
[Aug 2001]
<strong>
Page ???, Appendix A, instance of
<tt>
Monad IO
</tt>
.
</strong>
Delete defintion for
<tt>
>>
</tt>
. (The default definition will do.)
<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>
".
...
...
@@ 440,6 +489,10 @@ Replace the instances for <tt>Show Int</tt> and <tt>Read Int</tt> with
</
pre
>
The previous definitions (which are simply specifications, remember) failed on minInt.
<p><li>
[Aug 2001]
<strong>
Page ???, Appendix B.3, Layout
</strong>
.
Near the end of the subsection, delete from "Another place where..." to the end of the
subsection. (Note 5 covers the toplevel case.)
<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
...
...
@@ 634,6 +687,16 @@ Replace the definitions of <tt>maximumBy</tt> and <tt>minimumBy</tt> by the foll
<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, 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>
...
...
@@ 653,7 +716,7 @@ This change attempts to clarify the (murky) meaning of <tt>hGetContents</tt> fol
<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
"Implementations should enforce as far as possible,
at least
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
...
...
libraries/Makefile
View file @
b91dee4e
...
...
@@ 28,7 +28,8 @@ MAKEINDEX = makeindex
# 'expand' expands tabs to spaces
# On my machine the windows program (which does something
# quite different) shadows it. Sigh.
EXPAND
=
expand
# EXPAND = expand
EXPAND
=
c:/cygwin/bin/expand
#########################################
...
...
@@ 147,13 +148,13 @@ publishpdf: library.pdf
.SUFFIXES
:
.hs .verb .tex .dvi .gz .ps
.verb.tex
:
expand
<
$<

$(VERBATIM)
>
$@
$(EXPAND)
<
$<

$(VERBATIM)
>
$@
.hs.verb
:
expand
<
$<

$(SPLITPGM)
>
$@
$(EXPAND)
<
$<

$(SPLITPGM)
>
$@
.hs.tex
:
expand
<
$<

$(SPLITPGM)

$(VERBATIM)
>
$@
$(EXPAND)
<
$<

$(SPLITPGM)

$(VERBATIM)
>
$@
.tex.dvi
:
$(LATEX)
$<
...
...
libraries/array.verb
View file @
b91dee4e
...
...
@@ 48,7 +48,7 @@ a = array (1,100) ((1,1) : [(i, i * a!(i1))  i < [2..100]])
\eprog
Not every index within the bounds of the array need
appear in the association list, but the values associated with indices
that do not appear will be undefined.
that do not appear will be undefined
(i.e.~$\bot$)
.
Figure~\ref{arrayexamples} shows some examples that use the
@array@ constructor.
...
...
libraries/code/Numeric.hs
View file @
b91dee4e
...
...
@@ 201,7 +201,8 @@ roundTo base d is = case f d is of

 Based on "Printing FloatingPoint Numbers Quickly and Accurately"
 by R.G. Burger and R. K. Dybvig, in PLDI 96.
 This version uses a much slower logarithm estimator. It should be improved.
 The version here uses a much slower logarithm estimator.
 It should be improved.
 This function returns a list of digits (Ints in [0..base1]) and an
 exponent.
...
...
libraries/directory.verb
View file @
b91dee4e
...
...
@@ 18,11 +18,10 @@
These functions operate on directories in the file system.
Any @Directory@ operation could raise an @isIllegalOperation
Error
@, as
Any @Directory@ operation could raise an @isIllegalOperation@, as
described in Section~\ref{IOError}; all other permissible errors are
described below. Note that, in particular, if an implementation does
not support an operation it should raise an @isIllegalOperationError@.
not support an operation it should raise an @isIllegalOperation@.
A directory contains a series of entries, each of which is a named
reference to a file system object (file, directory etc.). Some
entries may be hidden, inaccessible, or have some administrative
...
...
@@ 43,7 +42,7 @@ Computation @createDirectory@~"dir" creates a new directory "dir" which is
initially empty, or as near to empty as the operating system allows.
\index{making directories}
{\em Error
reporting}:
{\em Error
~
reporting}:
the @createDirectory@ computation may fail with:
@isPermissionError@ if the user is not permitted to create the directory;
@isAlreadyExistsError@ if the directory already exists.
...
...
@@ 64,7 +63,7 @@ files}\index{removing files}. The implementation may specify additional
constraints which must be satisfied before a file can be removed (for instance, the
file may not be in use by other processes).
{\em Error
reporting}:
{\em Error
~
reporting}:
the @removeDirectory@ and @removeFile@ computations may fail with:
@isPermissionError@ if the user is not permitted to remove the file/directory;
or @isDoesNotExistError@ if the file/directory does not exist.
...
...
@@ 87,7 +86,7 @@ implementation need not support renaming files in all situations
(for instance, renaming across different physical devices), but the constraints must be
documented.
{\em Error
reporting}:
{\em Error
~
reporting}:
the @renameDirectory@ and @renameFile@ computations may fail with:
@isPermissionError@ if the user is not permitted to rename the file/directory,
or if either argument to @renameFile@ is a directory;
...
...
@@ 100,7 +99,7 @@ If the operating system has a notion of current directories,
@getCurrentDirectory@ returns an absolute path to the
current directory of the calling process\index{current directory}.
{\em Error
reporting}:
{\em Error
~
reporting}:
the @getDirectoryContents@ and @getCurrentDirectory@ computations may fail with:
@isPermissionError@ if the user is not permitted to access the directory;
or @isDoesNotExistError@ if the directory does not exist.
...
...
@@ 109,7 +108,7 @@ If the operating system has a notion of current directories,
@setCurrentDirectory@~"dir" changes the current directory of the
calling process to "dir"\index{changing the directory}\index{setting the directory}.
{\em Error
reporting}:
{\em Error
~
reporting}:
the @setCurrentDirectory@ computation may fail with:
@isPermissionError@ if the user is not permitted to change directory
to that specified;
...
...
@@ 141,7 +140,7 @@ if the argument file exists and is not a directory, and @False@ otherwise.
The @getModificationTime@ operation returns the
clock time at which the file/directory was last modified.
{\em Error
reporting}:
{\em Error
~
reporting}:
the @get(set)Permissions@,
@doesFile(Directory)Exist@,
and @getModificationTime@
...
...
libraries/index.html
View file @
b91dee4e
...
...
@@ 60,7 +60,7 @@ Thomas Johnsson</a>, Chalmers University of Technology <br>
Mark Jones
</a>
, Oregon Graduate Institute
<br>
<a
href=
"http://www.cse.ogi.edu/~jl"
>
John Launchbury
</a>
, Oregon Graduate Institute
<br>
<a
href=
"http://
haskell.org/erik.html
"
>
<a
href=
"http://
research.microsoft.com/~emeijer
"
>
Erik Meijer
</a>
, Microsoft Corporation
<br>
<a
href=
"http://www.cs.yale.edu/homes/petersonjohn.html"
>
John Peterson
</a>
, Yale University
<br>
...
...
libraries/introduction.verb
View file @
b91dee4e
...
...
@@ 18,9 +18,9 @@ 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 A
pril
2001 Revision}
\subsection*{The A
ugust
2001 Revision}
Both Haskell 98 Reports were revised in A
pril
2001, to incorporate
Both Haskell 98 Reports were revised in A
ugust
2001, to incorporate
dozens of typographical errors and presentational improvements. A
complete list of all changes can be found at @http://haskell.org@.
...
...
@@ 36,7 +36,7 @@ Sigbjorn Finne,
Andy Gill,
Mike Gunter,
Fergus Henderson,
Ø
rjan Johansen,
O
rjan Johansen,
Kent Karlsson,
Sandra Loosemore,
Graeme Moss,
...
...
libraries/io.verb
View file @
b91dee4e
...
...
@@ 61,16 +61,16 @@ have sufficient operating system privilege to perform that operation.
 a programmerdefined error value has been raised using
@fail@.\indextt{fail}
\end{itemize}
All these functions return
return
a @Bool@, which is @True@ if
All these functions return a @Bool@, which is @True@ if
its argument is the corresponding kind of error, and @False@
otherwise.
Any computation which returns an @IO@ result may fail with
@isIllegalOperation
Error
@. Additional errors which could be raised by
@isIllegalOperation@. Additional errors which could be raised by
an implementation are listed after the corresponding operation. In
some cases, an implementation will not be able to distinguish between
the possible error causes. In this case it should return
@isIllegalOperation
Error
@.
@isIllegalOperation@.
Three additional functions are provided to obtain information about an
error value. These are @ioeGetHandle@\indextt{ioeGetHandle} which
...
...
@@ 188,7 +188,7 @@ discarded.
\subsubsection{File locking}
Implementations should enforce as far as possible, locally to the
Implementations should enforce as far as possible,
at least
locally to the
\Haskell{} process, multiplereader singlewriter locking on files.
That is, {\em 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
...
...
libraries/library.verb
View file @
b91dee4e
%
% $Header: /home/cvs/root/haskellreport/libraries/library.verb,v 1.
5
2001/08/
14
07:
48:24
simonpj Exp $
% $Header: /home/cvs/root/haskellreport/libraries/library.verb,v 1.
6
2001/08/
20
07:
57:52
simonpj Exp $
%
% NOTE:
% The formatting of this report and the ``new font selection scheme''
...
...
@@ 74,7 +74,7 @@
\makeindex
% an extra thing for makeindex
\newcommand{\seealso}[2]{{\em see also\/} #1}
\
re
newcommand{\seealso}[2]{{\em see also\/} #1}
% NEWCOMMANDS
...
...
libraries/system.verb
View file @
b91dee4e
...
...
@@ 15,10 +15,10 @@
This library describes the interaction of the program with the
operating system.
Any @System@ operation could raise an @isIllegalOperation
Error
@, as
Any @System@ operation could raise an @isIllegalOperation@, as
described in Section~\ref{IOError}; all other permissible errors are
described below. Note that, in particular, if an implementation does
not support an operation it must raise an @isIllegalOperation
Error
@.
not support an operation it must raise an @isIllegalOperation@.
The @ExitCode@ type defines the exit codes that a program can return.
@ExitSuccess@ indicates successful termination; and @ExitFailure@
...
...
report/Makefile
View file @
b91dee4e
...
...
@@ 29,7 +29,8 @@ MAKEINDEX = makeindex
# 'expand' expands tabs to spaces
# On my machine the windows program (which does something
# quite different) shadows it. Sigh.
EXPAND
=
expand
# EXPAND = expand
EXPAND
=
c:/cygwin/bin/expand
#########################################
...
...
report/Prelude.hs
View file @
b91dee4e
...
...
@@ 426,8 +426,6 @@ instance Functor IO where
instance
Monad
IO
where
(
>>=
)
=
...
return
=
...
m
>>
k
=
m
>>=
\
_
>
k
fail
s
=
ioError
(
userError
s
)
 Ordering type
...
...
report/PreludeList.hs
View file @
b91dee4e
...
...
@@ 168,7 +168,7 @@ splitAt n xs = (take n xs, drop n xs)
 takeWhile, applied to a predicate p and a list xs, returns the longest
 prefix (possibly empty) of xs of elements that satisfy p. dropWhile p xs
 returns the remaining suffix.
S
pan p xs is equivalent to
 returns the remaining suffix.
s
pan p xs is equivalent to
 (takeWhile p xs, dropWhile p xs), while break p uses the negation of p.
takeWhile
::
(
a
>
Bool
)
>
[
a
]
>
[
a
]
...
...
report/README
View file @
b91dee4e
...
...
@@ 47,10 +47,10 @@ PreludeText.hs
Figures:
class
fig.cdr
 The original class figure (
Corel Draw 6 forma
t)
class
fig
.eps (*)  Postscript version of classfig
class
fig
.gif (*)  For html version
cover.cdr
 A nice looking cover for the report
class
es.ppt
 The original class figure (
Powerpoin
t)
class
es
.eps (*)  Postscript version of classfig
class
es
.gif (*)
 For html version
cover.cdr  A nice looking cover for the report
cover.eps (*)
Html support:
...
...
report/basic.verb
View file @
b91dee4e
%
% $Header: /home/cvs/root/haskellreport/report/basic.verb,v 1.
7
2001/08/
14 15:38:33
simonpj Exp $
% $Header: /home/cvs/root/haskellreport/report/basic.verb,v 1.
8
2001/08/
20 07:57:52
simonpj Exp $
%
%**<title>The Haskell 98 Report: Basic Types and Classes</title>
%*section 6
...
...
@@ 107,7 +107,7 @@ two convenient
syntaxes for special kinds of lists, are described in
Sections~\ref{arithmeticsequences} and \ref{listcomprehensions},
respectively. Lists are an instance of classes @Read@, @Show@, @Eq@, @Ord@,
@Monad@, and @MonadPlus@.
@Monad@,
@Functor@,
and @MonadPlus@.
\subsubsection{Tuples}
\label{basictuples}
...
...
@@ 167,8 +167,8 @@ functional values. The following simple functions are found in the Prelude:
\subsubsection{The IO and IOError Types}
The @IO@ type serves as a tag for operations (actions) that interact
with the outside world. The @IO@ type is abstract: no constructors are
visible to the user. @IO@ is an instance of the @Monad@ and
@Show@
classes. Section \ref{io} describes I/O operations.
visible to the user. @IO@ is an instance of the @Monad@ and
@Functor@
classes. Section \ref{io} describes I/O operations.
@IOError@ is an abstract type representing errors raised by I/O
operations. It is an instance of @Show@ and @Eq@. Values of this type
...
...
@@ 182,8 +182,8 @@ Report contains many more.
\subsubsection{Other Types}
\bprog
@
data Maybe a = Nothing  Just a
deriving (Eq, Ord, Read, Show)
data Either a b = Left a  Right b
deriving (Eq, Ord, Read, Show)
data Maybe a = Nothing  Just a
deriving (Eq, Ord, Read, Show)
data Either a b = Left a  Right b
deriving (Eq, Ord, Read, Show)
data Ordering = LT  EQ  GT deriving
(Eq, Ord, Bounded, Enum, Read, Show)
@
...
...
@@ 226,15 +226,15 @@ The function @seq@ is defined by the equations:
avoiding unneeded laziness. Strict datatypes (see
\index{strictness flags}
Section~\ref{strictnessflags}) are defined in terms of the @$!@
function
.
However,
i
t has important semantic consequences, because it is available
operator
.
However, t
he provision of @seq@
has important semantic consequences, because it is available
{\em at every type}.
As a consequence, "\bot" is
not the same as @\x > @ "\bot", since @seq@ can be used to distinguish them.
For the same reason, the existence of @seq@ weakens Haskell's parametricity properties.
The operator @$!@ is strict (callbyvalue) application, and is defined
in terms of @seq@. The Prelude also defines lazy application
, @$@
.
in terms of @seq@. The Prelude also defines
the @$@ operator to perform
lazy application.
\bprog
@
infixr 0 $, $!
...
...
@@ 280,7 +280,7 @@ of class @Eq@ is:
(==), (/=) :: a > a > Bool
x /= y = not (x == y)
x == y = not (x /= y)
x == y = not (x /= y)
@
\eprog
This declaration gives default method declarations for both @/=@ and @==@,
...
...
@@ 306,7 +306,7 @@ be given to fully specify an instance.
(==), (/=) :: a > a > Bool
x /= y = not (x == y)
x == y = not (x /= y)
x == y = not (x /= y)
@
\eprog
The @Eq@ class provides equality (@==@) and inequality (@/=@) methods.
...
...
@@ 328,16 +328,16 @@ constituents are also instances of @Eq@.
class (Eq a) => Ord a where
compare :: a > a > Ordering
(<), (<=), (>=), (>) :: a > a > Bool
max, min
:: a > a > a
max, min
:: a > a > a
compare x y  x == y = EQ
 x <= y = LT
 otherwise = GT
 x <= y = LT
 otherwise = GT
x <= y = compare x y /= GT
x <
y = compare x y == LT
x <
y = compare x y == LT
x >= y = compare x y /= LT
x >
y = compare x y == GT
x >
y = compare x y == GT
 Note that (min x y, max x y) = (x,y) or (y,x)
max x y  x <= y = y
...
...
@@ 389,7 +389,7 @@ class Show a where
showList :: [a] > ShowS
showsPrec _ x s = show x ++ s
show x
= showsPrec 0 x ""
show x
= showsPrec 0 x ""
 ... default decl for showList given in Prelude
@
\eprog
...
...
@@ 425,17 +425,17 @@ For convenience, the Prelude provides the following auxiliary
functions:
\bprog
@
reads
:: (Read a) => ReadS a
reads
= readsPrec 0
reads :: (Read a) => ReadS a
reads
= readsPrec 0
shows
:: (Show a) => a > ShowS
shows
= showsPrec 0
shows :: (Show a) => a > ShowS
shows
= showsPrec 0
read
:: (Read a) => String > a
read s
= case [x  (x,t) < reads s, ("","") < lex t] of
[x] > x
[] > error "PreludeText.read: no parse"
_ > error "PreludeText.read: ambiguous parse"
read :: (Read a) => String > a
read s
= case [x  (x,t) < reads s, ("","") < lex t] of
[x] > x
[] > error "PreludeText.read: no parse"
_ > error "PreludeText.read: ambiguous parse"
@
\eprog
\indextt{shows}\indextt{reads}\indextt{show}\indextt{read}
...
...
@@ 454,13 +454,13 @@ process. The @lex@ function used by @read@ is also part of the Prelude.
\bprog
@
class Enum a where
succ, pred
:: a > a
toEnum
:: Int > a
fromEnum
:: a > Int
enumFrom
:: a > [a]
 [n..]
enumFromThen
:: a > a > [a]
 [n,n'..]
enumFromTo
:: a > a > [a]
 [n..m]
enumFromThenTo
:: a > a > a > [a]
 [n,n'..m]
succ, pred
:: a > a
toEnum :: Int > a
fromEnum :: a > Int
enumFrom
:: a > [a]
 [n..]
enumFromThen
:: a > a > [a]
 [n,n'..]
enumFromTo
:: a > a > [a]
 [n..m]
enumFromThenTo
:: a > a > a > [a]
 [n,n'..m]
 Default declarations given in Prelude
@
...
...
@@ 503,7 +503,7 @@ Instances of @Functor@ should satisfy the following laws:
@fmap id@&=&@id@\\
@fmap (f . g)@&=&@fmap f . fmap g@\\
\ea\]
All instances defined in the Prelude satisfy these laws.
All instances
of @Functor@
defined in the Prelude satisfy these laws.
\subsubsection{Class @Monad@}
...
...
@@ 545,12 +545,14 @@ Instances of @Monad@ should satisfy the following laws:
@return a >>= k@&=&@k a@ \\
@m >>= return@&=&@m@ \\
@m >>= (\x > k x >>= h)@&=&@(m >>= k) >>= h@\\
\ea\]
Instances of both @Monad@ and @Functor@ should additionally satisfy the law:
\[\ba{lcl}
@fmap f xs@&=&@xs >>= return . f@\\
\ea\]
All instances defined in the Prelude satisfy these laws.
All instances
of @Monad@
defined in the Prelude satisfy these laws.
The Prelude provides the following auxiliary
functions:
The Prelude provides the following auxiliary functions:
\bprog
@
sequence :: Monad m => [m a] > m [a]
...
...
@@ 626,7 +628,7 @@ conform to current language independent arithmetic (LIA) standards. These
standards require considerably more complexity in the numeric
structure and have thus been relegated to a library. Some, but not
all, aspects of the IEEE floating point standard have been
accounted for in class @RealFloat@.
accounted for in
Prelude
class @RealFloat@.
b
The standard numeric types are listed in Table~\ref{standardnumerictypes}.
The finiteprecision integer type @Int@\indextycon{Int} covers at
...
...
@@ 677,31 +679,31 @@ builtin types that are instances of the numeric classes.
\outlinec{
@
class (Eq a, Show a) => Num a where
(+), (), (*)
:: a > a > a
negate
:: a > a
abs, signum
:: a > a
fromInteger
:: Integer > a
(+), (), (*)
:: a > a > a
negate
:: a > a
abs, signum
:: a > a
fromInteger
:: Integer > a
class (Num a, Ord a) => Real a where
toRational
:: a > Rational
toRational
:: a > Rational
class (Real a, Enum a) => Integral a where
quot, rem, div, mod
:: a > a > a
quotRem, divMod
:: a > a > (a,a)
toInteger
:: a > Integer
quot, rem, div, mod
:: a > a > a
quotRem, divMod
:: a > a > (a,a)
toInteger
:: a > Integer
class (Num a) => Fractional a where
(/)
:: a > a > a
recip
:: a > a
fromRational
:: Rational > a
(/)
:: a > a > a
recip
:: a > a
fromRational
:: Rational > a
class (Fractional a) => Floating a where
pi
:: a
exp, log, sqrt
:: a > a
(**), logBase
:: a > a > a
sin, cos, tan
:: a > a
asin, acos, atan
:: a > a
sinh, cosh, tanh
:: a > a
pi
:: a
exp, log, sqrt
:: a > a
(**), logBase
:: a > a > a
sin, cos, tan
:: a > a
asin, acos, atan
:: a > a
sinh, cosh, tanh
:: a > a
asinh, acosh, atanh :: a > a
@
}
...
...
@@ 735,29 +737,29 @@ class (Fractional a) => Floating a where
\outlinec{
@
class (Real a, Fractional a) => RealFrac a where
properFraction
:: (Integral b) => a > (b,a)
truncate, round
:: (Integral b) => a > b
ceiling, floor
:: (Integral b) => a > b
properFraction
:: (Integral b) => a > (b,a)
truncate, round
:: (Integral b) => a > b
ceiling, floor
:: (Integral b) => a > b
class (RealFrac a, Floating a) => RealFloat a where
floatRadix
:: a > Integer
floatDigits
:: a > Int
floatRange
:: a > (Int,Int)
decodeFloat
:: a > (Integer,Int)
encodeFloat
:: Integer > Int > a
exponent
:: a > Int
significand
:: a > a
scaleFloat
:: Int > a > a
floatRadix
:: a > Integer
floatDigits
:: a > Int
floatRange
:: a > (Int,Int)
decodeFloat
:: a > (Integer,Int)
encodeFloat
:: Integer > Int > a
exponent
:: a > Int
significand
:: a > a
scaleFloat
:: Int > a > a
isNaN, isInfinite, isDenormalized, isNegativeZero, isIEEE
:: a > Bool
atan2
:: a > a > a
atan2
:: a > a > a