Commit 1dcaf124 authored by Simon Marlow's avatar Simon Marlow
Browse files

update to latest generated by Haddock

parent 6f0896ed
......@@ -143,9 +143,6 @@ the identity of \haddockid{mplus}. It should also satisfy the equations
v >> mzero = mzero
\end{verbatim}}
\end{quote}
(but the instance for \haddocktt{System.IO.IO} defined in Control.Monad.Error
in the mtl package does not satisfy the second one).
\par
\end{haddockdesc}
\begin{haddockdesc}
......@@ -366,7 +363,7 @@ function' are not commutative.
\par
\begin{quote}
{\haddockverb\begin{verbatim}
foldM f a1 [x1, x2, ..., xm ]
foldM f a1 [x1, x2, ..., xm]
\end{verbatim}}
\end{quote}
==
......
......@@ -17,9 +17,8 @@ in particular, a programmer may reasonably expect rapid access to
the components. To ensure the possibility of such an implementation,
arrays are treated as data, not as general functions.
\par
Since most array functions involve the class \haddockid{Ix}, this module is exported
from \haddocktt{Data.Array} so that modules need not import both \haddocktt{Data.Array} and
\haddocktt{Data.Ix}.
Since most array functions involve the class \haddockid{Ix}, the contents of the
module \haddocktt{Data.Ix} are re-exported from \haddocktt{Data.Array} for convenience:
\par
\begin{haddockdesc}
......@@ -68,15 +67,13 @@ Construct an array with the specified bounds and containing values
for given indices within these bounds.
\par
The array is undefined (i.e. bottom) if any index in the list is
out of bounds. The Haskell 98 Report further specifies that if any
out of bounds. If any
two associations in the list have the same index, the value at that
index is undefined (i.e. bottom). However in GHC's implementation,
the value at such an index is the value part of the last association
with that index in the list.
index is undefined (i.e. bottom).
\par
Because the indices must be checked for these errors, \haddockid{array} is
strict in the bounds argument and in the indices of the association
list, but nonstrict in the values. Thus, recurrences such as the
list, but non-strict in the values. Thus, recurrences such as the
following are possible:
\par
\begin{quote}
......@@ -202,8 +199,7 @@ Constructs an array identical to the first argument except that it has
is the same matrix, except with the diagonal zeroed.
\par
Repeated indices in the association list are handled as for \haddockid{array}:
Haskell 98 specifies that the resulting array is undefined (i.e. bottom),
but GHC's implementation uses the last association for each index.
the resulting array is undefined (i.e. bottom),
\par
\end{haddockdesc}
......@@ -242,34 +238,28 @@ A similar transformation of array values may be achieved using \haddockid{fmap}
\begin{quote}
{\haddockverb\begin{verbatim}
module Array (
module Ix, -- export all of Ix
module Data.Ix, -- export all of Data.Ix
Array, array, listArray, (!), bounds, indices, elems, assocs,
accumArray, (//), accum, ixmap ) where
import Ix
import List( (\\) )
import Data.Ix
import Data.List( (\\) )
infixl 9 !, //
data (Ix a) => Array a b = MkArray (a,a) (a -> b) deriving ()
array :: (Ix a) => (a,a) -> [(a,b)] -> Array a b
array b ivs =
if and [inRange b i | (i,_) <- ivs]
then MkArray b
(\j -> case [v | (i,v) <- ivs, i == j] of
[v] -> v
[] -> error "Array.!: > \undefined array element"
\end{verbatim}}
\end{quote}
\begin{quote}
{\haddockverb\begin{verbatim}
_ -> error "Array.!: > \multiply defined array element")
\end{verbatim}}
\end{quote}
\begin{quote}
{\haddockverb\begin{verbatim}
else error "Array.array: out-of-range array association"
array b ivs
| any (not . inRange b. fst) ivs
= error "Data.Array.array: out-of-range array association"
| otherwise
= MkArray b arr
where
arr j = case [ v | (i,v) <- ivs, i == j ] of
[v] -> v
[] -> error "Data.Array.!: undefined array element"
_ -> error "Data.Array.!: multiply defined array element"
listArray :: (Ix a) => (a,a) -> [b] -> Array a b
listArray b vs = array b (zipWith (\ a b -> (a,b)) (range b) vs)
......@@ -292,9 +282,9 @@ A similar transformation of array values may be achieved using \haddockid{fmap}
(//) :: (Ix a) => Array a b -> [(a,b)] -> Array a b
a // new_ivs = array (bounds a) (old_ivs ++ new_ivs)
where
old_ivs = [(i,a!i) | i <- indices a,
old_ivs = [(i,a!i) | i <- indices a,
i `notElem` new_is]
new_is = [i | (i,_) <- new_ivs]
new_is = [i | (i,_) <- new_ivs]
accum :: (Ix a) => (b -> c -> b) -> Array a b -> [(a,c)]
-> Array a b
......
......@@ -109,8 +109,8 @@ The conjugate of a complex number.
}
\begin{quote}
{\haddockverb\begin{verbatim}
module Complex(Complex((:+)), realPart, imagPart, conjugate, mkPolar,
cis, polar, magnitude, phase) where
module Data.Complex(Complex((:+)), realPart, imagPart, conjugate, mkPolar,
cis, polar, magnitude, phase) where
infix 6 :+
......@@ -118,26 +118,26 @@ The conjugate of a complex number.
realPart, imagPart :: (RealFloat a) => Complex a -> a
realPart (x:+y) = x
imagPart (x:+y) = y
realPart (x:+y) = x
imagPart (x:+y) = y
conjugate :: (RealFloat a) => Complex a -> Complex a
conjugate :: (RealFloat a) => Complex a -> Complex a
conjugate (x:+y) = x :+ (-y)
mkPolar :: (RealFloat a) => a -> a -> Complex a
mkPolar r theta = r * cos theta :+ r * sin theta
mkPolar :: (RealFloat a) => a -> a -> Complex a
mkPolar r theta = r * cos theta :+ r * sin theta
cis :: (RealFloat a) => a -> Complex a
cis theta = cos theta :+ sin theta
cis :: (RealFloat a) => a -> Complex a
cis theta = cos theta :+ sin theta
polar :: (RealFloat a) => Complex a -> (a,a)
polar z = (magnitude z, phase z)
polar :: (RealFloat a) => Complex a -> (a,a)
polar z = (magnitude z, phase z)
magnitude :: (RealFloat a) => Complex a -> a
magnitude (x:+y) = scaleFloat k
(sqrt ((scaleFloat mk x)^2 + (scaleFloat mk y)^2))
where k = max (exponent x) (exponent y)
mk = - k
(sqrt ((scaleFloat mk x)^2 + (scaleFloat mk y)^2))
where k = max (exponent x) (exponent y)
mk = - k
phase :: (RealFloat a) => Complex a -> a
phase (0 :+ 0) = 0
......@@ -145,25 +145,25 @@ The conjugate of a complex number.
instance (RealFloat a) => Num (Complex a) where
(x:+y) + (x':+y') = (x+x') :+ (y+y')
(x:+y) - (x':+y') = (x-x') :+ (y-y')
(x:+y) * (x':+y') = (x*x'-y*y') :+ (x*y'+y*x')
negate (x:+y) = negate x :+ negate y
abs z = magnitude z :+ 0
signum 0 = 0
signum z@(x:+y) = x/r :+ y/r where r = magnitude z
fromInteger n = fromInteger n :+ 0
(x:+y) + (x':+y') = (x+x') :+ (y+y')
(x:+y) - (x':+y') = (x-x') :+ (y-y')
(x:+y) * (x':+y') = (x*x'-y*y') :+ (x*y'+y*x')
negate (x:+y) = negate x :+ negate y
abs z = magnitude z :+ 0
signum 0 = 0
signum z@(x:+y) = x/r :+ y/r where r = magnitude z
fromInteger n = fromInteger n :+ 0
instance (RealFloat a) => Fractional (Complex a) where
(x:+y) / (x':+y') = (x*x''+y*y'') / d :+ (y*x''-x*y'') / d
where x'' = scaleFloat k x'
y'' = scaleFloat k y'
k = - max (exponent x') (exponent y')
d = x'*x'' + y'*y''
fromRational a = fromRational a :+ 0
(x:+y) / (x':+y') = (x*x''+y*y'') / d :+ (y*x''-x*y'') / d
where x'' = scaleFloat k x'
y'' = scaleFloat k y'
k = - max (exponent x') (exponent y')
d = x'*x'' + y'*y''
fromRational a = fromRational a :+ 0
instance (RealFloat a) => Floating (Complex a) where
instance (RealFloat a) => Floating (Complex a) where
pi = pi :+ 0
exp (x:+y) = expx * cos y :+ expx * sin y
where expx = exp x
......
......@@ -25,26 +25,20 @@ An implementation is entitled to assume the following laws about these
\par
\begin{itemize}
\item
\begin{quote}
{\haddockverb\begin{verbatim}
inRange (l,u) i == elem i (range (l,u))\end{verbatim}}
\end{quote}
\haddocktt{inRange\ (l,u)\ i\ ==\ elem\ i\ (range\ (l,u))} \haddocktt{\ }
\par
\item
\haddocktt{range\ (l,u)\ !!\ index\ (l,u)\ i\ ==\ i}, when \haddocktt{inRange\ (l,u)\ i}
\par
\item
\begin{quote}
{\haddockverb\begin{verbatim}
map (index (l,u)) (range (l,u))) == [0..rangeSize (l,u)-1]\end{verbatim}}
\end{quote}
\haddocktt{map\ (index\ (l,u))\ (range\ (l,u)))\ ==\ {\char 91}0..rangeSize\ (l,u)-1{\char 93}} \haddocktt{\ }
\par
\item
\begin{quote}
{\haddockverb\begin{verbatim}
rangeSize (l,u) == length (range (l,u))\end{verbatim}}
\end{quote}
\haddocktt{rangeSize\ (l,u)\ ==\ length\ (range\ (l,u))} \haddocktt{\ }
\par
\end{itemize}
Minimal complete instance: \haddockid{range}, \haddockid{index} and \haddockid{inRange}.
......
......@@ -666,10 +666,10 @@ The \haddockid{stripPrefix} function drops the given prefix from a list.
\par
\begin{quote}
{\haddockverb\begin{verbatim}
stripPrefix "foo" "foobar" -> Just "bar"
stripPrefix "foo" "foo" -> Just ""
stripPrefix "foo" "barfoo" -> Nothing
stripPrefix "foo" "barfoobaz" -> Nothing
stripPrefix "foo" "foobar" == Just "bar"
stripPrefix "foo" "foo" == Just ""
stripPrefix "foo" "barfoo" == Nothing
stripPrefix "foo" "barfoobaz" == Nothing
\end{verbatim}}
\end{quote}
......@@ -753,8 +753,8 @@ Example:
\par
\begin{quote}
{\haddockverb\begin{verbatim}
isInfixOf "Haskell" "I really like Haskell." -> True
isInfixOf "Ial" "I really like Haskell." -> False
isInfixOf "Haskell" "I really like Haskell." == True
isInfixOf "Ial" "I really like Haskell." == False
\end{verbatim}}
\end{quote}
......
......@@ -125,7 +125,7 @@ The \haddockid{mapMaybe} function is a version of \haddockid{map} which can thro
}
\begin{quote}
{\haddockverb\begin{verbatim}
module Maybe(
module Data.Maybe(
Maybe(Nothing, Just),
isJust, isNothing,
fromJust, fromMaybe, listToMaybe, maybeToList,
......
......@@ -85,7 +85,7 @@ Any real interval contains a unique simplest rational;
}
\begin{quote}
{\haddockverb\begin{verbatim}
module Ratio (
module Data.Ratio (
Ratio, Rational, (%), numerator, denominator, approxRational ) where
infixl 7 %
......@@ -107,7 +107,7 @@ Any real interval contains a unique simplest rational;
-- E.g., 12 `reduce` 8 == 3 :% 2
-- 12 `reduce` (-8) == 3 :% (-2)
reduce _ 0 = error "Ratio.% : zero denominator"
reduce _ 0 = error "Data.Ratio.% : zero denominator"
reduce x y = (x `quot` d) :% (y `quot` d)
where d = gcd x y
......@@ -146,10 +146,10 @@ Any real interval contains a unique simplest rational;
succ x = x+1
pred x = x-1
toEnum = fromIntegral
fromEnum = fromInteger . truncate -- May overflow
enumFrom = numericEnumFrom -- These numericEnumXXX functions
enumFromThen = numericEnumFromThen -- are as defined in Prelude.hs
enumFromTo = numericEnumFromTo -- but not exported from it!
fromEnum = fromInteger . truncate -- May overflow
enumFrom = numericEnumFrom -- These numericEnumXXX functions
enumFromThen = numericEnumFromThen -- are as defined in Prelude.hs
enumFromTo = numericEnumFromTo -- but not exported from it!
enumFromThenTo = numericEnumFromThenTo
instance (Read a, Integral a) => Read (Ratio a) where
......@@ -160,9 +160,9 @@ Any real interval contains a unique simplest rational;
instance (Integral a) => Show (Ratio a) where
showsPrec p (x:%y) = showParen (p > ratPrec)
(showsPrec (ratPrec+1) x .
showString " % " .
showsPrec (ratPrec+1) y)
showsPrec (ratPrec+1) x .
showString " % " .
showsPrec (ratPrec+1) y)
......
......@@ -12,8 +12,7 @@ module Data.Word (
This module provides unsigned integer types of unspecified width (\haddockid{Word})
and fixed widths (\haddockid{Word8}, \haddockid{Word16}, \haddockid{Word32} and \haddockid{Word64}). All
arithmetic is performed modulo 2{\char '136}n, where \haddocktt{n} is the number of bits in
the type. One non-obvious consequence of this is that \haddockid{negate}
should \emph{not} raise an error on negative arguments.
the type.
\par
For coercing between any two integer types, use
\haddockid{fromIntegral}. Coercing word types to and from integer
......
......@@ -403,7 +403,7 @@ errnoToIOError
\\
\haddockdecltt{->} & \haddockdecltt{IOError} & \\
\end{tabulary}\par
Construct a Haskell 98 I/O error based on the given \haddockid{Errno} value.
Construct an \haddockid{IOError} based on the given \haddockid{Errno} value.
The optional information can be used to improve the accuracy of
error messages.
\par
......@@ -543,7 +543,7 @@ throwErrnoIfRetryMayBlock
\\
\haddockdecltt{->} & \haddockdecltt{IO a} & \\
\end{tabulary}\par
as \haddockid{throwErrnoIfRetry}, but additionlly if the operation
as \haddockid{throwErrnoIfRetry}, but additionally if the operation
yields the error code \haddockid{eAGAIN} or \haddockid{eWOULDBLOCK}, an alternative
action is executed before retrying.
\par
......
......@@ -342,13 +342,6 @@ data\ CTime
\end{tabular}]\haddockbegindoc
Haskell type representing the C \haddocktt{time{\char '137}t} type.
\par
To convert to a \haddocktt{Data.Time.UTCTime}, use the following formula:
\par
\begin{quote}
{\haddockverb\begin{verbatim}
posixSecondsToUTCTime (realToFrac :: POSIXTime)
\end{verbatim}}
\end{quote}
\end{haddockdesc}
\begin{haddockdesc}
......
......@@ -44,7 +44,7 @@ instance\ Eq\ (ForeignPtr\ a)\\instance\ Ord\ (ForeignPtr\ a)\\instance\ Show\ (
\item[\begin{tabular}{@{}l}
type\ FinalizerPtr\ a\ =\ FunPtr\ (Ptr\ a\ ->\ IO\ ())
\end{tabular}]\haddockbegindoc
A Finalizer is represented as a pointer to a foreign function that, at
A finalizer is represented as a pointer to a foreign function that, at
finalisation time, gets as an argument a plain pointer variant of the
foreign pointer that the finalizer is associated with.
\par
......@@ -103,7 +103,7 @@ This variant of \haddockid{newForeignPtr} adds a finalizer that expects an
\item[\begin{tabular}{@{}l}
addForeignPtrFinalizerEnv\ ::\ FinalizerEnvPtr\ env\ a\\\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ->\ Ptr\ env\ ->\ ForeignPtr\ a\ ->\ IO\ ()
\end{tabular}]\haddockbegindoc
like \haddockid{addForeignPtrFinalizerEnv} but allows the finalizer to be
Like \haddockid{addForeignPtrFinalizerEnv} but allows the finalizer to be
passed an additional environment parameter to be passed to the
finalizer. The environment passed to the finalizer is fixed by the
second argument to \haddockid{addForeignPtrFinalizerEnv}
......@@ -165,7 +165,7 @@ touchForeignPtr\ ::\ ForeignPtr\ a\ ->\ IO\ ()
\end{tabular}]\haddockbegindoc
This function ensures that the foreign object in
question is alive at the given place in the sequence of IO
actions. In particular \haddocktt{Foreign.ForeignPtr.withForeignPtr}
actions. In particular \haddockid{withForeignPtr}
does a \haddockid{touchForeignPtr} after it
executes the user action.
\par
......@@ -175,17 +175,12 @@ Note that this function should not be used to express dependencies
\haddockid{ForeignPtr} \haddocktt{F2}, then the only guarantee is that the finalizer
for \haddocktt{F2} is never started before the finalizer for \haddocktt{F1}. They
might be started together if for example both \haddocktt{F1} and \haddocktt{F2} are
otherwise unreachable, and in that case the scheduler might end up
running the finalizer for \haddocktt{F2} first.
otherwise unreachable.
\par
In general, it is not recommended to use finalizers on separate
objects with ordering constraints between them. To express the
ordering robustly requires explicit synchronisation using \haddocktt{MVar}s
between the finalizers, but even then the runtime sometimes runs
multiple finalizers sequentially in a single thread (for
performance reasons), so synchronisation between finalizers could
result in artificial deadlock. Another alternative is to use
explicit reference counting.
ordering robustly requires explicit synchronisation between
finalizers.
\par
\end{haddockdesc}
......
......@@ -86,10 +86,7 @@ Adjust the size of an array including an extra position for the end marker.
\item[\begin{tabular}{@{}l}
peekArray\ ::\ Storable\ a\ =>\ Int\ ->\ Ptr\ a\ ->\ IO\ {\char 91}a{\char 93}
\end{tabular}]\haddockbegindoc
Convert an array of given length into a Haskell list. This version
traverses the array backwards using an accumulating parameter,
which uses constant stack space. The previous version using mapM
needed linear stack space.
Convert an array of given length into a Haskell list.
\par
\end{haddockdesc}
......
......@@ -63,7 +63,7 @@ Convert a Boolean in numeric representation to a Haskell value
\item[\begin{tabular}{@{}l}
maybeNew\ ::\ (a\ ->\ IO\ (Ptr\ a))\ ->\ Maybe\ a\ ->\ IO\ (Ptr\ a)
\end{tabular}]\haddockbegindoc
Allocate storage and marshall a storable value wrapped into a \haddockid{Maybe}
Allocate storage and marshal a storable value wrapped into a \haddockid{Maybe}
\par
\begin{itemize}
\item
......
......@@ -102,7 +102,7 @@ A value of type \haddocktt{FunPtr\ a} is a pointer to a function callable
\begin{itemize}
\item
the argument types are \emph{marshallable foreign types},
i.e. \haddockid{Char}, \haddockid{Int}, \haddocktt{Prelude.Double}, \haddocktt{Prelude.Float},
i.e. \haddockid{Char}, \haddockid{Int}, \haddockid{Double}, \haddockid{Float},
\haddockid{Bool}, \haddocktt{Data.Int.Int8}, \haddocktt{Data.Int.Int16}, \haddocktt{Data.Int.Int32},
\haddocktt{Data.Int.Int64}, \haddocktt{Data.Word.Word8}, \haddocktt{Data.Word.Word16},
\haddocktt{Data.Word.Word32}, \haddocktt{Data.Word.Word64}, \haddocktt{Ptr\ a}, \haddocktt{FunPtr\ a},
......@@ -112,7 +112,7 @@ A value of type \haddocktt{FunPtr\ a} is a pointer to a function callable
\item
the return type is either a marshallable foreign type or has the form
\haddocktt{\haddocktt{Prelude.IO}\ t} where \haddocktt{t} is a marshallable foreign type or \haddocktt{()}.
\haddocktt{IO\ t} where \haddocktt{t} is a marshallable foreign type or \haddocktt{()}.
\par
\end{itemize}
......
......@@ -61,7 +61,7 @@ exitSuccess\ ::\ IO\ a
\end{tabular}]\haddockbegindoc
The computation \haddockid{exitSuccess} is equivalent to
\haddockid{exitWith} \haddockid{ExitSuccess}, It terminates the program
sucessfully.
successfully.
\par
\end{haddockdesc}
\ No newline at end of file
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