Commit 5807b057 authored by Simon Peyton Jones's avatar Simon Peyton Jones
Browse files

--------------------------------

	Just pre-CUP-publication version
	--------------------------------

Includes all the changes that are in the CUP published version,
but still as two separate reports.  Next thing to do is to merge them.
parent a5f54154
RELEASE_DIR = haskell98-revised
JFP_DIR = jfp-release
release:
(cd report; make release)
(cd libraries; make release)
(cd jfp-release; make)
cp h98-revised.html $(RELEASE_DIR)/index.html
cp haskell98-bugs.html h98.gif $(RELEASE_DIR)
gzip < jfp-release/h98-book.ps > $(RELEASE_DIR)/h98-book.ps.gz
gzip < jfp-release/h98-book.pdf > $(RELEASE_DIR)/h98-book.pdf.gz
jfp:
-mkdir $(JFP_DIR)
(cd report; make jfp)
(cd libraries; make jfp)
# Places to change when you change the date of the Report
# h98-revised.html
# report/index.html libraries/index.html
# report/html.config libraries/html.config
# report/haskell.verb libraries/library.verb
This diff is collapsed.
......@@ -40,6 +40,7 @@ EXPAND = expand
# generator so I'm changing the .verb files to lower case -- jcp
RELEASE_DIR = ../haskell98-revised
JFP_DIR = ../jfp-release
PARTS = library.tex introduction.tex ratio.tex complex.tex ix.tex \
numeric.tex \
......@@ -140,6 +141,12 @@ release: library.ps html
publish-pdf: library.pdf
gzip < library.pdf > y:Haskell/haskell98-library/library.pdf.gz
jfp: ${PARTS} ${CODE} ${HEADERS} index-intro.tex
-mkdir $(JFP_DIR)
-mkdir $(JFP_DIR)/code
-mkdir $(JFP_DIR)/headers
for n in ${PARTS} ${CODE} ${HEADERS}; do \
../tools/subsection < $$n > $(JFP_DIR)/$$n ; done
#########################################
# Suffix rules
......
......@@ -59,7 +59,7 @@ a single digit @Char@ and the corresponding @Int@.
@digitToInt@ operates fails unless its argument satisfies @isHexDigit@,
but recognises both upper and lower-case hexadecimal digits (i.e. @'0'@..@'9'@,
@'a'@..@'f'@, @'A'@..@'F'@). @intToDigit@ fails unless its argument is in the range
@0@..@15@, and generates lower-case hexadecmial digits.
@0@..@15@, and generates lower-case hexadecimal digits.
The @isSpace@ function recognizes only white characters in the Latin-1
range.
......@@ -74,7 +74,7 @@ to the character that it encodes. For example:
@
showLitChar '\n' s = "\\n" ++ s
lexLitChar "\\nHello" = [("\\n", "Hello")]
readLitChar "\\nHello" = [("\n", "Hello")]
readLitChar "\\nHello" = [('\n', "Hello")]
@
\eprog
......
......@@ -69,13 +69,17 @@ instance (Ix a, Ord b) => Ord (Array a b) where
a <= a' = assocs a <= assocs a'
instance (Ix a, Show a, Show b) => Show (Array a b) where
showsPrec p a = showParen (p > 9) (
showsPrec p a = showParen (p > arrPrec) (
showString "array " .
shows (bounds a) . showChar ' ' .
shows (assocs a) )
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 > 9)
(\r -> [(array b as, u) | ("array",s) <- lex r,
(b,t) <- reads s,
(as,u) <- reads t ])
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
......@@ -6,7 +6,7 @@ module Char (
ord, chr,
readLitChar, showLitChar, lexLitChar,
-- ...and what the Prelude exports
-- ...and what the Prelude exports
Char, String
) where
......@@ -27,11 +27,11 @@ isControl c = c < ' ' || c >= '\DEL' && c <= '\x9f'
isPrint = primUnicodeIsPrint
isSpace c = c `elem` " \t\n\r\f\v\xA0"
-- Only Latin-1 spaces recognized
-- Only Latin-1 spaces recognized
isUpper = primUnicodeIsUpper -- 'A'..'Z'
isUpper = primUnicodeIsUpper -- 'A'..'Z'
isLower = primUnicodeIsLower -- 'a'..'z'
isLower = primUnicodeIsLower -- 'a'..'z'
isAlpha c = isUpper c || isLower c
......@@ -61,52 +61,52 @@ intToDigit i
-- Case-changing operations
toUpper :: Char -> Char
toUpper = primUnicodeToUpper
toLower :: Char -> Char
toLower = primUnicodeToLower
toUpper :: Char -> Char
toUpper = primUnicodeToUpper
toLower :: Char -> Char
toLower = primUnicodeToLower
-- Character code functions
ord :: Char -> Int
ord = fromEnum
chr :: Int -> Char
chr = toEnum
ord :: Char -> Int
ord = fromEnum
chr :: Int -> Char
chr = toEnum
-- Text functions
readLitChar :: ReadS Char
readLitChar ('\\':s) = readEsc s
where
readEsc ('a':s) = [('\a',s)]
readEsc ('b':s) = [('\b',s)]
readEsc ('f':s) = [('\f',s)]
readEsc ('n':s) = [('\n',s)]
readEsc ('r':s) = [('\r',s)]
readEsc ('t':s) = [('\t',s)]
readEsc ('v':s) = [('\v',s)]
readEsc ('\\':s) = [('\\',s)]
readEsc ('"':s) = [('"',s)]
readEsc ('\'':s) = [('\'',s)]
readEsc ('^':c:s) | c >= '@' && c <= '_'
= [(chr (ord c - ord '@'), s)]
readEsc s@(d:_) | isDigit d
= [(chr n, t) | (n,t) <- readDec s]
readEsc ('o':s) = [(chr n, t) | (n,t) <- readOct s]
readEsc ('x':s) = [(chr n, t) | (n,t) <- readHex s]
readEsc s@(c:_) | isUpper c
= let table = ('\DEL', "DEL") : assocs asciiTab
in case [(c,s') | (c, mne) <- table,
([],s') <- [match mne s]]
of (pr:_) -> [pr]
[] -> []
readEsc _ = []
match :: (Eq a) => [a] -> [a] -> ([a],[a])
match (x:xs) (y:ys) | x == y = match xs ys
match xs ys = (xs,ys)
readLitChar (c:s) = [(c,s)]
readLitChar :: ReadS Char
readLitChar ('\\':s) = readEsc s
readLitChar (c:s) = [(c,s)]
readEsc :: ReadS Char
readEsc ('a':s) = [('\a',s)]
readEsc ('b':s) = [('\b',s)]
readEsc ('f':s) = [('\f',s)]
readEsc ('n':s) = [('\n',s)]
readEsc ('r':s) = [('\r',s)]
readEsc ('t':s) = [('\t',s)]
readEsc ('v':s) = [('\v',s)]
readEsc ('\\':s) = [('\\',s)]
readEsc ('"':s) = [('"',s)]
readEsc ('\'':s) = [('\'',s)]
readEsc ('^':c:s) | c >= '@' && c <= '_'
= [(chr (ord c - ord '@'), s)]
readEsc s@(d:_) | isDigit d
= [(chr n, t) | (n,t) <- readDec s]
readEsc ('o':s) = [(chr n, t) | (n,t) <- readOct s]
readEsc ('x':s) = [(chr n, t) | (n,t) <- readHex s]
readEsc s@(c:_) | isUpper c
= let table = ('\DEL', "DEL") : assocs asciiTab
in case [(c,s') | (c, mne) <- table,
([],s') <- [match mne s]]
of (pr:_) -> [pr]
[] -> []
readEsc _ = []
match :: (Eq a) => [a] -> [a] -> ([a],[a])
match (x:xs) (y:ys) | x == y = match xs ys
match xs ys = (xs,ys)
showLitChar :: Char -> ShowS
showLitChar c | c > '\DEL' = showChar '\\' .
......@@ -135,15 +135,22 @@ asciiTab = listArray ('\NUL', ' ')
"SP"]
lexLitChar :: ReadS String
lexLitChar ('\\':s) = [('\\':esc, t) | (esc,t) <- lexEsc s]
lexLitChar ('\\':s) = map (prefix '\\') (lexEsc s)
where
lexEsc (c:s) | c `elem` "abfnrtv\\\"'" = [([c],s)]
lexEsc s@(d:_) | isDigit d = lexDigits s
lexEsc ('^':c:s) | c >= '@' && c <= '_' = [(['^',c],s)]
-- Very crude approximation to \XYZ. Let readers work this out.
lexEsc s@(c:_) | isUpper c = [span isCharName s]
lexEsc _ = []
isCharName c = isUpper c || isDigit c
-- 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)
lexLitChar (c:s) = [([c],s)]
lexLitChar "" = []
......
module IO {- export list omitted -} where
-- Just provide an implementation of the system-indendent
-- Just provide an implementation of the system-independent
-- actions that IO exports.
try :: IO a -> IO (Either IOError a)
......
module Ix ( Ix(range, index, inRange), rangeSize ) where
module Ix ( Ix(range, index, inRange, rangeSize) ) where
class Ix a where
class Ord a => Ix a where
range :: (a,a) -> [a]
index :: (a,a) -> a -> Int
inRange :: (a,a) -> a -> Bool
......
......@@ -313,7 +313,7 @@ floatToDigits base x =
-- This floating point reader uses a less restrictive syntax for floating
-- point than the Haskell lexer. The `.' is optional.
readFloat :: (RealFloat a) => ReadS a
readFloat :: (RealFrac a) => ReadS a
readFloat r = [(fromRational ((n%1)*10^^(k-d)),t) | (n,d,s) <- readFix r,
(k,t) <- readExp s] ++
[ (0/0, t) | ("NaN",t) <- lex r] ++
......
......@@ -5,7 +5,7 @@ module Ratio (
infixl 7 %
prec = 7 :: Int
ratPrec = 7 :: Int
data (Integral a) => Ratio a = !a :% !a deriving (Eq)
type Rational = Ratio Integer
......@@ -58,6 +58,8 @@ instance (Integral a) => RealFrac (Ratio a) where
where (q,r) = quotRem x y
instance (Integral a) => Enum (Ratio a) where
succ x = x+1
pred x = x-1
toEnum = fromIntegral
fromEnum = fromInteger . truncate -- May overflow
enumFrom = numericEnumFrom -- These numericEnumXXX functions
......@@ -66,14 +68,16 @@ instance (Integral a) => Enum (Ratio a) where
enumFromThenTo = numericEnumFromThenTo
instance (Read a, Integral a) => Read (Ratio a) where
readsPrec p = readParen (p > prec)
(\r -> [(x%y,u) | (x,s) <- reads r,
readsPrec p = readParen (p > ratPrec)
(\r -> [(x%y,u) | (x,s) <- readsPrec (ratPrec+1) r,
("%",t) <- lex s,
(y,u) <- reads t ])
(y,u) <- readsPrec (ratPrec+1) t ])
instance (Integral a) => Show (Ratio a) where
showsPrec p (x:%y) = showParen (p > prec)
(shows x . showString " % " . shows y)
showsPrec p (x:%y) = showParen (p > ratPrec)
(showsPrec (ratPrec+1) x .
showString " % " .
showsPrec (ratPrec+1) y)
......
module Ix ( Ix(range, index, inRange), rangeSize ) where
module Ix ( Ix(range, index, inRange, rangeSize) ) where
class Ix a where
class Ord a => Ix a where
range :: (a,a) -> [a]
index :: (a,a) -> a -> Int
inRange :: (a,a) -> a -> Bool
......
......@@ -29,5 +29,5 @@ showFloat :: (RealFloat a) => a -> ShowS
floatToDigits :: (RealFloat a) => Integer -> a -> ([Int], Int)
readFloat :: (RealFloat a) => ReadS a
readFloat :: (RealFrac a) => ReadS a
lexDigits :: ReadS String
......@@ -33,7 +33,7 @@ style=article
~back=<a href="~prev.html">back</a>
~nxt=<a href="~next.html">next</a>
~contents=<a href="libindex.html">contents</a>
~foot=<br><font size=2>December 2001</font>
~foot=<br><font size=2>Sept 2002</font>
~footer=<hr>~id~top | ~back | ~nxt | ~contents ~foot
~sfooter=<hr>~id~top | back | ~nxt | ~contents ~foot
~efooter=<hr>~id~top | ~back | next | ~contents ~foot
......
......@@ -7,7 +7,7 @@
<img src="h98-libs.gif" alt="Haskell 98 Libraries">
<h3 align="center">Standard Libraries for Haskell 98</h3>
<h3 align="center">Revised: December 2001</h3>
<h3 align="center">Revised: Sept 2002</h3>
</div>
<hr>
<h3>Table of Contents</h3>
......
......@@ -33,6 +33,7 @@ including
Olaf Chitil,
Mark Carroll,
Tony Davie,
Hal Daume,
Sigbjorn Finne,
Andy Gill,
Mike Gunter,
......
......@@ -259,7 +259,9 @@ permission to open the file.
Computation @hClose@~"hdl"\indextt{hClose} makes handle "hdl" closed. Before the
computation finishes, if "hdl" is writable its buffer is flushed as
for @hFlush@.
If the operation fails for any reason, any further operations on the
Performing @hClose@ 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 @hClose@ fails for any reason, any further operations (apart from @hClose@) on the
handle will still fail as if "hdl" had been successfully closed.
\subsection{Determining the Size of a File}
......@@ -478,16 +480,27 @@ within "t" milliseconds.
Computation @hReady@~"hdl"\indextt{hReady} indicates whether at least one item is
available for input from handle "hdl".
{\em Error reporting}.
The @hWaitForInput@ and @hReady@ computations fail with
@isEOFError@ if the end of file has been reached.
\subsubsection{Reading Input}
Computation @hGetChar@~"hdl"\indextt{hGetChar} reads a character from
the file or channel managed by "hdl".
Computation @hGetLine@~"hdl"\indextt{hGetLine} reads a line from
the file or channel managed by "hdl", similar to @getLine@ in the
Prelude.
{\em Error reporting}:
the @hWaitForInput@, @hReady@ and @hGetChar@ computations may fail with:
Computation @hGetLine@~"hdl"\indextt{hGetLine} reads a line from the file or
channel managed by "hdl". The Prelude's @getLine@ is a shorthand
for @hGetLine stdin@.
{\em Error reporting}.
The @hGetChar@ computation fails with
@isEOFError@ if the end of file has been reached.
The @hGetLine@ fails with @isEOFError@ if the end of file is encountered
when reading the {\em first} character of the line. If @hGetLine@ 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.
\subsubsection{Reading Ahead}
\label{hLookAhead}
......
%
% $Header: /home/cvs/root/haskell-report/libraries/library.verb,v 1.12 2001/12/21 16:00:22 simonpj Exp $
% $Header: /home/cvs/root/haskell-report/libraries/library.verb,v 1.13 2002/12/02 11:22:00 simonpj Exp $
%
% NOTE:--------------------------------------------------------------
% The formatting of this report and the ``new font selection scheme''
......@@ -412,7 +412,7 @@
{\Large\bf for the} \\[.1in]
{\huge\bf Haskell 98} \\[.3in]
{\LARGE\bf Programming Language} \\[.3in]
{\large\bf Revised: December 2001}
{\large\bf Revised: Sept 2002}
\end{center}
\vspace{.15in}
......
......@@ -32,8 +32,9 @@ or Nothing, if there is no such element.
There are a number of ``set'' operations defined over the @List@ type.
@nub@ (meaning ``essence'') removes duplicates elements from a list.
@delete@, @(\\)@, @union@ and @intersect@ preserve the invariant that
lists don't contain duplicates, provided that their first argument
@delete@, @(\\)@, @union@ and @intersect@ (and their @By@ variants)
preserve the invariant their result
does not contain duplicates, provided that their first argument
contains no duplicates.
\begin{itemize}
......@@ -72,7 +73,7 @@ has been removed from @xs@. Thus, @(xs ++ ys) \\ xs == ys@.
@intersect@\indextt{intersect} is list intersection, e.g.,
\bprog
@
intersect [1,2,3,4] `intersect` [2,4,6,8] == [2,4]
[1,2,3,4] `intersect` [2,4,6,8] == [2,4]
@
\eprog
\end{itemize}
......@@ -194,18 +195,18 @@ counterpart whose name is suffixed with ``@By@''. For example, the
function @nub@ could be defined as follows:
\bprog
@
nub :: (Eq a) => [a] -> [a]
nub [] = []
nub (x:xs) = x : nub (filter (\y -> x /= y) xs)
nub :: (Eq a) => [a] -> [a]
nub [] = []
nub (x:xs) = x : nub (filter (\y -> not (x == y)) xs)
@
\eprog
However, the equality method may not be appropriate in all situations.
The function:
\bprog
@
nubBy :: (a -> a -> Bool) -> [a] -> [a]
nubBy eq [] = []
nubBy eq (x:xs) = x : nubBy eq (filter (\y -> not (eq x y)) xs)
nubBy :: (a -> a -> Bool) -> [a] -> [a]
nubBy eq [] = []
nubBy eq (x:xs) = x : nubBy eq (filter (\y -> not (eq x y)) xs)
@
\eprog
allows the programmer to supply their own equality test.
......@@ -249,7 +250,7 @@ a generalised version of a @Prelude@ function. For example,
genericLength :: Integral a => [b] -> a
@
\eprog
is a generalised verion of @length@.
is a generalised version of @length@.
The ``@generic@'' operations are as follows:
@genericLength@, @genericTake@, @genericDrop@,
......
......@@ -67,13 +67,19 @@ then the following properties hold:
\item @readSigned :: (Real a) => ReadS a -> ReadS a@ \\
reads a {\em signed} @Real@ value,
given a reader for an unsigned value.
\item @readInt :: (Integral a) => a -> (Char->Bool) -> (Char->Int) -> ReadS a@
\item @readInt :: (Integral a) => a -> (Char->Bool) -> (Char->Int) -> ReadS a@ \\
reads an {\em unsigned} @Integral@ value in an arbitrary base. In the call "(@readInt@~ base ~isdig ~d2i)",
"base" is the base, "isdig" is a predicate distinguishing valid digits in this base, and "d2i" converts
a valid digit character to an @Int@.
\item @readFloat :: (RealFrac a) => ReadS a@ \\
reads an {\em unsigned} @RealFrac@ value, expressed in decimal scientific notation.
\item @readDec, readOct, readHex :: (Integral a) => ReadS a@ \\
each read an unsigned number, in decimal, octal, and hexadecimal notation respectively.
In the hexadecimal case, both upper or lower case letters are allowed.
\item @lexDigits :: ReadS String@ reads a non-empty string of decimal digits.
\end{itemize}
(NB: @readInt@ is the ``dual'' of @showIntAtBase@, and @readDec@ is the ``dual'' of @showInt@.
......
# Makefile for the Haskell Report
# read the README file before you start!
#
# Target 'jfp' copies stuff into $(JFP_DIR) for the JFP book
# you need to do the same in the libraries directory
##########################################
# What to make if you type 'make'
default: haskell.ps.gz html
default: haskell.ps html
# Begin by saying
# touch haskell.idx
......@@ -38,8 +41,10 @@ EXPAND = expand
#########################################
RELEASE_DIR = ../haskell98-revised
JFP_DIR = ../jfp-release
PARTS = preface-13.tex iso-chars.tex \
PARTS = preface-jfp.tex $(PARTS_NO_PREFACE)
PARTS_NO_PREFACE = iso-chars.tex \
intro.tex lexemes.tex exps.tex \
decls.tex modules.tex basic.tex io-13.tex \
derived.tex \
......@@ -162,6 +167,14 @@ release: haskell.ps html
publish-pdf: report.pdf
gzip < report.pdf > y:Haskell/haskell98-report/report.pdf.gz
jfp: h98-book.tex preface-jfp.tex ${PARTS_NO_PREFACE} $(SYNTAX) ${PRELUDE}
-mkdir $(JFP_DIR)
for n in h98-book.tex preface-jfp.tex \
${PARTS_NO_PREFACE} $(SYNTAX) ${PRELUDE} ; do \
../tools/subsection < $$n > $(JFP_DIR)/$$n ; done
cp classes.eps $(JFP_DIR)
cp haskell.bbl $(JFP_DIR)/h98-book.bbl
cp Makefile-jfp-book $(JFP_DIR)/Makefile
#########################################
# Suffix rules
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment