summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHerbert Valerio Riedel <hvr@gnu.org>2014-11-07 16:26:59 +0100
committerHerbert Valerio Riedel <hvr@gnu.org>2014-11-07 17:23:34 +0100
commitdf3b1d43cc862fe03f0724a9c0ac9e7cecdf4605 (patch)
tree2b18cef139638c86d35025e934b07ec2c484cd0e
parent832ef3fb8f45f98add9dbfac5387281e3e0bc5dc (diff)
downloadhaskell-df3b1d43cc862fe03f0724a9c0ac9e7cecdf4605.tar.gz
base: Manually unlit .lhs into .hs modules
This commit mostly converts literate comments into ordinary Haskell comments or sometimes even Haddock comments, while also removing literate comments in a few cases where they don't make much sense anymore. Moreover, in a few cases trailing whitespaces were removed as well. Reviewed By: austin Differential Revision: https://phabricator.haskell.org/D456
-rw-r--r--libraries/base/GHC/Arr.hs (renamed from libraries/base/GHC/Arr.lhs)70
-rw-r--r--libraries/base/GHC/Base.hs (renamed from libraries/base/GHC/Base.lhs)153
-rw-r--r--libraries/base/GHC/Conc.hs (renamed from libraries/base/GHC/Conc.lhs)7
-rw-r--r--libraries/base/GHC/Enum.hs (renamed from libraries/base/GHC/Enum.lhs)91
-rw-r--r--libraries/base/GHC/Err.hs (renamed from libraries/base/GHC/Err.lhs)33
-rw-r--r--libraries/base/GHC/Exception.hs (renamed from libraries/base/GHC/Exception.lhs)22
-rw-r--r--libraries/base/GHC/Exception.hs-boot (renamed from libraries/base/GHC/Exception.lhs-boot)18
-rw-r--r--libraries/base/GHC/Float.hs (renamed from libraries/base/GHC/Float.lhs)121
-rw-r--r--libraries/base/GHC/List.hs (renamed from libraries/base/GHC/List.lhs)53
-rw-r--r--libraries/base/GHC/Num.hs (renamed from libraries/base/GHC/Num.lhs)36
-rw-r--r--libraries/base/GHC/Pack.hs (renamed from libraries/base/GHC/Pack.lhs)12
-rw-r--r--libraries/base/GHC/Ptr.hs (renamed from libraries/base/GHC/Ptr.lhs)15
-rw-r--r--libraries/base/GHC/Read.hs (renamed from libraries/base/GHC/Read.lhs)74
-rw-r--r--libraries/base/GHC/Real.hs (renamed from libraries/base/GHC/Real.lhs)121
-rw-r--r--libraries/base/GHC/ST.hs (renamed from libraries/base/GHC/ST.lhs)20
-rw-r--r--libraries/base/GHC/STRef.hs (renamed from libraries/base/GHC/STRef.lhs)3
-rw-r--r--libraries/base/GHC/Show.hs (renamed from libraries/base/GHC/Show.lhs)65
-rw-r--r--libraries/base/GHC/Stable.hs (renamed from libraries/base/GHC/Stable.lhs)11
-rw-r--r--libraries/base/GHC/Storable.hs (renamed from libraries/base/GHC/Storable.lhs)70
-rw-r--r--libraries/base/GHC/TopHandler.hs (renamed from libraries/base/GHC/TopHandler.lhs)3
-rw-r--r--libraries/base/GHC/Weak.hs (renamed from libraries/base/GHC/Weak.lhs)3
21 files changed, 254 insertions, 747 deletions
diff --git a/libraries/base/GHC/Arr.lhs b/libraries/base/GHC/Arr.hs
index 2b30091b52..0d5099366b 100644
--- a/libraries/base/GHC/Arr.lhs
+++ b/libraries/base/GHC/Arr.hs
@@ -1,4 +1,3 @@
-\begin{code}
{-# LANGUAGE Unsafe #-}
{-# LANGUAGE NoImplicitPrelude, MagicHash, UnboxedTuples #-}
{-# OPTIONS_GHC -funbox-strict-fields #-}
@@ -52,16 +51,7 @@ import GHC.Show
infixl 9 !, //
default ()
-\end{code}
-
-%*********************************************************
-%* *
-\subsection{The @Ix@ class}
-%* *
-%*********************************************************
-
-\begin{code}
-- | The 'Ix' class is used to map a contiguous subrange of values in
-- a type onto integers. It is used primarily for array indexing
-- (see the array package).
@@ -116,8 +106,8 @@ class (Ord a) => Ix a where
-- tuples. E.g. (1,2) <= (2,1) but the range is empty
unsafeRangeSize b@(_l,h) = unsafeIndex b h + 1
-\end{code}
+{-
Note that the following is NOT right
rangeSize (l,h) | l <= h = index b h + 1
| otherwise = 0
@@ -128,11 +118,6 @@ is nevertheless empty. Consider
Here l<h, but the second index ranges from 2..1 and
hence is empty
-%*********************************************************
-%* *
-\subsection{Instances of @Ix@}
-%* *
-%*********************************************************
Note [Inlining index]
~~~~~~~~~~~~~~~~~~~~~
@@ -179,8 +164,8 @@ Note [Out-of-bounds error messages]
The default method for 'index' generates hoplelessIndexError, because
Ix doesn't have Show as a superclass. For particular base types we
can do better, so we override the default method for index.
+-}
-\begin{code}
-- Abstract these errors from the relevant index functions so that
-- the guts of the function will be small enough to inline.
@@ -369,15 +354,7 @@ instance (Ix a1, Ix a2, Ix a3, Ix a4, Ix a5) => Ix (a1,a2,a3,a4,a5) where
inRange (l5,u5) i5
-- Default method for index
-\end{code}
-
-%*********************************************************
-%* *
-\subsection{The @Array@ types}
-%* *
-%*********************************************************
-\begin{code}
-- | The type of immutable non-strict (boxed) arrays
-- with indices in @i@ and elements in @e@.
data Array i e
@@ -411,16 +388,10 @@ data STArray s i e
instance Eq (STArray s i e) where
STArray _ _ _ arr1# == STArray _ _ _ arr2# =
isTrue# (sameMutableArray# arr1# arr2#)
-\end{code}
+----------------------------------------------------------------------
+-- Operations on immutable arrays
-%*********************************************************
-%* *
-\subsection{Operations on immutable arrays}
-%* *
-%*********************************************************
-
-\begin{code}
{-# NOINLINE arrEleBottom #-}
arrEleBottom :: a
arrEleBottom = error "(Array.!): undefined array element"
@@ -718,16 +689,10 @@ cmpIntArray arr1@(Array l1 u1 n1 _) arr2@(Array l2 u2 n2 _) =
other -> other
{-# RULES "cmpArray/Int" cmpArray = cmpIntArray #-}
-\end{code}
-
-%*********************************************************
-%* *
-\subsection{Array instances}
-%* *
-%*********************************************************
+----------------------------------------------------------------------
+-- Array instances
-\begin{code}
instance Ix i => Functor (Array i) where
fmap = amap
@@ -747,15 +712,11 @@ instance (Ix a, Show a, Show b) => Show (Array a b) where
-- Precedence of 'array' is the precedence of application
-- The Read instance is in GHC.Read
-\end{code}
-
-%*********************************************************
-%* *
-\subsection{Operations on mutable arrays}
-%* *
-%*********************************************************
+----------------------------------------------------------------------
+-- Operations on mutable arrays
+{-
Idle ADR question: What's the tradeoff here between flattening these
datatypes into @STArray ix ix (MutableArray# s elt)@ and using
it as is? As I see it, the former uses slightly less heap and
@@ -768,8 +729,8 @@ Idle AJG answer: When I looked at the outputted code (though it was 2
years ago) it seems like you often needed the tuple, and we build
it frequently. Now we've got the overloading specialiser things
might be different, though.
+-}
-\begin{code}
{-# INLINE newSTArray #-}
newSTArray :: Ix i => (i,i) -> e -> ST s (STArray s i e)
newSTArray (l,u) initial = ST $ \s1# ->
@@ -805,16 +766,10 @@ unsafeWriteSTArray :: Ix i => STArray s i e -> Int -> e -> ST s ()
unsafeWriteSTArray (STArray _ _ _ marr#) (I# i#) e = ST $ \s1# ->
case writeArray# marr# i# e s1# of
s2# -> (# s2#, () #)
-\end{code}
+----------------------------------------------------------------------
+-- Moving between mutable and immutable
-%*********************************************************
-%* *
-\subsection{Moving between mutable and immutable}
-%* *
-%*********************************************************
-
-\begin{code}
freezeSTArray :: Ix i => STArray s i e -> ST s (Array i e)
freezeSTArray (STArray l u n@(I# n#) marr#) = ST $ \s1# ->
case newArray# n# arrEleBottom s1# of { (# s2#, marr'# #) ->
@@ -849,4 +804,3 @@ unsafeThawSTArray :: Ix i => Array i e -> ST s (STArray s i e)
unsafeThawSTArray (Array l u n arr#) = ST $ \s1# ->
case unsafeThawArray# arr# s1# of { (# s2#, marr# #) ->
(# s2#, STArray l u n marr# #) }
-\end{code}
diff --git a/libraries/base/GHC/Base.lhs b/libraries/base/GHC/Base.hs
index 217f6addd5..501a6d5693 100644
--- a/libraries/base/GHC/Base.lhs
+++ b/libraries/base/GHC/Base.hs
@@ -1,5 +1,4 @@
-\section[GHC.Base]{Module @GHC.Base@}
-
+{-
The overall structure of the GHC Prelude is a bit tricky.
a) We want to avoid "orphan modules", i.e. ones with instance
@@ -60,8 +59,8 @@ GHC.Float Classes: Floating, RealFloat
Other Prelude modules are much easier with fewer complex dependencies.
+-}
-\begin{code}
{-# LANGUAGE Unsafe #-}
{-# LANGUAGE CPP
, NoImplicitPrelude
@@ -127,8 +126,8 @@ infixr 0 $, $!
infixl 4 <*>, <*, *>, <**>
default () -- Double isn't available yet
-\end{code}
+{-
Note [Depend on GHC.Integer]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The Integer type is special because TidyPgm uses
@@ -159,16 +158,10 @@ Similarly, tuple syntax (or ()) creates an implicit dependency on
GHC.Tuple, so we use the same rule as for Integer --- see Note [Depend on
GHC.Integer] --- to explain this to the build system. We make GHC.Base
depend on GHC.Tuple, and everything else depends on GHC.Base or Prelude.
+-}
-%*********************************************************
-%* *
-\subsection{DEBUGGING STUFF}
-%* (for use when compiling GHC.Base itself doesn't work)
-%* *
-%*********************************************************
-
-\begin{code}
-{-
+#if 0
+-- for use when compiling GHC.Base itself doesn't work
data Bool = False | True
data Ordering = LT | EQ | GT
data Char = C# Char#
@@ -183,16 +176,7 @@ otherwise = True
build = error "urk"
foldr = error "urk"
--}
-
-\end{code}
-
-%*********************************************************
-%* *
-\subsection{The Maybe type}
-%* *
-%*********************************************************
-\begin{code}
+#endif
-- | The 'Maybe' type encapsulates an optional value. A value of type
-- @'Maybe' a@ either contains a value of type @a@ (represented as @'Just' a@),
@@ -207,16 +191,6 @@ foldr = error "urk"
data Maybe a = Nothing | Just a
deriving (Eq, Ord)
-\end{code}
-
-%*********************************************************
-%* *
-\subsection{Monoids}
-%* *
-%*********************************************************
-\begin{code}
-
--- ---------------------------------------------------------------------------
-- | The class of monoids (types with an associative binary operation that
-- has an identity). Instances should satisfy the following laws:
--
@@ -309,16 +283,8 @@ instance Monoid a => Monoid (Maybe a) where
instance Monoid a => Applicative ((,) a) where
pure x = (mempty, x)
(u, f) <*> (v, x) = (u `mappend` v, f x)
-\end{code}
-%*********************************************************
-%* *
-\subsection{Monadic classes @Functor@, @Applicative@, @Monad@ }
-%* *
-%*********************************************************
-
-\begin{code}
{- | The 'Functor' class is used for types that can be mapped over.
Instances of 'Functor' should satisfy the following laws:
@@ -696,16 +662,10 @@ class (Alternative m, Monad m) => MonadPlus m where
mplus = (<|>)
instance MonadPlus Maybe
-\end{code}
-
-%*********************************************************
-%* *
-\subsection{The list type}
-%* *
-%*********************************************************
+----------------------------------------------
+-- The list type
-\begin{code}
instance Functor [] where
fmap = map
@@ -724,16 +684,16 @@ instance Alternative [] where
(<|>) = (++)
instance MonadPlus []
-\end{code}
+{-
A few list functions that appear here because they are used here.
The rest of the prelude list functions are in GHC.List.
+-}
----------------------------------------------
-- foldr/build/augment
----------------------------------------------
-\begin{code}
-- | 'foldr', applied to a binary operator, a starting value (typically
-- the right-identity of the operator), and a list, reduces the list
-- using the binary operator, from right to left:
@@ -820,14 +780,11 @@ augment g xs = g (:) xs
-- This rule is true, but not (I think) useful:
-- augment g (augment h t) = augment (\cn -> g c (h c n)) t
-\end{code}
-
----------------------------------------------
-- map
----------------------------------------------
-\begin{code}
-- | 'map' @f xs@ is the list obtained by applying @f@ to each element
-- of @xs@, i.e.,
--
@@ -877,13 +834,11 @@ mapFB c f = \x ys -> c (f x) ys
{-# RULES "map/coerce" [1] map coerce = coerce #-}
-\end{code}
-
----------------------------------------------
-- append
----------------------------------------------
-\begin{code}
+
-- | Append two lists, i.e.,
--
-- > [x1, ..., xm] ++ [y1, ..., yn] == [x1, ..., xm, y1, ..., yn]
@@ -902,16 +857,7 @@ mapFB c f = \x ys -> c (f x) ys
"++" [~1] forall xs ys. xs ++ ys = augment (\c n -> foldr c n xs) ys
#-}
-\end{code}
-
-%*********************************************************
-%* *
-\subsection{Type @Bool@}
-%* *
-%*********************************************************
-
-\begin{code}
-- |'otherwise' is defined as the value 'True'. It helps to make
-- guards more readable. eg.
--
@@ -919,15 +865,11 @@ mapFB c f = \x ys -> c (f x) ys
-- > | otherwise = ...
otherwise :: Bool
otherwise = True
-\end{code}
-%*********************************************************
-%* *
-\subsection{Type @Char@ and @String@}
-%* *
-%*********************************************************
+----------------------------------------------
+-- Type Char and String
+----------------------------------------------
-\begin{code}
-- | A 'String' is a list of characters. String constants in Haskell are values
-- of type 'String'.
--
@@ -939,11 +881,9 @@ unsafeChr (I# i#) = C# (chr# i#)
-- | The 'Prelude.fromEnum' method restricted to the type 'Data.Char.Char'.
ord :: Char -> Int
ord (C# c#) = I# (ord# c#)
-\end{code}
-
-String equality is used when desugaring pattern-matches against strings.
-\begin{code}
+-- | This 'String' equality predicate is used when desugaring
+-- pattern-matches against strings.
eqString :: String -> String -> Bool
eqString [] [] = True
eqString (c1:cs1) (c2:cs2) = c1 == c2 && cs1 `eqString` cs2
@@ -952,16 +892,12 @@ eqString _ _ = False
{-# RULES "eqString" (==) = eqString #-}
-- eqString also has a BuiltInRule in PrelRules.lhs:
-- eqString (unpackCString# (Lit s1)) (unpackCString# (Lit s2) = s1==s2
-\end{code}
-%*********************************************************
-%* *
-\subsection{Type @Int@}
-%* *
-%*********************************************************
+----------------------------------------------
+-- 'Int' related definitions
+----------------------------------------------
-\begin{code}
maxInt, minInt :: Int
{- Seems clumsy. Should perhaps put minInt and MaxInt directly into MachDeps.h -}
@@ -975,16 +911,11 @@ maxInt = I# 0x7FFFFFFF#
minInt = I# (-0x8000000000000000#)
maxInt = I# 0x7FFFFFFFFFFFFFFF#
#endif
-\end{code}
-
-%*********************************************************
-%* *
-\subsection{The function type}
-%* *
-%*********************************************************
+----------------------------------------------
+-- The function type
+----------------------------------------------
-\begin{code}
-- | Identity function.
id :: a -> a
id x = x
@@ -1062,15 +993,11 @@ until p f = go
-- (which is usually overloaded) to have the same type as the second.
asTypeOf :: a -> a -> a
asTypeOf = const
-\end{code}
-%*********************************************************
-%* *
-\subsection{@Functor@ and @Monad@ instances for @IO@}
-%* *
-%*********************************************************
+----------------------------------------------
+-- Functor/Applicative/Monad instances for IO
+----------------------------------------------
-\begin{code}
instance Functor IO where
fmap f x = x >>= (return . f)
@@ -1098,14 +1025,8 @@ thenIO (IO m) k = IO $ \ s -> case m s of (# new_s, _ #) -> unIO k new_s
unIO :: IO a -> (State# RealWorld -> (# State# RealWorld, a #))
unIO (IO a) = a
-\end{code}
-
-%*********************************************************
-%* *
-\subsection{@getTag@}
-%* *
-%*********************************************************
+{- |
Returns the 'tag' of a constructor application; this function is used
by the deriving code for Eq, Ord and Enum.
@@ -1117,23 +1038,18 @@ dataToTag# can be an inline primop if it doesn't need to do any
evaluation, and (b) we want to expose the evaluation to the
simplifier, because it might be possible to eliminate the evaluation
in the case when the argument is already known to be evaluated.
-
-\begin{code}
+-}
{-# INLINE getTag #-}
getTag :: a -> Int#
getTag !x = dataToTag# x
-\end{code}
-%*********************************************************
-%* *
-\subsection{Numeric primops}
-%* *
-%*********************************************************
+----------------------------------------------
+-- Numeric primops
+----------------------------------------------
-Definitions of the boxed PrimOps; these will be
-used in the case of partial applications, etc.
+-- Definitions of the boxed PrimOps; these will be
+-- used in the case of partial applications, etc.
-\begin{code}
{-# INLINE quotInt #-}
{-# INLINE remInt #-}
@@ -1217,14 +1133,11 @@ a `iShiftRL#` b | isTrue# (b >=# WORD_SIZE_IN_BITS#) = 0#
-- unpackFoldr "foo" c (unpackFoldr "baz" c n) = unpackFoldr "foobaz" c n
#-}
-\end{code}
#ifdef __HADDOCK__
-\begin{code}
-- | A special argument for the 'Control.Monad.ST.ST' type constructor,
-- indexing a state embedded in the 'Prelude.IO' monad by
-- 'Control.Monad.ST.stToIO'.
data RealWorld
-\end{code}
#endif
diff --git a/libraries/base/GHC/Conc.lhs b/libraries/base/GHC/Conc.hs
index 1ba17f2912..f1708b33d4 100644
--- a/libraries/base/GHC/Conc.lhs
+++ b/libraries/base/GHC/Conc.hs
@@ -1,4 +1,3 @@
-\begin{code}
{-# LANGUAGE Unsafe #-}
{-# LANGUAGE CPP, NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-missing-signatures #-}
@@ -9,13 +8,13 @@
-- Module : GHC.Conc
-- Copyright : (c) The University of Glasgow, 1994-2002
-- License : see libraries/base/LICENSE
---
+--
-- Maintainer : cvs-ghc@haskell.org
-- Stability : internal
-- Portability : non-portable (GHC extensions)
--
-- Basic concurrency stuff.
---
+--
-----------------------------------------------------------------------------
-- No: #hide, because bits of this module are exposed by the stm package.
@@ -112,5 +111,3 @@ import GHC.Conc.Sync
#ifndef mingw32_HOST_OS
import GHC.Conc.Signal
#endif
-
-\end{code}
diff --git a/libraries/base/GHC/Enum.lhs b/libraries/base/GHC/Enum.hs
index 4e36ad4fec..b634516820 100644
--- a/libraries/base/GHC/Enum.lhs
+++ b/libraries/base/GHC/Enum.hs
@@ -1,4 +1,3 @@
-\begin{code}
{-# LANGUAGE Trustworthy #-}
{-# LANGUAGE CPP, NoImplicitPrelude, BangPatterns, MagicHash #-}
{-# OPTIONS_HADDOCK hide #-}
@@ -34,16 +33,7 @@ import GHC.Integer
import GHC.Num
import GHC.Show
default () -- Double isn't available yet
-\end{code}
-
-%*********************************************************
-%* *
-\subsection{Class declarations}
-%* *
-%*********************************************************
-
-\begin{code}
-- | The 'Bounded' class is used to name the upper and lower limits of a
-- type. 'Ord' is not a superclass of 'Bounded' since types that are not
-- totally ordered may also have upper and lower bounds.
@@ -125,9 +115,7 @@ boundedEnumFromThen n1 n2
where
i_n1 = fromEnum n1
i_n2 = fromEnum n2
-\end{code}
-\begin{code}
------------------------------------------------------------------------
-- Helper functions
------------------------------------------------------------------------
@@ -157,16 +145,11 @@ succError inst_ty =
predError :: String -> a
predError inst_ty =
error $ "Enum.pred{" ++ inst_ty ++ "}: tried to take `pred' of minBound"
-\end{code}
-
-%*********************************************************
-%* *
-\subsection{Tuples}
-%* *
-%*********************************************************
+------------------------------------------------------------------------
+-- Tuples
+------------------------------------------------------------------------
-\begin{code}
instance Bounded () where
minBound = ()
maxBound = ()
@@ -183,9 +166,7 @@ instance Enum () where
enumFromThen () () = let many = ():many in many
enumFromTo () () = [()]
enumFromThenTo () () () = let many = ():many in many
-\end{code}
-\begin{code}
-- Report requires instances up to 15
instance (Bounded a, Bounded b) => Bounded (a,b) where
minBound = (minBound, minBound)
@@ -274,16 +255,11 @@ instance (Bounded a, Bounded b, Bounded c, Bounded d, Bounded e, Bounded f, Boun
minBound, minBound, minBound, minBound, minBound, minBound, minBound)
maxBound = (maxBound, maxBound, maxBound, maxBound, maxBound, maxBound, maxBound, maxBound,
maxBound, maxBound, maxBound, maxBound, maxBound, maxBound, maxBound)
-\end{code}
+------------------------------------------------------------------------
+-- Bool
+------------------------------------------------------------------------
-%*********************************************************
-%* *
-\subsection{Type @Bool@}
-%* *
-%*********************************************************
-
-\begin{code}
instance Bounded Bool where
minBound = False
maxBound = True
@@ -305,15 +281,11 @@ instance Enum Bool where
-- Use defaults for the rest
enumFrom = boundedEnumFrom
enumFromThen = boundedEnumFromThen
-\end{code}
-%*********************************************************
-%* *
-\subsection{Type @Ordering@}
-%* *
-%*********************************************************
+------------------------------------------------------------------------
+-- Ordering
+------------------------------------------------------------------------
-\begin{code}
instance Bounded Ordering where
minBound = LT
maxBound = GT
@@ -339,15 +311,11 @@ instance Enum Ordering where
-- Use defaults for the rest
enumFrom = boundedEnumFrom
enumFromThen = boundedEnumFromThen
-\end{code}
-%*********************************************************
-%* *
-\subsection{Type @Char@}
-%* *
-%*********************************************************
+------------------------------------------------------------------------
+-- Char
+------------------------------------------------------------------------
-\begin{code}
instance Bounded Char where
minBound = '\0'
maxBound = '\x10FFFF'
@@ -461,21 +429,19 @@ go_dn_char_list x0 delta lim
where
go_dn x | isTrue# (x <# lim) = []
| otherwise = C# (chr# x) : go_dn (x +# delta)
-\end{code}
-%*********************************************************
-%* *
-\subsection{Type @Int@}
-%* *
-%*********************************************************
+------------------------------------------------------------------------
+-- Int
+------------------------------------------------------------------------
+{-
Be careful about these instances.
(a) remember that you have to count down as well as up e.g. [13,12..0]
(b) be careful of Int overflow
(c) remember that Int is bounded, so [1..] terminates at maxInt
+-}
-\begin{code}
instance Bounded Int where
minBound = minInt
maxBound = maxInt
@@ -628,16 +594,12 @@ efdtIntDnFB c n x1 x2 y -- Be careful about underflow!
go_dn x | isTrue# (x <# y') = I# x `c` n
| otherwise = I# x `c` go_dn (x +# delta)
in I# x1 `c` go_dn x2
-\end{code}
-%*********************************************************
-%* *
-\subsection{Type @Word@}
-%* *
-%*********************************************************
+------------------------------------------------------------------------
+-- Word
+------------------------------------------------------------------------
-\begin{code}
instance Bounded Word where
minBound = 0
@@ -685,16 +647,11 @@ integerToWordX i = W# (integerToWord i)
wordToIntegerX :: Word -> Integer
wordToIntegerX (W# x#) = wordToInteger x#
-\end{code}
-
-%*********************************************************
-%* *
-\subsection{The @Integer@ instance for @Enum@}
-%* *
-%*********************************************************
+------------------------------------------------------------------------
+-- Integer
+------------------------------------------------------------------------
-\begin{code}
instance Enum Integer where
succ x = x + 1
pred x = x - 1
@@ -772,5 +729,3 @@ dn_list x0 delta lim = go (x0 :: Integer)
where
go x | x < lim = []
| otherwise = x : go (x+delta)
-\end{code}
-
diff --git a/libraries/base/GHC/Err.lhs b/libraries/base/GHC/Err.hs
index f7679842e0..9bd71327d9 100644
--- a/libraries/base/GHC/Err.lhs
+++ b/libraries/base/GHC/Err.hs
@@ -1,4 +1,3 @@
-\begin{code}
{-# LANGUAGE Trustworthy #-}
{-# LANGUAGE NoImplicitPrelude, MagicHash #-}
{-# OPTIONS_HADDOCK hide #-}
@@ -8,18 +7,18 @@
-- Module : GHC.Err
-- Copyright : (c) The University of Glasgow, 1994-2002
-- License : see libraries/base/LICENSE
---
+--
-- Maintainer : cvs-ghc@haskell.org
-- Stability : internal
-- Portability : non-portable (GHC extensions)
--
-- The "GHC.Err" module defines the code for the wired-in error functions,
-- which have a special type in the compiler (with \"open tyvars\").
---
+--
-- We cannot define these functions in a module where they might be used
-- (e.g., "GHC.Base"), because the magical wired-in type will get confused
-- with what the typechecker figures out.
---
+--
-----------------------------------------------------------------------------
module GHC.Err( absentErr, error, undefined ) where
@@ -30,15 +29,7 @@ import GHC.Integer () -- Make sure Integer is compiled first
-- because GHC depends on it in a wired-in way
-- so the build system doesn't see the dependency
import {-# SOURCE #-} GHC.Exception( errorCallException )
-\end{code}
-
-%*********************************************************
-%* *
-\subsection{Error-ish functions}
-%* *
-%*********************************************************
-\begin{code}
-- | 'error' stops execution and displays an error message.
error :: [Char] -> a
error s = raise# (errorCallException s)
@@ -46,23 +37,11 @@ error s = raise# (errorCallException s)
-- | A special case of 'error'.
-- It is expected that compilers will recognize this and insert error
-- messages which are more appropriate to the context in which 'undefined'
--- appears.
-
+-- appears.
undefined :: a
undefined = error "Prelude.undefined"
-\end{code}
-
-%*********************************************************
-%* *
-\subsection{Compiler generated errors + local utils}
-%* *
-%*********************************************************
-Used for compiler-generated error message;
-encoding saves bytes of string junk.
-
-\begin{code}
+-- | Used for compiler-generated error message;
+-- encoding saves bytes of string junk.
absentErr :: a
absentErr = error "Oops! The program has entered an `absent' argument!\n"
-\end{code}
-
diff --git a/libraries/base/GHC/Exception.lhs b/libraries/base/GHC/Exception.hs
index e5bb0f9aaa..7a7c8c20fa 100644
--- a/libraries/base/GHC/Exception.lhs
+++ b/libraries/base/GHC/Exception.hs
@@ -1,4 +1,3 @@
-\begin{code}
{-# LANGUAGE Trustworthy #-}
{-# LANGUAGE NoImplicitPrelude
, ExistentialQuantification
@@ -34,15 +33,7 @@ import Data.Typeable (Typeable, cast)
-- loop: Data.Typeable -> GHC.Err -> GHC.Exception
import GHC.Base
import GHC.Show
-\end{code}
-%*********************************************************
-%* *
-\subsection{Exceptions}
-%* *
-%*********************************************************
-
-\begin{code}
{- |
The @SomeException@ type is the root of the exception type hierarchy.
When an exception of type @e@ is thrown, behind the scenes it is
@@ -152,22 +143,12 @@ class (Typeable e, Show e) => Exception e where
instance Exception SomeException where
toException se = se
fromException = Just
-\end{code}
-
-%*********************************************************
-%* *
-\subsection{Primitive throw}
-%* *
-%*********************************************************
-\begin{code}
-- | Throw an exception. Exceptions may be thrown from purely
-- functional code, but may only be caught within the 'IO' monad.
throw :: Exception e => e -> a
throw e = raise# (toException e)
-\end{code}
-\begin{code}
-- |This is thrown when the user calls 'error'. The @String@ is the
-- argument given to 'error'.
newtype ErrorCall = ErrorCall String
@@ -181,8 +162,6 @@ instance Show ErrorCall where
errorCallException :: String -> SomeException
errorCallException s = toException (ErrorCall s)
------
-
-- |Arithmetic exceptions.
data ArithException
= Overflow
@@ -207,4 +186,3 @@ instance Show ArithException where
showsPrec _ DivideByZero = showString "divide by zero"
showsPrec _ Denormal = showString "denormal"
showsPrec _ RatioZeroDenominator = showString "Ratio has zero denominator"
-\end{code}
diff --git a/libraries/base/GHC/Exception.lhs-boot b/libraries/base/GHC/Exception.hs-boot
index f93d806755..aa19897363 100644
--- a/libraries/base/GHC/Exception.lhs-boot
+++ b/libraries/base/GHC/Exception.hs-boot
@@ -1,3 +1,7 @@
+{-# LANGUAGE Trustworthy #-}
+{-# LANGUAGE NoImplicitPrelude #-}
+
+{-
This SOURCE-imported hs-boot module cuts a big dependency loop:
GHC.Exception
@@ -18,21 +22,13 @@ imports {-# SOURCE #-} GHC.Exception
However, GHC.Exceptions loop-breaking exports are all nice,
well-behaved, non-bottom values. The clients use 'raise#'
to get a visibly-bottom value.
-
-\begin{code}
-{-# LANGUAGE Trustworthy #-}
-{-# LANGUAGE NoImplicitPrelude #-}
-
----------------------------------------------------------------------------
--- Ghc.Exception.hs-boot
----------------------------------------------------------------------------
+-}
module GHC.Exception ( SomeException, errorCallException,
- divZeroException, overflowException, ratioZeroDenomException
- ) where
+ divZeroException, overflowException, ratioZeroDenomException
+ ) where
import GHC.Types( Char )
data SomeException
divZeroException, overflowException, ratioZeroDenomException :: SomeException
errorCallException :: [Char] -> SomeException
-\end{code}
diff --git a/libraries/base/GHC/Float.lhs b/libraries/base/GHC/Float.hs
index 4918e2a019..74d7cb8f01 100644
--- a/libraries/base/GHC/Float.lhs
+++ b/libraries/base/GHC/Float.hs
@@ -1,4 +1,3 @@
-\begin{code}
{-# LANGUAGE Trustworthy #-}
{-# LANGUAGE CPP
, NoImplicitPrelude
@@ -47,15 +46,11 @@ import GHC.Integer.Logarithms ( integerLogBase# )
import GHC.Integer.Logarithms.Internals
infixr 8 **
-\end{code}
-%*********************************************************
-%* *
-\subsection{Standard numeric classes}
-%* *
-%*********************************************************
+------------------------------------------------------------------------
+-- Standard numeric classes
+------------------------------------------------------------------------
-\begin{code}
-- | Trigonometric and hyperbolic functions and related functions.
class (Fractional a) => Floating a where
pi :: a
@@ -183,16 +178,11 @@ class (RealFrac a, Floating a) => RealFloat a where
= pi -- must be after the previous test on zero y
| x==0 && y==0 = y -- must be after the other double zero tests
| otherwise = x + y -- x or y is a NaN, return a NaN (via +)
-\end{code}
+------------------------------------------------------------------------
+-- Float
+------------------------------------------------------------------------
-%*********************************************************
-%* *
-\subsection{Type @Float@}
-%* *
-%*********************************************************
-
-\begin{code}
instance Num Float where
(+) x y = plusFloat x y
(-) x y = minusFloat x y
@@ -350,15 +340,11 @@ instance RealFloat Float where
instance Show Float where
showsPrec x = showSignedFloat showFloat x
showList = showList__ (showsPrec 0)
-\end{code}
-%*********************************************************
-%* *
-\subsection{Type @Double@}
-%* *
-%*********************************************************
+------------------------------------------------------------------------
+-- Double
+------------------------------------------------------------------------
-\begin{code}
instance Num Double where
(+) x y = plusDouble x y
(-) x y = minusDouble x y
@@ -512,14 +498,13 @@ instance RealFloat Double where
instance Show Double where
showsPrec x = showSignedFloat showFloat x
showList = showList__ (showsPrec 0)
-\end{code}
-%*********************************************************
-%* *
-\subsection{@Enum@ instances}
-%* *
-%*********************************************************
+------------------------------------------------------------------------
+-- Enum instances
+------------------------------------------------------------------------
+
+{-
The @Enum@ instances for Floats and Doubles are slightly unusual.
The @toEnum@ function truncates numbers to Int. The definitions
of @enumFrom@ and @enumFromThen@ allow floats to be used in arithmetic
@@ -532,8 +517,8 @@ methods for @enumFromTo@ and @enumFromThenTo@, as these rely on there being
a `non-lossy' conversion to and from Ints. Instead we make use of the
1.2 default methods (back in the days when Enum had Ord as a superclass)
for these (@numericEnumFromTo@ and @numericEnumFromThenTo@ below.)
+-}
-\begin{code}
instance Enum Float where
succ x = x + 1
pred x = x - 1
@@ -553,17 +538,11 @@ instance Enum Double where
enumFromTo = numericEnumFromTo
enumFromThen = numericEnumFromThen
enumFromThenTo = numericEnumFromThenTo
-\end{code}
-
-%*********************************************************
-%* *
-\subsection{Printing floating point}
-%* *
-%*********************************************************
+------------------------------------------------------------------------
+-- Printing floating point
+------------------------------------------------------------------------
-
-\begin{code}
-- | Show a signed 'RealFloat' value to full precision
-- using standard decimal notation for arguments whose absolute value lies
-- between @0.1@ and @9,999,999@, and scientific notation otherwise.
@@ -771,15 +750,11 @@ floatToDigits base x =
in
(map fromIntegral (reverse rds), k)
-\end{code}
-
-
-%*********************************************************
-%* *
-\subsection{Converting from a Rational to a RealFloat
-%* *
-%*********************************************************
+------------------------------------------------------------------------
+-- Converting from a Rational to a RealFloa
+------------------------------------------------------------------------
+{-
[In response to a request for documentation of how fromRational works,
Joe Fasel writes:] A quite reasonable request! This code was added to
the Prelude just before the 1.2 release, when Lennart, working with an
@@ -827,9 +802,9 @@ fromRat x = x'
/ fromInteger (denominator x))
\end{pseudocode}
-Now, here's Lennart's code (which works)
+Now, here's Lennart's code (which works):
+-}
-\begin{code}
-- | Converts a 'Rational' value into any type in class 'RealFloat'.
{-# RULES
"fromRat/Float" fromRat = (fromRational :: Rational -> Float)
@@ -910,8 +885,7 @@ integerLogBase b i
| b == 2 = I# (integerLog2# i)
| otherwise = I# (integerLogBase# b i)
-\end{code}
-
+{-
Unfortunately, the old conversion code was awfully slow due to
a) a slow integer logarithm
b) repeated calculation of gcd's
@@ -924,8 +898,8 @@ of division.
The below is an adaption of fromRat' for the conversion to
Float or Double exploiting the known floatRadix and avoiding
divisions as much as possible.
+-}
-\begin{code}
{-# SPECIALISE fromRat'' :: Int -> Int -> Integer -> Integer -> Float,
Int -> Int -> Integer -> Integer -> Double #-}
fromRat'' :: RealFloat a => Int -> Int -> Integer -> Integer -> a
@@ -992,19 +966,14 @@ fromRat'' minEx@(I# me#) mantDigs@(I# md#) n d =
then q else q+1
GT -> q+1
in encodeFloat rdq p'
-\end{code}
-
-%*********************************************************
-%* *
-\subsection{Floating point numeric primops}
-%* *
-%*********************************************************
+------------------------------------------------------------------------
+-- Floating point numeric primops
+------------------------------------------------------------------------
-Definitions of the boxed PrimOps; these will be
-used in the case of partial applications, etc.
+-- Definitions of the boxed PrimOps; these will be
+-- used in the case of partial applications, etc.
-\begin{code}
plusFloat, minusFloat, timesFloat, divideFloat :: Float -> Float -> Float
plusFloat (F# x) (F# y) = F# (plusFloat# x y)
minusFloat (F# x) (F# y) = F# (minusFloat# x y)
@@ -1087,9 +1056,7 @@ tanhDouble (D# x) = D# (tanhDouble# x)
powerDouble :: Double -> Double -> Double
powerDouble (D# x) (D# y) = D# (x **## y)
-\end{code}
-\begin{code}
foreign import ccall unsafe "isFloatNaN" isFloatNaN :: Float -> Int
foreign import ccall unsafe "isFloatInfinite" isFloatInfinite :: Float -> Int
foreign import ccall unsafe "isFloatDenormalized" isFloatDenormalized :: Float -> Int
@@ -1101,15 +1068,10 @@ foreign import ccall unsafe "isDoubleInfinite" isDoubleInfinite :: Double -> Int
foreign import ccall unsafe "isDoubleDenormalized" isDoubleDenormalized :: Double -> Int
foreign import ccall unsafe "isDoubleNegativeZero" isDoubleNegativeZero :: Double -> Int
foreign import ccall unsafe "isDoubleFinite" isDoubleFinite :: Double -> Int
-\end{code}
-
-%*********************************************************
-%* *
-\subsection{Coercion rules}
-%* *
-%*********************************************************
-\begin{code}
+------------------------------------------------------------------------
+-- Coercion rules
+------------------------------------------------------------------------
word2Double :: Word -> Double
word2Double (W# w) = D# (word2Double# w)
@@ -1129,8 +1091,8 @@ word2Float (W# w) = F# (word2Float# w)
"realToFrac/Int->Double" realToFrac = int2Double -- See Note [realToFrac int-to-float]
"realToFrac/Int->Float" realToFrac = int2Float -- ..ditto
#-}
-\end{code}
+{-
Note [realToFrac int-to-float]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Don found that the RULES for realToFrac/Int->Double and simliarly
@@ -1167,14 +1129,10 @@ with the native backend, and 0.143 seconds with the C backend.
A few more details in Trac #2251, and the patch message
"Add RULES for realToFrac from Int".
+-}
-%*********************************************************
-%* *
-\subsection{Utils}
-%* *
-%*********************************************************
+-- Utils
-\begin{code}
showSignedFloat :: (RealFloat a)
=> (a -> ShowS) -- ^ a function that can show unsigned values
-> Int -- ^ the precedence of the enclosing context
@@ -1184,13 +1142,12 @@ showSignedFloat showPos p x
| x < 0 || isNegativeZero x
= showParen (p > 6) (showChar '-' . showPos (-x))
| otherwise = showPos x
-\end{code}
+{-
We need to prevent over/underflow of the exponent in encodeFloat when
called from scaleFloat, hence we clamp the scaling parameter.
We must have a large enough range to cover the maximum difference of
exponents returned by decodeFloat.
-\begin{code}
+-}
clamp :: Int -> Int -> Int
clamp bd k = max (-bd) (min bd k)
-\end{code}
diff --git a/libraries/base/GHC/List.lhs b/libraries/base/GHC/List.hs
index da4c386564..19c771bdab 100644
--- a/libraries/base/GHC/List.lhs
+++ b/libraries/base/GHC/List.hs
@@ -1,4 +1,3 @@
-\begin{code}
{-# LANGUAGE Trustworthy #-}
{-# LANGUAGE CPP, NoImplicitPrelude, ScopedTypeVariables, MagicHash #-}
{-# LANGUAGE BangPatterns #-}
@@ -41,15 +40,11 @@ import GHC.Integer (Integer)
infixl 9 !!
infix 4 `elem`, `notElem`
-\end{code}
-%*********************************************************
-%* *
-\subsection{List-manipulation functions}
-%* *
-%*********************************************************
+--------------------------------------------------------------
+-- List-manipulation functions
+--------------------------------------------------------------
-\begin{code}
-- | Extract the first element of a list, which must be non-empty.
head :: [a] -> a
head (x:_) = x
@@ -844,10 +839,6 @@ concat = foldr (++) []
-- We don't bother to turn non-fusible applications of concat back into concat
#-}
-\end{code}
-
-
-\begin{code}
-- | List index (subscript) operator, starting from 0.
-- It is an instance of the more general 'Data.List.genericIndex',
-- which takes an index of any integral type.
@@ -876,16 +867,11 @@ xs !! n
0 -> x
_ -> r (k-1)) tooLarge xs n
#endif
-\end{code}
-
-%*********************************************************
-%* *
-\subsection{The zip family}
-%* *
-%*********************************************************
+--------------------------------------------------------------
+-- The zip family
+--------------------------------------------------------------
-\begin{code}
foldr2 :: (a -> b -> c -> c) -> c -> [a] -> [b] -> c
foldr2 k z = go
where
@@ -911,11 +897,10 @@ foldr2_right k _z y r (x:xs) = k x y (r xs)
"foldr2/right" forall k z xs (g::forall b.(a->b->b)->b->b) .
foldr2 k z xs (build g) = g (foldr2_right k z) (\_ -> z) xs
#-}
-\end{code}
-Zips for larger tuples are in the List module.
-\begin{code}
+-- Zips for larger tuples are in the List module.
+
----------------------------------------------
-- | 'zip' takes two lists and returns a list of corresponding pairs.
-- If one input list is short, excess elements of the longer list are
@@ -945,9 +930,7 @@ zipFB c = \x y r -> (x,y) `c` r
"zip" [~1] forall xs ys. zip xs ys = build (\c n -> foldr2 (zipFB c) n xs ys)
"zipList" [1] foldr2 (zipFB (:)) [] = zip
#-}
-\end{code}
-\begin{code}
----------------------------------------------
-- | 'zip3' takes three lists and returns a list of triples, analogous to
-- 'zip'.
@@ -956,13 +939,11 @@ zip3 :: [a] -> [b] -> [c] -> [(a,b,c)]
-- zip3 = zipWith3 (,,)
zip3 (a:as) (b:bs) (c:cs) = (a,b,c) : zip3 as bs cs
zip3 _ _ _ = []
-\end{code}
-- The zipWith family generalises the zip family by zipping with the
-- function given as the first argument, instead of a tupling function.
-\begin{code}
----------------------------------------------
-- | 'zipWith' generalises 'zip' by zipping with the function given
-- as the first argument, instead of a tupling function.
@@ -996,9 +977,7 @@ zipWithFB c f = \x y r -> (x `f` y) `c` r
"zipWith" [~1] forall f xs ys. zipWith f xs ys = build (\c n -> foldr2 (zipWithFB c f) n xs ys)
"zipWithList" [1] forall f. foldr2 (zipWithFB (:) f) [] = zipWith f
#-}
-\end{code}
-\begin{code}
-- | The 'zipWith3' function takes a function which combines three
-- elements, as well as three lists and returns a list of their point-wise
-- combination, analogous to 'zipWith'.
@@ -1019,23 +998,17 @@ unzip3 :: [(a,b,c)] -> ([a],[b],[c])
{-# INLINE unzip3 #-}
unzip3 = foldr (\(a,b,c) ~(as,bs,cs) -> (a:as,b:bs,c:cs))
([],[],[])
-\end{code}
-
-%*********************************************************
-%* *
-\subsection{Error code}
-%* *
-%*********************************************************
+--------------------------------------------------------------
+-- Error code
+--------------------------------------------------------------
-Common up near identical calls to `error' to reduce the number
-constant strings created when compiled:
+-- Common up near identical calls to `error' to reduce the number
+-- constant strings created when compiled:
-\begin{code}
errorEmptyList :: String -> a
errorEmptyList fun =
error (prel_list_str ++ fun ++ ": empty list")
prel_list_str :: String
prel_list_str = "Prelude."
-\end{code}
diff --git a/libraries/base/GHC/Num.lhs b/libraries/base/GHC/Num.hs
index 47f0aff7ad..34033f8e80 100644
--- a/libraries/base/GHC/Num.lhs
+++ b/libraries/base/GHC/Num.hs
@@ -1,4 +1,3 @@
-\begin{code}
{-# LANGUAGE Trustworthy #-}
{-# LANGUAGE NoImplicitPrelude, MagicHash, UnboxedTuples #-}
{-# OPTIONS_HADDOCK hide #-}
@@ -26,15 +25,7 @@ infixl 6 +, -
default () -- Double isn't available yet,
-- and we shouldn't be using defaults anyway
-\end{code}
-%*********************************************************
-%* *
-\subsection{Standard numeric class}
-%* *
-%*********************************************************
-
-\begin{code}
-- | Basic numeric class.
class Num a where
{-# MINIMAL (+), (*), abs, signum, fromInteger, (negate | (-)) #-}
@@ -71,16 +62,7 @@ class Num a where
{-# INLINE subtract #-}
subtract :: (Num a) => a -> a -> a
subtract x y = y - x
-\end{code}
-
-
-%*********************************************************
-%* *
-\subsection{Instances for @Int@}
-%* *
-%*********************************************************
-\begin{code}
instance Num Int where
I# x + I# y = I# (x +# y)
I# x - I# y = I# (x -# y)
@@ -94,15 +76,7 @@ instance Num Int where
{-# INLINE fromInteger #-} -- Just to be sure!
fromInteger i = I# (integerToInt i)
-\end{code}
-%*********************************************************
-%* *
-\subsection{Instances for @Word@}
-%* *
-%*********************************************************
-
-\begin{code}
instance Num Word where
(W# x#) + (W# y#) = W# (x# `plusWord#` y#)
(W# x#) - (W# y#) = W# (x# `minusWord#` y#)
@@ -112,15 +86,7 @@ instance Num Word where
signum 0 = 0
signum _ = 1
fromInteger i = W# (integerToWord i)
-\end{code}
-
-%*********************************************************
-%* *
-\subsection{The @Integer@ instances for @Num@}
-%* *
-%*********************************************************
-\begin{code}
instance Num Integer where
(+) = plusInteger
(-) = minusInteger
@@ -130,5 +96,3 @@ instance Num Integer where
abs = absInteger
signum = signumInteger
-\end{code}
-
diff --git a/libraries/base/GHC/Pack.lhs b/libraries/base/GHC/Pack.hs
index ba6107e548..95ff849f31 100644
--- a/libraries/base/GHC/Pack.lhs
+++ b/libraries/base/GHC/Pack.hs
@@ -1,4 +1,3 @@
-\begin{code}
{-# LANGUAGE Unsafe #-}
{-# LANGUAGE NoImplicitPrelude, MagicHash, UnboxedTuples #-}
{-# OPTIONS_HADDOCK hide #-}
@@ -8,7 +7,7 @@
-- Module : GHC.Pack
-- Copyright : (c) The University of Glasgow 1997-2002
-- License : see libraries/base/LICENSE
---
+--
-- Maintainer : cvs-ghc@haskell.org
-- Stability : internal
-- Portability : non-portable (GHC Extensions)
@@ -16,7 +15,7 @@
-- This module provides a small set of low-level functions for packing
-- and unpacking a chunk of bytes. Used by code emitted by the compiler
-- plus the prelude libraries.
---
+--
-- The programmer level view of packed strings is provided by a GHC
-- system library PackedString.
--
@@ -32,7 +31,7 @@ module GHC.Pack
unpackNBytes#,
unpackFoldrCString#, -- (**)
unpackAppendCString#, -- (**)
- )
+ )
where
import GHC.Base
@@ -61,7 +60,7 @@ packStringST str =
packNBytesST :: Int -> [Char] -> ST s (ByteArray Int)
packNBytesST (I# length#) str =
- {-
+ {-
allocate an array that will hold the string
(not forgetting the NUL byte at the end)
-}
@@ -83,7 +82,7 @@ packNBytesST (I# length#) str =
-- (Very :-) ``Specialised'' versions of some CharArray things...
new_ps_array :: Int# -> ST s (MutableByteArray s Int)
-write_ps_array :: MutableByteArray s Int -> Int# -> Char# -> ST s ()
+write_ps_array :: MutableByteArray s Int -> Int# -> Char# -> ST s ()
freeze_ps_array :: MutableByteArray s Int -> Int# -> ST s (ByteArray Int)
new_ps_array size = ST $ \ s ->
@@ -100,4 +99,3 @@ write_ps_array (MutableByteArray _ _ barr#) n ch = ST $ \ s# ->
freeze_ps_array (MutableByteArray _ _ arr#) len# = ST $ \ s# ->
case unsafeFreezeByteArray# arr# s# of { (# s2#, frozen# #) ->
(# s2#, ByteArray 0 (I# len#) frozen# #) }
-\end{code}
diff --git a/libraries/base/GHC/Ptr.lhs b/libraries/base/GHC/Ptr.hs
index a55f01e9b1..def63b7613 100644
--- a/libraries/base/GHC/Ptr.lhs
+++ b/libraries/base/GHC/Ptr.hs
@@ -1,4 +1,3 @@
-\begin{code}
{-# LANGUAGE Unsafe #-}
{-# LANGUAGE CPP, NoImplicitPrelude, MagicHash, RoleAnnotations #-}
{-# OPTIONS_HADDOCK hide #-}
@@ -8,7 +7,7 @@
-- Module : GHC.Ptr
-- Copyright : (c) The FFI Task Force, 2000-2002
-- License : see libraries/base/LICENSE
---
+--
-- Maintainer : ffi@haskell.org
-- Stability : internal
-- Portability : non-portable (GHC Extensions)
@@ -42,7 +41,7 @@ import Numeric ( showHex )
-- pointer. And phantom is useful to implement castPtr (see #9163)
-- redundant role annotation checks that this doesn't change
-type role Ptr phantom
+type role Ptr phantom
data Ptr a = Ptr Addr# deriving (Eq, Ord)
-- ^ A value of type @'Ptr' a@ represents a pointer to an object, or an
-- array of objects, which may be marshalled to or from Haskell values
@@ -78,7 +77,7 @@ alignPtr addr@(Ptr a) (I# i)
n -> Ptr (plusAddr# a (i -# n)) }
-- |Computes the offset required to get from the second to the first
--- argument. We have
+-- argument. We have
--
-- > p2 == p1 `plusPtr` (p2 `minusPtr` p1)
minusPtr :: Ptr a -> Ptr b -> Int
@@ -103,7 +102,7 @@ data FunPtr a = FunPtr Addr# deriving (Eq, Ord)
-- 'Data.Word.Word32', 'Data.Word.Word64', @'Ptr' a@, @'FunPtr' a@,
-- @'Foreign.StablePtr.StablePtr' a@ or a renaming of any of these
-- using @newtype@.
---
+--
-- * the return type is either a marshallable foreign type or has the form
-- @'IO' t@ where @t@ is a marshallable foreign type or @()@.
--
@@ -129,7 +128,7 @@ data FunPtr a = FunPtr Addr# deriving (Eq, Ord)
-- can define a /dynamic/ stub for the specific foreign type, e.g.
--
-- > type IntFunction = CInt -> IO ()
--- > foreign import ccall "dynamic"
+-- > foreign import ccall "dynamic"
-- > mkFun :: FunPtr IntFunction -> IntFunction
-- |The constant 'nullFunPtr' contains a
@@ -168,10 +167,8 @@ instance Show (Ptr a) where
showsPrec _ (Ptr a) rs = pad_out (showHex (wordToInteger(int2Word#(addr2Int# a))) "")
where
-- want 0s prefixed to pad it out to a fixed length.
- pad_out ls =
+ pad_out ls =
'0':'x':(replicate (2*SIZEOF_HSPTR - length ls) '0') ++ ls ++ rs
instance Show (FunPtr a) where
showsPrec p = showsPrec p . castFunPtrToPtr
-
-\end{code}
diff --git a/libraries/base/GHC/Read.lhs b/libraries/base/GHC/Read.hs
index 6dada41f6d..298b068c7e 100644
--- a/libraries/base/GHC/Read.lhs
+++ b/libraries/base/GHC/Read.hs
@@ -1,4 +1,3 @@
-\begin{code}
{-# LANGUAGE Trustworthy #-}
{-# LANGUAGE NoImplicitPrelude, StandaloneDeriving, ScopedTypeVariables #-}
{-# OPTIONS_HADDOCK hide #-}
@@ -8,7 +7,7 @@
-- Module : GHC.Read
-- Copyright : (c) The University of Glasgow, 1994-2002
-- License : see libraries/base/LICENSE
---
+--
-- Maintainer : cvs-ghc@haskell.org
-- Stability : internal
-- Portability : non-portable (GHC Extensions)
@@ -67,10 +66,8 @@ import GHC.Float
import GHC.Show
import GHC.Base
import GHC.Arr
-\end{code}
-\begin{code}
-- | @'readParen' 'True' p@ parses what @p@ parses, but surrounded with
-- parentheses.
--
@@ -85,18 +82,6 @@ readParen b g = if b then mandatory else optional
(x,t) <- optional s
(")",u) <- lex t
return (x,u)
-\end{code}
-
-
-%*********************************************************
-%* *
-\subsection{The @Read@ class}
-%* *
-%*********************************************************
-
-\begin{code}
-------------------------------------------------------------------------
--- class Read
-- | Parsing of 'String's, producing values.
--
@@ -198,7 +183,7 @@ class Read a where
-- The default definition uses 'readList'. Instances that define 'readPrec'
-- should also define 'readListPrec' as 'readListPrecDefault'.
readListPrec :: ReadPrec [a]
-
+
-- default definitions
readsPrec = readPrec_to_S readPrec
readList = readPrec_to_S (list readPrec) 0
@@ -280,7 +265,7 @@ paren p = do expectP (L.Punc "(")
return x
parens :: ReadPrec a -> ReadPrec a
--- ^ @(parens p)@ parses \"P\", \"(P0)\", \"((P0))\", etc,
+-- ^ @(parens p)@ parses \"P\", \"(P0)\", \"((P0))\", etc,
-- where @p@ parses \"P\" in the current precedence context
-- and parses \"P0\" in precedence context zero
parens p = optional
@@ -303,7 +288,7 @@ list readx =
"]" -> return []
"," | started -> listNext
_ -> pfail
-
+
listNext =
do x <- reset readx
xs <- listRest True
@@ -322,16 +307,11 @@ choose sps = foldr ((+++) . try_one) pfail sps
L.Ident s' | s==s' -> p
L.Symbol s' | s==s' -> p
_other -> pfail }
-\end{code}
+--------------------------------------------------------------
+-- Simple instances of Read
+--------------------------------------------------------------
-%*********************************************************
-%* *
-\subsection{Simple instances of Read}
-%* *
-%*********************************************************
-
-\begin{code}
instance Read Char where
readPrec =
parens
@@ -375,15 +355,12 @@ instance Read Ordering where
readListPrec = readListPrecDefault
readList = readListDefault
-\end{code}
-
-%*********************************************************
-%* *
-\subsection{Structure instances of Read: Maybe, List etc}
-%* *
-%*********************************************************
+--------------------------------------------------------------
+-- Structure instances of Read: Maybe, List etc
+--------------------------------------------------------------
+{-
For structured instances of Read we start using the precedences. The
idea is then that 'parens (prec k p)' will fail immediately when trying
to parse it in a context with a higher precedence level than k. But if
@@ -404,8 +381,8 @@ Note how step is used in for example the Maybe parser to increase the
precedence beyond appPrec, so that basically only literals and
parenthesis-like objects such as (...) and [...] can be an argument to
'Just'.
+-}
-\begin{code}
instance Read a => Read (Maybe a) where
readPrec =
parens
@@ -443,16 +420,11 @@ instance Read L.Lexeme where
readPrec = lexP
readListPrec = readListPrecDefault
readList = readListDefault
-\end{code}
-
-%*********************************************************
-%* *
-\subsection{Numeric instances of Read}
-%* *
-%*********************************************************
+--------------------------------------------------------------
+-- Numeric instances of Read
+--------------------------------------------------------------
-\begin{code}
readNumber :: Num a => (L.Lexeme -> ReadPrec a) -> ReadPrec a
-- Read a signed number
readNumber convert =
@@ -517,16 +489,12 @@ instance (Integral a, Read a) => Read (Ratio a) where
readListPrec = readListPrecDefault
readList = readListDefault
-\end{code}
-%*********************************************************
-%* *
- Tuple instances of Read, up to size 15
-%* *
-%*********************************************************
+------------------------------------------------------------------------
+-- Tuple instances of Read, up to size 15
+------------------------------------------------------------------------
-\begin{code}
instance Read () where
readPrec =
parens
@@ -572,8 +540,8 @@ read_tup8 = do (a,b,c,d) <- read_tup4
instance (Read a, Read b, Read c) => Read (a, b, c) where
- readPrec = wrap_tup (do { (a,b) <- read_tup2; read_comma
- ; c <- readPrec
+ readPrec = wrap_tup (do { (a,b) <- read_tup2; read_comma
+ ; c <- readPrec
; return (a,b,c) })
readListPrec = readListPrecDefault
readList = readListDefault
@@ -680,5 +648,3 @@ instance (Read a, Read b, Read c, Read d, Read e, Read f, Read g, Read h,
; return (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o) })
readListPrec = readListPrecDefault
readList = readListDefault
-\end{code}
-
diff --git a/libraries/base/GHC/Real.lhs b/libraries/base/GHC/Real.hs
index b9ec7757e1..dd806bc561 100644
--- a/libraries/base/GHC/Real.lhs
+++ b/libraries/base/GHC/Real.hs
@@ -1,4 +1,3 @@
-\begin{code}
{-# LANGUAGE Trustworthy #-}
{-# LANGUAGE CPP, NoImplicitPrelude, MagicHash, UnboxedTuples, BangPatterns #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
@@ -37,19 +36,14 @@ infixl 7 %
default () -- Double isn't available yet,
-- and we shouldn't be using defaults anyway
-\end{code}
+------------------------------------------------------------------------
+-- Divide by zero and arithmetic overflow
+------------------------------------------------------------------------
-%*********************************************************
-%* *
- Divide by zero and arithmetic overflow
-%* *
-%*********************************************************
+-- We put them here because they are needed relatively early
+-- in the libraries before the Exception type has been defined yet.
-We put them here because they are needed relatively early
-in the libraries before the Exception type has been defined yet.
-
-\begin{code}
{-# NOINLINE divZeroError #-}
divZeroError :: a
divZeroError = raise# divZeroException
@@ -61,15 +55,11 @@ ratioZeroDenominatorError = raise# ratioZeroDenomException
{-# NOINLINE overflowError #-}
overflowError :: a
overflowError = raise# overflowException
-\end{code}
-%*********************************************************
-%* *
-\subsection{The @Ratio@ and @Rational@ types}
-%* *
-%*********************************************************
+--------------------------------------------------------------
+-- The Ratio and Rational types
+--------------------------------------------------------------
-\begin{code}
-- | Rational numbers, with numerator and denominator of some 'Integral' type.
data Ratio a = !a :% !a deriving (Eq)
@@ -88,10 +78,7 @@ notANumber = 0 :% 0
-- Use :%, not % for Inf/NaN; the latter would
-- immediately lead to a runtime error, because it normalises.
-\end{code}
-
-\begin{code}
-- | Forms the ratio of two integral numbers.
{-# SPECIALISE (%) :: Integer -> Integer -> Rational #-}
(%) :: (Integral a) => a -> a -> Ratio a
@@ -105,35 +92,26 @@ numerator :: (Integral a) => Ratio a -> a
-- the numerator and denominator have no common factor and the denominator
-- is positive.
denominator :: (Integral a) => Ratio a -> a
-\end{code}
-\tr{reduce} is a subsidiary function used only in this module .
-It normalises a ratio by dividing both numerator and denominator by
-their greatest common divisor.
-\begin{code}
+-- | 'reduce' is a subsidiary function used only in this module.
+-- It normalises a ratio by dividing both numerator and denominator by
+-- their greatest common divisor.
reduce :: (Integral a) => a -> a -> Ratio a
{-# SPECIALISE reduce :: Integer -> Integer -> Rational #-}
reduce _ 0 = ratioZeroDenominatorError
reduce x y = (x `quot` d) :% (y `quot` d)
where d = gcd x y
-\end{code}
-\begin{code}
x % y = reduce (x * signum y) (abs y)
numerator (x :% _) = x
denominator (_ :% y) = y
-\end{code}
-
-%*********************************************************
-%* *
-\subsection{Standard numeric classes}
-%* *
-%*********************************************************
+--------------------------------------------------------------
+-- Standard numeric classes
+--------------------------------------------------------------
-\begin{code}
class (Num a, Ord a) => Real a where
-- | the rational equivalent of its real argument with full precision
toRational :: a -> Rational
@@ -229,12 +207,9 @@ class (Real a, Fractional a) => RealFrac a where
floor x = if r < 0 then n - 1 else n
where (n,r) = properFraction x
-\end{code}
+-- These 'numeric' enumerations come straight from the Report
-These 'numeric' enumerations come straight from the Report
-
-\begin{code}
numericEnumFrom :: (Fractional a) => a -> [a]
numericEnumFrom n = n `seq` (n : numericEnumFrom (n + 1))
@@ -251,16 +226,11 @@ numericEnumFromThenTo e1 e2 e3
mid = (e2 - e1) / 2
predicate | e2 >= e1 = (<= e3 + mid)
| otherwise = (>= e3 + mid)
-\end{code}
-
-%*********************************************************
-%* *
-\subsection{Instances for @Int@}
-%* *
-%*********************************************************
+--------------------------------------------------------------
+-- Instances for Int
+--------------------------------------------------------------
-\begin{code}
instance Real Int where
toRational x = toInteger x :% 1
@@ -306,16 +276,11 @@ instance Integral Int where
-- Note [Order of tests] in GHC.Int
| b == (-1) && a == minBound = (overflowError, 0)
| otherwise = a `divModInt` b
-\end{code}
+--------------------------------------------------------------
+-- Instances for @Word@
+--------------------------------------------------------------
-%*********************************************************
-%* *
-\subsection{Instances for @Word@}
-%* *
-%*********************************************************
-
-\begin{code}
instance Real Word where
toRational x = toInteger x % 1
@@ -341,16 +306,11 @@ instance Integral Word where
| y /= 0 = (W# (x# `quotWord#` y#), W# (x# `remWord#` y#))
| otherwise = divZeroError
toInteger (W# x#) = wordToInteger x#
-\end{code}
-
-%*********************************************************
-%* *
-\subsection{Instances for @Integer@}
-%* *
-%*********************************************************
+--------------------------------------------------------------
+-- Instances for Integer
+--------------------------------------------------------------
-\begin{code}
instance Real Integer where
toRational x = x :% 1
@@ -394,16 +354,11 @@ instance Integral Integer where
_ `quotRem` 0 = divZeroError
n `quotRem` d = case n `quotRemInteger` d of
(# q, r #) -> (q, r)
-\end{code}
+--------------------------------------------------------------
+-- Instances for @Ratio@
+--------------------------------------------------------------
-%*********************************************************
-%* *
-\subsection{Instances for @Ratio@}
-%* *
-%*********************************************************
-
-\begin{code}
instance (Integral a) => Ord (Ratio a) where
{-# SPECIALIZE instance Ord Rational #-}
(x:%y) <= (x':%y') = x * y' <= x' * y
@@ -461,16 +416,11 @@ instance (Integral a) => Enum (Ratio a) where
enumFromThen = numericEnumFromThen
enumFromTo = numericEnumFromTo
enumFromThenTo = numericEnumFromThenTo
-\end{code}
-
-%*********************************************************
-%* *
-\subsection{Coercions}
-%* *
-%*********************************************************
+--------------------------------------------------------------
+-- Coercions
+--------------------------------------------------------------
-\begin{code}
-- | general coercion from integral types
{-# NOINLINE [1] fromIntegral #-}
fromIntegral :: (Integral a, Num b) => a -> b
@@ -490,15 +440,11 @@ fromIntegral = fromInteger . toInteger
realToFrac :: (Real a, Fractional b) => a -> b
{-# NOINLINE [1] realToFrac #-}
realToFrac = fromRational . toRational
-\end{code}
-%*********************************************************
-%* *
-\subsection{Overloaded numeric functions}
-%* *
-%*********************************************************
+--------------------------------------------------------------
+-- Overloaded numeric functions
+--------------------------------------------------------------
-\begin{code}
-- | Converts a possibly-negative 'Real' value to a string.
showSigned :: (Real a)
=> (a -> ShowS) -- ^ a function that can show unsigned values
@@ -702,4 +648,3 @@ integralEnumFromTo n m = map fromInteger [toInteger n .. toInteger m]
integralEnumFromThenTo :: Integral a => a -> a -> a -> [a]
integralEnumFromThenTo n1 n2 m
= map fromInteger [toInteger n1, toInteger n2 .. toInteger m]
-\end{code}
diff --git a/libraries/base/GHC/ST.lhs b/libraries/base/GHC/ST.hs
index 6e922c0652..de6b9a6458 100644
--- a/libraries/base/GHC/ST.lhs
+++ b/libraries/base/GHC/ST.hs
@@ -1,4 +1,3 @@
-\begin{code}
{-# LANGUAGE Unsafe #-}
{-# LANGUAGE NoImplicitPrelude, MagicHash, UnboxedTuples, RankNTypes #-}
{-# OPTIONS_HADDOCK hide #-}
@@ -7,7 +6,7 @@
-- Module : GHC.ST
-- Copyright : (c) The University of Glasgow, 1992-2002
-- License : see libraries/base/LICENSE
---
+--
-- Maintainer : cvs-ghc@haskell.org
-- Stability : internal
-- Portability : non-portable (GHC Extensions)
@@ -28,18 +27,10 @@ import GHC.Base
import GHC.Show
default ()
-\end{code}
-
-%*********************************************************
-%* *
-\subsection{The @ST@ monad}
-%* *
-%*********************************************************
-The state-transformer monad proper. By default the monad is strict;
-too many people got bitten by space leaks when it was lazy.
+-- The state-transformer monad proper. By default the monad is strict;
+-- too many people got bitten by space leaks when it was lazy.
-\begin{code}
-- | The strict state-transformer monad.
-- A computation of type @'ST' s a@ transforms an internal state indexed
-- by @s@, and returns a value of type @a@.
@@ -111,8 +102,8 @@ fixST k = ST $ \ s ->
instance Show (ST s a) where
showsPrec _ _ = showString "<<ST action>>"
showList = showList__ (showsPrec 0)
-\end{code}
+{-
Definition of runST
~~~~~~~~~~~~~~~~~~~
@@ -144,8 +135,8 @@ f = let
freezeArray# a s''
\end{verbatim}
All calls to @f@ will share a {\em single} array! End SLPJ 95/04.
+-}
-\begin{code}
{-# INLINE runST #-}
-- The INLINE prevents runSTRep getting inlined in *this* module
-- so that it is still visible when runST is inlined in an importing
@@ -171,4 +162,3 @@ runST st = runSTRep (case st of { ST st_rep -> st_rep })
runSTRep :: (forall s. STRep s a) -> a
runSTRep st_rep = case st_rep realWorld# of
(# _, r #) -> r
-\end{code}
diff --git a/libraries/base/GHC/STRef.lhs b/libraries/base/GHC/STRef.hs
index 1fbc5a3d79..9997f72681 100644
--- a/libraries/base/GHC/STRef.lhs
+++ b/libraries/base/GHC/STRef.hs
@@ -1,4 +1,3 @@
-\begin{code}
{-# LANGUAGE Unsafe #-}
{-# LANGUAGE NoImplicitPrelude, MagicHash, UnboxedTuples #-}
{-# OPTIONS_HADDOCK hide #-}
@@ -48,5 +47,3 @@ writeSTRef (STRef var#) val = ST $ \s1# ->
-- Just pointer equality on mutable references:
instance Eq (STRef s a) where
STRef v1# == STRef v2# = isTrue# (sameMutVar# v1# v2#)
-
-\end{code}
diff --git a/libraries/base/GHC/Show.lhs b/libraries/base/GHC/Show.hs
index b4ba7d297c..25d9b97b56 100644
--- a/libraries/base/GHC/Show.lhs
+++ b/libraries/base/GHC/Show.hs
@@ -1,4 +1,3 @@
-\begin{code}
{-# LANGUAGE Trustworthy #-}
{-# LANGUAGE CPP, NoImplicitPrelude, BangPatterns, StandaloneDeriving,
MagicHash, UnboxedTuples #-}
@@ -53,17 +52,7 @@ module GHC.Show
import GHC.Base
import GHC.Num
import GHC.List ((!!), foldr1, break)
-\end{code}
-
-
-%*********************************************************
-%* *
-\subsection{The @Show@ class}
-%* *
-%*********************************************************
-
-\begin{code}
-- | The @shows@ functions return a function that prepends the
-- output 'String' to an existing 'String'. This allows constant-time
-- concatenation of results using function composition.
@@ -168,15 +157,10 @@ appPrec, appPrec1 :: Int
appPrec = I# 10# -- Precedence of application:
-- one more than the maximum operator precedence of 9
appPrec1 = I# 11# -- appPrec + 1
-\end{code}
-
-%*********************************************************
-%* *
-\subsection{Simple Instances}
-%* *
-%*********************************************************
-\begin{code}
+--------------------------------------------------------------
+-- Simple Instances
+--------------------------------------------------------------
deriving instance Show ()
@@ -209,16 +193,11 @@ showWord w# cs
showWord (w# `quotWord#` 10##) (C# c# : cs)
deriving instance Show a => Show (Maybe a)
-\end{code}
+--------------------------------------------------------------
+-- Show instances for the first few tuple
+--------------------------------------------------------------
-%*********************************************************
-%* *
-\subsection{Show instances for the first few tuples
-%* *
-%*********************************************************
-
-\begin{code}
-- The explicit 's' parameters are important
-- Otherwise GHC thinks that "shows x" might take a lot of work to compute
-- and generates defns like
@@ -300,16 +279,11 @@ show_tuple :: [ShowS] -> ShowS
show_tuple ss = showChar '('
. foldr1 (\s r -> s . showChar ',' . r) ss
. showChar ')'
-\end{code}
-
-%*********************************************************
-%* *
-\subsection{Support code for @Show@}
-%* *
-%*********************************************************
+--------------------------------------------------------------
+-- Support code for Show
+--------------------------------------------------------------
-\begin{code}
-- | equivalent to 'showsPrec' with a precedence of 0.
shows :: (Show a) => a -> ShowS
shows = showsPrec 0
@@ -331,11 +305,9 @@ showParen b p = if b then showChar '(' . p . showChar ')' else p
showSpace :: ShowS
showSpace = {-showChar ' '-} \ xs -> ' ' : xs
-\end{code}
-Code specific for characters
+-- Code specific for characters
-\begin{code}
-- | Convert a character to a string using only printable characters,
-- using Haskell source-language escape conventions. For example:
--
@@ -404,11 +376,9 @@ asciiTab = -- Using an array drags in the array module. listArray ('\NUL', ' ')
"DLE", "DC1", "DC2", "DC3", "DC4", "NAK", "SYN", "ETB",
"CAN", "EM", "SUB", "ESC", "FS", "GS", "RS", "US",
"SP"]
-\end{code}
-Code specific for Ints.
+-- Code specific for Ints.
-\begin{code}
-- | Convert an 'Int' in the range @0@..@15@ to the corresponding single
-- digit 'Char'. This function fails on other inputs, and generates
-- lower-case hexadecimal digits.
@@ -443,16 +413,11 @@ itos n# cs
case chr# (ord# '0'# +# r) of
c# ->
itos' q (C# c# : cs')
-\end{code}
+--------------------------------------------------------------
+-- The Integer instances for Show
+--------------------------------------------------------------
-%*********************************************************
-%* *
-\subsection{The @Integer@ instances for @Show@}
-%* *
-%*********************************************************
-
-\begin{code}
instance Show Integer where
showsPrec p n r
| p > 6 && n < 0 = '(' : integerToString n (')' : r)
@@ -540,5 +505,3 @@ integerToString n0 cs0
c@(C# _) -> jblock' (d - 1) q (c : cs)
where
(q, r) = n `quotRemInt` 10
-\end{code}
-
diff --git a/libraries/base/GHC/Stable.lhs b/libraries/base/GHC/Stable.hs
index 61f6621b88..89bc5a6058 100644
--- a/libraries/base/GHC/Stable.lhs
+++ b/libraries/base/GHC/Stable.hs
@@ -1,4 +1,3 @@
-\begin{code}
{-# LANGUAGE Unsafe, DeriveDataTypeable #-}
{-# LANGUAGE NoImplicitPrelude
, MagicHash
@@ -11,7 +10,7 @@
-- Module : GHC.Stable
-- Copyright : (c) The University of Glasgow, 1992-2004
-- License : see libraries/base/LICENSE
---
+--
-- Maintainer : ffi@haskell.org
-- Stability : internal
-- Portability : non-portable (GHC Extensions)
@@ -93,9 +92,9 @@ castStablePtrToPtr (StablePtr s) = Ptr (unsafeCoerce# s)
-- |
-- The inverse of 'castStablePtrToPtr', i.e., we have the identity
---
+--
-- > sp == castPtrToStablePtr (castStablePtrToPtr sp)
---
+--
-- for any stable pointer @sp@ on which 'freeStablePtr' has
-- not been executed yet. Moreover, 'castPtrToStablePtr' may
-- only be applied to pointers that have been produced by
@@ -104,10 +103,8 @@ castStablePtrToPtr (StablePtr s) = Ptr (unsafeCoerce# s)
castPtrToStablePtr :: Ptr () -> StablePtr a
castPtrToStablePtr (Ptr a) = StablePtr (unsafeCoerce# a)
-instance Eq (StablePtr a) where
+instance Eq (StablePtr a) where
(StablePtr sp1) == (StablePtr sp2) =
case eqStablePtr# sp1 sp2 of
0# -> False
_ -> True
-
-\end{code}
diff --git a/libraries/base/GHC/Storable.lhs b/libraries/base/GHC/Storable.hs
index 13668725af..f745a6fb47 100644
--- a/libraries/base/GHC/Storable.lhs
+++ b/libraries/base/GHC/Storable.hs
@@ -1,4 +1,3 @@
-\begin{code}
{-# LANGUAGE Trustworthy #-}
{-# LANGUAGE NoImplicitPrelude, MagicHash, UnboxedTuples #-}
{-# OPTIONS_HADDOCK hide #-}
@@ -8,7 +7,7 @@
-- Module : GHC.Storable
-- Copyright : (c) The FFI task force, 2000-2002
-- License : see libraries/base/LICENSE
---
+--
-- Maintainer : ffi@haskell.org
-- Stability : internal
-- Portability : non-portable (GHC Extensions)
@@ -18,38 +17,38 @@
-----------------------------------------------------------------------------
module GHC.Storable
- ( readWideCharOffPtr
- , readIntOffPtr
- , readWordOffPtr
- , readPtrOffPtr
- , readFunPtrOffPtr
- , readFloatOffPtr
- , readDoubleOffPtr
- , readStablePtrOffPtr
- , readInt8OffPtr
- , readInt16OffPtr
- , readInt32OffPtr
- , readInt64OffPtr
- , readWord8OffPtr
- , readWord16OffPtr
- , readWord32OffPtr
- , readWord64OffPtr
- , writeWideCharOffPtr
- , writeIntOffPtr
- , writeWordOffPtr
- , writePtrOffPtr
- , writeFunPtrOffPtr
- , writeFloatOffPtr
- , writeDoubleOffPtr
+ ( readWideCharOffPtr
+ , readIntOffPtr
+ , readWordOffPtr
+ , readPtrOffPtr
+ , readFunPtrOffPtr
+ , readFloatOffPtr
+ , readDoubleOffPtr
+ , readStablePtrOffPtr
+ , readInt8OffPtr
+ , readInt16OffPtr
+ , readInt32OffPtr
+ , readInt64OffPtr
+ , readWord8OffPtr
+ , readWord16OffPtr
+ , readWord32OffPtr
+ , readWord64OffPtr
+ , writeWideCharOffPtr
+ , writeIntOffPtr
+ , writeWordOffPtr
+ , writePtrOffPtr
+ , writeFunPtrOffPtr
+ , writeFloatOffPtr
+ , writeDoubleOffPtr
, writeStablePtrOffPtr
- , writeInt8OffPtr
- , writeInt16OffPtr
- , writeInt32OffPtr
- , writeInt64OffPtr
- , writeWord8OffPtr
- , writeWord16OffPtr
- , writeWord32OffPtr
- , writeWord64OffPtr
+ , writeInt8OffPtr
+ , writeInt16OffPtr
+ , writeInt32OffPtr
+ , writeInt64OffPtr
+ , writeWord8OffPtr
+ , writeWord16OffPtr
+ , writeWord32OffPtr
+ , writeWord64OffPtr
) where
import GHC.Stable ( StablePtr(..) )
@@ -57,9 +56,6 @@ import GHC.Int
import GHC.Word
import GHC.Ptr
import GHC.Base
-\end{code}
-
-\begin{code}
readWideCharOffPtr :: Ptr Char -> Int -> IO Char
readIntOffPtr :: Ptr Int -> Int -> IO Int
@@ -160,5 +156,3 @@ writeInt64OffPtr (Ptr a) (I# i) (I64# x)
= IO $ \s -> case writeInt64OffAddr# a i x s of s2 -> (# s2, () #)
writeWord64OffPtr (Ptr a) (I# i) (W64# x)
= IO $ \s -> case writeWord64OffAddr# a i x s of s2 -> (# s2, () #)
-
-\end{code}
diff --git a/libraries/base/GHC/TopHandler.lhs b/libraries/base/GHC/TopHandler.hs
index 52ac6c8eb8..d7c00384e4 100644
--- a/libraries/base/GHC/TopHandler.lhs
+++ b/libraries/base/GHC/TopHandler.hs
@@ -1,4 +1,3 @@
-\begin{code}
{-# LANGUAGE Trustworthy #-}
{-# LANGUAGE CPP
, NoImplicitPrelude
@@ -221,5 +220,3 @@ foreign import ccall "Rts.h shutdownHaskellAndExit"
useFastExit, useSafeExit :: CInt
useFastExit = 1
useSafeExit = 0
-
-\end{code}
diff --git a/libraries/base/GHC/Weak.lhs b/libraries/base/GHC/Weak.hs
index d341f5717d..77c93a5651 100644
--- a/libraries/base/GHC/Weak.lhs
+++ b/libraries/base/GHC/Weak.hs
@@ -1,4 +1,3 @@
-\begin{code}
{-# LANGUAGE Unsafe #-}
{-# LANGUAGE NoImplicitPrelude
, BangPatterns
@@ -156,5 +155,3 @@ runFinalizerBatch (I# n) arr =
}}
in
go n
-
-\end{code}