-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Basic libraries
gr
grThis package contains the <a>Prelude</a> and its support libraries,
grand a large collection of useful libraries ranging from data
grstructures to parsing combinators and debugging utilities.
@package base
@version 4.11.0.0


module GHC.Profiling

-- | Stop attributing ticks to cost centres. Allocations will still be
grattributed.
stopProfTimer :: IO ()

-- | Start attributing ticks to cost centres. This is called by the RTS on
grstartup.
startProfTimer :: IO ()

module GHC.IO.Encoding.CodePage

module GHC.Constants


-- | NB. the contents of this module are only available on Windows.
gr
grInstalling Win32 console handlers.
module GHC.ConsoleHandler


-- | Functions associated with the tuple data types.
module Data.Tuple

-- | Extract the first component of a pair.
fst :: (a, b) -> a

-- | Extract the second component of a pair.
snd :: (a, b) -> b

-- | <a>curry</a> converts an uncurried function to a curried function.
gr
gr<h4><b>Examples</b></h4>
gr
gr<pre>
gr&gt;&gt;&gt; curry fst 1 2
gr1
gr</pre>
curry :: ((a, b) -> c) -> a -> b -> c

-- | <a>uncurry</a> converts a curried function to a function on pairs.
gr
gr<h4><b>Examples</b></h4>
gr
gr<pre>
gr&gt;&gt;&gt; uncurry (+) (1,2)
gr3
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; uncurry ($) (show, 1)
gr"1"
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; map (uncurry max) [(1,2), (3,4), (6,8)]
gr[2,4,8]
gr</pre>
uncurry :: (a -> b -> c) -> ((a, b) -> c)

-- | Swap the components of a pair.
swap :: (a, b) -> (b, a)


-- | The Maybe type, and associated operations.
module Data.Maybe

-- | The <a>Maybe</a> type encapsulates an optional value. A value of type
gr<tt><a>Maybe</a> a</tt> either contains a value of type <tt>a</tt>
gr(represented as <tt><a>Just</a> a</tt>), or it is empty (represented
gras <a>Nothing</a>). Using <a>Maybe</a> is a good way to deal with
grerrors or exceptional cases without resorting to drastic measures such
gras <a>error</a>.
gr
grThe <a>Maybe</a> type is also a monad. It is a simple kind of error
grmonad, where all errors are represented by <a>Nothing</a>. A richer
grerror monad can be built using the <a>Either</a> type.
data Maybe a
Nothing :: Maybe a
Just :: a -> Maybe a

-- | The <a>maybe</a> function takes a default value, a function, and a
gr<a>Maybe</a> value. If the <a>Maybe</a> value is <a>Nothing</a>, the
grfunction returns the default value. Otherwise, it applies the function
grto the value inside the <a>Just</a> and returns the result.
gr
gr<h4><b>Examples</b></h4>
gr
grBasic usage:
gr
gr<pre>
gr&gt;&gt;&gt; maybe False odd (Just 3)
grTrue
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; maybe False odd Nothing
grFalse
gr</pre>
gr
grRead an integer from a string using <tt>readMaybe</tt>. If we succeed,
grreturn twice the integer; that is, apply <tt>(*2)</tt> to it. If
grinstead we fail to parse an integer, return <tt>0</tt> by default:
gr
gr<pre>
gr&gt;&gt;&gt; import Text.Read ( readMaybe )
gr
gr&gt;&gt;&gt; maybe 0 (*2) (readMaybe "5")
gr10
gr
gr&gt;&gt;&gt; maybe 0 (*2) (readMaybe "")
gr0
gr</pre>
gr
grApply <tt>show</tt> to a <tt>Maybe Int</tt>. If we have <tt>Just
grn</tt>, we want to show the underlying <a>Int</a> <tt>n</tt>. But if
grwe have <a>Nothing</a>, we return the empty string instead of (for
grexample) "Nothing":
gr
gr<pre>
gr&gt;&gt;&gt; maybe "" show (Just 5)
gr"5"
gr
gr&gt;&gt;&gt; maybe "" show Nothing
gr""
gr</pre>
maybe :: b -> (a -> b) -> Maybe a -> b

-- | The <a>isJust</a> function returns <a>True</a> iff its argument is of
grthe form <tt>Just _</tt>.
gr
gr<h4><b>Examples</b></h4>
gr
grBasic usage:
gr
gr<pre>
gr&gt;&gt;&gt; isJust (Just 3)
grTrue
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; isJust (Just ())
grTrue
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; isJust Nothing
grFalse
gr</pre>
gr
grOnly the outer constructor is taken into consideration:
gr
gr<pre>
gr&gt;&gt;&gt; isJust (Just Nothing)
grTrue
gr</pre>
isJust :: Maybe a -> Bool

-- | The <a>isNothing</a> function returns <a>True</a> iff its argument is
gr<a>Nothing</a>.
gr
gr<h4><b>Examples</b></h4>
gr
grBasic usage:
gr
gr<pre>
gr&gt;&gt;&gt; isNothing (Just 3)
grFalse
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; isNothing (Just ())
grFalse
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; isNothing Nothing
grTrue
gr</pre>
gr
grOnly the outer constructor is taken into consideration:
gr
gr<pre>
gr&gt;&gt;&gt; isNothing (Just Nothing)
grFalse
gr</pre>
isNothing :: Maybe a -> Bool

-- | The <a>fromJust</a> function extracts the element out of a <a>Just</a>
grand throws an error if its argument is <a>Nothing</a>.
gr
gr<h4><b>Examples</b></h4>
gr
grBasic usage:
gr
gr<pre>
gr&gt;&gt;&gt; fromJust (Just 1)
gr1
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; 2 * (fromJust (Just 10))
gr20
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; 2 * (fromJust Nothing)
gr*** Exception: Maybe.fromJust: Nothing
gr</pre>
fromJust :: Maybe a -> a

-- | The <a>fromMaybe</a> function takes a default value and and
gr<a>Maybe</a> value. If the <a>Maybe</a> is <a>Nothing</a>, it returns
grthe default values; otherwise, it returns the value contained in the
gr<a>Maybe</a>.
gr
gr<h4><b>Examples</b></h4>
gr
grBasic usage:
gr
gr<pre>
gr&gt;&gt;&gt; fromMaybe "" (Just "Hello, World!")
gr"Hello, World!"
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; fromMaybe "" Nothing
gr""
gr</pre>
gr
grRead an integer from a string using <tt>readMaybe</tt>. If we fail to
grparse an integer, we want to return <tt>0</tt> by default:
gr
gr<pre>
gr&gt;&gt;&gt; import Text.Read ( readMaybe )
gr
gr&gt;&gt;&gt; fromMaybe 0 (readMaybe "5")
gr5
gr
gr&gt;&gt;&gt; fromMaybe 0 (readMaybe "")
gr0
gr</pre>
fromMaybe :: a -> Maybe a -> a

-- | The <a>listToMaybe</a> function returns <a>Nothing</a> on an empty
grlist or <tt><a>Just</a> a</tt> where <tt>a</tt> is the first element
grof the list.
gr
gr<h4><b>Examples</b></h4>
gr
grBasic usage:
gr
gr<pre>
gr&gt;&gt;&gt; listToMaybe []
grNothing
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; listToMaybe [9]
grJust 9
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; listToMaybe [1,2,3]
grJust 1
gr</pre>
gr
grComposing <a>maybeToList</a> with <a>listToMaybe</a> should be the
gridentity on singleton/empty lists:
gr
gr<pre>
gr&gt;&gt;&gt; maybeToList $ listToMaybe [5]
gr[5]
gr
gr&gt;&gt;&gt; maybeToList $ listToMaybe []
gr[]
gr</pre>
gr
grBut not on lists with more than one element:
gr
gr<pre>
gr&gt;&gt;&gt; maybeToList $ listToMaybe [1,2,3]
gr[1]
gr</pre>
listToMaybe :: [a] -> Maybe a

-- | The <a>maybeToList</a> function returns an empty list when given
gr<a>Nothing</a> or a singleton list when not given <a>Nothing</a>.
gr
gr<h4><b>Examples</b></h4>
gr
grBasic usage:
gr
gr<pre>
gr&gt;&gt;&gt; maybeToList (Just 7)
gr[7]
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; maybeToList Nothing
gr[]
gr</pre>
gr
grOne can use <a>maybeToList</a> to avoid pattern matching when combined
grwith a function that (safely) works on lists:
gr
gr<pre>
gr&gt;&gt;&gt; import Text.Read ( readMaybe )
gr
gr&gt;&gt;&gt; sum $ maybeToList (readMaybe "3")
gr3
gr
gr&gt;&gt;&gt; sum $ maybeToList (readMaybe "")
gr0
gr</pre>
maybeToList :: Maybe a -> [a]

-- | The <a>catMaybes</a> function takes a list of <a>Maybe</a>s and
grreturns a list of all the <a>Just</a> values.
gr
gr<h4><b>Examples</b></h4>
gr
grBasic usage:
gr
gr<pre>
gr&gt;&gt;&gt; catMaybes [Just 1, Nothing, Just 3]
gr[1,3]
gr</pre>
gr
grWhen constructing a list of <a>Maybe</a> values, <a>catMaybes</a> can
grbe used to return all of the "success" results (if the list is the
grresult of a <a>map</a>, then <a>mapMaybe</a> would be more
grappropriate):
gr
gr<pre>
gr&gt;&gt;&gt; import Text.Read ( readMaybe )
gr
gr&gt;&gt;&gt; [readMaybe x :: Maybe Int | x &lt;- ["1", "Foo", "3"] ]
gr[Just 1,Nothing,Just 3]
gr
gr&gt;&gt;&gt; catMaybes $ [readMaybe x :: Maybe Int | x &lt;- ["1", "Foo", "3"] ]
gr[1,3]
gr</pre>
catMaybes :: [Maybe a] -> [a]

-- | The <a>mapMaybe</a> function is a version of <a>map</a> which can
grthrow out elements. In particular, the functional argument returns
grsomething of type <tt><a>Maybe</a> b</tt>. If this is <a>Nothing</a>,
grno element is added on to the result list. If it is <tt><a>Just</a>
grb</tt>, then <tt>b</tt> is included in the result list.
gr
gr<h4><b>Examples</b></h4>
gr
grUsing <tt><a>mapMaybe</a> f x</tt> is a shortcut for
gr<tt><a>catMaybes</a> $ <a>map</a> f x</tt> in most cases:
gr
gr<pre>
gr&gt;&gt;&gt; import Text.Read ( readMaybe )
gr
gr&gt;&gt;&gt; let readMaybeInt = readMaybe :: String -&gt; Maybe Int
gr
gr&gt;&gt;&gt; mapMaybe readMaybeInt ["1", "Foo", "3"]
gr[1,3]
gr
gr&gt;&gt;&gt; catMaybes $ map readMaybeInt ["1", "Foo", "3"]
gr[1,3]
gr</pre>
gr
grIf we map the <a>Just</a> constructor, the entire list should be
grreturned:
gr
gr<pre>
gr&gt;&gt;&gt; mapMaybe Just [1,2,3]
gr[1,2,3]
gr</pre>
mapMaybe :: (a -> Maybe b) -> [a] -> [b]

module GHC.Char

-- | The <a>toEnum</a> method restricted to the type <a>Char</a>.
chr :: Int -> Char
eqChar :: Char -> Char -> Bool
neChar :: Char -> Char -> Bool


-- | Functors: uniform action over a parameterized type, generalizing the
gr<a>map</a> function on lists.
module Data.Functor

-- | The <a>Functor</a> class is used for types that can be mapped over.
grInstances of <a>Functor</a> should satisfy the following laws:
gr
gr<pre>
grfmap id  ==  id
grfmap (f . g)  ==  fmap f . fmap g
gr</pre>
gr
grThe instances of <a>Functor</a> for lists, <a>Maybe</a> and <a>IO</a>
grsatisfy these laws.
class Functor f
fmap :: Functor f => (a -> b) -> f a -> f b

-- | Replace all locations in the input with the same value. The default
grdefinition is <tt><a>fmap</a> . <a>const</a></tt>, but this may be
groverridden with a more efficient version.
(<$) :: Functor f => a -> f b -> f a
infixl 4 <$

-- | Flipped version of <a>&lt;$</a>.
gr
gr<h4><b>Examples</b></h4>
gr
grReplace the contents of a <tt><tt>Maybe</tt> <tt>Int</tt></tt> with a
grconstant <tt>String</tt>:
gr
gr<pre>
gr&gt;&gt;&gt; Nothing $&gt; "foo"
grNothing
gr
gr&gt;&gt;&gt; Just 90210 $&gt; "foo"
grJust "foo"
gr</pre>
gr
grReplace the contents of an <tt><tt>Either</tt> <tt>Int</tt>
gr<tt>Int</tt></tt> with a constant <tt>String</tt>, resulting in an
gr<tt><tt>Either</tt> <tt>Int</tt> <tt>String</tt></tt>:
gr
gr<pre>
gr&gt;&gt;&gt; Left 8675309 $&gt; "foo"
grLeft 8675309
gr
gr&gt;&gt;&gt; Right 8675309 $&gt; "foo"
grRight "foo"
gr</pre>
gr
grReplace each element of a list with a constant <tt>String</tt>:
gr
gr<pre>
gr&gt;&gt;&gt; [1,2,3] $&gt; "foo"
gr["foo","foo","foo"]
gr</pre>
gr
grReplace the second element of a pair with a constant <tt>String</tt>:
gr
gr<pre>
gr&gt;&gt;&gt; (1,2) $&gt; "foo"
gr(1,"foo")
gr</pre>
($>) :: Functor f => f a -> b -> f b
infixl 4 $>

-- | An infix synonym for <a>fmap</a>.
gr
grThe name of this operator is an allusion to <tt>$</tt>. Note the
grsimilarities between their types:
gr
gr<pre>
gr ($)  ::              (a -&gt; b) -&gt;   a -&gt;   b
gr(&lt;$&gt;) :: Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
gr</pre>
gr
grWhereas <tt>$</tt> is function application, <a>&lt;$&gt;</a> is
grfunction application lifted over a <a>Functor</a>.
gr
gr<h4><b>Examples</b></h4>
gr
grConvert from a <tt><tt>Maybe</tt> <tt>Int</tt></tt> to a
gr<tt><tt>Maybe</tt> <tt>String</tt></tt> using <tt>show</tt>:
gr
gr<pre>
gr&gt;&gt;&gt; show &lt;$&gt; Nothing
grNothing
gr
gr&gt;&gt;&gt; show &lt;$&gt; Just 3
grJust "3"
gr</pre>
gr
grConvert from an <tt><tt>Either</tt> <tt>Int</tt> <tt>Int</tt></tt> to
gran <tt><tt>Either</tt> <tt>Int</tt></tt> <tt>String</tt> using
gr<tt>show</tt>:
gr
gr<pre>
gr&gt;&gt;&gt; show &lt;$&gt; Left 17
grLeft 17
gr
gr&gt;&gt;&gt; show &lt;$&gt; Right 17
grRight "17"
gr</pre>
gr
grDouble each element of a list:
gr
gr<pre>
gr&gt;&gt;&gt; (*2) &lt;$&gt; [1,2,3]
gr[2,4,6]
gr</pre>
gr
grApply <tt>even</tt> to the second element of a pair:
gr
gr<pre>
gr&gt;&gt;&gt; even &lt;$&gt; (2,2)
gr(2,True)
gr</pre>
(<$>) :: Functor f => (a -> b) -> f a -> f b
infixl 4 <$>

-- | Flipped version of <a>&lt;$&gt;</a>.
gr
gr<pre>
gr(<a>&lt;&amp;&gt;</a>) = <a>flip</a> <a>fmap</a>
gr</pre>
gr
gr<h4><b>Examples</b></h4>
gr
grApply <tt>(+1)</tt> to a list, a <a>Just</a> and a <a>Right</a>:
gr
gr<pre>
gr&gt;&gt;&gt; Just 2 &lt;&amp;&gt; (+1)
grJust 3
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; [1,2,3] &lt;&amp;&gt; (+1)
gr[2,3,4]
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; Right 3 &lt;&amp;&gt; (+1)
grRight 4
gr</pre>
(<&>) :: Functor f => f a -> (a -> b) -> f b
infixl 1 <&>

-- | <tt><a>void</a> value</tt> discards or ignores the result of
grevaluation, such as the return value of an <a>IO</a> action.
gr
gr<h4><b>Examples</b></h4>
gr
grReplace the contents of a <tt><tt>Maybe</tt> <tt>Int</tt></tt> with
grunit:
gr
gr<pre>
gr&gt;&gt;&gt; void Nothing
grNothing
gr
gr&gt;&gt;&gt; void (Just 3)
grJust ()
gr</pre>
gr
grReplace the contents of an <tt><tt>Either</tt> <tt>Int</tt>
gr<tt>Int</tt></tt> with unit, resulting in an <tt><tt>Either</tt>
gr<tt>Int</tt> '()'</tt>:
gr
gr<pre>
gr&gt;&gt;&gt; void (Left 8675309)
grLeft 8675309
gr
gr&gt;&gt;&gt; void (Right 8675309)
grRight ()
gr</pre>
gr
grReplace every element of a list with unit:
gr
gr<pre>
gr&gt;&gt;&gt; void [1,2,3]
gr[(),(),()]
gr</pre>
gr
grReplace the second element of a pair with unit:
gr
gr<pre>
gr&gt;&gt;&gt; void (1,2)
gr(1,())
gr</pre>
gr
grDiscard the result of an <a>IO</a> action:
gr
gr<pre>
gr&gt;&gt;&gt; mapM print [1,2]
gr1
gr2
gr[(),()]
gr
gr&gt;&gt;&gt; void $ mapM print [1,2]
gr1
gr2
gr</pre>
void :: Functor f => f a -> f ()


-- | Simple combinators working solely on and with functions.
module Data.Function

-- | Identity function.
gr
gr<pre>
grid x = x
gr</pre>
id :: a -> a

-- | <tt>const x</tt> is a unary function which evaluates to <tt>x</tt> for
grall inputs.
gr
gr<pre>
gr&gt;&gt;&gt; const 42 "hello"
gr42
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; map (const 42) [0..3]
gr[42,42,42,42]
gr</pre>
const :: a -> b -> a

-- | Function composition.
(.) :: (b -> c) -> (a -> b) -> a -> c
infixr 9 .

-- | <tt><a>flip</a> f</tt> takes its (first) two arguments in the reverse
grorder of <tt>f</tt>.
gr
gr<pre>
gr&gt;&gt;&gt; flip (++) "hello" "world"
gr"worldhello"
gr</pre>
flip :: (a -> b -> c) -> b -> a -> c

-- | Application operator. This operator is redundant, since ordinary
grapplication <tt>(f x)</tt> means the same as <tt>(f <a>$</a> x)</tt>.
grHowever, <a>$</a> has low, right-associative binding precedence, so it
grsometimes allows parentheses to be omitted; for example:
gr
gr<pre>
grf $ g $ h x  =  f (g (h x))
gr</pre>
gr
grIt is also useful in higher-order situations, such as <tt><a>map</a>
gr(<a>$</a> 0) xs</tt>, or <tt><a>zipWith</a> (<a>$</a>) fs xs</tt>.
($) :: (a -> b) -> a -> b
infixr 0 $

-- | <a>&amp;</a> is a reverse application operator. This provides
grnotational convenience. Its precedence is one higher than that of the
grforward application operator <a>$</a>, which allows <a>&amp;</a> to be
grnested in <a>$</a>.
gr
gr<pre>
gr&gt;&gt;&gt; 5 &amp; (+1) &amp; show
gr"6"
gr</pre>
(&) :: a -> (a -> b) -> b
infixl 1 &

-- | <tt><a>fix</a> f</tt> is the least fixed point of the function
gr<tt>f</tt>, i.e. the least defined <tt>x</tt> such that <tt>f x =
grx</tt>.
gr
grFor example, we can write the factorial function using direct
grrecursion as
gr
gr<pre>
gr&gt;&gt;&gt; let fac n = if n &lt;= 1 then 1 else n * fac (n-1) in fac 5
gr120
gr</pre>
gr
grThis uses the fact that Haskell’s <tt>let</tt> introduces recursive
grbindings. We can rewrite this definition using <a>fix</a>,
gr
gr<pre>
gr&gt;&gt;&gt; fix (\rec n -&gt; if n &lt;= 1 then 1 else n * rec (n-1)) 5
gr120
gr</pre>
gr
grInstead of making a recursive call, we introduce a dummy parameter
gr<tt>rec</tt>; when used within <a>fix</a>, this parameter then refers
grto <tt>fix'</tt> argument, hence the recursion is reintroduced.
fix :: (a -> a) -> a
on :: (b -> b -> c) -> (a -> b) -> a -> a -> c
infixl 0 `on`


-- | Equality
module Data.Eq

-- | The <a>Eq</a> class defines equality (<a>==</a>) and inequality
gr(<a>/=</a>). All the basic datatypes exported by the <a>Prelude</a>
grare instances of <a>Eq</a>, and <a>Eq</a> may be derived for any
grdatatype whose constituents are also instances of <a>Eq</a>.
gr
grMinimal complete definition: either <a>==</a> or <a>/=</a>.
class Eq a
(==) :: Eq a => a -> a -> Bool
(/=) :: Eq a => a -> a -> Bool


-- | Safe coercions between data types.
gr
grMore in-depth information can be found on the <a>Roles wiki page</a>
module Data.Coerce

-- | The function <tt>coerce</tt> allows you to safely convert between
grvalues of types that have the same representation with no run-time
groverhead. In the simplest case you can use it instead of a newtype
grconstructor, to go from the newtype's concrete type to the abstract
grtype. But it also works in more complicated settings, e.g. converting
gra list of newtypes to a list of concrete types.
coerce :: Coercible a b => a -> b

-- | <tt>Coercible</tt> is a two-parameter class that has instances for
grtypes <tt>a</tt> and <tt>b</tt> if the compiler can infer that they
grhave the same representation. This class does not have regular
grinstances; instead they are created on-the-fly during type-checking.
grTrying to manually declare an instance of <tt>Coercible</tt> is an
grerror.
gr
grNevertheless one can pretend that the following three kinds of
grinstances exist. First, as a trivial base-case:
gr
gr<pre>
grinstance Coercible a a
gr</pre>
gr
grFurthermore, for every type constructor there is an instance that
grallows to coerce under the type constructor. For example, let
gr<tt>D</tt> be a prototypical type constructor (<tt>data</tt> or
gr<tt>newtype</tt>) with three type arguments, which have roles
gr<tt>nominal</tt>, <tt>representational</tt> resp. <tt>phantom</tt>.
grThen there is an instance of the form
gr
gr<pre>
grinstance Coercible b b' =&gt; Coercible (D a b c) (D a b' c')
gr</pre>
gr
grNote that the <tt>nominal</tt> type arguments are equal, the
gr<tt>representational</tt> type arguments can differ, but need to have
gra <tt>Coercible</tt> instance themself, and the <tt>phantom</tt> type
grarguments can be changed arbitrarily.
gr
grThe third kind of instance exists for every <tt>newtype NT = MkNT
grT</tt> and comes in two variants, namely
gr
gr<pre>
grinstance Coercible a T =&gt; Coercible a NT
gr</pre>
gr
gr<pre>
grinstance Coercible T b =&gt; Coercible NT b
gr</pre>
gr
grThis instance is only usable if the constructor <tt>MkNT</tt> is in
grscope.
gr
grIf, as a library author of a type constructor like <tt>Set a</tt>, you
grwant to prevent a user of your module to write <tt>coerce :: Set T
gr-&gt; Set NT</tt>, you need to set the role of <tt>Set</tt>'s type
grparameter to <tt>nominal</tt>, by writing
gr
gr<pre>
grtype role Set nominal
gr</pre>
gr
grFor more details about this feature, please refer to <a>Safe
grCoercions</a> by Joachim Breitner, Richard A. Eisenberg, Simon Peyton
grJones and Stephanie Weirich.
class a ~R# b => Coercible (a :: k0) (b :: k0)


-- | The <a>Bool</a> type and related functions.
module Data.Bool
data Bool
False :: Bool
True :: Bool

-- | Boolean "and"
(&&) :: Bool -> Bool -> Bool
infixr 3 &&

-- | Boolean "or"
(||) :: Bool -> Bool -> Bool
infixr 2 ||

-- | Boolean "not"
not :: Bool -> Bool

-- | <a>otherwise</a> is defined as the value <a>True</a>. It helps to make
grguards more readable. eg.
gr
gr<pre>
grf x | x &lt; 0     = ...
gr    | otherwise = ...
gr</pre>
otherwise :: Bool

-- | Case analysis for the <a>Bool</a> type. <tt><a>bool</a> x y p</tt>
grevaluates to <tt>x</tt> when <tt>p</tt> is <a>False</a>, and evaluates
grto <tt>y</tt> when <tt>p</tt> is <a>True</a>.
gr
grThis is equivalent to <tt>if p then y else x</tt>; that is, one can
grthink of it as an if-then-else construct with its arguments reordered.
gr
gr<h4><b>Examples</b></h4>
gr
grBasic usage:
gr
gr<pre>
gr&gt;&gt;&gt; bool "foo" "bar" True
gr"bar"
gr
gr&gt;&gt;&gt; bool "foo" "bar" False
gr"foo"
gr</pre>
gr
grConfirm that <tt><a>bool</a> x y p</tt> and <tt>if p then y else
grx</tt> are equivalent:
gr
gr<pre>
gr&gt;&gt;&gt; let p = True; x = "bar"; y = "foo"
gr
gr&gt;&gt;&gt; bool x y p == if p then y else x
grTrue
gr
gr&gt;&gt;&gt; let p = False
gr
gr&gt;&gt;&gt; bool x y p == if p then y else x
grTrue
gr</pre>
bool :: a -> a -> Bool -> a


-- | Basic operations on type-level Booleans.
module Data.Type.Bool

-- | Type-level <a>If</a>. <tt>If True a b</tt> ==&gt; <tt>a</tt>; <tt>If
grFalse a b</tt> ==&gt; <tt>b</tt>

-- | Type-level "and"

-- | Type-level "or"

-- | Type-level "not". An injective type family since <tt>4.10.0.0</tt>.


-- | This module defines bitwise operations for signed and unsigned
grintegers. Instances of the class <a>Bits</a> for the <a>Int</a> and
gr<a>Integer</a> types are available from this module, and instances for
grexplicitly sized integral types are available from the <a>Data.Int</a>
grand <a>Data.Word</a> modules.
module Data.Bits

-- | The <a>Bits</a> class defines bitwise operations over integral types.
gr
gr<ul>
gr<li>Bits are numbered from 0 with bit 0 being the least significant
grbit.</li>
gr</ul>
class Eq a => Bits a

-- | Bitwise "and"
(.&.) :: Bits a => a -> a -> a

-- | Bitwise "or"
(.|.) :: Bits a => a -> a -> a

-- | Bitwise "xor"
xor :: Bits a => a -> a -> a

-- | Reverse all the bits in the argument
complement :: Bits a => a -> a

-- | <tt><a>shift</a> x i</tt> shifts <tt>x</tt> left by <tt>i</tt> bits if
gr<tt>i</tt> is positive, or right by <tt>-i</tt> bits otherwise. Right
grshifts perform sign extension on signed number types; i.e. they fill
grthe top bits with 1 if the <tt>x</tt> is negative and with 0
grotherwise.
gr
grAn instance can define either this unified <a>shift</a> or
gr<a>shiftL</a> and <a>shiftR</a>, depending on which is more convenient
grfor the type in question.
shift :: Bits a => a -> Int -> a

-- | <tt><a>rotate</a> x i</tt> rotates <tt>x</tt> left by <tt>i</tt> bits
grif <tt>i</tt> is positive, or right by <tt>-i</tt> bits otherwise.
gr
grFor unbounded types like <a>Integer</a>, <a>rotate</a> is equivalent
grto <a>shift</a>.
gr
grAn instance can define either this unified <a>rotate</a> or
gr<a>rotateL</a> and <a>rotateR</a>, depending on which is more
grconvenient for the type in question.
rotate :: Bits a => a -> Int -> a

-- | <a>zeroBits</a> is the value with all bits unset.
gr
grThe following laws ought to hold (for all valid bit indices
gr<tt><i>n</i></tt>):
gr
gr<ul>
gr<li><pre><a>clearBit</a> <a>zeroBits</a> <i>n</i> ==
gr<a>zeroBits</a></pre></li>
gr<li><pre><a>setBit</a> <a>zeroBits</a> <i>n</i> == <a>bit</a>
gr<i>n</i></pre></li>
gr<li><pre><a>testBit</a> <a>zeroBits</a> <i>n</i> == False</pre></li>
gr<li><pre><a>popCount</a> <a>zeroBits</a> == 0</pre></li>
gr</ul>
gr
grThis method uses <tt><a>clearBit</a> (<a>bit</a> 0) 0</tt> as its
grdefault implementation (which ought to be equivalent to
gr<a>zeroBits</a> for types which possess a 0th bit).
zeroBits :: Bits a => a

-- | <tt>bit <i>i</i></tt> is a value with the <tt><i>i</i></tt>th bit set
grand all other bits clear.
gr
grCan be implemented using <a>bitDefault</a> if <tt>a</tt> is also an
grinstance of <a>Num</a>.
gr
grSee also <a>zeroBits</a>.
bit :: Bits a => Int -> a

-- | <tt>x `setBit` i</tt> is the same as <tt>x .|. bit i</tt>
setBit :: Bits a => a -> Int -> a

-- | <tt>x `clearBit` i</tt> is the same as <tt>x .&amp;. complement (bit
gri)</tt>
clearBit :: Bits a => a -> Int -> a

-- | <tt>x `complementBit` i</tt> is the same as <tt>x `xor` bit i</tt>
complementBit :: Bits a => a -> Int -> a

-- | Return <a>True</a> if the <tt>n</tt>th bit of the argument is 1
gr
grCan be implemented using <a>testBitDefault</a> if <tt>a</tt> is also
gran instance of <a>Num</a>.
testBit :: Bits a => a -> Int -> Bool

-- | Return the number of bits in the type of the argument. The actual
grvalue of the argument is ignored. Returns Nothing for types that do
grnot have a fixed bitsize, like <a>Integer</a>.
bitSizeMaybe :: Bits a => a -> Maybe Int

-- | Return the number of bits in the type of the argument. The actual
grvalue of the argument is ignored. The function <a>bitSize</a> is
grundefined for types that do not have a fixed bitsize, like
gr<a>Integer</a>.

-- | <i>Deprecated: Use <a>bitSizeMaybe</a> or <a>finiteBitSize</a>
grinstead</i>
bitSize :: Bits a => a -> Int

-- | Return <a>True</a> if the argument is a signed type. The actual value
grof the argument is ignored
isSigned :: Bits a => a -> Bool

-- | Shift the argument left by the specified number of bits (which must be
grnon-negative).
gr
grAn instance can define either this and <a>shiftR</a> or the unified
gr<a>shift</a>, depending on which is more convenient for the type in
grquestion.
shiftL :: Bits a => a -> Int -> a

-- | Shift the argument left by the specified number of bits. The result is
grundefined for negative shift amounts and shift amounts greater or
grequal to the <a>bitSize</a>.
gr
grDefaults to <a>shiftL</a> unless defined explicitly by an instance.
unsafeShiftL :: Bits a => a -> Int -> a

-- | Shift the first argument right by the specified number of bits. The
grresult is undefined for negative shift amounts and shift amounts
grgreater or equal to the <a>bitSize</a>.
gr
grRight shifts perform sign extension on signed number types; i.e. they
grfill the top bits with 1 if the <tt>x</tt> is negative and with 0
grotherwise.
gr
grAn instance can define either this and <a>shiftL</a> or the unified
gr<a>shift</a>, depending on which is more convenient for the type in
grquestion.
shiftR :: Bits a => a -> Int -> a

-- | Shift the first argument right by the specified number of bits, which
grmust be non-negative and smaller than the number of bits in the type.
gr
grRight shifts perform sign extension on signed number types; i.e. they
grfill the top bits with 1 if the <tt>x</tt> is negative and with 0
grotherwise.
gr
grDefaults to <a>shiftR</a> unless defined explicitly by an instance.
unsafeShiftR :: Bits a => a -> Int -> a

-- | Rotate the argument left by the specified number of bits (which must
grbe non-negative).
gr
grAn instance can define either this and <a>rotateR</a> or the unified
gr<a>rotate</a>, depending on which is more convenient for the type in
grquestion.
rotateL :: Bits a => a -> Int -> a

-- | Rotate the argument right by the specified number of bits (which must
grbe non-negative).
gr
grAn instance can define either this and <a>rotateL</a> or the unified
gr<a>rotate</a>, depending on which is more convenient for the type in
grquestion.
rotateR :: Bits a => a -> Int -> a

-- | Return the number of set bits in the argument. This number is known as
grthe population count or the Hamming weight.
gr
grCan be implemented using <a>popCountDefault</a> if <tt>a</tt> is also
gran instance of <a>Num</a>.
popCount :: Bits a => a -> Int

-- | The <a>FiniteBits</a> class denotes types with a finite, fixed number
grof bits.
class Bits b => FiniteBits b

-- | Return the number of bits in the type of the argument. The actual
grvalue of the argument is ignored. Moreover, <a>finiteBitSize</a> is
grtotal, in contrast to the deprecated <a>bitSize</a> function it
grreplaces.
gr
gr<pre>
gr<a>finiteBitSize</a> = <a>bitSize</a>
gr<a>bitSizeMaybe</a> = <a>Just</a> . <a>finiteBitSize</a>
gr</pre>
finiteBitSize :: FiniteBits b => b -> Int

-- | Count number of zero bits preceding the most significant set bit.
gr
gr<pre>
gr<a>countLeadingZeros</a> (<a>zeroBits</a> :: a) = finiteBitSize (<a>zeroBits</a> :: a)
gr</pre>
gr
gr<a>countLeadingZeros</a> can be used to compute log base 2 via
gr
gr<pre>
grlogBase2 x = <a>finiteBitSize</a> x - 1 - <a>countLeadingZeros</a> x
gr</pre>
gr
grNote: The default implementation for this method is intentionally
grnaive. However, the instances provided for the primitive integral
grtypes are implemented using CPU specific machine instructions.
countLeadingZeros :: FiniteBits b => b -> Int

-- | Count number of zero bits following the least significant set bit.
gr
gr<pre>
gr<a>countTrailingZeros</a> (<a>zeroBits</a> :: a) = finiteBitSize (<a>zeroBits</a> :: a)
gr<a>countTrailingZeros</a> . <a>negate</a> = <a>countTrailingZeros</a>
gr</pre>
gr
grThe related <a>find-first-set operation</a> can be expressed in terms
grof <a>countTrailingZeros</a> as follows
gr
gr<pre>
grfindFirstSet x = 1 + <a>countTrailingZeros</a> x
gr</pre>
gr
grNote: The default implementation for this method is intentionally
grnaive. However, the instances provided for the primitive integral
grtypes are implemented using CPU specific machine instructions.
countTrailingZeros :: FiniteBits b => b -> Int

-- | Default implementation for <a>bit</a>.
gr
grNote that: <tt>bitDefault i = 1 <a>shiftL</a> i</tt>
bitDefault :: (Bits a, Num a) => Int -> a

-- | Default implementation for <a>testBit</a>.
gr
grNote that: <tt>testBitDefault x i = (x .&amp;. bit i) /= 0</tt>
testBitDefault :: (Bits a, Num a) => a -> Int -> Bool

-- | Default implementation for <a>popCount</a>.
gr
grThis implementation is intentionally naive. Instances are expected to
grprovide an optimized implementation for their size.
popCountDefault :: (Bits a, Num a) => a -> Int

-- | Attempt to convert an <a>Integral</a> type <tt>a</tt> to an
gr<a>Integral</a> type <tt>b</tt> using the size of the types as
grmeasured by <a>Bits</a> methods.
gr
grA simpler version of this function is:
gr
gr<pre>
grtoIntegral :: (Integral a, Integral b) =&gt; a -&gt; Maybe b
grtoIntegral x
gr  | toInteger x == y = Just (fromInteger y)
gr  | otherwise        = Nothing
gr  where
gr    y = toInteger x
gr</pre>
gr
grThis version requires going through <a>Integer</a>, which can be
grinefficient. However, <tt>toIntegralSized</tt> is optimized to allow
grGHC to statically determine the relative type sizes (as measured by
gr<a>bitSizeMaybe</a> and <a>isSigned</a>) and avoid going through
gr<a>Integer</a> for many types. (The implementation uses
gr<a>fromIntegral</a>, which is itself optimized with rules for
gr<tt>base</tt> types but may go through <a>Integer</a> for some type
grpairs.)
toIntegralSized :: (Integral a, Integral b, Bits a, Bits b) => a -> Maybe b
instance Data.Bits.FiniteBits GHC.Types.Bool
instance Data.Bits.Bits GHC.Types.Int
instance Data.Bits.FiniteBits GHC.Types.Int
instance Data.Bits.Bits GHC.Types.Word
instance Data.Bits.FiniteBits GHC.Types.Word
instance Data.Bits.Bits GHC.Types.Bool
instance Data.Bits.Bits GHC.Integer.Type.Integer


-- | Transitional module providing the <a>MonadFail</a> class and primitive
grinstances.
gr
grThis module can be imported for defining forward compatible
gr<a>MonadFail</a> instances:
gr
gr<pre>
grimport qualified Control.Monad.Fail as Fail
gr
grinstance Monad Foo where
gr  (&gt;&gt;=) = {- ...bind impl... -}
gr
gr  -- Provide legacy <a>fail</a> implementation for when
gr  -- new-style MonadFail desugaring is not enabled.
gr  fail = Fail.fail
gr
grinstance Fail.MonadFail Foo where
gr  fail = {- ...fail implementation... -}
gr</pre>
gr
grSee
gr<a>https://prime.haskell.org/wiki/Libraries/Proposals/MonadFail</a>
grfor more details.
module Control.Monad.Fail

-- | When a value is bound in <tt>do</tt>-notation, the pattern on the left
grhand side of <tt>&lt;-</tt> might not match. In this case, this class
grprovides a function to recover.
gr
grA <a>Monad</a> without a <a>MonadFail</a> instance may only be used in
grconjunction with pattern that always match, such as newtypes, tuples,
grdata types with only a single data constructor, and irrefutable
grpatterns (<tt>~pat</tt>).
gr
grInstances of <a>MonadFail</a> should satisfy the following law:
gr<tt>fail s</tt> should be a left zero for <tt>&gt;&gt;=</tt>,
gr
gr<pre>
grfail s &gt;&gt;= f  =  fail s
gr</pre>
gr
grIf your <a>Monad</a> is also <tt>MonadPlus</tt>, a popular definition
gris
gr
gr<pre>
grfail _ = mzero
gr</pre>
class Monad m => MonadFail m
fail :: MonadFail m => String -> m a
instance Control.Monad.Fail.MonadFail GHC.Base.Maybe
instance Control.Monad.Fail.MonadFail []
instance Control.Monad.Fail.MonadFail GHC.Types.IO


-- | This is a library of parser combinators, originally written by Koen
grClaessen. It parses all alternatives in parallel, so it never keeps
grhold of the beginning of the input string, a common source of space
grleaks with other parsers. The '(+++)' choice combinator is genuinely
grcommutative; it makes no difference which branch is "shorter".
module Text.ParserCombinators.ReadP
data ReadP a

-- | Consumes and returns the next character. Fails if there is no input
grleft.
get :: ReadP Char

-- | Look-ahead: returns the part of the input that is left, without
grconsuming it.
look :: ReadP String

-- | Symmetric choice.
(+++) :: ReadP a -> ReadP a -> ReadP a
infixr 5 +++

-- | Local, exclusive, left-biased choice: If left parser locally produces
grany result at all, then right parser is not used.
(<++) :: ReadP a -> ReadP a -> ReadP a
infixr 5 <++

-- | Transforms a parser into one that does the same, but in addition
grreturns the exact characters read. IMPORTANT NOTE: <a>gather</a> gives
gra runtime error if its first argument is built using any occurrences
grof readS_to_P.
gather :: ReadP a -> ReadP (String, a)

-- | Always fails.
pfail :: ReadP a

-- | Succeeds iff we are at the end of input
eof :: ReadP ()

-- | Consumes and returns the next character, if it satisfies the specified
grpredicate.
satisfy :: (Char -> Bool) -> ReadP Char

-- | Parses and returns the specified character.
char :: Char -> ReadP Char

-- | Parses and returns the specified string.
string :: String -> ReadP String

-- | Parses the first zero or more characters satisfying the predicate.
grAlways succeeds, exactly once having consumed all the characters Hence
grNOT the same as (many (satisfy p))
munch :: (Char -> Bool) -> ReadP String

-- | Parses the first one or more characters satisfying the predicate.
grFails if none, else succeeds exactly once having consumed all the
grcharacters Hence NOT the same as (many1 (satisfy p))
munch1 :: (Char -> Bool) -> ReadP String

-- | Skips all whitespace.
skipSpaces :: ReadP ()

-- | Combines all parsers in the specified list.
choice :: [ReadP a] -> ReadP a

-- | <tt>count n p</tt> parses <tt>n</tt> occurrences of <tt>p</tt> in
grsequence. A list of results is returned.
count :: Int -> ReadP a -> ReadP [a]

-- | <tt>between open close p</tt> parses <tt>open</tt>, followed by
gr<tt>p</tt> and finally <tt>close</tt>. Only the value of <tt>p</tt> is
grreturned.
between :: ReadP open -> ReadP close -> ReadP a -> ReadP a

-- | <tt>option x p</tt> will either parse <tt>p</tt> or return <tt>x</tt>
grwithout consuming any input.
option :: a -> ReadP a -> ReadP a

-- | <tt>optional p</tt> optionally parses <tt>p</tt> and always returns
gr<tt>()</tt>.
optional :: ReadP a -> ReadP ()

-- | Parses zero or more occurrences of the given parser.
many :: ReadP a -> ReadP [a]

-- | Parses one or more occurrences of the given parser.
many1 :: ReadP a -> ReadP [a]

-- | Like <a>many</a>, but discards the result.
skipMany :: ReadP a -> ReadP ()

-- | Like <a>many1</a>, but discards the result.
skipMany1 :: ReadP a -> ReadP ()

-- | <tt>sepBy p sep</tt> parses zero or more occurrences of <tt>p</tt>,
grseparated by <tt>sep</tt>. Returns a list of values returned by
gr<tt>p</tt>.
sepBy :: ReadP a -> ReadP sep -> ReadP [a]

-- | <tt>sepBy1 p sep</tt> parses one or more occurrences of <tt>p</tt>,
grseparated by <tt>sep</tt>. Returns a list of values returned by
gr<tt>p</tt>.
sepBy1 :: ReadP a -> ReadP sep -> ReadP [a]

-- | <tt>endBy p sep</tt> parses zero or more occurrences of <tt>p</tt>,
grseparated and ended by <tt>sep</tt>.
endBy :: ReadP a -> ReadP sep -> ReadP [a]

-- | <tt>endBy p sep</tt> parses one or more occurrences of <tt>p</tt>,
grseparated and ended by <tt>sep</tt>.
endBy1 :: ReadP a -> ReadP sep -> ReadP [a]

-- | <tt>chainr p op x</tt> parses zero or more occurrences of <tt>p</tt>,
grseparated by <tt>op</tt>. Returns a value produced by a <i>right</i>
grassociative application of all functions returned by <tt>op</tt>. If
grthere are no occurrences of <tt>p</tt>, <tt>x</tt> is returned.
chainr :: ReadP a -> ReadP (a -> a -> a) -> a -> ReadP a

-- | <tt>chainl p op x</tt> parses zero or more occurrences of <tt>p</tt>,
grseparated by <tt>op</tt>. Returns a value produced by a <i>left</i>
grassociative application of all functions returned by <tt>op</tt>. If
grthere are no occurrences of <tt>p</tt>, <tt>x</tt> is returned.
chainl :: ReadP a -> ReadP (a -> a -> a) -> a -> ReadP a

-- | Like <a>chainl</a>, but parses one or more occurrences of <tt>p</tt>.
chainl1 :: ReadP a -> ReadP (a -> a -> a) -> ReadP a

-- | Like <a>chainr</a>, but parses one or more occurrences of <tt>p</tt>.
chainr1 :: ReadP a -> ReadP (a -> a -> a) -> ReadP a

-- | <tt>manyTill p end</tt> parses zero or more occurrences of <tt>p</tt>,
gruntil <tt>end</tt> succeeds. Returns a list of values returned by
gr<tt>p</tt>.
manyTill :: ReadP a -> ReadP end -> ReadP [a]

-- | A parser for a type <tt>a</tt>, represented as a function that takes a
gr<a>String</a> and returns a list of possible parses as
gr<tt>(a,<a>String</a>)</tt> pairs.
gr
grNote that this kind of backtracking parser is very inefficient;
grreading a large structure may be quite slow (cf <a>ReadP</a>).
type ReadS a = String -> [(a, String)]

-- | Converts a parser into a Haskell ReadS-style function. This is the
grmain way in which you can "run" a <a>ReadP</a> parser: the expanded
grtype is <tt> readP_to_S :: ReadP a -&gt; String -&gt; [(a,String)]
gr</tt>
readP_to_S :: ReadP a -> ReadS a

-- | Converts a Haskell ReadS-style function into a parser. Warning: This
grintroduces local backtracking in the resulting parser, and therefore a
grpossible inefficiency.
readS_to_P :: ReadS a -> ReadP a
instance GHC.Base.Functor Text.ParserCombinators.ReadP.P
instance GHC.Base.Functor Text.ParserCombinators.ReadP.ReadP
instance GHC.Base.Applicative Text.ParserCombinators.ReadP.ReadP
instance GHC.Base.Monad Text.ParserCombinators.ReadP.ReadP
instance Control.Monad.Fail.MonadFail Text.ParserCombinators.ReadP.ReadP
instance GHC.Base.Alternative Text.ParserCombinators.ReadP.ReadP
instance GHC.Base.MonadPlus Text.ParserCombinators.ReadP.ReadP
instance GHC.Base.Applicative Text.ParserCombinators.ReadP.P
instance GHC.Base.MonadPlus Text.ParserCombinators.ReadP.P
instance GHC.Base.Monad Text.ParserCombinators.ReadP.P
instance Control.Monad.Fail.MonadFail Text.ParserCombinators.ReadP.P
instance GHC.Base.Alternative Text.ParserCombinators.ReadP.P


-- | This library defines parser combinators for precedence parsing.
module Text.ParserCombinators.ReadPrec
data ReadPrec a
type Prec = Int
minPrec :: Prec

-- | Lift a precedence-insensitive <a>ReadP</a> to a <a>ReadPrec</a>.
lift :: ReadP a -> ReadPrec a

-- | <tt>(prec n p)</tt> checks whether the precedence context is less than
gror equal to <tt>n</tt>, and
gr
gr<ul>
gr<li>if not, fails</li>
gr<li>if so, parses <tt>p</tt> in context <tt>n</tt>.</li>
gr</ul>
prec :: Prec -> ReadPrec a -> ReadPrec a

-- | Increases the precedence context by one.
step :: ReadPrec a -> ReadPrec a

-- | Resets the precedence context to zero.
reset :: ReadPrec a -> ReadPrec a

-- | Consumes and returns the next character. Fails if there is no input
grleft.
get :: ReadPrec Char

-- | Look-ahead: returns the part of the input that is left, without
grconsuming it.
look :: ReadPrec String

-- | Symmetric choice.
(+++) :: ReadPrec a -> ReadPrec a -> ReadPrec a

-- | Local, exclusive, left-biased choice: If left parser locally produces
grany result at all, then right parser is not used.
(<++) :: ReadPrec a -> ReadPrec a -> ReadPrec a

-- | Always fails.
pfail :: ReadPrec a

-- | Combines all parsers in the specified list.
choice :: [ReadPrec a] -> ReadPrec a
readPrec_to_P :: ReadPrec a -> (Int -> ReadP a)
readP_to_Prec :: (Int -> ReadP a) -> ReadPrec a
readPrec_to_S :: ReadPrec a -> (Int -> ReadS a)
readS_to_Prec :: (Int -> ReadS a) -> ReadPrec a
instance GHC.Base.Functor Text.ParserCombinators.ReadPrec.ReadPrec
instance GHC.Base.Applicative Text.ParserCombinators.ReadPrec.ReadPrec
instance GHC.Base.Monad Text.ParserCombinators.ReadPrec.ReadPrec
instance Control.Monad.Fail.MonadFail Text.ParserCombinators.ReadPrec.ReadPrec
instance GHC.Base.MonadPlus Text.ParserCombinators.ReadPrec.ReadPrec
instance GHC.Base.Alternative Text.ParserCombinators.ReadPrec.ReadPrec


-- | The cut-down Haskell lexer, used by Text.Read
module Text.Read.Lex
data Lexeme

-- | Character literal
Char :: Char -> Lexeme

-- | String literal, with escapes interpreted
String :: String -> Lexeme

-- | Punctuation or reserved symbol, e.g. <tt>(</tt>, <tt>::</tt>
Punc :: String -> Lexeme

-- | Haskell identifier, e.g. <tt>foo</tt>, <tt>Baz</tt>
Ident :: String -> Lexeme

-- | Haskell symbol, e.g. <tt>&gt;&gt;</tt>, <tt>:%</tt>
Symbol :: String -> Lexeme

Number :: Number -> Lexeme
EOF :: Lexeme

data Number

numberToInteger :: Number -> Maybe Integer

numberToFixed :: Integer -> Number -> Maybe (Integer, Integer)

numberToRational :: Number -> Rational

numberToRangedRational :: (Int, Int) -> Number -> Maybe Rational
lex :: ReadP Lexeme

expect :: Lexeme -> ReadP ()

-- | Haskell lexer: returns the lexed string, rather than the lexeme
hsLex :: ReadP String
lexChar :: ReadP Char
readIntP :: Num a => a -> (Char -> Bool) -> (Char -> Int) -> ReadP a
readOctP :: (Eq a, Num a) => ReadP a
readDecP :: (Eq a, Num a) => ReadP a
readHexP :: (Eq a, Num a) => ReadP a
isSymbolChar :: Char -> Bool
instance GHC.Show.Show Text.Read.Lex.Lexeme
instance GHC.Classes.Eq Text.Read.Lex.Lexeme
instance GHC.Show.Show Text.Read.Lex.Number
instance GHC.Classes.Eq Text.Read.Lex.Number


-- | Odds and ends, mostly functions for reading and showing
gr<a>RealFloat</a>-like kind of values.
module Numeric

-- | Converts a possibly-negative <a>Real</a> value to a string.
showSigned :: (Real a) => (a -> ShowS) -> Int -> a -> ShowS

-- | Shows a <i>non-negative</i> <a>Integral</a> number using the base
grspecified by the first argument, and the character representation
grspecified by the second.
showIntAtBase :: (Integral a, Show a) => a -> (Int -> Char) -> a -> ShowS

-- | Show <i>non-negative</i> <a>Integral</a> numbers in base 10.
showInt :: Integral a => a -> ShowS

-- | Show <i>non-negative</i> <a>Integral</a> numbers in base 16.
showHex :: (Integral a, Show a) => a -> ShowS

-- | Show <i>non-negative</i> <a>Integral</a> numbers in base 8.
showOct :: (Integral a, Show a) => a -> ShowS

-- | Show a signed <a>RealFloat</a> value using scientific (exponential)
grnotation (e.g. <tt>2.45e2</tt>, <tt>1.5e-3</tt>).
gr
grIn the call <tt><a>showEFloat</a> digs val</tt>, if <tt>digs</tt> is
gr<a>Nothing</a>, the value is shown to full precision; if <tt>digs</tt>
gris <tt><a>Just</a> d</tt>, then at most <tt>d</tt> digits after the
grdecimal point are shown.
showEFloat :: (RealFloat a) => Maybe Int -> a -> ShowS

-- | Show a signed <a>RealFloat</a> value using standard decimal notation
gr(e.g. <tt>245000</tt>, <tt>0.0015</tt>).
gr
grIn the call <tt><a>showFFloat</a> digs val</tt>, if <tt>digs</tt> is
gr<a>Nothing</a>, the value is shown to full precision; if <tt>digs</tt>
gris <tt><a>Just</a> d</tt>, then at most <tt>d</tt> digits after the
grdecimal point are shown.
showFFloat :: (RealFloat a) => Maybe Int -> a -> ShowS

-- | Show a signed <a>RealFloat</a> value using standard decimal notation
grfor arguments whose absolute value lies between <tt>0.1</tt> and
gr<tt>9,999,999</tt>, and scientific notation otherwise.
gr
grIn the call <tt><a>showGFloat</a> digs val</tt>, if <tt>digs</tt> is
gr<a>Nothing</a>, the value is shown to full precision; if <tt>digs</tt>
gris <tt><a>Just</a> d</tt>, then at most <tt>d</tt> digits after the
grdecimal point are shown.
showGFloat :: (RealFloat a) => Maybe Int -> a -> ShowS

-- | Show a signed <a>RealFloat</a> value using standard decimal notation
gr(e.g. <tt>245000</tt>, <tt>0.0015</tt>).
gr
grThis behaves as <a>showFFloat</a>, except that a decimal point is
gralways guaranteed, even if not needed.
showFFloatAlt :: (RealFloat a) => Maybe Int -> a -> ShowS

-- | Show a signed <a>RealFloat</a> value using standard decimal notation
grfor arguments whose absolute value lies between <tt>0.1</tt> and
gr<tt>9,999,999</tt>, and scientific notation otherwise.
gr
grThis behaves as <a>showFFloat</a>, except that a decimal point is
gralways guaranteed, even if not needed.
showGFloatAlt :: (RealFloat a) => Maybe Int -> a -> ShowS

-- | Show a signed <a>RealFloat</a> value to full precision using standard
grdecimal notation for arguments whose absolute value lies between
gr<tt>0.1</tt> and <tt>9,999,999</tt>, and scientific notation
grotherwise.
showFloat :: (RealFloat a) => a -> ShowS

-- | Show a floating-point value in the hexadecimal format, similar to the
gr<tt>%a</tt> specifier in C's printf.
gr
gr<pre>
gr&gt;&gt;&gt; showHFloat (212.21 :: Double) ""
gr"0x1.a86b851eb851fp7"
gr
gr&gt;&gt;&gt; showHFloat (-12.76 :: Float) ""
gr"-0x1.9851ecp3"
gr
gr&gt;&gt;&gt; showHFloat (-0 :: Double) ""
gr"-0x0p+0"
gr</pre>
showHFloat :: RealFloat a => a -> ShowS

-- | <a>floatToDigits</a> takes a base and a non-negative <a>RealFloat</a>
grnumber, and returns a list of digits and an exponent. In particular,
grif <tt>x&gt;=0</tt>, and
gr
gr<pre>
grfloatToDigits base x = ([d1,d2,...,dn], e)
gr</pre>
gr
grthen
gr
gr<ol>
gr<li><pre>n &gt;= 1</pre></li>
gr<li><pre>x = 0.d1d2...dn * (base**e)</pre></li>
gr<li><pre>0 &lt;= di &lt;= base-1</pre></li>
gr</ol>
floatToDigits :: (RealFloat a) => Integer -> a -> ([Int], Int)

-- | Reads a <i>signed</i> <a>Real</a> value, given a reader for an
grunsigned value.
readSigned :: (Real a) => ReadS a -> ReadS a

-- | Reads an <i>unsigned</i> <a>Integral</a> value in an arbitrary base.
readInt :: Num a => a -> (Char -> Bool) -> (Char -> Int) -> ReadS a

-- | Read an unsigned number in decimal notation.
gr
gr<pre>
gr&gt;&gt;&gt; readDec "0644"
gr[(644,"")]
gr</pre>
readDec :: (Eq a, Num a) => ReadS a

-- | Read an unsigned number in octal notation.
gr
gr<pre>
gr&gt;&gt;&gt; readOct "0644"
gr[(420,"")]
gr</pre>
readOct :: (Eq a, Num a) => ReadS a

-- | Read an unsigned number in hexadecimal notation. Both upper or lower
grcase letters are allowed.
gr
gr<pre>
gr&gt;&gt;&gt; readHex "deadbeef"
gr[(3735928559,"")]
gr</pre>
readHex :: (Eq a, Num a) => ReadS a

-- | Reads an <i>unsigned</i> <a>RealFrac</a> value, expressed in decimal
grscientific notation.
readFloat :: RealFrac a => ReadS a

-- | Reads a non-empty string of decimal digits.
lexDigits :: ReadS String

-- | Converts a <a>Rational</a> value into any type in class
gr<a>RealFloat</a>.
fromRat :: (RealFloat a) => Rational -> a

-- | Trigonometric and hyperbolic functions and related functions.
class (Fractional a) => Floating a
pi :: Floating a => a
exp :: Floating a => a -> a
log :: Floating a => a -> a
sqrt :: Floating a => a -> a
(**) :: Floating a => a -> a -> a
logBase :: Floating a => a -> a -> a
sin :: Floating a => a -> a
cos :: Floating a => a -> a
tan :: Floating a => a -> a
asin :: Floating a => a -> a
acos :: Floating a => a -> a
atan :: Floating a => a -> a
sinh :: Floating a => a -> a
cosh :: Floating a => a -> a
tanh :: Floating a => a -> a
asinh :: Floating a => a -> a
acosh :: Floating a => a -> a
atanh :: Floating a => a -> a

-- | <tt><a>log1p</a> x</tt> computes <tt><a>log</a> (1 + x)</tt>, but
grprovides more precise results for small (absolute) values of
gr<tt>x</tt> if possible.
log1p :: Floating a => a -> a

-- | <tt><a>expm1</a> x</tt> computes <tt><a>exp</a> x - 1</tt>, but
grprovides more precise results for small (absolute) values of
gr<tt>x</tt> if possible.
expm1 :: Floating a => a -> a

-- | <tt><a>log1pexp</a> x</tt> computes <tt><a>log</a> (1 + <a>exp</a>
grx)</tt>, but provides more precise results if possible.
gr
grExamples:
gr
gr<ul>
gr<li>if <tt>x</tt> is a large negative number, <tt><a>log</a> (1 +
gr<a>exp</a> x)</tt> will be imprecise for the reasons given in
gr<a>log1p</a>.</li>
gr<li>if <tt><a>exp</a> x</tt> is close to <tt>-1</tt>, <tt><a>log</a>
gr(1 + <a>exp</a> x)</tt> will be imprecise for the reasons given in
gr<a>expm1</a>.</li>
gr</ul>
log1pexp :: Floating a => a -> a

-- | <tt><a>log1mexp</a> x</tt> computes <tt><a>log</a> (1 - <a>exp</a>
grx)</tt>, but provides more precise results if possible.
gr
grExamples:
gr
gr<ul>
gr<li>if <tt>x</tt> is a large negative number, <tt><a>log</a> (1 -
gr<a>exp</a> x)</tt> will be imprecise for the reasons given in
gr<a>log1p</a>.</li>
gr<li>if <tt><a>exp</a> x</tt> is close to <tt>1</tt>, <tt><a>log</a> (1
gr- <a>exp</a> x)</tt> will be imprecise for the reasons given in
gr<a>expm1</a>.</li>
gr</ul>
log1mexp :: Floating a => a -> a


-- | This module is part of the Foreign Function Interface (FFI) and will
grusually be imported via the module <a>Foreign</a>.
module Foreign.StablePtr

-- | A <i>stable pointer</i> is a reference to a Haskell expression that is
grguaranteed not to be affected by garbage collection, i.e., it will
grneither be deallocated nor will the value of the stable pointer itself
grchange during garbage collection (ordinary references may be relocated
grduring garbage collection). Consequently, stable pointers can be
grpassed to foreign code, which can treat it as an opaque reference to a
grHaskell value.
gr
grA value of type <tt>StablePtr a</tt> is a stable pointer to a Haskell
grexpression of type <tt>a</tt>.
data {-# CTYPE "HsStablePtr" #-} StablePtr a

-- | Create a stable pointer referring to the given Haskell value.
newStablePtr :: a -> IO (StablePtr a)

-- | Obtain the Haskell value referenced by a stable pointer, i.e., the
grsame value that was passed to the corresponding call to
gr<tt>makeStablePtr</tt>. If the argument to <a>deRefStablePtr</a> has
gralready been freed using <a>freeStablePtr</a>, the behaviour of
gr<a>deRefStablePtr</a> is undefined.
deRefStablePtr :: StablePtr a -> IO a

-- | Dissolve the association between the stable pointer and the Haskell
grvalue. Afterwards, if the stable pointer is passed to
gr<a>deRefStablePtr</a> or <a>freeStablePtr</a>, the behaviour is
grundefined. However, the stable pointer may still be passed to
gr<a>castStablePtrToPtr</a>, but the <tt><a>Ptr</a> ()</tt> value
grreturned by <a>castStablePtrToPtr</a>, in this case, is undefined (in
grparticular, it may be <a>nullPtr</a>). Nevertheless, the call to
gr<a>castStablePtrToPtr</a> is guaranteed not to diverge.
freeStablePtr :: StablePtr a -> IO ()

-- | Coerce a stable pointer to an address. No guarantees are made about
grthe resulting value, except that the original stable pointer can be
grrecovered by <a>castPtrToStablePtr</a>. In particular, the address may
grnot refer to an accessible memory location and any attempt to pass it
grto the member functions of the class <a>Storable</a> leads to
grundefined behaviour.
castStablePtrToPtr :: StablePtr a -> Ptr ()

-- | The inverse of <a>castStablePtrToPtr</a>, i.e., we have the identity
gr
gr<pre>
grsp == castPtrToStablePtr (castStablePtrToPtr sp)
gr</pre>
gr
grfor any stable pointer <tt>sp</tt> on which <a>freeStablePtr</a> has
grnot been executed yet. Moreover, <a>castPtrToStablePtr</a> may only be
grapplied to pointers that have been produced by
gr<a>castStablePtrToPtr</a>.
castPtrToStablePtr :: Ptr () -> StablePtr a

module GHC.Fingerprint.Type
data Fingerprint
Fingerprint :: {-# UNPACK #-} !Word64 -> {-# UNPACK #-} !Word64 -> Fingerprint
instance GHC.Classes.Ord GHC.Fingerprint.Type.Fingerprint
instance GHC.Classes.Eq GHC.Fingerprint.Type.Fingerprint
instance GHC.Show.Show GHC.Fingerprint.Type.Fingerprint


-- | The module <a>Foreign.Storable</a> provides most elementary support
grfor marshalling and is part of the language-independent portion of the
grForeign Function Interface (FFI), and will normally be imported via
grthe <a>Foreign</a> module.
module Foreign.Storable

-- | The member functions of this class facilitate writing values of
grprimitive types to raw memory (which may have been allocated with the
grabove mentioned routines) and reading values from blocks of raw
grmemory. The class, furthermore, includes support for computing the
grstorage requirements and alignment restrictions of storable types.
gr
grMemory addresses are represented as values of type <tt><a>Ptr</a>
gra</tt>, for some <tt>a</tt> which is an instance of class
gr<a>Storable</a>. The type argument to <a>Ptr</a> helps provide some
grvaluable type safety in FFI code (you can't mix pointers of different
grtypes without an explicit cast), while helping the Haskell type system
grfigure out which marshalling method is needed for a given pointer.
gr
grAll marshalling between Haskell and a foreign language ultimately
grboils down to translating Haskell data structures into the binary
grrepresentation of a corresponding data structure of the foreign
grlanguage and vice versa. To code this marshalling in Haskell, it is
grnecessary to manipulate primitive data types stored in unstructured
grmemory blocks. The class <a>Storable</a> facilitates this manipulation
gron all types for which it is instantiated, which are the standard
grbasic types of Haskell, the fixed size <tt>Int</tt> types
gr(<a>Int8</a>, <a>Int16</a>, <a>Int32</a>, <a>Int64</a>), the fixed
grsize <tt>Word</tt> types (<a>Word8</a>, <a>Word16</a>, <a>Word32</a>,
gr<a>Word64</a>), <a>StablePtr</a>, all types from
gr<a>Foreign.C.Types</a>, as well as <a>Ptr</a>.
class Storable a

-- | Computes the storage requirements (in bytes) of the argument. The
grvalue of the argument is not used.
sizeOf :: Storable a => a -> Int

-- | Computes the alignment constraint of the argument. An alignment
grconstraint <tt>x</tt> is fulfilled by any address divisible by
gr<tt>x</tt>. The value of the argument is not used.
alignment :: Storable a => a -> Int

-- | Read a value from a memory area regarded as an array of values of the
grsame kind. The first argument specifies the start address of the array
grand the second the index into the array (the first element of the
grarray has index <tt>0</tt>). The following equality holds,
gr
gr<pre>
grpeekElemOff addr idx = IOExts.fixIO $ \result -&gt;
gr  peek (addr `plusPtr` (idx * sizeOf result))
gr</pre>
gr
grNote that this is only a specification, not necessarily the concrete
grimplementation of the function.
peekElemOff :: Storable a => Ptr a -> Int -> IO a

-- | Write a value to a memory area regarded as an array of values of the
grsame kind. The following equality holds:
gr
gr<pre>
grpokeElemOff addr idx x = 
gr  poke (addr `plusPtr` (idx * sizeOf x)) x
gr</pre>
pokeElemOff :: Storable a => Ptr a -> Int -> a -> IO ()

-- | Read a value from a memory location given by a base address and
groffset. The following equality holds:
gr
gr<pre>
grpeekByteOff addr off = peek (addr `plusPtr` off)
gr</pre>
peekByteOff :: Storable a => Ptr b -> Int -> IO a

-- | Write a value to a memory location given by a base address and offset.
grThe following equality holds:
gr
gr<pre>
grpokeByteOff addr off x = poke (addr `plusPtr` off) x
gr</pre>
pokeByteOff :: Storable a => Ptr b -> Int -> a -> IO ()

-- | Read a value from the given memory location.
gr
grNote that the peek and poke functions might require properly aligned
graddresses to function correctly. This is architecture dependent; thus,
grportable code should ensure that when peeking or poking values of some
grtype <tt>a</tt>, the alignment constraint for <tt>a</tt>, as given by
grthe function <a>alignment</a> is fulfilled.
peek :: Storable a => Ptr a -> IO a

-- | Write the given value to the given memory location. Alignment
grrestrictions might apply; see <a>peek</a>.
poke :: Storable a => Ptr a -> a -> IO ()
instance Foreign.Storable.Storable ()
instance Foreign.Storable.Storable GHC.Types.Bool
instance Foreign.Storable.Storable GHC.Types.Char
instance Foreign.Storable.Storable GHC.Types.Int
instance Foreign.Storable.Storable GHC.Types.Word
instance Foreign.Storable.Storable (GHC.Ptr.Ptr a)
instance Foreign.Storable.Storable (GHC.Ptr.FunPtr a)
instance Foreign.Storable.Storable (GHC.Stable.StablePtr a)
instance Foreign.Storable.Storable GHC.Types.Float
instance Foreign.Storable.Storable GHC.Types.Double
instance Foreign.Storable.Storable GHC.Word.Word8
instance Foreign.Storable.Storable GHC.Word.Word16
instance Foreign.Storable.Storable GHC.Word.Word32
instance Foreign.Storable.Storable GHC.Word.Word64
instance Foreign.Storable.Storable GHC.Int.Int8
instance Foreign.Storable.Storable GHC.Int.Int16
instance Foreign.Storable.Storable GHC.Int.Int32
instance Foreign.Storable.Storable GHC.Int.Int64
instance (Foreign.Storable.Storable a, GHC.Real.Integral a) => Foreign.Storable.Storable (GHC.Real.Ratio a)
instance Foreign.Storable.Storable GHC.Fingerprint.Type.Fingerprint


-- | Signed integer types
module Data.Int

-- | A fixed-precision integer type with at least the range <tt>[-2^29 ..
gr2^29-1]</tt>. The exact range for a given implementation can be
grdetermined by using <a>minBound</a> and <a>maxBound</a> from the
gr<a>Bounded</a> class.
data Int

-- | 8-bit signed integer type
data {-# CTYPE "HsInt8" #-} Int8

-- | 16-bit signed integer type
data {-# CTYPE "HsInt16" #-} Int16

-- | 32-bit signed integer type
data {-# CTYPE "HsInt32" #-} Int32

-- | 64-bit signed integer type
data {-# CTYPE "HsInt64" #-} Int64


-- | This module provides typed pointers to foreign data. It is part of the
grForeign Function Interface (FFI) and will normally be imported via the
gr<a>Foreign</a> module.
module Foreign.Ptr

-- | A value of type <tt><a>Ptr</a> a</tt> represents a pointer to an
grobject, or an array of objects, which may be marshalled to or from
grHaskell values of type <tt>a</tt>.
gr
grThe type <tt>a</tt> will often be an instance of class <a>Storable</a>
grwhich provides the marshalling operations. However this is not
gressential, and you can provide your own operations to access the
grpointer. For example you might write small foreign functions to get or
grset the fields of a C <tt>struct</tt>.
data Ptr a

-- | The constant <a>nullPtr</a> contains a distinguished value of
gr<a>Ptr</a> that is not associated with a valid memory location.
nullPtr :: Ptr a

-- | The <a>castPtr</a> function casts a pointer from one type to another.
castPtr :: Ptr a -> Ptr b

-- | Advances the given address by the given offset in bytes.
plusPtr :: Ptr a -> Int -> Ptr b

-- | Given an arbitrary address and an alignment constraint,
gr<a>alignPtr</a> yields the next higher address that fulfills the
gralignment constraint. An alignment constraint <tt>x</tt> is fulfilled
grby any address divisible by <tt>x</tt>. This operation is idempotent.
alignPtr :: Ptr a -> Int -> Ptr a

-- | Computes the offset required to get from the second to the first
grargument. We have
gr
gr<pre>
grp2 == p1 `plusPtr` (p2 `minusPtr` p1)
gr</pre>
minusPtr :: Ptr a -> Ptr b -> Int

-- | A value of type <tt><a>FunPtr</a> a</tt> is a pointer to a function
grcallable from foreign code. The type <tt>a</tt> will normally be a
gr<i>foreign type</i>, a function type with zero or more arguments where
gr
gr<ul>
gr<li>the argument types are <i>marshallable foreign types</i>, i.e.
gr<a>Char</a>, <a>Int</a>, <a>Double</a>, <a>Float</a>, <a>Bool</a>,
gr<a>Int8</a>, <a>Int16</a>, <a>Int32</a>, <a>Int64</a>, <a>Word8</a>,
gr<a>Word16</a>, <a>Word32</a>, <a>Word64</a>, <tt><a>Ptr</a> a</tt>,
gr<tt><a>FunPtr</a> a</tt>, <tt><a>StablePtr</a> a</tt> or a renaming of
grany of these using <tt>newtype</tt>.</li>
gr<li>the return type is either a marshallable foreign type or has the
grform <tt><a>IO</a> t</tt> where <tt>t</tt> is a marshallable foreign
grtype or <tt>()</tt>.</li>
gr</ul>
gr
grA value of type <tt><a>FunPtr</a> a</tt> may be a pointer to a foreign
grfunction, either returned by another foreign function or imported with
gra a static address import like
gr
gr<pre>
grforeign import ccall "stdlib.h &amp;free"
gr  p_free :: FunPtr (Ptr a -&gt; IO ())
gr</pre>
gr
gror a pointer to a Haskell function created using a <i>wrapper</i> stub
grdeclared to produce a <a>FunPtr</a> of the correct type. For example:
gr
gr<pre>
grtype Compare = Int -&gt; Int -&gt; Bool
grforeign import ccall "wrapper"
gr  mkCompare :: Compare -&gt; IO (FunPtr Compare)
gr</pre>
gr
grCalls to wrapper stubs like <tt>mkCompare</tt> allocate storage, which
grshould be released with <a>freeHaskellFunPtr</a> when no longer
grrequired.
gr
grTo convert <a>FunPtr</a> values to corresponding Haskell functions,
grone can define a <i>dynamic</i> stub for the specific foreign type,
gre.g.
gr
gr<pre>
grtype IntFunction = CInt -&gt; IO ()
grforeign import ccall "dynamic"
gr  mkFun :: FunPtr IntFunction -&gt; IntFunction
gr</pre>
data FunPtr a

-- | The constant <a>nullFunPtr</a> contains a distinguished value of
gr<a>FunPtr</a> that is not associated with a valid memory location.
nullFunPtr :: FunPtr a

-- | Casts a <a>FunPtr</a> to a <a>FunPtr</a> of a different type.
castFunPtr :: FunPtr a -> FunPtr b

-- | Casts a <a>FunPtr</a> to a <a>Ptr</a>.
gr
gr<i>Note:</i> this is valid only on architectures where data and
grfunction pointers range over the same set of addresses, and should
gronly be used for bindings to external libraries whose interface
gralready relies on this assumption.
castFunPtrToPtr :: FunPtr a -> Ptr b

-- | Casts a <a>Ptr</a> to a <a>FunPtr</a>.
gr
gr<i>Note:</i> this is valid only on architectures where data and
grfunction pointers range over the same set of addresses, and should
gronly be used for bindings to external libraries whose interface
gralready relies on this assumption.
castPtrToFunPtr :: Ptr a -> FunPtr b

-- | Release the storage associated with the given <a>FunPtr</a>, which
grmust have been obtained from a wrapper stub. This should be called
grwhenever the return value from a foreign import wrapper function is no
grlonger required; otherwise, the storage it uses will leak.
freeHaskellFunPtr :: FunPtr a -> IO ()

-- | A signed integral type that can be losslessly converted to and from
gr<tt>Ptr</tt>. This type is also compatible with the C99 type
gr<tt>intptr_t</tt>, and can be marshalled to and from that type safely.
newtype IntPtr
IntPtr :: Int -> IntPtr

-- | casts a <tt>Ptr</tt> to an <tt>IntPtr</tt>
ptrToIntPtr :: Ptr a -> IntPtr

-- | casts an <tt>IntPtr</tt> to a <tt>Ptr</tt>
intPtrToPtr :: IntPtr -> Ptr a

-- | An unsigned integral type that can be losslessly converted to and from
gr<tt>Ptr</tt>. This type is also compatible with the C99 type
gr<tt>uintptr_t</tt>, and can be marshalled to and from that type
grsafely.
newtype WordPtr
WordPtr :: Word -> WordPtr

-- | casts a <tt>Ptr</tt> to a <tt>WordPtr</tt>
ptrToWordPtr :: Ptr a -> WordPtr

-- | casts a <tt>WordPtr</tt> to a <tt>Ptr</tt>
wordPtrToPtr :: WordPtr -> Ptr a
instance GHC.Show.Show Foreign.Ptr.IntPtr
instance GHC.Read.Read Foreign.Ptr.IntPtr
instance Data.Bits.FiniteBits Foreign.Ptr.IntPtr
instance Data.Bits.Bits Foreign.Ptr.IntPtr
instance GHC.Real.Integral Foreign.Ptr.IntPtr
instance GHC.Enum.Bounded Foreign.Ptr.IntPtr
instance GHC.Real.Real Foreign.Ptr.IntPtr
instance Foreign.Storable.Storable Foreign.Ptr.IntPtr
instance GHC.Enum.Enum Foreign.Ptr.IntPtr
instance GHC.Num.Num Foreign.Ptr.IntPtr
instance GHC.Classes.Ord Foreign.Ptr.IntPtr
instance GHC.Classes.Eq Foreign.Ptr.IntPtr
instance GHC.Show.Show Foreign.Ptr.WordPtr
instance GHC.Read.Read Foreign.Ptr.WordPtr
instance Data.Bits.FiniteBits Foreign.Ptr.WordPtr
instance Data.Bits.Bits Foreign.Ptr.WordPtr
instance GHC.Real.Integral Foreign.Ptr.WordPtr
instance GHC.Enum.Bounded Foreign.Ptr.WordPtr
instance GHC.Real.Real Foreign.Ptr.WordPtr
instance Foreign.Storable.Storable Foreign.Ptr.WordPtr
instance GHC.Enum.Enum Foreign.Ptr.WordPtr
instance GHC.Num.Num Foreign.Ptr.WordPtr
instance GHC.Classes.Ord Foreign.Ptr.WordPtr
instance GHC.Classes.Eq Foreign.Ptr.WordPtr


-- | Unsigned integer types.
module Data.Word

-- | A <a>Word</a> is an unsigned integral type, with the same size as
gr<a>Int</a>.
data Word

-- | 8-bit unsigned integer type
data {-# CTYPE "HsWord8" #-} Word8

-- | 16-bit unsigned integer type
data {-# CTYPE "HsWord16" #-} Word16

-- | 32-bit unsigned integer type
data {-# CTYPE "HsWord32" #-} Word32

-- | 64-bit unsigned integer type
data {-# CTYPE "HsWord64" #-} Word64

-- | Swap bytes in <a>Word16</a>.
byteSwap16 :: Word16 -> Word16

-- | Reverse order of bytes in <a>Word32</a>.
byteSwap32 :: Word32 -> Word32

-- | Reverse order of bytes in <a>Word64</a>.
byteSwap64 :: Word64 -> Word64


-- | The arbitrary-precision <a>Natural</a> number type.
gr
gr<b>Note</b>: This is an internal GHC module with an API subject to
grchange. It's recommended use the <a>Numeric.Natural</a> module to
grimport the <a>Natural</a> type.
module GHC.Natural

-- | Type representing arbitrary-precision non-negative integers.
gr
gr<pre>
gr&gt;&gt;&gt; 2^20 :: Natural
gr1267650600228229401496703205376
gr</pre>
gr
grOperations whose result would be negative <tt><tt>throw</tt>
gr(<tt>Underflow</tt> :: <tt>ArithException</tt>)</tt>,
gr
gr<pre>
gr&gt;&gt;&gt; -1 :: Natural
gr*** Exception: arithmetic underflow
gr</pre>
data Natural

-- | in <tt>[0, maxBound::Word]</tt>
NatS# :: GmpLimb# -> Natural

-- | in <tt>]maxBound::Word, +inf[</tt>
gr
gr<b>Invariant</b>: <a>NatJ#</a> is used <i>iff</i> value doesn't fit in
gr<a>NatS#</a> constructor.
NatJ# :: {-# UNPACK #-} !BigNat -> Natural

-- | Test whether all internal invariants are satisfied by <a>Natural</a>
grvalue
gr
grThis operation is mostly useful for test-suites and/or code which
grconstructs <a>Integer</a> values directly.
isValidNatural :: Natural -> Bool

naturalFromInteger :: Integer -> Natural

-- | Construct <a>Natural</a> from <a>Word</a> value.
wordToNatural :: Word -> Natural

-- | Try downcasting <a>Natural</a> to <a>Word</a> value. Returns
gr<a>Nothing</a> if value doesn't fit in <a>Word</a>.
naturalToWordMaybe :: Natural -> Maybe Word

-- | <a>Natural</a> subtraction. Returns <a>Nothing</a>s for non-positive
grresults.
minusNaturalMaybe :: Natural -> Natural -> Maybe Natural

-- | "<tt><a>powModNatural</a> <i>b</i> <i>e</i> <i>m</i></tt>" computes
grbase <tt><i>b</i></tt> raised to exponent <tt><i>e</i></tt> modulo
gr<tt><i>m</i></tt>.
powModNatural :: Natural -> Natural -> Natural -> Natural
instance GHC.Classes.Ord GHC.Natural.Natural
instance GHC.Classes.Eq GHC.Natural.Natural
instance GHC.Show.Show GHC.Natural.Natural
instance GHC.Read.Read GHC.Natural.Natural
instance GHC.Num.Num GHC.Natural.Natural
instance GHC.Real.Real GHC.Natural.Natural
instance GHC.Enum.Enum GHC.Natural.Natural
instance GHC.Real.Integral GHC.Natural.Natural
instance GHC.Arr.Ix GHC.Natural.Natural
instance Data.Bits.Bits GHC.Natural.Natural


-- | The arbitrary-precision <a>Natural</a> number type.
module Numeric.Natural

-- | Type representing arbitrary-precision non-negative integers.
gr
gr<pre>
gr&gt;&gt;&gt; 2^20 :: Natural
gr1267650600228229401496703205376
gr</pre>
gr
grOperations whose result would be negative <tt><tt>throw</tt>
gr(<tt>Underflow</tt> :: <tt>ArithException</tt>)</tt>,
gr
gr<pre>
gr&gt;&gt;&gt; -1 :: Natural
gr*** Exception: arithmetic underflow
gr</pre>
data Natural

module GHC.Clock

-- | Return monotonic time in seconds, since some unspecified starting
grpoint
getMonotonicTime :: IO Double

-- | Return monotonic time in nanoseconds, since some unspecified starting
grpoint
getMonotonicTimeNSec :: IO Word64


-- | Mapping of C types to corresponding Haskell types.
module Foreign.C.Types

-- | Haskell type representing the C <tt>char</tt> type.
newtype CChar
CChar :: Int8 -> CChar

-- | Haskell type representing the C <tt>signed char</tt> type.
newtype CSChar
CSChar :: Int8 -> CSChar

-- | Haskell type representing the C <tt>unsigned char</tt> type.
newtype CUChar
CUChar :: Word8 -> CUChar

-- | Haskell type representing the C <tt>short</tt> type.
newtype CShort
CShort :: Int16 -> CShort

-- | Haskell type representing the C <tt>unsigned short</tt> type.
newtype CUShort
CUShort :: Word16 -> CUShort

-- | Haskell type representing the C <tt>int</tt> type.
newtype CInt
CInt :: Int32 -> CInt

-- | Haskell type representing the C <tt>unsigned int</tt> type.
newtype CUInt
CUInt :: Word32 -> CUInt

-- | Haskell type representing the C <tt>long</tt> type.
newtype CLong
CLong :: Int64 -> CLong

-- | Haskell type representing the C <tt>unsigned long</tt> type.
newtype CULong
CULong :: Word64 -> CULong

-- | Haskell type representing the C <tt>ptrdiff_t</tt> type.
newtype CPtrdiff
CPtrdiff :: Int64 -> CPtrdiff

-- | Haskell type representing the C <tt>size_t</tt> type.
newtype CSize
CSize :: Word64 -> CSize

-- | Haskell type representing the C <tt>wchar_t</tt> type.
newtype CWchar
CWchar :: Int32 -> CWchar

-- | Haskell type representing the C <tt>sig_atomic_t</tt> type.
newtype CSigAtomic
CSigAtomic :: Int32 -> CSigAtomic

-- | Haskell type representing the C <tt>long long</tt> type.
newtype CLLong
CLLong :: Int64 -> CLLong

-- | Haskell type representing the C <tt>unsigned long long</tt> type.
newtype CULLong
CULLong :: Word64 -> CULLong

-- | Haskell type representing the C <tt>bool</tt> type.
newtype {-# CTYPE "bool" #-} CBool
CBool :: Word8 -> CBool
newtype CIntPtr
CIntPtr :: Int64 -> CIntPtr
newtype CUIntPtr
CUIntPtr :: Word64 -> CUIntPtr
newtype CIntMax
CIntMax :: Int64 -> CIntMax
newtype CUIntMax
CUIntMax :: Word64 -> CUIntMax

-- | Haskell type representing the C <tt>clock_t</tt> type.
newtype CClock
CClock :: Int64 -> CClock

-- | Haskell type representing the C <tt>time_t</tt> type.
newtype CTime
CTime :: Int64 -> CTime

-- | Haskell type representing the C <tt>useconds_t</tt> type.
newtype CUSeconds
CUSeconds :: Word32 -> CUSeconds

-- | Haskell type representing the C <tt>suseconds_t</tt> type.
newtype CSUSeconds
CSUSeconds :: Int64 -> CSUSeconds

-- | Haskell type representing the C <tt>float</tt> type.
newtype CFloat
CFloat :: Float -> CFloat

-- | Haskell type representing the C <tt>double</tt> type.
newtype CDouble
CDouble :: Double -> CDouble

-- | Haskell type representing the C <tt>FILE</tt> type.
data CFile

-- | Haskell type representing the C <tt>fpos_t</tt> type.
data CFpos

-- | Haskell type representing the C <tt>jmp_buf</tt> type.
data CJmpBuf
instance GHC.Show.Show Foreign.C.Types.CUIntMax
instance GHC.Read.Read Foreign.C.Types.CUIntMax
instance Data.Bits.FiniteBits Foreign.C.Types.CUIntMax
instance Data.Bits.Bits Foreign.C.Types.CUIntMax
instance GHC.Real.Integral Foreign.C.Types.CUIntMax
instance GHC.Enum.Bounded Foreign.C.Types.CUIntMax
instance GHC.Real.Real Foreign.C.Types.CUIntMax
instance Foreign.Storable.Storable Foreign.C.Types.CUIntMax
instance GHC.Enum.Enum Foreign.C.Types.CUIntMax
instance GHC.Num.Num Foreign.C.Types.CUIntMax
instance GHC.Classes.Ord Foreign.C.Types.CUIntMax
instance GHC.Classes.Eq Foreign.C.Types.CUIntMax
instance GHC.Show.Show Foreign.C.Types.CIntMax
instance GHC.Read.Read Foreign.C.Types.CIntMax
instance Data.Bits.FiniteBits Foreign.C.Types.CIntMax
instance Data.Bits.Bits Foreign.C.Types.CIntMax
instance GHC.Real.Integral Foreign.C.Types.CIntMax
instance GHC.Enum.Bounded Foreign.C.Types.CIntMax
instance GHC.Real.Real Foreign.C.Types.CIntMax
instance Foreign.Storable.Storable Foreign.C.Types.CIntMax
instance GHC.Enum.Enum Foreign.C.Types.CIntMax
instance GHC.Num.Num Foreign.C.Types.CIntMax
instance GHC.Classes.Ord Foreign.C.Types.CIntMax
instance GHC.Classes.Eq Foreign.C.Types.CIntMax
instance GHC.Show.Show Foreign.C.Types.CUIntPtr
instance GHC.Read.Read Foreign.C.Types.CUIntPtr
instance Data.Bits.FiniteBits Foreign.C.Types.CUIntPtr
instance Data.Bits.Bits Foreign.C.Types.CUIntPtr
instance GHC.Real.Integral Foreign.C.Types.CUIntPtr
instance GHC.Enum.Bounded Foreign.C.Types.CUIntPtr
instance GHC.Real.Real Foreign.C.Types.CUIntPtr
instance Foreign.Storable.Storable Foreign.C.Types.CUIntPtr
instance GHC.Enum.Enum Foreign.C.Types.CUIntPtr
instance GHC.Num.Num Foreign.C.Types.CUIntPtr
instance GHC.Classes.Ord Foreign.C.Types.CUIntPtr
instance GHC.Classes.Eq Foreign.C.Types.CUIntPtr
instance GHC.Show.Show Foreign.C.Types.CIntPtr
instance GHC.Read.Read Foreign.C.Types.CIntPtr
instance Data.Bits.FiniteBits Foreign.C.Types.CIntPtr
instance Data.Bits.Bits Foreign.C.Types.CIntPtr
instance GHC.Real.Integral Foreign.C.Types.CIntPtr
instance GHC.Enum.Bounded Foreign.C.Types.CIntPtr
instance GHC.Real.Real Foreign.C.Types.CIntPtr
instance Foreign.Storable.Storable Foreign.C.Types.CIntPtr
instance GHC.Enum.Enum Foreign.C.Types.CIntPtr
instance GHC.Num.Num Foreign.C.Types.CIntPtr
instance GHC.Classes.Ord Foreign.C.Types.CIntPtr
instance GHC.Classes.Eq Foreign.C.Types.CIntPtr
instance GHC.Show.Show Foreign.C.Types.CSUSeconds
instance GHC.Read.Read Foreign.C.Types.CSUSeconds
instance GHC.Real.Real Foreign.C.Types.CSUSeconds
instance Foreign.Storable.Storable Foreign.C.Types.CSUSeconds
instance GHC.Enum.Enum Foreign.C.Types.CSUSeconds
instance GHC.Num.Num Foreign.C.Types.CSUSeconds
instance GHC.Classes.Ord Foreign.C.Types.CSUSeconds
instance GHC.Classes.Eq Foreign.C.Types.CSUSeconds
instance GHC.Show.Show Foreign.C.Types.CUSeconds
instance GHC.Read.Read Foreign.C.Types.CUSeconds
instance GHC.Real.Real Foreign.C.Types.CUSeconds
instance Foreign.Storable.Storable Foreign.C.Types.CUSeconds
instance GHC.Enum.Enum Foreign.C.Types.CUSeconds
instance GHC.Num.Num Foreign.C.Types.CUSeconds
instance GHC.Classes.Ord Foreign.C.Types.CUSeconds
instance GHC.Classes.Eq Foreign.C.Types.CUSeconds
instance GHC.Show.Show Foreign.C.Types.CTime
instance GHC.Read.Read Foreign.C.Types.CTime
instance GHC.Real.Real Foreign.C.Types.CTime
instance Foreign.Storable.Storable Foreign.C.Types.CTime
instance GHC.Enum.Enum Foreign.C.Types.CTime
instance GHC.Num.Num Foreign.C.Types.CTime
instance GHC.Classes.Ord Foreign.C.Types.CTime
instance GHC.Classes.Eq Foreign.C.Types.CTime
instance GHC.Show.Show Foreign.C.Types.CClock
instance GHC.Read.Read Foreign.C.Types.CClock
instance GHC.Real.Real Foreign.C.Types.CClock
instance Foreign.Storable.Storable Foreign.C.Types.CClock
instance GHC.Enum.Enum Foreign.C.Types.CClock
instance GHC.Num.Num Foreign.C.Types.CClock
instance GHC.Classes.Ord Foreign.C.Types.CClock
instance GHC.Classes.Eq Foreign.C.Types.CClock
instance GHC.Show.Show Foreign.C.Types.CSigAtomic
instance GHC.Read.Read Foreign.C.Types.CSigAtomic
instance Data.Bits.FiniteBits Foreign.C.Types.CSigAtomic
instance Data.Bits.Bits Foreign.C.Types.CSigAtomic
instance GHC.Real.Integral Foreign.C.Types.CSigAtomic
instance GHC.Enum.Bounded Foreign.C.Types.CSigAtomic
instance GHC.Real.Real Foreign.C.Types.CSigAtomic
instance Foreign.Storable.Storable Foreign.C.Types.CSigAtomic
instance GHC.Enum.Enum Foreign.C.Types.CSigAtomic
instance GHC.Num.Num Foreign.C.Types.CSigAtomic
instance GHC.Classes.Ord Foreign.C.Types.CSigAtomic
instance GHC.Classes.Eq Foreign.C.Types.CSigAtomic
instance GHC.Show.Show Foreign.C.Types.CWchar
instance GHC.Read.Read Foreign.C.Types.CWchar
instance Data.Bits.FiniteBits Foreign.C.Types.CWchar
instance Data.Bits.Bits Foreign.C.Types.CWchar
instance GHC.Real.Integral Foreign.C.Types.CWchar
instance GHC.Enum.Bounded Foreign.C.Types.CWchar
instance GHC.Real.Real Foreign.C.Types.CWchar
instance Foreign.Storable.Storable Foreign.C.Types.CWchar
instance GHC.Enum.Enum Foreign.C.Types.CWchar
instance GHC.Num.Num Foreign.C.Types.CWchar
instance GHC.Classes.Ord Foreign.C.Types.CWchar
instance GHC.Classes.Eq Foreign.C.Types.CWchar
instance GHC.Show.Show Foreign.C.Types.CSize
instance GHC.Read.Read Foreign.C.Types.CSize
instance Data.Bits.FiniteBits Foreign.C.Types.CSize
instance Data.Bits.Bits Foreign.C.Types.CSize
instance GHC.Real.Integral Foreign.C.Types.CSize
instance GHC.Enum.Bounded Foreign.C.Types.CSize
instance GHC.Real.Real Foreign.C.Types.CSize
instance Foreign.Storable.Storable Foreign.C.Types.CSize
instance GHC.Enum.Enum Foreign.C.Types.CSize
instance GHC.Num.Num Foreign.C.Types.CSize
instance GHC.Classes.Ord Foreign.C.Types.CSize
instance GHC.Classes.Eq Foreign.C.Types.CSize
instance GHC.Show.Show Foreign.C.Types.CPtrdiff
instance GHC.Read.Read Foreign.C.Types.CPtrdiff
instance Data.Bits.FiniteBits Foreign.C.Types.CPtrdiff
instance Data.Bits.Bits Foreign.C.Types.CPtrdiff
instance GHC.Real.Integral Foreign.C.Types.CPtrdiff
instance GHC.Enum.Bounded Foreign.C.Types.CPtrdiff
instance GHC.Real.Real Foreign.C.Types.CPtrdiff
instance Foreign.Storable.Storable Foreign.C.Types.CPtrdiff
instance GHC.Enum.Enum Foreign.C.Types.CPtrdiff
instance GHC.Num.Num Foreign.C.Types.CPtrdiff
instance GHC.Classes.Ord Foreign.C.Types.CPtrdiff
instance GHC.Classes.Eq Foreign.C.Types.CPtrdiff
instance GHC.Show.Show Foreign.C.Types.CDouble
instance GHC.Read.Read Foreign.C.Types.CDouble
instance GHC.Float.RealFloat Foreign.C.Types.CDouble
instance GHC.Real.RealFrac Foreign.C.Types.CDouble
instance GHC.Float.Floating Foreign.C.Types.CDouble
instance GHC.Real.Fractional Foreign.C.Types.CDouble
instance GHC.Real.Real Foreign.C.Types.CDouble
instance Foreign.Storable.Storable Foreign.C.Types.CDouble
instance GHC.Enum.Enum Foreign.C.Types.CDouble
instance GHC.Num.Num Foreign.C.Types.CDouble
instance GHC.Classes.Ord Foreign.C.Types.CDouble
instance GHC.Classes.Eq Foreign.C.Types.CDouble
instance GHC.Show.Show Foreign.C.Types.CFloat
instance GHC.Read.Read Foreign.C.Types.CFloat
instance GHC.Float.RealFloat Foreign.C.Types.CFloat
instance GHC.Real.RealFrac Foreign.C.Types.CFloat
instance GHC.Float.Floating Foreign.C.Types.CFloat
instance GHC.Real.Fractional Foreign.C.Types.CFloat
instance GHC.Real.Real Foreign.C.Types.CFloat
instance Foreign.Storable.Storable Foreign.C.Types.CFloat
instance GHC.Enum.Enum Foreign.C.Types.CFloat
instance GHC.Num.Num Foreign.C.Types.CFloat
instance GHC.Classes.Ord Foreign.C.Types.CFloat
instance GHC.Classes.Eq Foreign.C.Types.CFloat
instance GHC.Show.Show Foreign.C.Types.CBool
instance GHC.Read.Read Foreign.C.Types.CBool
instance Data.Bits.FiniteBits Foreign.C.Types.CBool
instance Data.Bits.Bits Foreign.C.Types.CBool
instance GHC.Real.Integral Foreign.C.Types.CBool
instance GHC.Enum.Bounded Foreign.C.Types.CBool
instance GHC.Real.Real Foreign.C.Types.CBool
instance Foreign.Storable.Storable Foreign.C.Types.CBool
instance GHC.Enum.Enum Foreign.C.Types.CBool
instance GHC.Num.Num Foreign.C.Types.CBool
instance GHC.Classes.Ord Foreign.C.Types.CBool
instance GHC.Classes.Eq Foreign.C.Types.CBool
instance GHC.Show.Show Foreign.C.Types.CULLong
instance GHC.Read.Read Foreign.C.Types.CULLong
instance Data.Bits.FiniteBits Foreign.C.Types.CULLong
instance Data.Bits.Bits Foreign.C.Types.CULLong
instance GHC.Real.Integral Foreign.C.Types.CULLong
instance GHC.Enum.Bounded Foreign.C.Types.CULLong
instance GHC.Real.Real Foreign.C.Types.CULLong
instance Foreign.Storable.Storable Foreign.C.Types.CULLong
instance GHC.Enum.Enum Foreign.C.Types.CULLong
instance GHC.Num.Num Foreign.C.Types.CULLong
instance GHC.Classes.Ord Foreign.C.Types.CULLong
instance GHC.Classes.Eq Foreign.C.Types.CULLong
instance GHC.Show.Show Foreign.C.Types.CLLong
instance GHC.Read.Read Foreign.C.Types.CLLong
instance Data.Bits.FiniteBits Foreign.C.Types.CLLong
instance Data.Bits.Bits Foreign.C.Types.CLLong
instance GHC.Real.Integral Foreign.C.Types.CLLong
instance GHC.Enum.Bounded Foreign.C.Types.CLLong
instance GHC.Real.Real Foreign.C.Types.CLLong
instance Foreign.Storable.Storable Foreign.C.Types.CLLong
instance GHC.Enum.Enum Foreign.C.Types.CLLong
instance GHC.Num.Num Foreign.C.Types.CLLong
instance GHC.Classes.Ord Foreign.C.Types.CLLong
instance GHC.Classes.Eq Foreign.C.Types.CLLong
instance GHC.Show.Show Foreign.C.Types.CULong
instance GHC.Read.Read Foreign.C.Types.CULong
instance Data.Bits.FiniteBits Foreign.C.Types.CULong
instance Data.Bits.Bits Foreign.C.Types.CULong
instance GHC.Real.Integral Foreign.C.Types.CULong
instance GHC.Enum.Bounded Foreign.C.Types.CULong
instance GHC.Real.Real Foreign.C.Types.CULong
instance Foreign.Storable.Storable Foreign.C.Types.CULong
instance GHC.Enum.Enum Foreign.C.Types.CULong
instance GHC.Num.Num Foreign.C.Types.CULong
instance GHC.Classes.Ord Foreign.C.Types.CULong
instance GHC.Classes.Eq Foreign.C.Types.CULong
instance GHC.Show.Show Foreign.C.Types.CLong
instance GHC.Read.Read Foreign.C.Types.CLong
instance Data.Bits.FiniteBits Foreign.C.Types.CLong
instance Data.Bits.Bits Foreign.C.Types.CLong
instance GHC.Real.Integral Foreign.C.Types.CLong
instance GHC.Enum.Bounded Foreign.C.Types.CLong
instance GHC.Real.Real Foreign.C.Types.CLong
instance Foreign.Storable.Storable Foreign.C.Types.CLong
instance GHC.Enum.Enum Foreign.C.Types.CLong
instance GHC.Num.Num Foreign.C.Types.CLong
instance GHC.Classes.Ord Foreign.C.Types.CLong
instance GHC.Classes.Eq Foreign.C.Types.CLong
instance GHC.Show.Show Foreign.C.Types.CUInt
instance GHC.Read.Read Foreign.C.Types.CUInt
instance Data.Bits.FiniteBits Foreign.C.Types.CUInt
instance Data.Bits.Bits Foreign.C.Types.CUInt
instance GHC.Real.Integral Foreign.C.Types.CUInt
instance GHC.Enum.Bounded Foreign.C.Types.CUInt
instance GHC.Real.Real Foreign.C.Types.CUInt
instance Foreign.Storable.Storable Foreign.C.Types.CUInt
instance GHC.Enum.Enum Foreign.C.Types.CUInt
instance GHC.Num.Num Foreign.C.Types.CUInt
instance GHC.Classes.Ord Foreign.C.Types.CUInt
instance GHC.Classes.Eq Foreign.C.Types.CUInt
instance GHC.Show.Show Foreign.C.Types.CInt
instance GHC.Read.Read Foreign.C.Types.CInt
instance Data.Bits.FiniteBits Foreign.C.Types.CInt
instance Data.Bits.Bits Foreign.C.Types.CInt
instance GHC.Real.Integral Foreign.C.Types.CInt
instance GHC.Enum.Bounded Foreign.C.Types.CInt
instance GHC.Real.Real Foreign.C.Types.CInt
instance Foreign.Storable.Storable Foreign.C.Types.CInt
instance GHC.Enum.Enum Foreign.C.Types.CInt
instance GHC.Num.Num Foreign.C.Types.CInt
instance GHC.Classes.Ord Foreign.C.Types.CInt
instance GHC.Classes.Eq Foreign.C.Types.CInt
instance GHC.Show.Show Foreign.C.Types.CUShort
instance GHC.Read.Read Foreign.C.Types.CUShort
instance Data.Bits.FiniteBits Foreign.C.Types.CUShort
instance Data.Bits.Bits Foreign.C.Types.CUShort
instance GHC.Real.Integral Foreign.C.Types.CUShort
instance GHC.Enum.Bounded Foreign.C.Types.CUShort
instance GHC.Real.Real Foreign.C.Types.CUShort
instance Foreign.Storable.Storable Foreign.C.Types.CUShort
instance GHC.Enum.Enum Foreign.C.Types.CUShort
instance GHC.Num.Num Foreign.C.Types.CUShort
instance GHC.Classes.Ord Foreign.C.Types.CUShort
instance GHC.Classes.Eq Foreign.C.Types.CUShort
instance GHC.Show.Show Foreign.C.Types.CShort
instance GHC.Read.Read Foreign.C.Types.CShort
instance Data.Bits.FiniteBits Foreign.C.Types.CShort
instance Data.Bits.Bits Foreign.C.Types.CShort
instance GHC.Real.Integral Foreign.C.Types.CShort
instance GHC.Enum.Bounded Foreign.C.Types.CShort
instance GHC.Real.Real Foreign.C.Types.CShort
instance Foreign.Storable.Storable Foreign.C.Types.CShort
instance GHC.Enum.Enum Foreign.C.Types.CShort
instance GHC.Num.Num Foreign.C.Types.CShort
instance GHC.Classes.Ord Foreign.C.Types.CShort
instance GHC.Classes.Eq Foreign.C.Types.CShort
instance GHC.Show.Show Foreign.C.Types.CUChar
instance GHC.Read.Read Foreign.C.Types.CUChar
instance Data.Bits.FiniteBits Foreign.C.Types.CUChar
instance Data.Bits.Bits Foreign.C.Types.CUChar
instance GHC.Real.Integral Foreign.C.Types.CUChar
instance GHC.Enum.Bounded Foreign.C.Types.CUChar
instance GHC.Real.Real Foreign.C.Types.CUChar
instance Foreign.Storable.Storable Foreign.C.Types.CUChar
instance GHC.Enum.Enum Foreign.C.Types.CUChar
instance GHC.Num.Num Foreign.C.Types.CUChar
instance GHC.Classes.Ord Foreign.C.Types.CUChar
instance GHC.Classes.Eq Foreign.C.Types.CUChar
instance GHC.Show.Show Foreign.C.Types.CSChar
instance GHC.Read.Read Foreign.C.Types.CSChar
instance Data.Bits.FiniteBits Foreign.C.Types.CSChar
instance Data.Bits.Bits Foreign.C.Types.CSChar
instance GHC.Real.Integral Foreign.C.Types.CSChar
instance GHC.Enum.Bounded Foreign.C.Types.CSChar
instance GHC.Real.Real Foreign.C.Types.CSChar
instance Foreign.Storable.Storable Foreign.C.Types.CSChar
instance GHC.Enum.Enum Foreign.C.Types.CSChar
instance GHC.Num.Num Foreign.C.Types.CSChar
instance GHC.Classes.Ord Foreign.C.Types.CSChar
instance GHC.Classes.Eq Foreign.C.Types.CSChar
instance GHC.Show.Show Foreign.C.Types.CChar
instance GHC.Read.Read Foreign.C.Types.CChar
instance Data.Bits.FiniteBits Foreign.C.Types.CChar
instance Data.Bits.Bits Foreign.C.Types.CChar
instance GHC.Real.Integral Foreign.C.Types.CChar
instance GHC.Enum.Bounded Foreign.C.Types.CChar
instance GHC.Real.Real Foreign.C.Types.CChar
instance Foreign.Storable.Storable Foreign.C.Types.CChar
instance GHC.Enum.Enum Foreign.C.Types.CChar
instance GHC.Num.Num Foreign.C.Types.CChar
instance GHC.Classes.Ord Foreign.C.Types.CChar
instance GHC.Classes.Eq Foreign.C.Types.CChar


-- | Definition of propositional equality <tt>(:~:)</tt>. Pattern-matching
gron a variable of type <tt>(a :~: b)</tt> produces a proof that <tt>a ~
grb</tt>.
module Data.Type.Equality

-- | Propositional equality. If <tt>a :~: b</tt> is inhabited by some
grterminating value, then the type <tt>a</tt> is the same as the type
gr<tt>b</tt>. To use this equality in practice, pattern-match on the
gr<tt>a :~: b</tt> to get out the <tt>Refl</tt> constructor; in the body
grof the pattern-match, the compiler knows that <tt>a ~ b</tt>.
data a (:~:) b
[Refl] :: a :~: a

-- | Lifted, heterogeneous equality. By lifted, we mean that it can be
grbogus (deferred type error). By heterogeneous, the two types
gr<tt>a</tt> and <tt>b</tt> might have different kinds. Because
gr<tt>~~</tt> can appear unexpectedly in error messages to users who do
grnot care about the difference between heterogeneous equality
gr<tt>~~</tt> and homogeneous equality <tt>~</tt>, this is printed as
gr<tt>~</tt> unless <tt>-fprint-equality-relations</tt> is set.
class a ~# b => (~~) (a :: k0) (b :: k1)

-- | Kind heterogeneous propositional equality. Like <a>:~:</a>, <tt>a :~~:
grb</tt> is inhabited by a terminating value if and only if <tt>a</tt>
gris the same type as <tt>b</tt>.
data (a :: k1) (:~~:) (b :: k2)
[HRefl] :: a :~~: a

-- | Symmetry of equality
sym :: (a :~: b) -> (b :~: a)

-- | Transitivity of equality
trans :: (a :~: b) -> (b :~: c) -> (a :~: c)

-- | Type-safe cast, using propositional equality
castWith :: (a :~: b) -> a -> b

-- | Generalized form of type-safe cast using propositional equality
gcastWith :: (a :~: b) -> ((a ~ b) => r) -> r

-- | Apply one equality to another, respectively
apply :: (f :~: g) -> (a :~: b) -> (f a :~: g b)

-- | Extract equality of the arguments from an equality of applied types
inner :: (f a :~: g b) -> (a :~: b)

-- | Extract equality of type constructors from an equality of applied
grtypes
outer :: (f a :~: g b) -> (f :~: g)

-- | This class contains types where you can learn the equality of two
grtypes from information contained in <i>terms</i>. Typically, only
grsingleton types should inhabit this class.
class TestEquality f

-- | Conditionally prove the equality of <tt>a</tt> and <tt>b</tt>.
testEquality :: TestEquality f => f a -> f b -> Maybe (a :~: b)

-- | A type family to compute Boolean equality.
instance forall k (a :: k) (b :: k). GHC.Classes.Eq (a Data.Type.Equality.:~: b)
instance forall k (a :: k) (b :: k). GHC.Show.Show (a Data.Type.Equality.:~: b)
instance forall k (a :: k) (b :: k). GHC.Classes.Ord (a Data.Type.Equality.:~: b)
instance forall k (a :: k) (b :: k). (a ~ b) => GHC.Read.Read (a Data.Type.Equality.:~: b)
instance forall k (a :: k) (b :: k). (a ~ b) => GHC.Enum.Bounded (a Data.Type.Equality.:~: b)
instance forall k2 k1 (a :: k1) (b :: k2). GHC.Classes.Eq (a Data.Type.Equality.:~~: b)
instance forall k2 k1 (a :: k1) (b :: k2). GHC.Show.Show (a Data.Type.Equality.:~~: b)
instance forall k2 k1 (a :: k1) (b :: k2). GHC.Classes.Ord (a Data.Type.Equality.:~~: b)
instance forall k2 k1 (a :: k1) (b :: k2). ((a :: k1) ~~ (b :: k2)) => GHC.Read.Read (a Data.Type.Equality.:~~: b)
instance forall k2 k1 (a :: k1) (b :: k2). ((a :: k1) ~~ (b :: k2)) => GHC.Enum.Bounded (a Data.Type.Equality.:~~: b)
instance forall k (a :: k). Data.Type.Equality.TestEquality ((Data.Type.Equality.:~:) a)
instance forall k k1 (a :: k1). Data.Type.Equality.TestEquality ((Data.Type.Equality.:~~:) a)
instance forall k2 k1 (a :: k1) (b :: k2). ((a :: k1) ~~ (b :: k2)) => GHC.Enum.Enum (a Data.Type.Equality.:~~: b)
instance forall k (a :: k) (b :: k). (a ~ b) => GHC.Enum.Enum (a Data.Type.Equality.:~: b)
instance forall k (a :: k) (b :: k). (a ~ b) => a ~ b


-- | Definition of representational equality (<a>Coercion</a>).
module Data.Type.Coercion

-- | Representational equality. If <tt>Coercion a b</tt> is inhabited by
grsome terminating value, then the type <tt>a</tt> has the same
grunderlying representation as the type <tt>b</tt>.
gr
grTo use this equality in practice, pattern-match on the <tt>Coercion a
grb</tt> to get out the <tt>Coercible a b</tt> instance, and then use
gr<a>coerce</a> to apply it.
data Coercion a b
[Coercion] :: Coercible a b => Coercion a b

-- | Type-safe cast, using representational equality
coerceWith :: Coercion a b -> a -> b

-- | Generalized form of type-safe cast using representational equality
gcoerceWith :: Coercion a b -> (Coercible a b => r) -> r

-- | Symmetry of representational equality
sym :: Coercion a b -> Coercion b a

-- | Transitivity of representational equality
trans :: Coercion a b -> Coercion b c -> Coercion a c

-- | Convert propositional (nominal) equality to representational equality
repr :: (a :~: b) -> Coercion a b

-- | This class contains types where you can learn the equality of two
grtypes from information contained in <i>terms</i>. Typically, only
grsingleton types should inhabit this class.
class TestCoercion f

-- | Conditionally prove the representational equality of <tt>a</tt> and
gr<tt>b</tt>.
testCoercion :: TestCoercion f => f a -> f b -> Maybe (Coercion a b)
instance forall k (a :: k) (b :: k). GHC.Classes.Eq (Data.Type.Coercion.Coercion a b)
instance forall k (a :: k) (b :: k). GHC.Show.Show (Data.Type.Coercion.Coercion a b)
instance forall k (a :: k) (b :: k). GHC.Classes.Ord (Data.Type.Coercion.Coercion a b)
instance forall k (a :: k) (b :: k). GHC.Types.Coercible a b => GHC.Read.Read (Data.Type.Coercion.Coercion a b)
instance forall k (a :: k) (b :: k). GHC.Types.Coercible a b => GHC.Enum.Bounded (Data.Type.Coercion.Coercion a b)
instance forall k (a :: k). Data.Type.Coercion.TestCoercion ((Data.Type.Equality.:~:) a)
instance forall k k1 (a :: k1). Data.Type.Coercion.TestCoercion ((Data.Type.Equality.:~~:) a)
instance forall k (a :: k). Data.Type.Coercion.TestCoercion (Data.Type.Coercion.Coercion a)
instance forall k (a :: k) (b :: k). GHC.Types.Coercible a b => GHC.Enum.Enum (Data.Type.Coercion.Coercion a b)


module Control.Category

-- | A class for categories. Instances should satisfy the laws
gr
gr<pre>
grf <a>.</a> <a>id</a>  =  f  -- (right identity)
gr<a>id</a> <a>.</a> f  =  f  -- (left identity)
grf <a>.</a> (g <a>.</a> h)  =  (f <a>.</a> g) <a>.</a> h  -- (associativity)
gr</pre>
class Category cat

-- | the identity morphism
id :: Category cat => cat a a

-- | morphism composition
(.) :: Category cat => cat b c -> cat a b -> cat a c

-- | Right-to-left composition
(<<<) :: Category cat => cat b c -> cat a b -> cat a c
infixr 1 <<<

-- | Left-to-right composition
(>>>) :: Category cat => cat a b -> cat b c -> cat a c
infixr 1 >>>
instance Control.Category.Category (->)
instance Control.Category.Category (Data.Type.Equality.:~:)
instance Control.Category.Category (Data.Type.Equality.:~~:)
instance Control.Category.Category Data.Type.Coercion.Coercion


-- | Definition of a Proxy type (poly-kinded in GHC)
module Data.Proxy

-- | <a>Proxy</a> is a type that holds no data, but has a phantom parameter
grof arbitrary type (or even kind). Its use is to provide type
grinformation, even though there is no value available of that type (or
grit may be too costly to create one).
gr
grHistorically, <tt><a>Proxy</a> :: <a>Proxy</a> a</tt> is a safer
gralternative to the <tt>'undefined :: a'</tt> idiom.
gr
gr<pre>
gr&gt;&gt;&gt; Proxy :: Proxy (Void, Int -&gt; Int)
grProxy
gr</pre>
gr
grProxy can even hold types of higher kinds,
gr
gr<pre>
gr&gt;&gt;&gt; Proxy :: Proxy Either
grProxy
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; Proxy :: Proxy Functor
grProxy
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; Proxy :: Proxy complicatedStructure
grProxy
gr</pre>
data Proxy t
Proxy :: Proxy t

-- | <a>asProxyTypeOf</a> is a type-restricted version of <a>const</a>. It
gris usually used as an infix operator, and its typing forces its first
grargument (which is usually overloaded) to have the same type as the
grtag of the second.
gr
gr<pre>
gr&gt;&gt;&gt; import Data.Word
gr
gr&gt;&gt;&gt; :type asProxyTypeOf 123 (Proxy :: Proxy Word8)
grasProxyTypeOf 123 (Proxy :: Proxy Word8) :: Word8
gr</pre>
gr
grNote the lower-case <tt>proxy</tt> in the definition. This allows any
grtype constructor with just one argument to be passed to the function,
grfor example we could also write
gr
gr<pre>
gr&gt;&gt;&gt; import Data.Word
gr
gr&gt;&gt;&gt; :type asProxyTypeOf 123 (Just (undefined :: Word8))
grasProxyTypeOf 123 (Just (undefined :: Word8)) :: Word8
gr</pre>
asProxyTypeOf :: a -> proxy a -> a

-- | A concrete, promotable proxy type, for use at the kind level There are
grno instances for this because it is intended at the kind level only
data KProxy (t :: *)
KProxy :: KProxy
instance forall k (t :: k). GHC.Read.Read (Data.Proxy.Proxy t)
instance forall k (t :: k). GHC.Enum.Bounded (Data.Proxy.Proxy t)
instance forall k (s :: k). GHC.Classes.Eq (Data.Proxy.Proxy s)
instance forall k (s :: k). GHC.Classes.Ord (Data.Proxy.Proxy s)
instance forall k (s :: k). GHC.Show.Show (Data.Proxy.Proxy s)
instance forall k (s :: k). GHC.Enum.Enum (Data.Proxy.Proxy s)
instance forall k (s :: k). GHC.Arr.Ix (Data.Proxy.Proxy s)
instance forall k (s :: k). GHC.Base.Semigroup (Data.Proxy.Proxy s)
instance forall k (s :: k). GHC.Base.Monoid (Data.Proxy.Proxy s)
instance GHC.Base.Functor Data.Proxy.Proxy
instance GHC.Base.Applicative Data.Proxy.Proxy
instance GHC.Base.Alternative Data.Proxy.Proxy
instance GHC.Base.Monad Data.Proxy.Proxy
instance GHC.Base.MonadPlus Data.Proxy.Proxy


-- | Orderings
module Data.Ord

-- | The <a>Ord</a> class is used for totally ordered datatypes.
gr
grInstances of <a>Ord</a> can be derived for any user-defined datatype
grwhose constituent types are in <a>Ord</a>. The declared order of the
grconstructors in the data declaration determines the ordering in
grderived <a>Ord</a> instances. The <a>Ordering</a> datatype allows a
grsingle comparison to determine the precise ordering of two objects.
gr
grMinimal complete definition: either <a>compare</a> or <a>&lt;=</a>.
grUsing <a>compare</a> can be more efficient for complex types.
class Eq a => Ord a
compare :: Ord a => a -> a -> Ordering
(<) :: Ord a => a -> a -> Bool
(<=) :: Ord a => a -> a -> Bool
(>) :: Ord a => a -> a -> Bool
(>=) :: Ord a => a -> a -> Bool
max :: Ord a => a -> a -> a
min :: Ord a => a -> a -> a
data Ordering
LT :: Ordering
EQ :: Ordering
GT :: Ordering

-- | The <a>Down</a> type allows you to reverse sort order conveniently. A
grvalue of type <tt><a>Down</a> a</tt> contains a value of type
gr<tt>a</tt> (represented as <tt><a>Down</a> a</tt>). If <tt>a</tt> has
gran <tt><a>Ord</a></tt> instance associated with it then comparing two
grvalues thus wrapped will give you the opposite of their normal sort
grorder. This is particularly useful when sorting in generalised list
grcomprehensions, as in: <tt>then sortWith by <a>Down</a> x</tt>
newtype Down a
Down :: a -> Down a

-- | <pre>
grcomparing p x y = compare (p x) (p y)
gr</pre>
gr
grUseful combinator for use in conjunction with the <tt>xxxBy</tt>
grfamily of functions from <a>Data.List</a>, for example:
gr
gr<pre>
gr... sortBy (comparing fst) ...
gr</pre>
comparing :: (Ord a) => (b -> a) -> b -> b -> Ordering
instance GHC.Base.Monoid a => GHC.Base.Monoid (Data.Ord.Down a)
instance GHC.Base.Semigroup a => GHC.Base.Semigroup (Data.Ord.Down a)
instance GHC.Num.Num a => GHC.Num.Num (Data.Ord.Down a)
instance GHC.Read.Read a => GHC.Read.Read (Data.Ord.Down a)
instance GHC.Show.Show a => GHC.Show.Show (Data.Ord.Down a)
instance GHC.Classes.Eq a => GHC.Classes.Eq (Data.Ord.Down a)
instance GHC.Classes.Ord a => GHC.Classes.Ord (Data.Ord.Down a)
instance GHC.Base.Functor Data.Ord.Down
instance GHC.Base.Applicative Data.Ord.Down
instance GHC.Base.Monad Data.Ord.Down


-- | The Either type, and associated operations.
module Data.Either

-- | The <a>Either</a> type represents values with two possibilities: a
grvalue of type <tt><a>Either</a> a b</tt> is either <tt><a>Left</a>
gra</tt> or <tt><a>Right</a> b</tt>.
gr
grThe <a>Either</a> type is sometimes used to represent a value which is
greither correct or an error; by convention, the <a>Left</a> constructor
gris used to hold an error value and the <a>Right</a> constructor is
grused to hold a correct value (mnemonic: "right" also means "correct").
gr
gr<h4><b>Examples</b></h4>
gr
grThe type <tt><a>Either</a> <a>String</a> <a>Int</a></tt> is the type
grof values which can be either a <a>String</a> or an <a>Int</a>. The
gr<a>Left</a> constructor can be used only on <a>String</a>s, and the
gr<a>Right</a> constructor can be used only on <a>Int</a>s:
gr
gr<pre>
gr&gt;&gt;&gt; let s = Left "foo" :: Either String Int
gr
gr&gt;&gt;&gt; s
grLeft "foo"
gr
gr&gt;&gt;&gt; let n = Right 3 :: Either String Int
gr
gr&gt;&gt;&gt; n
grRight 3
gr
gr&gt;&gt;&gt; :type s
grs :: Either String Int
gr
gr&gt;&gt;&gt; :type n
grn :: Either String Int
gr</pre>
gr
grThe <a>fmap</a> from our <a>Functor</a> instance will ignore
gr<a>Left</a> values, but will apply the supplied function to values
grcontained in a <a>Right</a>:
gr
gr<pre>
gr&gt;&gt;&gt; let s = Left "foo" :: Either String Int
gr
gr&gt;&gt;&gt; let n = Right 3 :: Either String Int
gr
gr&gt;&gt;&gt; fmap (*2) s
grLeft "foo"
gr
gr&gt;&gt;&gt; fmap (*2) n
grRight 6
gr</pre>
gr
grThe <a>Monad</a> instance for <a>Either</a> allows us to chain
grtogether multiple actions which may fail, and fail overall if any of
grthe individual steps failed. First we'll write a function that can
greither parse an <a>Int</a> from a <a>Char</a>, or fail.
gr
gr<pre>
gr&gt;&gt;&gt; import Data.Char ( digitToInt, isDigit )
gr
gr&gt;&gt;&gt; :{
gr    let parseEither :: Char -&gt; Either String Int
gr        parseEither c
gr          | isDigit c = Right (digitToInt c)
gr          | otherwise = Left "parse error"
gr
gr&gt;&gt;&gt; :}
gr</pre>
gr
grThe following should work, since both <tt>'1'</tt> and <tt>'2'</tt>
grcan be parsed as <a>Int</a>s.
gr
gr<pre>
gr&gt;&gt;&gt; :{
gr    let parseMultiple :: Either String Int
gr        parseMultiple = do
gr          x &lt;- parseEither '1'
gr          y &lt;- parseEither '2'
gr          return (x + y)
gr
gr&gt;&gt;&gt; :}
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; parseMultiple
grRight 3
gr</pre>
gr
grBut the following should fail overall, since the first operation where
grwe attempt to parse <tt>'m'</tt> as an <a>Int</a> will fail:
gr
gr<pre>
gr&gt;&gt;&gt; :{
gr    let parseMultiple :: Either String Int
gr        parseMultiple = do
gr          x &lt;- parseEither 'm'
gr          y &lt;- parseEither '2'
gr          return (x + y)
gr
gr&gt;&gt;&gt; :}
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; parseMultiple
grLeft "parse error"
gr</pre>
data Either a b
Left :: a -> Either a b
Right :: b -> Either a b

-- | Case analysis for the <a>Either</a> type. If the value is
gr<tt><a>Left</a> a</tt>, apply the first function to <tt>a</tt>; if it
gris <tt><a>Right</a> b</tt>, apply the second function to <tt>b</tt>.
gr
gr<h4><b>Examples</b></h4>
gr
grWe create two values of type <tt><a>Either</a> <a>String</a>
gr<a>Int</a></tt>, one using the <a>Left</a> constructor and another
grusing the <a>Right</a> constructor. Then we apply "either" the
gr<tt>length</tt> function (if we have a <a>String</a>) or the
gr"times-two" function (if we have an <a>Int</a>):
gr
gr<pre>
gr&gt;&gt;&gt; let s = Left "foo" :: Either String Int
gr
gr&gt;&gt;&gt; let n = Right 3 :: Either String Int
gr
gr&gt;&gt;&gt; either length (*2) s
gr3
gr
gr&gt;&gt;&gt; either length (*2) n
gr6
gr</pre>
either :: (a -> c) -> (b -> c) -> Either a b -> c

-- | Extracts from a list of <a>Either</a> all the <a>Left</a> elements.
grAll the <a>Left</a> elements are extracted in order.
gr
gr<h4><b>Examples</b></h4>
gr
grBasic usage:
gr
gr<pre>
gr&gt;&gt;&gt; let list = [ Left "foo", Right 3, Left "bar", Right 7, Left "baz" ]
gr
gr&gt;&gt;&gt; lefts list
gr["foo","bar","baz"]
gr</pre>
lefts :: [Either a b] -> [a]

-- | Extracts from a list of <a>Either</a> all the <a>Right</a> elements.
grAll the <a>Right</a> elements are extracted in order.
gr
gr<h4><b>Examples</b></h4>
gr
grBasic usage:
gr
gr<pre>
gr&gt;&gt;&gt; let list = [ Left "foo", Right 3, Left "bar", Right 7, Left "baz" ]
gr
gr&gt;&gt;&gt; rights list
gr[3,7]
gr</pre>
rights :: [Either a b] -> [b]

-- | Return <a>True</a> if the given value is a <a>Left</a>-value,
gr<a>False</a> otherwise.
gr
gr<h4><b>Examples</b></h4>
gr
grBasic usage:
gr
gr<pre>
gr&gt;&gt;&gt; isLeft (Left "foo")
grTrue
gr
gr&gt;&gt;&gt; isLeft (Right 3)
grFalse
gr</pre>
gr
grAssuming a <a>Left</a> value signifies some sort of error, we can use
gr<a>isLeft</a> to write a very simple error-reporting function that
grdoes absolutely nothing in the case of success, and outputs "ERROR" if
grany error occurred.
gr
grThis example shows how <a>isLeft</a> might be used to avoid pattern
grmatching when one does not care about the value contained in the
grconstructor:
gr
gr<pre>
gr&gt;&gt;&gt; import Control.Monad ( when )
gr
gr&gt;&gt;&gt; let report e = when (isLeft e) $ putStrLn "ERROR"
gr
gr&gt;&gt;&gt; report (Right 1)
gr
gr&gt;&gt;&gt; report (Left "parse error")
grERROR
gr</pre>
isLeft :: Either a b -> Bool

-- | Return <a>True</a> if the given value is a <a>Right</a>-value,
gr<a>False</a> otherwise.
gr
gr<h4><b>Examples</b></h4>
gr
grBasic usage:
gr
gr<pre>
gr&gt;&gt;&gt; isRight (Left "foo")
grFalse
gr
gr&gt;&gt;&gt; isRight (Right 3)
grTrue
gr</pre>
gr
grAssuming a <a>Left</a> value signifies some sort of error, we can use
gr<a>isRight</a> to write a very simple reporting function that only
groutputs "SUCCESS" when a computation has succeeded.
gr
grThis example shows how <a>isRight</a> might be used to avoid pattern
grmatching when one does not care about the value contained in the
grconstructor:
gr
gr<pre>
gr&gt;&gt;&gt; import Control.Monad ( when )
gr
gr&gt;&gt;&gt; let report e = when (isRight e) $ putStrLn "SUCCESS"
gr
gr&gt;&gt;&gt; report (Left "parse error")
gr
gr&gt;&gt;&gt; report (Right 1)
grSUCCESS
gr</pre>
isRight :: Either a b -> Bool

-- | Return the contents of a <a>Left</a>-value or a default value
grotherwise.
gr
gr<h4><b>Examples</b></h4>
gr
grBasic usage:
gr
gr<pre>
gr&gt;&gt;&gt; fromLeft 1 (Left 3)
gr3
gr
gr&gt;&gt;&gt; fromLeft 1 (Right "foo")
gr1
gr</pre>
fromLeft :: a -> Either a b -> a

-- | Return the contents of a <a>Right</a>-value or a default value
grotherwise.
gr
gr<h4><b>Examples</b></h4>
gr
grBasic usage:
gr
gr<pre>
gr&gt;&gt;&gt; fromRight 1 (Right 3)
gr3
gr
gr&gt;&gt;&gt; fromRight 1 (Left "foo")
gr1
gr</pre>
fromRight :: b -> Either a b -> b

-- | Partitions a list of <a>Either</a> into two lists. All the <a>Left</a>
grelements are extracted, in order, to the first component of the
groutput. Similarly the <a>Right</a> elements are extracted to the
grsecond component of the output.
gr
gr<h4><b>Examples</b></h4>
gr
grBasic usage:
gr
gr<pre>
gr&gt;&gt;&gt; let list = [ Left "foo", Right 3, Left "bar", Right 7, Left "baz" ]
gr
gr&gt;&gt;&gt; partitionEithers list
gr(["foo","bar","baz"],[3,7])
gr</pre>
gr
grThe pair returned by <tt><a>partitionEithers</a> x</tt> should be the
grsame pair as <tt>(<a>lefts</a> x, <a>rights</a> x)</tt>:
gr
gr<pre>
gr&gt;&gt;&gt; let list = [ Left "foo", Right 3, Left "bar", Right 7, Left "baz" ]
gr
gr&gt;&gt;&gt; partitionEithers list == (lefts list, rights list)
grTrue
gr</pre>
partitionEithers :: [Either a b] -> ([a], [b])
instance (GHC.Show.Show a, GHC.Show.Show b) => GHC.Show.Show (Data.Either.Either a b)
instance (GHC.Read.Read a, GHC.Read.Read b) => GHC.Read.Read (Data.Either.Either a b)
instance (GHC.Classes.Ord a, GHC.Classes.Ord b) => GHC.Classes.Ord (Data.Either.Either a b)
instance (GHC.Classes.Eq a, GHC.Classes.Eq b) => GHC.Classes.Eq (Data.Either.Either a b)
instance GHC.Base.Functor (Data.Either.Either a)
instance GHC.Base.Semigroup (Data.Either.Either a b)
instance GHC.Base.Applicative (Data.Either.Either e)
instance GHC.Base.Monad (Data.Either.Either e)


-- | Converting strings to values.
gr
grThe <a>Text.Read</a> library is the canonical library to import for
gr<a>Read</a>-class facilities. For GHC only, it offers an extended and
grmuch improved <a>Read</a> class, which constitutes a proposed
gralternative to the Haskell 2010 <a>Read</a>. In particular, writing
grparsers is easier, and the parsers are much more efficient.
module Text.Read

-- | Parsing of <a>String</a>s, producing values.
gr
grDerived instances of <a>Read</a> make the following assumptions, which
grderived instances of <a>Show</a> obey:
gr
gr<ul>
gr<li>If the constructor is defined to be an infix operator, then the
grderived <a>Read</a> instance will parse only infix applications of the
grconstructor (not the prefix form).</li>
gr<li>Associativity is not used to reduce the occurrence of parentheses,
gralthough precedence may be.</li>
gr<li>If the constructor is defined using record syntax, the derived
gr<a>Read</a> will parse only the record-syntax form, and furthermore,
grthe fields must be given in the same order as the original
grdeclaration.</li>
gr<li>The derived <a>Read</a> instance allows arbitrary Haskell
grwhitespace between tokens of the input string. Extra parentheses are
gralso allowed.</li>
gr</ul>
gr
grFor example, given the declarations
gr
gr<pre>
grinfixr 5 :^:
grdata Tree a =  Leaf a  |  Tree a :^: Tree a
gr</pre>
gr
grthe derived instance of <a>Read</a> in Haskell 2010 is equivalent to
gr
gr<pre>
grinstance (Read a) =&gt; Read (Tree a) where
gr
gr        readsPrec d r =  readParen (d &gt; app_prec)
gr                         (\r -&gt; [(Leaf m,t) |
gr                                 ("Leaf",s) &lt;- lex r,
gr                                 (m,t) &lt;- readsPrec (app_prec+1) s]) r
gr
gr                      ++ readParen (d &gt; up_prec)
gr                         (\r -&gt; [(u:^:v,w) |
gr                                 (u,s) &lt;- readsPrec (up_prec+1) r,
gr                                 (":^:",t) &lt;- lex s,
gr                                 (v,w) &lt;- readsPrec (up_prec+1) t]) r
gr
gr          where app_prec = 10
gr                up_prec = 5
gr</pre>
gr
grNote that right-associativity of <tt>:^:</tt> is unused.
gr
grThe derived instance in GHC is equivalent to
gr
gr<pre>
grinstance (Read a) =&gt; Read (Tree a) where
gr
gr        readPrec = parens $ (prec app_prec $ do
gr                                 Ident "Leaf" &lt;- lexP
gr                                 m &lt;- step readPrec
gr                                 return (Leaf m))
gr
gr                     +++ (prec up_prec $ do
gr                                 u &lt;- step readPrec
gr                                 Symbol ":^:" &lt;- lexP
gr                                 v &lt;- step readPrec
gr                                 return (u :^: v))
gr
gr          where app_prec = 10
gr                up_prec = 5
gr
gr        readListPrec = readListPrecDefault
gr</pre>
gr
grWhy do both <a>readsPrec</a> and <a>readPrec</a> exist, and why does
grGHC opt to implement <a>readPrec</a> in derived <a>Read</a> instances
grinstead of <a>readsPrec</a>? The reason is that <a>readsPrec</a> is
grbased on the <a>ReadS</a> type, and although <a>ReadS</a> is mentioned
grin the Haskell 2010 Report, it is not a very efficient parser data
grstructure.
gr
gr<a>readPrec</a>, on the other hand, is based on a much more efficient
gr<a>ReadPrec</a> datatype (a.k.a "new-style parsers"), but its
grdefinition relies on the use of the <tt>RankNTypes</tt> language
grextension. Therefore, <a>readPrec</a> (and its cousin,
gr<a>readListPrec</a>) are marked as GHC-only. Nevertheless, it is
grrecommended to use <a>readPrec</a> instead of <a>readsPrec</a>
grwhenever possible for the efficiency improvements it brings.
gr
grAs mentioned above, derived <a>Read</a> instances in GHC will
grimplement <a>readPrec</a> instead of <a>readsPrec</a>. The default
grimplementations of <a>readsPrec</a> (and its cousin, <a>readList</a>)
grwill simply use <a>readPrec</a> under the hood. If you are writing a
gr<a>Read</a> instance by hand, it is recommended to write it like so:
gr
gr<pre>
grinstance <a>Read</a> T where
gr  <a>readPrec</a>     = ...
gr  <a>readListPrec</a> = <a>readListPrecDefault</a>
gr</pre>
class Read a

-- | attempts to parse a value from the front of the string, returning a
grlist of (parsed value, remaining string) pairs. If there is no
grsuccessful parse, the returned list is empty.
gr
grDerived instances of <a>Read</a> and <a>Show</a> satisfy the
grfollowing:
gr
gr<ul>
gr<li><tt>(x,"")</tt> is an element of <tt>(<a>readsPrec</a> d
gr(<a>showsPrec</a> d x ""))</tt>.</li>
gr</ul>
gr
grThat is, <a>readsPrec</a> parses the string produced by
gr<a>showsPrec</a>, and delivers the value that <a>showsPrec</a> started
grwith.
readsPrec :: Read a => Int -> ReadS a

-- | The method <a>readList</a> is provided to allow the programmer to give
gra specialised way of parsing lists of values. For example, this is
grused by the predefined <a>Read</a> instance of the <a>Char</a> type,
grwhere values of type <a>String</a> should be are expected to use
grdouble quotes, rather than square brackets.
readList :: Read a => ReadS [a]

-- | Proposed replacement for <a>readsPrec</a> using new-style parsers (GHC
gronly).
readPrec :: Read a => ReadPrec a

-- | Proposed replacement for <a>readList</a> using new-style parsers (GHC
gronly). The default definition uses <a>readList</a>. Instances that
grdefine <a>readPrec</a> should also define <a>readListPrec</a> as
gr<a>readListPrecDefault</a>.
readListPrec :: Read a => ReadPrec [a]

-- | A parser for a type <tt>a</tt>, represented as a function that takes a
gr<a>String</a> and returns a list of possible parses as
gr<tt>(a,<a>String</a>)</tt> pairs.
gr
grNote that this kind of backtracking parser is very inefficient;
grreading a large structure may be quite slow (cf <a>ReadP</a>).
type ReadS a = String -> [(a, String)]

-- | equivalent to <a>readsPrec</a> with a precedence of 0.
reads :: Read a => ReadS a

-- | The <a>read</a> function reads input from a string, which must be
grcompletely consumed by the input process. <a>read</a> fails with an
gr<a>error</a> if the parse is unsuccessful, and it is therefore
grdiscouraged from being used in real applications. Use <a>readMaybe</a>
gror <a>readEither</a> for safe alternatives.
gr
gr<pre>
gr&gt;&gt;&gt; read "123" :: Int
gr123
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; read "hello" :: Int
gr*** Exception: Prelude.read: no parse
gr</pre>
read :: Read a => String -> a

-- | <tt><a>readParen</a> <a>True</a> p</tt> parses what <tt>p</tt> parses,
grbut surrounded with parentheses.
gr
gr<tt><a>readParen</a> <a>False</a> p</tt> parses what <tt>p</tt>
grparses, but optionally surrounded with parentheses.
readParen :: Bool -> ReadS a -> ReadS a

-- | The <a>lex</a> function reads a single lexeme from the input,
grdiscarding initial white space, and returning the characters that
grconstitute the lexeme. If the input string contains only white space,
gr<a>lex</a> returns a single successful `lexeme' consisting of the
grempty string. (Thus <tt><a>lex</a> "" = [("","")]</tt>.) If there is
grno legal lexeme at the beginning of the input string, <a>lex</a> fails
gr(i.e. returns <tt>[]</tt>).
gr
grThis lexer is not completely faithful to the Haskell lexical syntax in
grthe following respects:
gr
gr<ul>
gr<li>Qualified names are not handled properly</li>
gr<li>Octal and hexadecimal numerics are not recognized as a single
grtoken</li>
gr<li>Comments are not treated properly</li>
gr</ul>
lex :: ReadS String
data Lexeme

-- | Character literal
Char :: Char -> Lexeme

-- | String literal, with escapes interpreted
String :: String -> Lexeme

-- | Punctuation or reserved symbol, e.g. <tt>(</tt>, <tt>::</tt>
Punc :: String -> Lexeme

-- | Haskell identifier, e.g. <tt>foo</tt>, <tt>Baz</tt>
Ident :: String -> Lexeme

-- | Haskell symbol, e.g. <tt>&gt;&gt;</tt>, <tt>:%</tt>
Symbol :: String -> Lexeme

Number :: Number -> Lexeme
EOF :: Lexeme

-- | Parse a single lexeme
lexP :: ReadPrec Lexeme

-- | <tt>(parens p)</tt> parses "P", "(P0)", "((P0))", etc, where
gr<tt>p</tt> parses "P" in the current precedence context and parses
gr"P0" in precedence context zero
parens :: ReadPrec a -> ReadPrec a

-- | A possible replacement definition for the <a>readList</a> method (GHC
gronly). This is only needed for GHC, and even then only for <a>Read</a>
grinstances where <a>readListPrec</a> isn't defined as
gr<a>readListPrecDefault</a>.
readListDefault :: Read a => ReadS [a]

-- | A possible replacement definition for the <a>readListPrec</a> method,
grdefined using <a>readPrec</a> (GHC only).
readListPrecDefault :: Read a => ReadPrec [a]

-- | Parse a string using the <a>Read</a> instance. Succeeds if there is
grexactly one valid result. A <a>Left</a> value indicates a parse error.
gr
gr<pre>
gr&gt;&gt;&gt; readEither "123" :: Either String Int
grRight 123
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; readEither "hello" :: Either String Int
grLeft "Prelude.read: no parse"
gr</pre>
readEither :: Read a => String -> Either String a

-- | Parse a string using the <a>Read</a> instance. Succeeds if there is
grexactly one valid result.
gr
gr<pre>
gr&gt;&gt;&gt; readMaybe "123" :: Maybe Int
grJust 123
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; readMaybe "hello" :: Maybe Int
grNothing
gr</pre>
readMaybe :: Read a => String -> Maybe a


-- | The Char type and associated operations.
module Data.Char

-- | The character type <a>Char</a> is an enumeration whose values
grrepresent Unicode (or equivalently ISO/IEC 10646) code points (i.e.
grcharacters, see <a>http://www.unicode.org/</a> for details). This set
grextends the ISO 8859-1 (Latin-1) character set (the first 256
grcharacters), which is itself an extension of the ASCII character set
gr(the first 128 characters). A character literal in Haskell has type
gr<a>Char</a>.
gr
grTo convert a <a>Char</a> to or from the corresponding <a>Int</a> value
grdefined by Unicode, use <a>toEnum</a> and <a>fromEnum</a> from the
gr<a>Enum</a> class respectively (or equivalently <tt>ord</tt> and
gr<tt>chr</tt>).
data Char

-- | Selects control characters, which are the non-printing characters of
grthe Latin-1 subset of Unicode.
isControl :: Char -> Bool

-- | Returns <a>True</a> for any Unicode space character, and the control
grcharacters <tt>\t</tt>, <tt>\n</tt>, <tt>\r</tt>, <tt>\f</tt>,
gr<tt>\v</tt>.
isSpace :: Char -> Bool

-- | Selects lower-case alphabetic Unicode characters (letters).
isLower :: Char -> Bool

-- | Selects upper-case or title-case alphabetic Unicode characters
gr(letters). Title case is used by a small number of letter ligatures
grlike the single-character form of <i>Lj</i>.
isUpper :: Char -> Bool

-- | Selects alphabetic Unicode characters (lower-case, upper-case and
grtitle-case letters, plus letters of caseless scripts and modifiers
grletters). This function is equivalent to <a>isLetter</a>.
isAlpha :: Char -> Bool

-- | Selects alphabetic or numeric digit Unicode characters.
gr
grNote that numeric digits outside the ASCII range are selected by this
grfunction but not by <a>isDigit</a>. Such digits may be part of
gridentifiers but are not used by the printer and reader to represent
grnumbers.
isAlphaNum :: Char -> Bool

-- | Selects printable Unicode characters (letters, numbers, marks,
grpunctuation, symbols and spaces).
isPrint :: Char -> Bool

-- | Selects ASCII digits, i.e. <tt>'0'</tt>..<tt>'9'</tt>.
isDigit :: Char -> Bool

-- | Selects ASCII octal digits, i.e. <tt>'0'</tt>..<tt>'7'</tt>.
isOctDigit :: Char -> Bool

-- | Selects ASCII hexadecimal digits, i.e. <tt>'0'</tt>..<tt>'9'</tt>,
gr<tt>'a'</tt>..<tt>'f'</tt>, <tt>'A'</tt>..<tt>'F'</tt>.
isHexDigit :: Char -> Bool

-- | Selects alphabetic Unicode characters (lower-case, upper-case and
grtitle-case letters, plus letters of caseless scripts and modifiers
grletters). This function is equivalent to <a>isAlpha</a>.
gr
grThis function returns <a>True</a> if its argument has one of the
grfollowing <a>GeneralCategory</a>s, or <a>False</a> otherwise:
gr
gr<ul>
gr<li><a>UppercaseLetter</a></li>
gr<li><a>LowercaseLetter</a></li>
gr<li><a>TitlecaseLetter</a></li>
gr<li><a>ModifierLetter</a></li>
gr<li><a>OtherLetter</a></li>
gr</ul>
gr
grThese classes are defined in the <a>Unicode Character Database</a>,
grpart of the Unicode standard. The same document defines what is and is
grnot a "Letter".
gr
gr<h4><b>Examples</b></h4>
gr
grBasic usage:
gr
gr<pre>
gr&gt;&gt;&gt; isLetter 'a'
grTrue
gr
gr&gt;&gt;&gt; isLetter 'A'
grTrue
gr
gr&gt;&gt;&gt; isLetter 'λ'
grTrue
gr
gr&gt;&gt;&gt; isLetter '0'
grFalse
gr
gr&gt;&gt;&gt; isLetter '%'
grFalse
gr
gr&gt;&gt;&gt; isLetter '♥'
grFalse
gr
gr&gt;&gt;&gt; isLetter '\31'
grFalse
gr</pre>
gr
grEnsure that <a>isLetter</a> and <a>isAlpha</a> are equivalent.
gr
gr<pre>
gr&gt;&gt;&gt; let chars = [(chr 0)..]
gr
gr&gt;&gt;&gt; let letters = map isLetter chars
gr
gr&gt;&gt;&gt; let alphas = map isAlpha chars
gr
gr&gt;&gt;&gt; letters == alphas
grTrue
gr</pre>
isLetter :: Char -> Bool

-- | Selects Unicode mark characters, for example accents and the like,
grwhich combine with preceding characters.
gr
grThis function returns <a>True</a> if its argument has one of the
grfollowing <a>GeneralCategory</a>s, or <a>False</a> otherwise:
gr
gr<ul>
gr<li><a>NonSpacingMark</a></li>
gr<li><a>SpacingCombiningMark</a></li>
gr<li><a>EnclosingMark</a></li>
gr</ul>
gr
grThese classes are defined in the <a>Unicode Character Database</a>,
grpart of the Unicode standard. The same document defines what is and is
grnot a "Mark".
gr
gr<h4><b>Examples</b></h4>
gr
grBasic usage:
gr
gr<pre>
gr&gt;&gt;&gt; isMark 'a'
grFalse
gr
gr&gt;&gt;&gt; isMark '0'
grFalse
gr</pre>
gr
grCombining marks such as accent characters usually need to follow
granother character before they become printable:
gr
gr<pre>
gr&gt;&gt;&gt; map isMark "ò"
gr[False,True]
gr</pre>
gr
grPuns are not necessarily supported:
gr
gr<pre>
gr&gt;&gt;&gt; isMark '✓'
grFalse
gr</pre>
isMark :: Char -> Bool

-- | Selects Unicode numeric characters, including digits from various
grscripts, Roman numerals, et cetera.
gr
grThis function returns <a>True</a> if its argument has one of the
grfollowing <a>GeneralCategory</a>s, or <a>False</a> otherwise:
gr
gr<ul>
gr<li><a>DecimalNumber</a></li>
gr<li><a>LetterNumber</a></li>
gr<li><a>OtherNumber</a></li>
gr</ul>
gr
grThese classes are defined in the <a>Unicode Character Database</a>,
grpart of the Unicode standard. The same document defines what is and is
grnot a "Number".
gr
gr<h4><b>Examples</b></h4>
gr
grBasic usage:
gr
gr<pre>
gr&gt;&gt;&gt; isNumber 'a'
grFalse
gr
gr&gt;&gt;&gt; isNumber '%'
grFalse
gr
gr&gt;&gt;&gt; isNumber '3'
grTrue
gr</pre>
gr
grASCII <tt>'0'</tt> through <tt>'9'</tt> are all numbers:
gr
gr<pre>
gr&gt;&gt;&gt; and $ map isNumber ['0'..'9']
grTrue
gr</pre>
gr
grUnicode Roman numerals are "numbers" as well:
gr
gr<pre>
gr&gt;&gt;&gt; isNumber 'Ⅸ'
grTrue
gr</pre>
isNumber :: Char -> Bool

-- | Selects Unicode punctuation characters, including various kinds of
grconnectors, brackets and quotes.
gr
grThis function returns <a>True</a> if its argument has one of the
grfollowing <a>GeneralCategory</a>s, or <a>False</a> otherwise:
gr
gr<ul>
gr<li><a>ConnectorPunctuation</a></li>
gr<li><a>DashPunctuation</a></li>
gr<li><a>OpenPunctuation</a></li>
gr<li><a>ClosePunctuation</a></li>
gr<li><a>InitialQuote</a></li>
gr<li><a>FinalQuote</a></li>
gr<li><a>OtherPunctuation</a></li>
gr</ul>
gr
grThese classes are defined in the <a>Unicode Character Database</a>,
grpart of the Unicode standard. The same document defines what is and is
grnot a "Punctuation".
gr
gr<h4><b>Examples</b></h4>
gr
grBasic usage:
gr
gr<pre>
gr&gt;&gt;&gt; isPunctuation 'a'
grFalse
gr
gr&gt;&gt;&gt; isPunctuation '7'
grFalse
gr
gr&gt;&gt;&gt; isPunctuation '♥'
grFalse
gr
gr&gt;&gt;&gt; isPunctuation '"'
grTrue
gr
gr&gt;&gt;&gt; isPunctuation '?'
grTrue
gr
gr&gt;&gt;&gt; isPunctuation '—'
grTrue
gr</pre>
isPunctuation :: Char -> Bool

-- | Selects Unicode symbol characters, including mathematical and currency
grsymbols.
gr
grThis function returns <a>True</a> if its argument has one of the
grfollowing <a>GeneralCategory</a>s, or <a>False</a> otherwise:
gr
gr<ul>
gr<li><a>MathSymbol</a></li>
gr<li><a>CurrencySymbol</a></li>
gr<li><a>ModifierSymbol</a></li>
gr<li><a>OtherSymbol</a></li>
gr</ul>
gr
grThese classes are defined in the <a>Unicode Character Database</a>,
grpart of the Unicode standard. The same document defines what is and is
grnot a "Symbol".
gr
gr<h4><b>Examples</b></h4>
gr
grBasic usage:
gr
gr<pre>
gr&gt;&gt;&gt; isSymbol 'a'
grFalse
gr
gr&gt;&gt;&gt; isSymbol '6'
grFalse
gr
gr&gt;&gt;&gt; isSymbol '='
grTrue
gr</pre>
gr
grThe definition of "math symbol" may be a little counter-intuitive
grdepending on one's background:
gr
gr<pre>
gr&gt;&gt;&gt; isSymbol '+'
grTrue
gr
gr&gt;&gt;&gt; isSymbol '-'
grFalse
gr</pre>
isSymbol :: Char -> Bool

-- | Selects Unicode space and separator characters.
gr
grThis function returns <a>True</a> if its argument has one of the
grfollowing <a>GeneralCategory</a>s, or <a>False</a> otherwise:
gr
gr<ul>
gr<li><a>Space</a></li>
gr<li><a>LineSeparator</a></li>
gr<li><a>ParagraphSeparator</a></li>
gr</ul>
gr
grThese classes are defined in the <a>Unicode Character Database</a>,
grpart of the Unicode standard. The same document defines what is and is
grnot a "Separator".
gr
gr<h4><b>Examples</b></h4>
gr
grBasic usage:
gr
gr<pre>
gr&gt;&gt;&gt; isSeparator 'a'
grFalse
gr
gr&gt;&gt;&gt; isSeparator '6'
grFalse
gr
gr&gt;&gt;&gt; isSeparator ' '
grTrue
gr</pre>
gr
grWarning: newlines and tab characters are not considered separators.
gr
gr<pre>
gr&gt;&gt;&gt; isSeparator '\n'
grFalse
gr
gr&gt;&gt;&gt; isSeparator '\t'
grFalse
gr</pre>
gr
grBut some more exotic characters are (like HTML's <tt>&amp;nbsp;</tt>):
gr
gr<pre>
gr&gt;&gt;&gt; isSeparator '\160'
grTrue
gr</pre>
isSeparator :: Char -> Bool

-- | Selects the first 128 characters of the Unicode character set,
grcorresponding to the ASCII character set.
isAscii :: Char -> Bool

-- | Selects the first 256 characters of the Unicode character set,
grcorresponding to the ISO 8859-1 (Latin-1) character set.
isLatin1 :: Char -> Bool

-- | Selects ASCII upper-case letters, i.e. characters satisfying both
gr<a>isAscii</a> and <a>isUpper</a>.
isAsciiUpper :: Char -> Bool

-- | Selects ASCII lower-case letters, i.e. characters satisfying both
gr<a>isAscii</a> and <a>isLower</a>.
isAsciiLower :: Char -> Bool

-- | Unicode General Categories (column 2 of the UnicodeData table) in the
grorder they are listed in the Unicode standard (the Unicode Character
grDatabase, in particular).
gr
gr<h4><b>Examples</b></h4>
gr
grBasic usage:
gr
gr<pre>
gr&gt;&gt;&gt; :t OtherLetter
grOtherLetter :: GeneralCategory
gr</pre>
gr
gr<a>Eq</a> instance:
gr
gr<pre>
gr&gt;&gt;&gt; UppercaseLetter == UppercaseLetter
grTrue
gr
gr&gt;&gt;&gt; UppercaseLetter == LowercaseLetter
grFalse
gr</pre>
gr
gr<a>Ord</a> instance:
gr
gr<pre>
gr&gt;&gt;&gt; NonSpacingMark &lt;= MathSymbol
grTrue
gr</pre>
gr
gr<a>Enum</a> instance:
gr
gr<pre>
gr&gt;&gt;&gt; enumFromTo ModifierLetter SpacingCombiningMark
gr[ModifierLetter,OtherLetter,NonSpacingMark,SpacingCombiningMark]
gr</pre>
gr
gr<tt>Read</tt> instance:
gr
gr<pre>
gr&gt;&gt;&gt; read "DashPunctuation" :: GeneralCategory
grDashPunctuation
gr
gr&gt;&gt;&gt; read "17" :: GeneralCategory
gr*** Exception: Prelude.read: no parse
gr</pre>
gr
gr<a>Show</a> instance:
gr
gr<pre>
gr&gt;&gt;&gt; show EnclosingMark
gr"EnclosingMark"
gr</pre>
gr
gr<a>Bounded</a> instance:
gr
gr<pre>
gr&gt;&gt;&gt; minBound :: GeneralCategory
grUppercaseLetter
gr
gr&gt;&gt;&gt; maxBound :: GeneralCategory
grNotAssigned
gr</pre>
gr
gr<a>Ix</a> instance:
gr
gr<pre>
gr&gt;&gt;&gt; import Data.Ix ( index )
gr
gr&gt;&gt;&gt; index (OtherLetter,Control) FinalQuote
gr12
gr
gr&gt;&gt;&gt; index (OtherLetter,Control) Format
gr*** Exception: Error in array index
gr</pre>
data GeneralCategory

-- | Lu: Letter, Uppercase
UppercaseLetter :: GeneralCategory

-- | Ll: Letter, Lowercase
LowercaseLetter :: GeneralCategory

-- | Lt: Letter, Titlecase
TitlecaseLetter :: GeneralCategory

-- | Lm: Letter, Modifier
ModifierLetter :: GeneralCategory

-- | Lo: Letter, Other
OtherLetter :: GeneralCategory

-- | Mn: Mark, Non-Spacing
NonSpacingMark :: GeneralCategory

-- | Mc: Mark, Spacing Combining
SpacingCombiningMark :: GeneralCategory

-- | Me: Mark, Enclosing
EnclosingMark :: GeneralCategory

-- | Nd: Number, Decimal
DecimalNumber :: GeneralCategory

-- | Nl: Number, Letter
LetterNumber :: GeneralCategory

-- | No: Number, Other
OtherNumber :: GeneralCategory

-- | Pc: Punctuation, Connector
ConnectorPunctuation :: GeneralCategory

-- | Pd: Punctuation, Dash
DashPunctuation :: GeneralCategory

-- | Ps: Punctuation, Open
OpenPunctuation :: GeneralCategory

-- | Pe: Punctuation, Close
ClosePunctuation :: GeneralCategory

-- | Pi: Punctuation, Initial quote
InitialQuote :: GeneralCategory

-- | Pf: Punctuation, Final quote
FinalQuote :: GeneralCategory

-- | Po: Punctuation, Other
OtherPunctuation :: GeneralCategory

-- | Sm: Symbol, Math
MathSymbol :: GeneralCategory

-- | Sc: Symbol, Currency
CurrencySymbol :: GeneralCategory

-- | Sk: Symbol, Modifier
ModifierSymbol :: GeneralCategory

-- | So: Symbol, Other
OtherSymbol :: GeneralCategory

-- | Zs: Separator, Space
Space :: GeneralCategory

-- | Zl: Separator, Line
LineSeparator :: GeneralCategory

-- | Zp: Separator, Paragraph
ParagraphSeparator :: GeneralCategory

-- | Cc: Other, Control
Control :: GeneralCategory

-- | Cf: Other, Format
Format :: GeneralCategory

-- | Cs: Other, Surrogate
Surrogate :: GeneralCategory

-- | Co: Other, Private Use
PrivateUse :: GeneralCategory

-- | Cn: Other, Not Assigned
NotAssigned :: GeneralCategory

-- | The Unicode general category of the character. This relies on the
gr<a>Enum</a> instance of <a>GeneralCategory</a>, which must remain in
grthe same order as the categories are presented in the Unicode
grstandard.
gr
gr<h4><b>Examples</b></h4>
gr
grBasic usage:
gr
gr<pre>
gr&gt;&gt;&gt; generalCategory 'a'
grLowercaseLetter
gr
gr&gt;&gt;&gt; generalCategory 'A'
grUppercaseLetter
gr
gr&gt;&gt;&gt; generalCategory '0'
grDecimalNumber
gr
gr&gt;&gt;&gt; generalCategory '%'
grOtherPunctuation
gr
gr&gt;&gt;&gt; generalCategory '♥'
grOtherSymbol
gr
gr&gt;&gt;&gt; generalCategory '\31'
grControl
gr
gr&gt;&gt;&gt; generalCategory ' '
grSpace
gr</pre>
generalCategory :: Char -> GeneralCategory

-- | Convert a letter to the corresponding upper-case letter, if any. Any
grother character is returned unchanged.
toUpper :: Char -> Char

-- | Convert a letter to the corresponding lower-case letter, if any. Any
grother character is returned unchanged.
toLower :: Char -> Char

-- | Convert a letter to the corresponding title-case or upper-case letter,
grif any. (Title case differs from upper case only for a small number of
grligature letters.) Any other character is returned unchanged.
toTitle :: Char -> Char

-- | Convert a single digit <a>Char</a> to the corresponding <a>Int</a>.
grThis function fails unless its argument satisfies <a>isHexDigit</a>,
grbut recognises both upper- and lower-case hexadecimal digits (that is,
gr<tt>'0'</tt>..<tt>'9'</tt>, <tt>'a'</tt>..<tt>'f'</tt>,
gr<tt>'A'</tt>..<tt>'F'</tt>).
gr
gr<h4><b>Examples</b></h4>
gr
grCharacters <tt>'0'</tt> through <tt>'9'</tt> are converted properly to
gr<tt>0..9</tt>:
gr
gr<pre>
gr&gt;&gt;&gt; map digitToInt ['0'..'9']
gr[0,1,2,3,4,5,6,7,8,9]
gr</pre>
gr
grBoth upper- and lower-case <tt>'A'</tt> through <tt>'F'</tt> are
grconverted as well, to <tt>10..15</tt>.
gr
gr<pre>
gr&gt;&gt;&gt; map digitToInt ['a'..'f']
gr[10,11,12,13,14,15]
gr
gr&gt;&gt;&gt; map digitToInt ['A'..'F']
gr[10,11,12,13,14,15]
gr</pre>
gr
grAnything else throws an exception:
gr
gr<pre>
gr&gt;&gt;&gt; digitToInt 'G'
gr*** Exception: Char.digitToInt: not a digit 'G'
gr
gr&gt;&gt;&gt; digitToInt '♥'
gr*** Exception: Char.digitToInt: not a digit '\9829'
gr</pre>
digitToInt :: Char -> Int

-- | Convert an <a>Int</a> in the range <tt>0</tt>..<tt>15</tt> to the
grcorresponding single digit <a>Char</a>. This function fails on other
grinputs, and generates lower-case hexadecimal digits.
intToDigit :: Int -> Char

-- | The <a>fromEnum</a> method restricted to the type <a>Char</a>.
ord :: Char -> Int

-- | The <a>toEnum</a> method restricted to the type <a>Char</a>.
chr :: Int -> Char

-- | Convert a character to a string using only printable characters, using
grHaskell source-language escape conventions. For example:
gr
gr<pre>
grshowLitChar '\n' s  =  "\\n" ++ s
gr</pre>
showLitChar :: Char -> ShowS

-- | Read a string representation of a character, using Haskell
grsource-language escape conventions. For example:
gr
gr<pre>
grlexLitChar  "\\nHello"  =  [("\\n", "Hello")]
gr</pre>
lexLitChar :: ReadS String

-- | Read a string representation of a character, using Haskell
grsource-language escape conventions, and convert it to the character
grthat it encodes. For example:
gr
gr<pre>
grreadLitChar "\\nHello"  =  [('\n', "Hello")]
gr</pre>
readLitChar :: ReadS Char


-- | This legacy module provides access to the list-specialised operations
grof <a>Data.List</a>. This module may go away again in future GHC
grversions and is provided as transitional tool to access some of the
grlist-specialised operations that had to be generalised due to the
grimplementation of the <a>Foldable/Traversable-in-Prelude Proposal
gr(FTP)</a>.
gr
grIf the operations needed are available in <a>GHC.List</a>, it's
grrecommended to avoid importing this module and use <a>GHC.List</a>
grinstead for now.
module GHC.OldList

-- | Append two lists, i.e.,
gr
gr<pre>
gr[x1, ..., xm] ++ [y1, ..., yn] == [x1, ..., xm, y1, ..., yn]
gr[x1, ..., xm] ++ [y1, ...] == [x1, ..., xm, y1, ...]
gr</pre>
gr
grIf the first list is not finite, the result is the first list.
(++) :: [a] -> [a] -> [a]
infixr 5 ++

-- | Extract the first element of a list, which must be non-empty.
head :: [a] -> a

-- | Extract the last element of a list, which must be finite and
grnon-empty.
last :: [a] -> a

-- | Extract the elements after the head of a list, which must be
grnon-empty.
tail :: [a] -> [a]

-- | Return all the elements of a list except the last one. The list must
grbe non-empty.
init :: [a] -> [a]

-- | Decompose a list into its head and tail. If the list is empty, returns
gr<a>Nothing</a>. If the list is non-empty, returns <tt><a>Just</a> (x,
grxs)</tt>, where <tt>x</tt> is the head of the list and <tt>xs</tt> its
grtail.
uncons :: [a] -> Maybe (a, [a])

-- | Test whether a list is empty.
null :: [a] -> Bool

-- | <i>O(n)</i>. <a>length</a> returns the length of a finite list as an
gr<a>Int</a>. It is an instance of the more general
gr<a>genericLength</a>, the result type of which may be any kind of
grnumber.
length :: [a] -> Int

-- | <a>map</a> <tt>f xs</tt> is the list obtained by applying <tt>f</tt>
grto each element of <tt>xs</tt>, i.e.,
gr
gr<pre>
grmap f [x1, x2, ..., xn] == [f x1, f x2, ..., f xn]
grmap f [x1, x2, ...] == [f x1, f x2, ...]
gr</pre>
map :: (a -> b) -> [a] -> [b]

-- | <a>reverse</a> <tt>xs</tt> returns the elements of <tt>xs</tt> in
grreverse order. <tt>xs</tt> must be finite.
reverse :: [a] -> [a]

-- | The <a>intersperse</a> function takes an element and a list and
gr`intersperses' that element between the elements of the list. For
grexample,
gr
gr<pre>
gr&gt;&gt;&gt; intersperse ',' "abcde"
gr"a,b,c,d,e"
gr</pre>
intersperse :: a -> [a] -> [a]

-- | <a>intercalate</a> <tt>xs xss</tt> is equivalent to <tt>(<a>concat</a>
gr(<a>intersperse</a> xs xss))</tt>. It inserts the list <tt>xs</tt> in
grbetween the lists in <tt>xss</tt> and concatenates the result.
gr
gr<pre>
gr&gt;&gt;&gt; intercalate ", " ["Lorem", "ipsum", "dolor"]
gr"Lorem, ipsum, dolor"
gr</pre>
intercalate :: [a] -> [[a]] -> [a]

-- | The <a>transpose</a> function transposes the rows and columns of its
grargument. For example,
gr
gr<pre>
gr&gt;&gt;&gt; transpose [[1,2,3],[4,5,6]]
gr[[1,4],[2,5],[3,6]]
gr</pre>
gr
grIf some of the rows are shorter than the following rows, their
grelements are skipped:
gr
gr<pre>
gr&gt;&gt;&gt; transpose [[10,11],[20],[],[30,31,32]]
gr[[10,20,30],[11,31],[32]]
gr</pre>
transpose :: [[a]] -> [[a]]

-- | The <a>subsequences</a> function returns the list of all subsequences
grof the argument.
gr
gr<pre>
gr&gt;&gt;&gt; subsequences "abc"
gr["","a","b","ab","c","ac","bc","abc"]
gr</pre>
subsequences :: [a] -> [[a]]

-- | The <a>permutations</a> function returns the list of all permutations
grof the argument.
gr
gr<pre>
gr&gt;&gt;&gt; permutations "abc"
gr["abc","bac","cba","bca","cab","acb"]
gr</pre>
permutations :: [a] -> [[a]]

-- | <a>foldl</a>, applied to a binary operator, a starting value
gr(typically the left-identity of the operator), and a list, reduces the
grlist using the binary operator, from left to right:
gr
gr<pre>
grfoldl f z [x1, x2, ..., xn] == (...((z `f` x1) `f` x2) `f`...) `f` xn
gr</pre>
gr
grThe list must be finite.
foldl :: forall a b. (b -> a -> b) -> b -> [a] -> b

-- | A strict version of <a>foldl</a>.
foldl' :: forall a b. (b -> a -> b) -> b -> [a] -> b

-- | <a>foldl1</a> is a variant of <a>foldl</a> that has no starting value
grargument, and thus must be applied to non-empty lists.
foldl1 :: (a -> a -> a) -> [a] -> a

-- | A strict version of <a>foldl1</a>
foldl1' :: (a -> a -> a) -> [a] -> a

-- | <a>foldr</a>, applied to a binary operator, a starting value
gr(typically the right-identity of the operator), and a list, reduces
grthe list using the binary operator, from right to left:
gr
gr<pre>
grfoldr f z [x1, x2, ..., xn] == x1 `f` (x2 `f` ... (xn `f` z)...)
gr</pre>
foldr :: (a -> b -> b) -> b -> [a] -> b

-- | <a>foldr1</a> is a variant of <a>foldr</a> that has no starting value
grargument, and thus must be applied to non-empty lists.
foldr1 :: (a -> a -> a) -> [a] -> a

-- | Concatenate a list of lists.
concat :: [[a]] -> [a]

-- | Map a function over a list and concatenate the results.
concatMap :: (a -> [b]) -> [a] -> [b]

-- | <a>and</a> returns the conjunction of a Boolean list. For the result
grto be <a>True</a>, the list must be finite; <a>False</a>, however,
grresults from a <a>False</a> value at a finite index of a finite or
grinfinite list.
and :: [Bool] -> Bool

-- | <a>or</a> returns the disjunction of a Boolean list. For the result to
grbe <a>False</a>, the list must be finite; <a>True</a>, however,
grresults from a <a>True</a> value at a finite index of a finite or
grinfinite list.
or :: [Bool] -> Bool

-- | Applied to a predicate and a list, <a>any</a> determines if any
grelement of the list satisfies the predicate. For the result to be
gr<a>False</a>, the list must be finite; <a>True</a>, however, results
grfrom a <a>True</a> value for the predicate applied to an element at a
grfinite index of a finite or infinite list.
any :: (a -> Bool) -> [a] -> Bool

-- | Applied to a predicate and a list, <a>all</a> determines if all
grelements of the list satisfy the predicate. For the result to be
gr<a>True</a>, the list must be finite; <a>False</a>, however, results
grfrom a <a>False</a> value for the predicate applied to an element at a
grfinite index of a finite or infinite list.
all :: (a -> Bool) -> [a] -> Bool

-- | The <a>sum</a> function computes the sum of a finite list of numbers.
sum :: (Num a) => [a] -> a

-- | The <a>product</a> function computes the product of a finite list of
grnumbers.
product :: (Num a) => [a] -> a

-- | <a>maximum</a> returns the maximum value from a list, which must be
grnon-empty, finite, and of an ordered type. It is a special case of
gr<a>maximumBy</a>, which allows the programmer to supply their own
grcomparison function.
maximum :: (Ord a) => [a] -> a

-- | <a>minimum</a> returns the minimum value from a list, which must be
grnon-empty, finite, and of an ordered type. It is a special case of
gr<a>minimumBy</a>, which allows the programmer to supply their own
grcomparison function.
minimum :: (Ord a) => [a] -> a

-- | <a>scanl</a> is similar to <a>foldl</a>, but returns a list of
grsuccessive reduced values from the left:
gr
gr<pre>
grscanl f z [x1, x2, ...] == [z, z `f` x1, (z `f` x1) `f` x2, ...]
gr</pre>
gr
grNote that
gr
gr<pre>
grlast (scanl f z xs) == foldl f z xs.
gr</pre>
scanl :: (b -> a -> b) -> b -> [a] -> [b]

-- | A strictly accumulating version of <a>scanl</a>
scanl' :: (b -> a -> b) -> b -> [a] -> [b]

-- | <a>scanl1</a> is a variant of <a>scanl</a> that has no starting value
grargument:
gr
gr<pre>
grscanl1 f [x1, x2, ...] == [x1, x1 `f` x2, ...]
gr</pre>
scanl1 :: (a -> a -> a) -> [a] -> [a]

-- | <a>scanr</a> is the right-to-left dual of <a>scanl</a>. Note that
gr
gr<pre>
grhead (scanr f z xs) == foldr f z xs.
gr</pre>
scanr :: (a -> b -> b) -> b -> [a] -> [b]

-- | <a>scanr1</a> is a variant of <a>scanr</a> that has no starting value
grargument.
scanr1 :: (a -> a -> a) -> [a] -> [a]

-- | The <a>mapAccumL</a> function behaves like a combination of <a>map</a>
grand <a>foldl</a>; it applies a function to each element of a list,
grpassing an accumulating parameter from left to right, and returning a
grfinal value of this accumulator together with the new list.
mapAccumL :: (acc -> x -> (acc, y)) -> acc -> [x] -> (acc, [y])

-- | The <a>mapAccumR</a> function behaves like a combination of <a>map</a>
grand <a>foldr</a>; it applies a function to each element of a list,
grpassing an accumulating parameter from right to left, and returning a
grfinal value of this accumulator together with the new list.
mapAccumR :: (acc -> x -> (acc, y)) -> acc -> [x] -> (acc, [y])

-- | <a>iterate</a> <tt>f x</tt> returns an infinite list of repeated
grapplications of <tt>f</tt> to <tt>x</tt>:
gr
gr<pre>
griterate f x == [x, f x, f (f x), ...]
gr</pre>
gr
grNote that <a>iterate</a> is lazy, potentially leading to thunk
grbuild-up if the consumer doesn't force each iterate. See 'iterate\''
grfor a strict variant of this function.
iterate :: (a -> a) -> a -> [a]

-- | 'iterate\'' is the strict version of <a>iterate</a>.
gr
grIt ensures that the result of each application of force to weak head
grnormal form before proceeding.
iterate' :: (a -> a) -> a -> [a]

-- | <a>repeat</a> <tt>x</tt> is an infinite list, with <tt>x</tt> the
grvalue of every element.
repeat :: a -> [a]

-- | <a>replicate</a> <tt>n x</tt> is a list of length <tt>n</tt> with
gr<tt>x</tt> the value of every element. It is an instance of the more
grgeneral <a>genericReplicate</a>, in which <tt>n</tt> may be of any
grintegral type.
replicate :: Int -> a -> [a]

-- | <a>cycle</a> ties a finite list into a circular one, or equivalently,
grthe infinite repetition of the original list. It is the identity on
grinfinite lists.
cycle :: [a] -> [a]

-- | The <a>unfoldr</a> function is a `dual' to <a>foldr</a>: while
gr<a>foldr</a> reduces a list to a summary value, <a>unfoldr</a> builds
gra list from a seed value. The function takes the element and returns
gr<a>Nothing</a> if it is done producing the list or returns <a>Just</a>
gr<tt>(a,b)</tt>, in which case, <tt>a</tt> is a prepended to the list
grand <tt>b</tt> is used as the next element in a recursive call. For
grexample,
gr
gr<pre>
griterate f == unfoldr (\x -&gt; Just (x, f x))
gr</pre>
gr
grIn some cases, <a>unfoldr</a> can undo a <a>foldr</a> operation:
gr
gr<pre>
grunfoldr f' (foldr f z xs) == xs
gr</pre>
gr
grif the following holds:
gr
gr<pre>
grf' (f x y) = Just (x,y)
grf' z       = Nothing
gr</pre>
gr
grA simple use of unfoldr:
gr
gr<pre>
gr&gt;&gt;&gt; unfoldr (\b -&gt; if b == 0 then Nothing else Just (b, b-1)) 10
gr[10,9,8,7,6,5,4,3,2,1]
gr</pre>
unfoldr :: (b -> Maybe (a, b)) -> b -> [a]

-- | <a>take</a> <tt>n</tt>, applied to a list <tt>xs</tt>, returns the
grprefix of <tt>xs</tt> of length <tt>n</tt>, or <tt>xs</tt> itself if
gr<tt>n &gt; <a>length</a> xs</tt>:
gr
gr<pre>
grtake 5 "Hello World!" == "Hello"
grtake 3 [1,2,3,4,5] == [1,2,3]
grtake 3 [1,2] == [1,2]
grtake 3 [] == []
grtake (-1) [1,2] == []
grtake 0 [1,2] == []
gr</pre>
gr
grIt is an instance of the more general <a>genericTake</a>, in which
gr<tt>n</tt> may be of any integral type.
take :: Int -> [a] -> [a]

-- | <a>drop</a> <tt>n xs</tt> returns the suffix of <tt>xs</tt> after the
grfirst <tt>n</tt> elements, or <tt>[]</tt> if <tt>n &gt; <a>length</a>
grxs</tt>:
gr
gr<pre>
grdrop 6 "Hello World!" == "World!"
grdrop 3 [1,2,3,4,5] == [4,5]
grdrop 3 [1,2] == []
grdrop 3 [] == []
grdrop (-1) [1,2] == [1,2]
grdrop 0 [1,2] == [1,2]
gr</pre>
gr
grIt is an instance of the more general <a>genericDrop</a>, in which
gr<tt>n</tt> may be of any integral type.
drop :: Int -> [a] -> [a]

-- | <a>splitAt</a> <tt>n xs</tt> returns a tuple where first element is
gr<tt>xs</tt> prefix of length <tt>n</tt> and second element is the
grremainder of the list:
gr
gr<pre>
grsplitAt 6 "Hello World!" == ("Hello ","World!")
grsplitAt 3 [1,2,3,4,5] == ([1,2,3],[4,5])
grsplitAt 1 [1,2,3] == ([1],[2,3])
grsplitAt 3 [1,2,3] == ([1,2,3],[])
grsplitAt 4 [1,2,3] == ([1,2,3],[])
grsplitAt 0 [1,2,3] == ([],[1,2,3])
grsplitAt (-1) [1,2,3] == ([],[1,2,3])
gr</pre>
gr
grIt is equivalent to <tt>(<a>take</a> n xs, <a>drop</a> n xs)</tt> when
gr<tt>n</tt> is not <tt>_|_</tt> (<tt>splitAt _|_ xs = _|_</tt>).
gr<a>splitAt</a> is an instance of the more general
gr<a>genericSplitAt</a>, in which <tt>n</tt> may be of any integral
grtype.
splitAt :: Int -> [a] -> ([a], [a])

-- | <a>takeWhile</a>, applied to a predicate <tt>p</tt> and a list
gr<tt>xs</tt>, returns the longest prefix (possibly empty) of
gr<tt>xs</tt> of elements that satisfy <tt>p</tt>:
gr
gr<pre>
grtakeWhile (&lt; 3) [1,2,3,4,1,2,3,4] == [1,2]
grtakeWhile (&lt; 9) [1,2,3] == [1,2,3]
grtakeWhile (&lt; 0) [1,2,3] == []
gr</pre>
takeWhile :: (a -> Bool) -> [a] -> [a]

-- | <a>dropWhile</a> <tt>p xs</tt> returns the suffix remaining after
gr<a>takeWhile</a> <tt>p xs</tt>:
gr
gr<pre>
grdropWhile (&lt; 3) [1,2,3,4,5,1,2,3] == [3,4,5,1,2,3]
grdropWhile (&lt; 9) [1,2,3] == []
grdropWhile (&lt; 0) [1,2,3] == [1,2,3]
gr</pre>
dropWhile :: (a -> Bool) -> [a] -> [a]

-- | The <a>dropWhileEnd</a> function drops the largest suffix of a list in
grwhich the given predicate holds for all elements. For example:
gr
gr<pre>
gr&gt;&gt;&gt; dropWhileEnd isSpace "foo\n"
gr"foo"
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; dropWhileEnd isSpace "foo bar"
gr"foo bar"
gr</pre>
gr
gr<pre>
grdropWhileEnd isSpace ("foo\n" ++ undefined) == "foo" ++ undefined
gr</pre>
dropWhileEnd :: (a -> Bool) -> [a] -> [a]

-- | <a>span</a>, applied to a predicate <tt>p</tt> and a list <tt>xs</tt>,
grreturns a tuple where first element is longest prefix (possibly empty)
grof <tt>xs</tt> of elements that satisfy <tt>p</tt> and second element
gris the remainder of the list:
gr
gr<pre>
grspan (&lt; 3) [1,2,3,4,1,2,3,4] == ([1,2],[3,4,1,2,3,4])
grspan (&lt; 9) [1,2,3] == ([1,2,3],[])
grspan (&lt; 0) [1,2,3] == ([],[1,2,3])
gr</pre>
gr
gr<a>span</a> <tt>p xs</tt> is equivalent to <tt>(<a>takeWhile</a> p xs,
gr<a>dropWhile</a> p xs)</tt>
span :: (a -> Bool) -> [a] -> ([a], [a])

-- | <a>break</a>, applied to a predicate <tt>p</tt> and a list
gr<tt>xs</tt>, returns a tuple where first element is longest prefix
gr(possibly empty) of <tt>xs</tt> of elements that <i>do not satisfy</i>
gr<tt>p</tt> and second element is the remainder of the list:
gr
gr<pre>
grbreak (&gt; 3) [1,2,3,4,1,2,3,4] == ([1,2,3],[4,1,2,3,4])
grbreak (&lt; 9) [1,2,3] == ([],[1,2,3])
grbreak (&gt; 9) [1,2,3] == ([1,2,3],[])
gr</pre>
gr
gr<a>break</a> <tt>p</tt> is equivalent to <tt><a>span</a> (<a>not</a> .
grp)</tt>.
break :: (a -> Bool) -> [a] -> ([a], [a])

-- | The <a>stripPrefix</a> function drops the given prefix from a list. It
grreturns <a>Nothing</a> if the list did not start with the prefix
grgiven, or <a>Just</a> the list after the prefix, if it does.
gr
gr<pre>
gr&gt;&gt;&gt; stripPrefix "foo" "foobar"
grJust "bar"
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; stripPrefix "foo" "foo"
grJust ""
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; stripPrefix "foo" "barfoo"
grNothing
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; stripPrefix "foo" "barfoobaz"
grNothing
gr</pre>
stripPrefix :: Eq a => [a] -> [a] -> Maybe [a]

-- | The <a>group</a> function takes a list and returns a list of lists
grsuch that the concatenation of the result is equal to the argument.
grMoreover, each sublist in the result contains only equal elements. For
grexample,
gr
gr<pre>
gr&gt;&gt;&gt; group "Mississippi"
gr["M","i","ss","i","ss","i","pp","i"]
gr</pre>
gr
grIt is a special case of <a>groupBy</a>, which allows the programmer to
grsupply their own equality test.
group :: Eq a => [a] -> [[a]]

-- | The <a>inits</a> function returns all initial segments of the
grargument, shortest first. For example,
gr
gr<pre>
gr&gt;&gt;&gt; inits "abc"
gr["","a","ab","abc"]
gr</pre>
gr
grNote that <a>inits</a> has the following strictness property:
gr<tt>inits (xs ++ _|_) = inits xs ++ _|_</tt>
gr
grIn particular, <tt>inits _|_ = [] : _|_</tt>
inits :: [a] -> [[a]]

-- | The <a>tails</a> function returns all final segments of the argument,
grlongest first. For example,
gr
gr<pre>
gr&gt;&gt;&gt; tails "abc"
gr["abc","bc","c",""]
gr</pre>
gr
grNote that <a>tails</a> has the following strictness property:
gr<tt>tails _|_ = _|_ : _|_</tt>
tails :: [a] -> [[a]]

-- | The <a>isPrefixOf</a> function takes two lists and returns <a>True</a>
griff the first list is a prefix of the second.
gr
gr<pre>
gr&gt;&gt;&gt; "Hello" `isPrefixOf` "Hello World!"
grTrue
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; "Hello" `isPrefixOf` "Wello Horld!"
grFalse
gr</pre>
isPrefixOf :: (Eq a) => [a] -> [a] -> Bool

-- | The <a>isSuffixOf</a> function takes two lists and returns <a>True</a>
griff the first list is a suffix of the second. The second list must be
grfinite.
gr
gr<pre>
gr&gt;&gt;&gt; "ld!" `isSuffixOf` "Hello World!"
grTrue
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; "World" `isSuffixOf` "Hello World!"
grFalse
gr</pre>
isSuffixOf :: (Eq a) => [a] -> [a] -> Bool

-- | The <a>isInfixOf</a> function takes two lists and returns <a>True</a>
griff the first list is contained, wholly and intact, anywhere within
grthe second.
gr
gr<pre>
gr&gt;&gt;&gt; isInfixOf "Haskell" "I really like Haskell."
grTrue
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; isInfixOf "Ial" "I really like Haskell."
grFalse
gr</pre>
isInfixOf :: (Eq a) => [a] -> [a] -> Bool

-- | <a>elem</a> is the list membership predicate, usually written in infix
grform, e.g., <tt>x `elem` xs</tt>. For the result to be <a>False</a>,
grthe list must be finite; <a>True</a>, however, results from an element
grequal to <tt>x</tt> found at a finite index of a finite or infinite
grlist.
elem :: (Eq a) => a -> [a] -> Bool
infix 4 `elem`

-- | <a>notElem</a> is the negation of <a>elem</a>.
notElem :: (Eq a) => a -> [a] -> Bool
infix 4 `notElem`

-- | <a>lookup</a> <tt>key assocs</tt> looks up a key in an association
grlist.
lookup :: (Eq a) => a -> [(a, b)] -> Maybe b

-- | The <a>find</a> function takes a predicate and a list and returns the
grfirst element in the list matching the predicate, or <a>Nothing</a> if
grthere is no such element.
gr
gr<pre>
gr&gt;&gt;&gt; find (&gt; 4) [1..]
grJust 5
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; find (&lt; 0) [1..10]
grNothing
gr</pre>
find :: (a -> Bool) -> [a] -> Maybe a

-- | <a>filter</a>, applied to a predicate and a list, returns the list of
grthose elements that satisfy the predicate; i.e.,
gr
gr<pre>
grfilter p xs = [ x | x &lt;- xs, p x]
gr</pre>
filter :: (a -> Bool) -> [a] -> [a]

-- | The <a>partition</a> function takes a predicate a list and returns the
grpair of lists of elements which do and do not satisfy the predicate,
grrespectively; i.e.,
gr
gr<pre>
grpartition p xs == (filter p xs, filter (not . p) xs)
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; partition (`elem` "aeiou") "Hello World!"
gr("eoo","Hll Wrld!")
gr</pre>
partition :: (a -> Bool) -> [a] -> ([a], [a])

-- | List index (subscript) operator, starting from 0. It is an instance of
grthe more general <a>genericIndex</a>, which takes an index of any
grintegral type.
(!!) :: [a] -> Int -> a
infixl 9 !!

-- | The <a>elemIndex</a> function returns the index of the first element
grin the given list which is equal (by <a>==</a>) to the query element,
gror <a>Nothing</a> if there is no such element.
gr
gr<pre>
gr&gt;&gt;&gt; elemIndex 4 [0..]
grJust 4
gr</pre>
elemIndex :: Eq a => a -> [a] -> Maybe Int

-- | The <a>elemIndices</a> function extends <a>elemIndex</a>, by returning
grthe indices of all elements equal to the query element, in ascending
grorder.
gr
gr<pre>
gr&gt;&gt;&gt; elemIndices 'o' "Hello World"
gr[4,7]
gr</pre>
elemIndices :: Eq a => a -> [a] -> [Int]

-- | The <a>findIndex</a> function takes a predicate and a list and returns
grthe index of the first element in the list satisfying the predicate,
gror <a>Nothing</a> if there is no such element.
gr
gr<pre>
gr&gt;&gt;&gt; findIndex isSpace "Hello World!"
grJust 5
gr</pre>
findIndex :: (a -> Bool) -> [a] -> Maybe Int

-- | The <a>findIndices</a> function extends <a>findIndex</a>, by returning
grthe indices of all elements satisfying the predicate, in ascending
grorder.
gr
gr<pre>
gr&gt;&gt;&gt; findIndices (`elem` "aeiou") "Hello World!"
gr[1,4,7]
gr</pre>
findIndices :: (a -> Bool) -> [a] -> [Int]

-- | <a>zip</a> takes two lists and returns a list of corresponding pairs.
grIf one input list is short, excess elements of the longer list are
grdiscarded.
gr
gr<a>zip</a> is right-lazy:
gr
gr<pre>
grzip [] _|_ = []
gr</pre>
zip :: [a] -> [b] -> [(a, b)]

-- | <a>zip3</a> takes three lists and returns a list of triples, analogous
grto <a>zip</a>.
zip3 :: [a] -> [b] -> [c] -> [(a, b, c)]

-- | The <a>zip4</a> function takes four lists and returns a list of
grquadruples, analogous to <a>zip</a>.
zip4 :: [a] -> [b] -> [c] -> [d] -> [(a, b, c, d)]

-- | The <a>zip5</a> function takes five lists and returns a list of
grfive-tuples, analogous to <a>zip</a>.
zip5 :: [a] -> [b] -> [c] -> [d] -> [e] -> [(a, b, c, d, e)]

-- | The <a>zip6</a> function takes six lists and returns a list of
grsix-tuples, analogous to <a>zip</a>.
zip6 :: [a] -> [b] -> [c] -> [d] -> [e] -> [f] -> [(a, b, c, d, e, f)]

-- | The <a>zip7</a> function takes seven lists and returns a list of
grseven-tuples, analogous to <a>zip</a>.
zip7 :: [a] -> [b] -> [c] -> [d] -> [e] -> [f] -> [g] -> [(a, b, c, d, e, f, g)]

-- | <a>zipWith</a> generalises <a>zip</a> by zipping with the function
grgiven as the first argument, instead of a tupling function. For
grexample, <tt><a>zipWith</a> (+)</tt> is applied to two lists to
grproduce the list of corresponding sums.
gr
gr<a>zipWith</a> is right-lazy:
gr
gr<pre>
grzipWith f [] _|_ = []
gr</pre>
zipWith :: (a -> b -> c) -> [a] -> [b] -> [c]

-- | The <a>zipWith3</a> function takes a function which combines three
grelements, as well as three lists and returns a list of their
grpoint-wise combination, analogous to <a>zipWith</a>.
zipWith3 :: (a -> b -> c -> d) -> [a] -> [b] -> [c] -> [d]

-- | The <a>zipWith4</a> function takes a function which combines four
grelements, as well as four lists and returns a list of their point-wise
grcombination, analogous to <a>zipWith</a>.
zipWith4 :: (a -> b -> c -> d -> e) -> [a] -> [b] -> [c] -> [d] -> [e]

-- | The <a>zipWith5</a> function takes a function which combines five
grelements, as well as five lists and returns a list of their point-wise
grcombination, analogous to <a>zipWith</a>.
zipWith5 :: (a -> b -> c -> d -> e -> f) -> [a] -> [b] -> [c] -> [d] -> [e] -> [f]

-- | The <a>zipWith6</a> function takes a function which combines six
grelements, as well as six lists and returns a list of their point-wise
grcombination, analogous to <a>zipWith</a>.
zipWith6 :: (a -> b -> c -> d -> e -> f -> g) -> [a] -> [b] -> [c] -> [d] -> [e] -> [f] -> [g]

-- | The <a>zipWith7</a> function takes a function which combines seven
grelements, as well as seven lists and returns a list of their
grpoint-wise combination, analogous to <a>zipWith</a>.
zipWith7 :: (a -> b -> c -> d -> e -> f -> g -> h) -> [a] -> [b] -> [c] -> [d] -> [e] -> [f] -> [g] -> [h]

-- | <a>unzip</a> transforms a list of pairs into a list of first
grcomponents and a list of second components.
unzip :: [(a, b)] -> ([a], [b])

-- | The <a>unzip3</a> function takes a list of triples and returns three
grlists, analogous to <a>unzip</a>.
unzip3 :: [(a, b, c)] -> ([a], [b], [c])

-- | The <a>unzip4</a> function takes a list of quadruples and returns four
grlists, analogous to <a>unzip</a>.
unzip4 :: [(a, b, c, d)] -> ([a], [b], [c], [d])

-- | The <a>unzip5</a> function takes a list of five-tuples and returns
grfive lists, analogous to <a>unzip</a>.
unzip5 :: [(a, b, c, d, e)] -> ([a], [b], [c], [d], [e])

-- | The <a>unzip6</a> function takes a list of six-tuples and returns six
grlists, analogous to <a>unzip</a>.
unzip6 :: [(a, b, c, d, e, f)] -> ([a], [b], [c], [d], [e], [f])

-- | The <a>unzip7</a> function takes a list of seven-tuples and returns
grseven lists, analogous to <a>unzip</a>.
unzip7 :: [(a, b, c, d, e, f, g)] -> ([a], [b], [c], [d], [e], [f], [g])

-- | <a>lines</a> breaks a string up into a list of strings at newline
grcharacters. The resulting strings do not contain newlines.
gr
grNote that after splitting the string at newline characters, the last
grpart of the string is considered a line even if it doesn't end with a
grnewline. For example,
gr
gr<pre>
gr&gt;&gt;&gt; lines ""
gr[]
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; lines "\n"
gr[""]
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; lines "one"
gr["one"]
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; lines "one\n"
gr["one"]
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; lines "one\n\n"
gr["one",""]
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; lines "one\ntwo"
gr["one","two"]
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; lines "one\ntwo\n"
gr["one","two"]
gr</pre>
gr
grThus <tt><a>lines</a> s</tt> contains at least as many elements as
grnewlines in <tt>s</tt>.
lines :: String -> [String]

-- | <a>words</a> breaks a string up into a list of words, which were
grdelimited by white space.
gr
gr<pre>
gr&gt;&gt;&gt; words "Lorem ipsum\ndolor"
gr["Lorem","ipsum","dolor"]
gr</pre>
words :: String -> [String]

-- | <a>unlines</a> is an inverse operation to <a>lines</a>. It joins
grlines, after appending a terminating newline to each.
gr
gr<pre>
gr&gt;&gt;&gt; unlines ["Hello", "World", "!"]
gr"Hello\nWorld\n!\n"
gr</pre>
unlines :: [String] -> String

-- | <a>unwords</a> is an inverse operation to <a>words</a>. It joins words
grwith separating spaces.
gr
gr<pre>
gr&gt;&gt;&gt; unwords ["Lorem", "ipsum", "dolor"]
gr"Lorem ipsum dolor"
gr</pre>
unwords :: [String] -> String

-- | <i>O(n^2)</i>. The <a>nub</a> function removes duplicate elements from
gra list. In particular, it keeps only the first occurrence of each
grelement. (The name <a>nub</a> means `essence'.) It is a special case
grof <a>nubBy</a>, which allows the programmer to supply their own
grequality test.
gr
gr<pre>
gr&gt;&gt;&gt; nub [1,2,3,4,3,2,1,2,4,3,5]
gr[1,2,3,4,5]
gr</pre>
nub :: (Eq a) => [a] -> [a]

-- | <a>delete</a> <tt>x</tt> removes the first occurrence of <tt>x</tt>
grfrom its list argument. For example,
gr
gr<pre>
gr&gt;&gt;&gt; delete 'a' "banana"
gr"bnana"
gr</pre>
gr
grIt is a special case of <a>deleteBy</a>, which allows the programmer
grto supply their own equality test.
delete :: (Eq a) => a -> [a] -> [a]

-- | The <a>\\</a> function is list difference (non-associative). In the
grresult of <tt>xs</tt> <a>\\</a> <tt>ys</tt>, the first occurrence of
greach element of <tt>ys</tt> in turn (if any) has been removed from
gr<tt>xs</tt>. Thus
gr
gr<pre>
gr(xs ++ ys) \\ xs == ys.
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; "Hello World!" \\ "ell W"
gr"Hoorld!"
gr</pre>
gr
grIt is a special case of <a>deleteFirstsBy</a>, which allows the
grprogrammer to supply their own equality test.
(\\) :: (Eq a) => [a] -> [a] -> [a]
infix 5 \\

-- | The <a>union</a> function returns the list union of the two lists. For
grexample,
gr
gr<pre>
gr&gt;&gt;&gt; "dog" `union` "cow"
gr"dogcw"
gr</pre>
gr
grDuplicates, and elements of the first list, are removed from the the
grsecond list, but if the first list contains duplicates, so will the
grresult. It is a special case of <a>unionBy</a>, which allows the
grprogrammer to supply their own equality test.
union :: (Eq a) => [a] -> [a] -> [a]

-- | The <a>intersect</a> function takes the list intersection of two
grlists. For example,
gr
gr<pre>
gr&gt;&gt;&gt; [1,2,3,4] `intersect` [2,4,6,8]
gr[2,4]
gr</pre>
gr
grIf the first list contains duplicates, so will the result.
gr
gr<pre>
gr&gt;&gt;&gt; [1,2,2,3,4] `intersect` [6,4,4,2]
gr[2,2,4]
gr</pre>
gr
grIt is a special case of <a>intersectBy</a>, which allows the
grprogrammer to supply their own equality test. If the element is found
grin both the first and the second list, the element from the first list
grwill be used.
intersect :: (Eq a) => [a] -> [a] -> [a]

-- | The <a>sort</a> function implements a stable sorting algorithm. It is
gra special case of <a>sortBy</a>, which allows the programmer to supply
grtheir own comparison function.
gr
grElements are arranged from from lowest to highest, keeping duplicates
grin the order they appeared in the input.
gr
gr<pre>
gr&gt;&gt;&gt; sort [1,6,4,3,2,5]
gr[1,2,3,4,5,6]
gr</pre>
sort :: (Ord a) => [a] -> [a]

-- | Sort a list by comparing the results of a key function applied to each
grelement. <tt>sortOn f</tt> is equivalent to <tt>sortBy (comparing
grf)</tt>, but has the performance advantage of only evaluating
gr<tt>f</tt> once for each element in the input list. This is called the
grdecorate-sort-undecorate paradigm, or Schwartzian transform.
gr
grElements are arranged from from lowest to highest, keeping duplicates
grin the order they appeared in the input.
gr
gr<pre>
gr&gt;&gt;&gt; sortOn fst [(2, "world"), (4, "!"), (1, "Hello")]
gr[(1,"Hello"),(2,"world"),(4,"!")]
gr</pre>
sortOn :: Ord b => (a -> b) -> [a] -> [a]

-- | The <a>insert</a> function takes an element and a list and inserts the
grelement into the list at the first position where it is less than or
grequal to the next element. In particular, if the list is sorted before
grthe call, the result will also be sorted. It is a special case of
gr<a>insertBy</a>, which allows the programmer to supply their own
grcomparison function.
gr
gr<pre>
gr&gt;&gt;&gt; insert 4 [1,2,3,5,6,7]
gr[1,2,3,4,5,6,7]
gr</pre>
insert :: Ord a => a -> [a] -> [a]

-- | The <a>nubBy</a> function behaves just like <a>nub</a>, except it uses
gra user-supplied equality predicate instead of the overloaded <a>==</a>
grfunction.
gr
gr<pre>
gr&gt;&gt;&gt; nubBy (\x y -&gt; mod x 3 == mod y 3) [1,2,4,5,6]
gr[1,2,6]
gr</pre>
nubBy :: (a -> a -> Bool) -> [a] -> [a]

-- | The <a>deleteBy</a> function behaves like <a>delete</a>, but takes a
gruser-supplied equality predicate.
gr
gr<pre>
gr&gt;&gt;&gt; deleteBy (&lt;=) 4 [1..10]
gr[1,2,3,5,6,7,8,9,10]
gr</pre>
deleteBy :: (a -> a -> Bool) -> a -> [a] -> [a]

-- | The <a>deleteFirstsBy</a> function takes a predicate and two lists and
grreturns the first list with the first occurrence of each element of
grthe second list removed.
deleteFirstsBy :: (a -> a -> Bool) -> [a] -> [a] -> [a]

-- | The <a>unionBy</a> function is the non-overloaded version of
gr<a>union</a>.
unionBy :: (a -> a -> Bool) -> [a] -> [a] -> [a]

-- | The <a>intersectBy</a> function is the non-overloaded version of
gr<a>intersect</a>.
intersectBy :: (a -> a -> Bool) -> [a] -> [a] -> [a]

-- | The <a>groupBy</a> function is the non-overloaded version of
gr<a>group</a>.
groupBy :: (a -> a -> Bool) -> [a] -> [[a]]

-- | The <a>sortBy</a> function is the non-overloaded version of
gr<a>sort</a>.
gr
gr<pre>
gr&gt;&gt;&gt; sortBy (\(a,_) (b,_) -&gt; compare a b) [(2, "world"), (4, "!"), (1, "Hello")]
gr[(1,"Hello"),(2,"world"),(4,"!")]
gr</pre>
sortBy :: (a -> a -> Ordering) -> [a] -> [a]

-- | The non-overloaded version of <a>insert</a>.
insertBy :: (a -> a -> Ordering) -> a -> [a] -> [a]

-- | The <a>maximumBy</a> function takes a comparison function and a list
grand returns the greatest element of the list by the comparison
grfunction. The list must be finite and non-empty.
gr
grWe can use this to find the longest entry of a list:
gr
gr<pre>
gr&gt;&gt;&gt; maximumBy (\x y -&gt; compare (length x) (length y)) ["Hello", "World", "!", "Longest", "bar"]
gr"Longest"
gr</pre>
maximumBy :: (a -> a -> Ordering) -> [a] -> a

-- | The <a>minimumBy</a> function takes a comparison function and a list
grand returns the least element of the list by the comparison function.
grThe list must be finite and non-empty.
gr
grWe can use this to find the shortest entry of a list:
gr
gr<pre>
gr&gt;&gt;&gt; minimumBy (\x y -&gt; compare (length x) (length y)) ["Hello", "World", "!", "Longest", "bar"]
gr"!"
gr</pre>
minimumBy :: (a -> a -> Ordering) -> [a] -> a

-- | The <a>genericLength</a> function is an overloaded version of
gr<a>length</a>. In particular, instead of returning an <a>Int</a>, it
grreturns any type which is an instance of <a>Num</a>. It is, however,
grless efficient than <a>length</a>.
genericLength :: (Num i) => [a] -> i

-- | The <a>genericTake</a> function is an overloaded version of
gr<a>take</a>, which accepts any <a>Integral</a> value as the number of
grelements to take.
genericTake :: (Integral i) => i -> [a] -> [a]

-- | The <a>genericDrop</a> function is an overloaded version of
gr<a>drop</a>, which accepts any <a>Integral</a> value as the number of
grelements to drop.
genericDrop :: (Integral i) => i -> [a] -> [a]

-- | The <a>genericSplitAt</a> function is an overloaded version of
gr<a>splitAt</a>, which accepts any <a>Integral</a> value as the
grposition at which to split.
genericSplitAt :: (Integral i) => i -> [a] -> ([a], [a])

-- | The <a>genericIndex</a> function is an overloaded version of
gr<a>!!</a>, which accepts any <a>Integral</a> value as the index.
genericIndex :: (Integral i) => [a] -> i -> a

-- | The <a>genericReplicate</a> function is an overloaded version of
gr<a>replicate</a>, which accepts any <a>Integral</a> value as the
grnumber of repetitions to make.
genericReplicate :: (Integral i) => i -> a -> [a]


-- | Converting values to readable strings: the <a>Show</a> class and
grassociated functions.
module Text.Show

-- | The <tt>shows</tt> functions return a function that prepends the
groutput <a>String</a> to an existing <a>String</a>. This allows
grconstant-time concatenation of results using function composition.
type ShowS = String -> String

-- | Conversion of values to readable <a>String</a>s.
gr
grDerived instances of <a>Show</a> have the following properties, which
grare compatible with derived instances of <a>Read</a>:
gr
gr<ul>
gr<li>The result of <a>show</a> is a syntactically correct Haskell
grexpression containing only constants, given the fixity declarations in
grforce at the point where the type is declared. It contains only the
grconstructor names defined in the data type, parentheses, and spaces.
grWhen labelled constructor fields are used, braces, commas, field
grnames, and equal signs are also used.</li>
gr<li>If the constructor is defined to be an infix operator, then
gr<a>showsPrec</a> will produce infix applications of the
grconstructor.</li>
gr<li>the representation will be enclosed in parentheses if the
grprecedence of the top-level constructor in <tt>x</tt> is less than
gr<tt>d</tt> (associativity is ignored). Thus, if <tt>d</tt> is
gr<tt>0</tt> then the result is never surrounded in parentheses; if
gr<tt>d</tt> is <tt>11</tt> it is always surrounded in parentheses,
grunless it is an atomic expression.</li>
gr<li>If the constructor is defined using record syntax, then
gr<a>show</a> will produce the record-syntax form, with the fields given
grin the same order as the original declaration.</li>
gr</ul>
gr
grFor example, given the declarations
gr
gr<pre>
grinfixr 5 :^:
grdata Tree a =  Leaf a  |  Tree a :^: Tree a
gr</pre>
gr
grthe derived instance of <a>Show</a> is equivalent to
gr
gr<pre>
grinstance (Show a) =&gt; Show (Tree a) where
gr
gr       showsPrec d (Leaf m) = showParen (d &gt; app_prec) $
gr            showString "Leaf " . showsPrec (app_prec+1) m
gr         where app_prec = 10
gr
gr       showsPrec d (u :^: v) = showParen (d &gt; up_prec) $
gr            showsPrec (up_prec+1) u .
gr            showString " :^: "      .
gr            showsPrec (up_prec+1) v
gr         where up_prec = 5
gr</pre>
gr
grNote that right-associativity of <tt>:^:</tt> is ignored. For example,
gr
gr<ul>
gr<li><tt><a>show</a> (Leaf 1 :^: Leaf 2 :^: Leaf 3)</tt> produces the
grstring <tt>"Leaf 1 :^: (Leaf 2 :^: Leaf 3)"</tt>.</li>
gr</ul>
class Show a

-- | Convert a value to a readable <a>String</a>.
gr
gr<a>showsPrec</a> should satisfy the law
gr
gr<pre>
grshowsPrec d x r ++ s  ==  showsPrec d x (r ++ s)
gr</pre>
gr
grDerived instances of <a>Read</a> and <a>Show</a> satisfy the
grfollowing:
gr
gr<ul>
gr<li><tt>(x,"")</tt> is an element of <tt>(<a>readsPrec</a> d
gr(<a>showsPrec</a> d x ""))</tt>.</li>
gr</ul>
gr
grThat is, <a>readsPrec</a> parses the string produced by
gr<a>showsPrec</a>, and delivers the value that <a>showsPrec</a> started
grwith.
showsPrec :: Show a => Int -> a -> ShowS

-- | A specialised variant of <a>showsPrec</a>, using precedence context
grzero, and returning an ordinary <a>String</a>.
show :: Show a => a -> String

-- | The method <a>showList</a> is provided to allow the programmer to give
gra specialised way of showing lists of values. For example, this is
grused by the predefined <a>Show</a> instance of the <a>Char</a> type,
grwhere values of type <a>String</a> should be shown in double quotes,
grrather than between square brackets.
showList :: Show a => [a] -> ShowS

-- | equivalent to <a>showsPrec</a> with a precedence of 0.
shows :: (Show a) => a -> ShowS

-- | utility function converting a <a>Char</a> to a show function that
grsimply prepends the character unchanged.
showChar :: Char -> ShowS

-- | utility function converting a <a>String</a> to a show function that
grsimply prepends the string unchanged.
showString :: String -> ShowS

-- | utility function that surrounds the inner show function with
grparentheses when the <a>Bool</a> parameter is <a>True</a>.
showParen :: Bool -> ShowS -> ShowS

-- | Show a list (using square brackets and commas), given a function for
grshowing elements.
showListWith :: (a -> ShowS) -> [a] -> ShowS


-- | The highly unsafe primitive <a>unsafeCoerce</a> converts a value from
grany type to any other type. Needless to say, if you use this function,
grit is your responsibility to ensure that the old and new types have
gridentical internal representations, in order to prevent runtime
grcorruption.
gr
grThe types for which <a>unsafeCoerce</a> is representation-safe may
grdiffer from compiler to compiler (and version to version).
gr
gr<ul>
gr<li>Documentation for correct usage in GHC will be found under
gr<a>unsafeCoerce#</a> in GHC.Base (around which <a>unsafeCoerce</a> is
grjust a trivial wrapper).</li>
gr<li>In nhc98, the only representation-safe coercions are between Enum
grtypes with the same range (e.g. Int, Int32, Char, Word32), or between
gra newtype and the type that it wraps.</li>
gr</ul>
module Unsafe.Coerce
unsafeCoerce :: a -> b


-- | This module is an internal GHC module. It declares the constants used
grin the implementation of type-level natural numbers. The programmer
grinterface for working with type-level naturals should be defined in a
grseparate library.
module GHC.TypeNats

-- | (Kind) This is the kind of type-level natural numbers.
data Nat

-- | This class gives the integer associated with a type-level natural.
grThere are instances of the class for every concrete literal: 0, 1, 2,
gretc.
class KnownNat (n :: Nat)

natVal :: forall n proxy. KnownNat n => proxy n -> Natural

natVal' :: forall n. KnownNat n => Proxy# n -> Natural

-- | This type represents unknown type-level natural numbers.
data SomeNat
SomeNat :: (Proxy n) -> SomeNat

-- | Convert an integer into an unknown type-level natural.
someNatVal :: Natural -> SomeNat

-- | We either get evidence that this function was instantiated with the
grsame type-level numbers, or <a>Nothing</a>.
sameNat :: (KnownNat a, KnownNat b) => Proxy a -> Proxy b -> Maybe (a :~: b)

-- | Comparison of type-level naturals, as a constraint.
type x <= y = (x <=? y) ~  'True

-- | Comparison of type-level naturals, as a function. NOTE: The
grfunctionality for this function should be subsumed by <a>CmpNat</a>,
grso this might go away in the future. Please let us know, if you
grencounter discrepancies between the two.

-- | Addition of type-level naturals.

-- | Multiplication of type-level naturals.

-- | Exponentiation of type-level naturals.

-- | Subtraction of type-level naturals.

-- | Comparison of type-level naturals, as a function.

-- | Division (round down) of natural numbers. <tt>Div x 0</tt> is
grundefined (i.e., it cannot be reduced).

-- | Modulus of natural numbers. <tt>Mod x 0</tt> is undefined (i.e., it
grcannot be reduced).

-- | Log base 2 (round down) of natural numbers. <tt>Log 0</tt> is
grundefined (i.e., it cannot be reduced).
instance GHC.Classes.Eq GHC.TypeNats.SomeNat
instance GHC.Classes.Ord GHC.TypeNats.SomeNat
instance GHC.Show.Show GHC.TypeNats.SomeNat
instance GHC.Read.Read GHC.TypeNats.SomeNat


-- | This module is an internal GHC module. It declares the constants used
grin the implementation of type-level natural numbers. The programmer
grinterface for working with type-level naturals should be defined in a
grseparate library.
module GHC.TypeLits

-- | (Kind) This is the kind of type-level natural numbers.
data Nat

-- | (Kind) This is the kind of type-level symbols. Declared here because
grclass IP needs it
data Symbol

-- | This class gives the integer associated with a type-level natural.
grThere are instances of the class for every concrete literal: 0, 1, 2,
gretc.
class KnownNat (n :: Nat)

natVal :: forall n proxy. KnownNat n => proxy n -> Integer

natVal' :: forall n. KnownNat n => Proxy# n -> Integer

-- | This class gives the string associated with a type-level symbol. There
grare instances of the class for every concrete literal: "hello", etc.
class KnownSymbol (n :: Symbol)

symbolVal :: forall n proxy. KnownSymbol n => proxy n -> String

symbolVal' :: forall n. KnownSymbol n => Proxy# n -> String

-- | This type represents unknown type-level natural numbers.
data SomeNat
SomeNat :: (Proxy n) -> SomeNat

-- | This type represents unknown type-level symbols.
data SomeSymbol

SomeSymbol :: (Proxy n) -> SomeSymbol

-- | Convert an integer into an unknown type-level natural.
someNatVal :: Integer -> Maybe SomeNat

-- | Convert a string into an unknown type-level symbol.
someSymbolVal :: String -> SomeSymbol

-- | We either get evidence that this function was instantiated with the
grsame type-level numbers, or <a>Nothing</a>.
sameNat :: (KnownNat a, KnownNat b) => Proxy a -> Proxy b -> Maybe (a :~: b)

-- | We either get evidence that this function was instantiated with the
grsame type-level symbols, or <a>Nothing</a>.
sameSymbol :: (KnownSymbol a, KnownSymbol b) => Proxy a -> Proxy b -> Maybe (a :~: b)

-- | Comparison of type-level naturals, as a constraint.
type x <= y = (x <=? y) ~  'True

-- | Comparison of type-level naturals, as a function. NOTE: The
grfunctionality for this function should be subsumed by <a>CmpNat</a>,
grso this might go away in the future. Please let us know, if you
grencounter discrepancies between the two.

-- | Addition of type-level naturals.

-- | Multiplication of type-level naturals.

-- | Exponentiation of type-level naturals.

-- | Subtraction of type-level naturals.

-- | Division (round down) of natural numbers. <tt>Div x 0</tt> is
grundefined (i.e., it cannot be reduced).

-- | Modulus of natural numbers. <tt>Mod x 0</tt> is undefined (i.e., it
grcannot be reduced).

-- | Log base 2 (round down) of natural numbers. <tt>Log 0</tt> is
grundefined (i.e., it cannot be reduced).

-- | Concatenation of type-level symbols.

-- | Comparison of type-level naturals, as a function.

-- | Comparison of type-level symbols, as a function.

-- | The type-level equivalent of <tt>error</tt>.
gr
grThe polymorphic kind of this type allows it to be used in several
grsettings. For instance, it can be used as a constraint, e.g. to
grprovide a better error message for a non-existent instance,
gr
gr<pre>
gr-- in a context
grinstance TypeError (Text "Cannot <a>Show</a> functions." :$$:
gr                    Text "Perhaps there is a missing argument?")
gr      =&gt; Show (a -&gt; b) where
gr    showsPrec = error "unreachable"
gr</pre>
gr
grIt can also be placed on the right-hand side of a type-level function
grto provide an error for an invalid case,
gr
gr<pre>
grtype family ByteSize x where
gr   ByteSize Word16   = 2
gr   ByteSize Word8    = 1
gr   ByteSize a        = TypeError (Text "The type " :&lt;&gt;: ShowType a :&lt;&gt;:
gr                                  Text " is not exportable.")
gr</pre>

-- | A description of a custom type error.
data ErrorMessage

-- | Show the text as is.
Text :: Symbol -> ErrorMessage

-- | Pretty print the type. <tt>ShowType :: k -&gt; ErrorMessage</tt>
ShowType :: t -> ErrorMessage

-- | Put two pieces of error message next to each other.
(:<>:) :: ErrorMessage -> ErrorMessage -> ErrorMessage

-- | Stack two pieces of error message on top of each other.
(:$$:) :: ErrorMessage -> ErrorMessage -> ErrorMessage
instance GHC.Classes.Eq GHC.TypeLits.SomeSymbol
instance GHC.Classes.Ord GHC.TypeLits.SomeSymbol
instance GHC.Show.Show GHC.TypeLits.SomeSymbol
instance GHC.Read.Read GHC.TypeLits.SomeSymbol


-- | If you're using <tt>GHC.Generics</tt>, you should consider using the
gr<a>http://hackage.haskell.org/package/generic-deriving</a> package,
grwhich contains many useful generic functions.
module GHC.Generics

-- | Void: used for datatypes without constructors
data V1 (p :: k)

-- | Unit: used for constructors without arguments
data U1 (p :: k)
U1 :: U1

-- | Used for marking occurrences of the parameter
newtype Par1 p
Par1 :: p -> Par1 p
[unPar1] :: Par1 p -> p

-- | Recursive calls of kind <tt>* -&gt; *</tt> (or kind <tt>k -&gt;
gr*</tt>, when <tt>PolyKinds</tt> is enabled)
newtype Rec1 (f :: k -> *) (p :: k)
Rec1 :: f p -> Rec1
[unRec1] :: Rec1 -> f p

-- | Constants, additional parameters and recursion of kind <tt>*</tt>
newtype K1 (i :: *) c (p :: k)
K1 :: c -> K1 c
[unK1] :: K1 c -> c

-- | Meta-information (constructor names, etc.)
newtype M1 (i :: *) (c :: Meta) (f :: k -> *) (p :: k)
M1 :: f p -> M1
[unM1] :: M1 -> f p

-- | Sums: encode choice between constructors
data (:+:) (f :: k -> *) (g :: k -> *) (p :: k)
L1 :: (f p) -> (:+:)
R1 :: (g p) -> (:+:)

-- | Products: encode multiple arguments to constructors
data (:*:) (f :: k -> *) (g :: k -> *) (p :: k)
(:*:) :: f p -> g p -> (:*:)

-- | Composition of functors
newtype (:.:) (f :: k2 -> *) (g :: k1 -> k2) (p :: k1)
Comp1 :: f (g p) -> (:.:)
[unComp1] :: (:.:) -> f (g p)

-- | Constants of unlifted kinds

-- | Type synonym for <tt><a>URec</a> <a>Addr#</a></tt>
type UAddr = URec (Ptr ())

-- | Type synonym for <tt><a>URec</a> <a>Char#</a></tt>
type UChar = URec Char

-- | Type synonym for <tt><a>URec</a> <a>Double#</a></tt>
type UDouble = URec Double

-- | Type synonym for <tt><a>URec</a> <a>Float#</a></tt>
type UFloat = URec Float

-- | Type synonym for <tt><a>URec</a> <a>Int#</a></tt>
type UInt = URec Int

-- | Type synonym for <tt><a>URec</a> <a>Word#</a></tt>
type UWord = URec Word

-- | Type synonym for encoding recursion (of kind <tt>*</tt>)
type Rec0 = K1 R

-- | Tag for K1: recursion (of kind <tt>*</tt>)
data R

-- | Type synonym for encoding meta-information for datatypes
type D1 = M1 D

-- | Type synonym for encoding meta-information for constructors
type C1 = M1 C

-- | Type synonym for encoding meta-information for record selectors
type S1 = M1 S

-- | Tag for M1: datatype
data D

-- | Tag for M1: constructor
data C

-- | Tag for M1: record selector
data S

-- | Class for datatypes that represent datatypes
class Datatype d

-- | The name of the datatype (unqualified)
datatypeName :: Datatype d => t d (f :: k -> *) (a :: k) -> [Char]

-- | The fully-qualified name of the module where the type is declared
moduleName :: Datatype d => t d (f :: k -> *) (a :: k) -> [Char]

-- | The package name of the module where the type is declared
packageName :: Datatype d => t d (f :: k -> *) (a :: k) -> [Char]

-- | Marks if the datatype is actually a newtype
isNewtype :: Datatype d => t d (f :: k -> *) (a :: k) -> Bool

-- | Class for datatypes that represent data constructors
class Constructor c

-- | The name of the constructor
conName :: Constructor c => t c (f :: k -> *) (a :: k) -> [Char]

-- | The fixity of the constructor
conFixity :: Constructor c => t c (f :: k -> *) (a :: k) -> Fixity

-- | Marks if this constructor is a record
conIsRecord :: Constructor c => t c (f :: k -> *) (a :: k) -> Bool

-- | Class for datatypes that represent records
class Selector s

-- | The name of the selector
selName :: Selector s => t s (f :: k -> *) (a :: k) -> [Char]

-- | The selector's unpackedness annotation (if any)
selSourceUnpackedness :: Selector s => t s (f :: k -> *) (a :: k) -> SourceUnpackedness

-- | The selector's strictness annotation (if any)
selSourceStrictness :: Selector s => t s (f :: k -> *) (a :: k) -> SourceStrictness

-- | The strictness that the compiler inferred for the selector
selDecidedStrictness :: Selector s => t s (f :: k -> *) (a :: k) -> DecidedStrictness

-- | Datatype to represent the fixity of a constructor. An infix |
grdeclaration directly corresponds to an application of <a>Infix</a>.
data Fixity
Prefix :: Fixity
Infix :: Associativity -> Int -> Fixity

-- | This variant of <a>Fixity</a> appears at the type level.
data FixityI
PrefixI :: FixityI
InfixI :: Associativity -> Nat -> FixityI

-- | Datatype to represent the associativity of a constructor
data Associativity
LeftAssociative :: Associativity
RightAssociative :: Associativity
NotAssociative :: Associativity

-- | Get the precedence of a fixity value.
prec :: Fixity -> Int

-- | The unpackedness of a field as the user wrote it in the source code.
grFor example, in the following data type:
gr
gr<pre>
grdata E = ExampleConstructor     Int
gr           {-# NOUNPACK #-} Int
gr           {-#   UNPACK #-} Int
gr</pre>
gr
grThe fields of <tt>ExampleConstructor</tt> have
gr<a>NoSourceUnpackedness</a>, <a>SourceNoUnpack</a>, and
gr<a>SourceUnpack</a>, respectively.
data SourceUnpackedness
NoSourceUnpackedness :: SourceUnpackedness
SourceNoUnpack :: SourceUnpackedness
SourceUnpack :: SourceUnpackedness

-- | The strictness of a field as the user wrote it in the source code. For
grexample, in the following data type:
gr
gr<pre>
grdata E = ExampleConstructor Int ~Int !Int
gr</pre>
gr
grThe fields of <tt>ExampleConstructor</tt> have
gr<a>NoSourceStrictness</a>, <a>SourceLazy</a>, and <a>SourceStrict</a>,
grrespectively.
data SourceStrictness
NoSourceStrictness :: SourceStrictness
SourceLazy :: SourceStrictness
SourceStrict :: SourceStrictness

-- | The strictness that GHC infers for a field during compilation. Whereas
grthere are nine different combinations of <a>SourceUnpackedness</a> and
gr<a>SourceStrictness</a>, the strictness that GHC decides will
grultimately be one of lazy, strict, or unpacked. What GHC decides is
graffected both by what the user writes in the source code and by GHC
grflags. As an example, consider this data type:
gr
gr<pre>
grdata E = ExampleConstructor {-# UNPACK #-} !Int !Int Int
gr</pre>
gr
gr<ul>
gr<li>If compiled without optimization or other language extensions,
grthen the fields of <tt>ExampleConstructor</tt> will have
gr<a>DecidedStrict</a>, <a>DecidedStrict</a>, and <a>DecidedLazy</a>,
grrespectively.</li>
gr<li>If compiled with <tt>-XStrictData</tt> enabled, then the fields
grwill have <a>DecidedStrict</a>, <a>DecidedStrict</a>, and
gr<a>DecidedStrict</a>, respectively.</li>
gr<li>If compiled with <tt>-O2</tt> enabled, then the fields will have
gr<a>DecidedUnpack</a>, <a>DecidedStrict</a>, and <a>DecidedLazy</a>,
grrespectively.</li>
gr</ul>
data DecidedStrictness
DecidedLazy :: DecidedStrictness
DecidedStrict :: DecidedStrictness
DecidedUnpack :: DecidedStrictness

-- | Datatype to represent metadata associated with a datatype
gr(<tt>MetaData</tt>), constructor (<tt>MetaCons</tt>), or field
grselector (<tt>MetaSel</tt>).
gr
gr<ul>
gr<li>In <tt>MetaData n m p nt</tt>, <tt>n</tt> is the datatype's name,
gr<tt>m</tt> is the module in which the datatype is defined, <tt>p</tt>
gris the package in which the datatype is defined, and <tt>nt</tt> is
gr<tt>'True</tt> if the datatype is a <tt>newtype</tt>.</li>
gr<li>In <tt>MetaCons n f s</tt>, <tt>n</tt> is the constructor's name,
gr<tt>f</tt> is its fixity, and <tt>s</tt> is <tt>'True</tt> if the
grconstructor contains record selectors.</li>
gr<li>In <tt>MetaSel mn su ss ds</tt>, if the field uses record syntax,
grthen <tt>mn</tt> is <a>Just</a> the record name. Otherwise,
gr<tt>mn</tt> is <a>Nothing</a>. <tt>su</tt> and <tt>ss</tt> are the
grfield's unpackedness and strictness annotations, and <tt>ds</tt> is
grthe strictness that GHC infers for the field.</li>
gr</ul>
data Meta
MetaData :: Symbol -> Symbol -> Symbol -> Bool -> Meta
MetaCons :: Symbol -> FixityI -> Bool -> Meta
MetaSel :: (Maybe Symbol) -> SourceUnpackedness -> SourceStrictness -> DecidedStrictness -> Meta

-- | Representable types of kind <tt>*</tt>. This class is derivable in GHC
grwith the <tt>DeriveGeneric</tt> flag on.
gr
grA <a>Generic</a> instance must satisfy the following laws:
gr
gr<pre>
gr<a>from</a> . <a>to</a> ≡ <tt>id</tt>
gr<a>to</a> . <a>from</a> ≡ <tt>id</tt>
gr</pre>
class Generic a where {
    type family Rep a :: * -> *;
}

-- | Convert from the datatype to its representation
from :: Generic a => a -> (Rep a) x

-- | Convert from the representation to the datatype
to :: Generic a => (Rep a) x -> a

-- | Representable types of kind <tt>* -&gt; *</tt> (or kind <tt>k -&gt;
gr*</tt>, when <tt>PolyKinds</tt> is enabled). This class is derivable
grin GHC with the <tt>DeriveGeneric</tt> flag on.
gr
grA <a>Generic1</a> instance must satisfy the following laws:
gr
gr<pre>
gr<a>from1</a> . <a>to1</a> ≡ <tt>id</tt>
gr<a>to1</a> . <a>from1</a> ≡ <tt>id</tt>
gr</pre>
class Generic1 (f :: k -> *) where {
    type family Rep1 f :: k -> *;
}

-- | Convert from the datatype to its representation
from1 :: Generic1 f => f a -> (Rep1 f) a

-- | Convert from the representation to the datatype
to1 :: Generic1 f => (Rep1 f) a -> f a
instance forall i (c :: GHC.Generics.Meta) k (f :: k -> *). GHC.Generics.Generic1 (GHC.Generics.M1 i c f)
instance forall i (c :: GHC.Generics.Meta) k (f :: k -> *) (p :: k). GHC.Generics.Generic (GHC.Generics.M1 i c f p)
instance GHC.Base.Functor f => GHC.Base.Functor (GHC.Generics.M1 i c f)
instance forall i (c :: GHC.Generics.Meta) k (f :: k -> *) (p :: k). GHC.Show.Show (f p) => GHC.Show.Show (GHC.Generics.M1 i c f p)
instance forall i (c :: GHC.Generics.Meta) k (f :: k -> *) (p :: k). GHC.Read.Read (f p) => GHC.Read.Read (GHC.Generics.M1 i c f p)
instance forall i (c :: GHC.Generics.Meta) k (f :: k -> *) (p :: k). GHC.Classes.Ord (f p) => GHC.Classes.Ord (GHC.Generics.M1 i c f p)
instance forall i (c :: GHC.Generics.Meta) k (f :: k -> *) (p :: k). GHC.Classes.Eq (f p) => GHC.Classes.Eq (GHC.Generics.M1 i c f p)
instance GHC.Generics.Generic1 GHC.Generics.V1
instance forall k (p :: k). GHC.Generics.Generic (GHC.Generics.V1 p)
instance GHC.Base.Functor GHC.Generics.V1
instance forall k (p :: k). GHC.Show.Show (GHC.Generics.V1 p)
instance forall k (p :: k). GHC.Read.Read (GHC.Generics.V1 p)
instance forall k (p :: k). GHC.Classes.Ord (GHC.Generics.V1 p)
instance forall k (p :: k). GHC.Classes.Eq (GHC.Generics.V1 p)
instance GHC.Generics.Generic1 GHC.Generics.U1
instance forall k (p :: k). GHC.Generics.Generic (GHC.Generics.U1 p)
instance GHC.Generics.Generic1 GHC.Generics.Par1
instance GHC.Generics.Generic (GHC.Generics.Par1 p)
instance GHC.Base.Functor GHC.Generics.Par1
instance GHC.Show.Show p => GHC.Show.Show (GHC.Generics.Par1 p)
instance GHC.Read.Read p => GHC.Read.Read (GHC.Generics.Par1 p)
instance GHC.Classes.Ord p => GHC.Classes.Ord (GHC.Generics.Par1 p)
instance GHC.Classes.Eq p => GHC.Classes.Eq (GHC.Generics.Par1 p)
instance forall k (f :: k -> *). GHC.Generics.Generic1 (GHC.Generics.Rec1 f)
instance forall k (f :: k -> *) (p :: k). GHC.Generics.Generic (GHC.Generics.Rec1 f p)
instance GHC.Base.Functor f => GHC.Base.Functor (GHC.Generics.Rec1 f)
instance forall k (f :: k -> *) (p :: k). GHC.Show.Show (f p) => GHC.Show.Show (GHC.Generics.Rec1 f p)
instance forall k (f :: k -> *) (p :: k). GHC.Read.Read (f p) => GHC.Read.Read (GHC.Generics.Rec1 f p)
instance forall k (f :: k -> *) (p :: k). GHC.Classes.Ord (f p) => GHC.Classes.Ord (GHC.Generics.Rec1 f p)
instance forall k (f :: k -> *) (p :: k). GHC.Classes.Eq (f p) => GHC.Classes.Eq (GHC.Generics.Rec1 f p)
instance GHC.Generics.Generic1 (GHC.Generics.K1 i c)
instance forall i c k (p :: k). GHC.Generics.Generic (GHC.Generics.K1 i c p)
instance GHC.Base.Functor (GHC.Generics.K1 i c)
instance forall i c k (p :: k). GHC.Show.Show c => GHC.Show.Show (GHC.Generics.K1 i c p)
instance forall i c k (p :: k). GHC.Read.Read c => GHC.Read.Read (GHC.Generics.K1 i c p)
instance forall i c k (p :: k). GHC.Classes.Ord c => GHC.Classes.Ord (GHC.Generics.K1 i c p)
instance forall i c k (p :: k). GHC.Classes.Eq c => GHC.Classes.Eq (GHC.Generics.K1 i c p)
instance forall k (f :: k -> *) (g :: k -> *). GHC.Generics.Generic1 (f GHC.Generics.:+: g)
instance forall k (f :: k -> *) (g :: k -> *) (p :: k). GHC.Generics.Generic ((GHC.Generics.:+:) f g p)
instance (GHC.Base.Functor f, GHC.Base.Functor g) => GHC.Base.Functor (f GHC.Generics.:+: g)
instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Show.Show (f p), GHC.Show.Show (g p)) => GHC.Show.Show ((GHC.Generics.:+:) f g p)
instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Read.Read (f p), GHC.Read.Read (g p)) => GHC.Read.Read ((GHC.Generics.:+:) f g p)
instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Ord (f p), GHC.Classes.Ord (g p)) => GHC.Classes.Ord ((GHC.Generics.:+:) f g p)
instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Eq (f p), GHC.Classes.Eq (g p)) => GHC.Classes.Eq ((GHC.Generics.:+:) f g p)
instance forall k (f :: k -> *) (g :: k -> *). GHC.Generics.Generic1 (f GHC.Generics.:*: g)
instance forall k (f :: k -> *) (g :: k -> *) (p :: k). GHC.Generics.Generic ((GHC.Generics.:*:) f g p)
instance (GHC.Base.Functor f, GHC.Base.Functor g) => GHC.Base.Functor (f GHC.Generics.:*: g)
instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Show.Show (f p), GHC.Show.Show (g p)) => GHC.Show.Show ((GHC.Generics.:*:) f g p)
instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Read.Read (f p), GHC.Read.Read (g p)) => GHC.Read.Read ((GHC.Generics.:*:) f g p)
instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Ord (f p), GHC.Classes.Ord (g p)) => GHC.Classes.Ord ((GHC.Generics.:*:) f g p)
instance forall k (f :: k -> *) (g :: k -> *) (p :: k). (GHC.Classes.Eq (f p), GHC.Classes.Eq (g p)) => GHC.Classes.Eq ((GHC.Generics.:*:) f g p)
instance forall (f :: * -> *) k (g :: k -> *). GHC.Base.Functor f => GHC.Generics.Generic1 (f GHC.Generics.:.: g)
instance forall k2 (f :: k2 -> *) k1 (g :: k1 -> k2) (p :: k1). GHC.Generics.Generic ((GHC.Generics.:.:) f g p)
instance (GHC.Base.Functor f, GHC.Base.Functor g) => GHC.Base.Functor (f GHC.Generics.:.: g)
instance forall k2 (f :: k2 -> *) k1 (g :: k1 -> k2) (p :: k1). GHC.Show.Show (f (g p)) => GHC.Show.Show ((GHC.Generics.:.:) f g p)
instance forall k2 (f :: k2 -> *) k1 (g :: k1 -> k2) (p :: k1). GHC.Read.Read (f (g p)) => GHC.Read.Read ((GHC.Generics.:.:) f g p)
instance forall k2 (f :: k2 -> *) k1 (g :: k1 -> k2) (p :: k1). GHC.Classes.Ord (f (g p)) => GHC.Classes.Ord ((GHC.Generics.:.:) f g p)
instance forall k2 (f :: k2 -> *) k1 (g :: k1 -> k2) (p :: k1). GHC.Classes.Eq (f (g p)) => GHC.Classes.Eq ((GHC.Generics.:.:) f g p)
instance GHC.Generics.Generic GHC.Generics.Fixity
instance GHC.Read.Read GHC.Generics.Fixity
instance GHC.Classes.Ord GHC.Generics.Fixity
instance GHC.Show.Show GHC.Generics.Fixity
instance GHC.Classes.Eq GHC.Generics.Fixity
instance GHC.Generics.Generic GHC.Generics.Associativity
instance GHC.Arr.Ix GHC.Generics.Associativity
instance GHC.Enum.Bounded GHC.Generics.Associativity
instance GHC.Enum.Enum GHC.Generics.Associativity
instance GHC.Read.Read GHC.Generics.Associativity
instance GHC.Classes.Ord GHC.Generics.Associativity
instance GHC.Show.Show GHC.Generics.Associativity
instance GHC.Classes.Eq GHC.Generics.Associativity
instance GHC.Generics.Generic GHC.Generics.SourceUnpackedness
instance GHC.Arr.Ix GHC.Generics.SourceUnpackedness
instance GHC.Enum.Bounded GHC.Generics.SourceUnpackedness
instance GHC.Enum.Enum GHC.Generics.SourceUnpackedness
instance GHC.Read.Read GHC.Generics.SourceUnpackedness
instance GHC.Classes.Ord GHC.Generics.SourceUnpackedness
instance GHC.Show.Show GHC.Generics.SourceUnpackedness
instance GHC.Classes.Eq GHC.Generics.SourceUnpackedness
instance GHC.Generics.Generic GHC.Generics.SourceStrictness
instance GHC.Arr.Ix GHC.Generics.SourceStrictness
instance GHC.Enum.Bounded GHC.Generics.SourceStrictness
instance GHC.Enum.Enum GHC.Generics.SourceStrictness
instance GHC.Read.Read GHC.Generics.SourceStrictness
instance GHC.Classes.Ord GHC.Generics.SourceStrictness
instance GHC.Show.Show GHC.Generics.SourceStrictness
instance GHC.Classes.Eq GHC.Generics.SourceStrictness
instance GHC.Generics.Generic GHC.Generics.DecidedStrictness
instance GHC.Arr.Ix GHC.Generics.DecidedStrictness
instance GHC.Enum.Bounded GHC.Generics.DecidedStrictness
instance GHC.Enum.Enum GHC.Generics.DecidedStrictness
instance GHC.Read.Read GHC.Generics.DecidedStrictness
instance GHC.Classes.Ord GHC.Generics.DecidedStrictness
instance GHC.Show.Show GHC.Generics.DecidedStrictness
instance GHC.Classes.Eq GHC.Generics.DecidedStrictness
instance GHC.Generics.Generic1 (GHC.Generics.URec (GHC.Ptr.Ptr ()))
instance forall k (p :: k). GHC.Generics.Generic (GHC.Generics.URec (GHC.Ptr.Ptr ()) p)
instance GHC.Base.Functor (GHC.Generics.URec (GHC.Ptr.Ptr ()))
instance forall k (p :: k). GHC.Classes.Ord (GHC.Generics.URec (GHC.Ptr.Ptr ()) p)
instance forall k (p :: k). GHC.Classes.Eq (GHC.Generics.URec (GHC.Ptr.Ptr ()) p)
instance GHC.Generics.Generic1 (GHC.Generics.URec GHC.Types.Char)
instance forall k (p :: k). GHC.Generics.Generic (GHC.Generics.URec GHC.Types.Char p)
instance GHC.Base.Functor (GHC.Generics.URec GHC.Types.Char)
instance forall k (p :: k). GHC.Show.Show (GHC.Generics.URec GHC.Types.Char p)
instance forall k (p :: k). GHC.Classes.Ord (GHC.Generics.URec GHC.Types.Char p)
instance forall k (p :: k). GHC.Classes.Eq (GHC.Generics.URec GHC.Types.Char p)
instance GHC.Generics.Generic1 (GHC.Generics.URec GHC.Types.Double)
instance forall k (p :: k). GHC.Generics.Generic (GHC.Generics.URec GHC.Types.Double p)
instance GHC.Base.Functor (GHC.Generics.URec GHC.Types.Double)
instance forall k (p :: k). GHC.Show.Show (GHC.Generics.URec GHC.Types.Double p)
instance forall k (p :: k). GHC.Classes.Ord (GHC.Generics.URec GHC.Types.Double p)
instance forall k (p :: k). GHC.Classes.Eq (GHC.Generics.URec GHC.Types.Double p)
instance GHC.Generics.Generic1 (GHC.Generics.URec GHC.Types.Float)
instance forall k (p :: k). GHC.Generics.Generic (GHC.Generics.URec GHC.Types.Float p)
instance GHC.Base.Functor (GHC.Generics.URec GHC.Types.Float)
instance forall k (p :: k). GHC.Show.Show (GHC.Generics.URec GHC.Types.Float p)
instance forall k (p :: k). GHC.Classes.Ord (GHC.Generics.URec GHC.Types.Float p)
instance forall k (p :: k). GHC.Classes.Eq (GHC.Generics.URec GHC.Types.Float p)
instance GHC.Generics.Generic1 (GHC.Generics.URec GHC.Types.Int)
instance forall k (p :: k). GHC.Generics.Generic (GHC.Generics.URec GHC.Types.Int p)
instance GHC.Base.Functor (GHC.Generics.URec GHC.Types.Int)
instance forall k (p :: k). GHC.Show.Show (GHC.Generics.URec GHC.Types.Int p)
instance forall k (p :: k). GHC.Classes.Ord (GHC.Generics.URec GHC.Types.Int p)
instance forall k (p :: k). GHC.Classes.Eq (GHC.Generics.URec GHC.Types.Int p)
instance GHC.Generics.Generic1 (GHC.Generics.URec GHC.Types.Word)
instance forall k (p :: k). GHC.Generics.Generic (GHC.Generics.URec GHC.Types.Word p)
instance GHC.Base.Functor (GHC.Generics.URec GHC.Types.Word)
instance forall k (p :: k). GHC.Show.Show (GHC.Generics.URec GHC.Types.Word p)
instance forall k (p :: k). GHC.Classes.Ord (GHC.Generics.URec GHC.Types.Word p)
instance forall k (p :: k). GHC.Classes.Eq (GHC.Generics.URec GHC.Types.Word p)
instance forall k (p :: k). GHC.Read.Read (GHC.Generics.U1 p)
instance GHC.Base.Applicative f => GHC.Base.Applicative (GHC.Generics.Rec1 f)
instance GHC.Base.Alternative f => GHC.Base.Alternative (GHC.Generics.Rec1 f)
instance GHC.Base.MonadPlus f => GHC.Base.MonadPlus (GHC.Generics.Rec1 f)
instance GHC.Base.Applicative f => GHC.Base.Applicative (GHC.Generics.M1 i c f)
instance GHC.Base.Alternative f => GHC.Base.Alternative (GHC.Generics.M1 i c f)
instance GHC.Base.Monad f => GHC.Base.Monad (GHC.Generics.M1 i c f)
instance GHC.Base.MonadPlus f => GHC.Base.MonadPlus (GHC.Generics.M1 i c f)
instance GHC.Generics.Generic [a]
instance GHC.Generics.Generic (GHC.Base.NonEmpty a)
instance GHC.Generics.Generic (GHC.Base.Maybe a)
instance GHC.Generics.Generic (Data.Either.Either a b)
instance GHC.Generics.Generic GHC.Types.Bool
instance GHC.Generics.Generic GHC.Types.Ordering
instance forall k (t :: k). GHC.Generics.Generic (Data.Proxy.Proxy t)
instance GHC.Generics.Generic ()
instance GHC.Generics.Generic (a, b)
instance GHC.Generics.Generic (a, b, c)
instance GHC.Generics.Generic (a, b, c, d)
instance GHC.Generics.Generic (a, b, c, d, e)
instance GHC.Generics.Generic (a, b, c, d, e, f)
instance GHC.Generics.Generic (a, b, c, d, e, f, g)
instance GHC.Generics.Generic1 []
instance GHC.Generics.Generic1 GHC.Base.NonEmpty
instance GHC.Generics.Generic1 GHC.Base.Maybe
instance GHC.Generics.Generic1 (Data.Either.Either a)
instance GHC.Generics.Generic1 Data.Proxy.Proxy
instance GHC.Generics.Generic1 ((,) a)
instance GHC.Generics.Generic1 ((,,) a b)
instance GHC.Generics.Generic1 ((,,,) a b c)
instance GHC.Generics.Generic1 ((,,,,) a b c d)
instance GHC.Generics.Generic1 ((,,,,,) a b c d e)
instance GHC.Generics.Generic1 ((,,,,,,) a b c d e f)
instance (GHC.TypeLits.KnownSymbol n, GHC.TypeLits.KnownSymbol m, GHC.TypeLits.KnownSymbol p, GHC.Generics.SingI nt) => GHC.Generics.Datatype ('GHC.Generics.MetaData n m p nt)
instance (GHC.TypeLits.KnownSymbol n, GHC.Generics.SingI f, GHC.Generics.SingI r) => GHC.Generics.Constructor ('GHC.Generics.MetaCons n f r)
instance (GHC.Generics.SingI mn, GHC.Generics.SingI su, GHC.Generics.SingI ss, GHC.Generics.SingI ds) => GHC.Generics.Selector ('GHC.Generics.MetaSel mn su ss ds)
instance GHC.Generics.SingKind GHC.Types.Symbol
instance GHC.Generics.SingKind GHC.Types.Bool
instance GHC.Generics.SingKind a => GHC.Generics.SingKind (GHC.Base.Maybe a)
instance GHC.Generics.SingKind GHC.Generics.FixityI
instance GHC.Generics.SingKind GHC.Generics.Associativity
instance GHC.Generics.SingKind GHC.Generics.SourceUnpackedness
instance GHC.Generics.SingKind GHC.Generics.SourceStrictness
instance GHC.Generics.SingKind GHC.Generics.DecidedStrictness
instance GHC.TypeLits.KnownSymbol a => GHC.Generics.SingI a
instance GHC.Generics.SingI 'GHC.Types.True
instance GHC.Generics.SingI 'GHC.Types.False
instance GHC.Generics.SingI 'GHC.Base.Nothing
instance forall a1 (a2 :: a1). GHC.Generics.SingI a2 => GHC.Generics.SingI ('GHC.Base.Just a2)
instance GHC.Generics.SingI 'GHC.Generics.PrefixI
instance (GHC.Generics.SingI a, GHC.TypeNats.KnownNat n) => GHC.Generics.SingI ('GHC.Generics.InfixI a n)
instance GHC.Generics.SingI 'GHC.Generics.LeftAssociative
instance GHC.Generics.SingI 'GHC.Generics.RightAssociative
instance GHC.Generics.SingI 'GHC.Generics.NotAssociative
instance GHC.Generics.SingI 'GHC.Generics.NoSourceUnpackedness
instance GHC.Generics.SingI 'GHC.Generics.SourceNoUnpack
instance GHC.Generics.SingI 'GHC.Generics.SourceUnpack
instance GHC.Generics.SingI 'GHC.Generics.NoSourceStrictness
instance GHC.Generics.SingI 'GHC.Generics.SourceLazy
instance GHC.Generics.SingI 'GHC.Generics.SourceStrict
instance GHC.Generics.SingI 'GHC.Generics.DecidedLazy
instance GHC.Generics.SingI 'GHC.Generics.DecidedStrict
instance GHC.Generics.SingI 'GHC.Generics.DecidedUnpack
instance forall k (p :: k). GHC.Classes.Eq (GHC.Generics.U1 p)
instance forall k (p :: k). GHC.Classes.Ord (GHC.Generics.U1 p)
instance forall k (p :: k). GHC.Show.Show (GHC.Generics.U1 p)
instance GHC.Base.Functor GHC.Generics.U1
instance GHC.Base.Applicative GHC.Generics.U1
instance GHC.Base.Alternative GHC.Generics.U1
instance GHC.Base.Monad GHC.Generics.U1
instance GHC.Base.MonadPlus GHC.Generics.U1
instance GHC.Base.Applicative GHC.Generics.Par1
instance GHC.Base.Monad GHC.Generics.Par1
instance GHC.Base.Monad f => GHC.Base.Monad (GHC.Generics.Rec1 f)
instance (GHC.Base.Applicative f, GHC.Base.Applicative g) => GHC.Base.Applicative (f GHC.Generics.:*: g)
instance (GHC.Base.Alternative f, GHC.Base.Alternative g) => GHC.Base.Alternative (f GHC.Generics.:*: g)
instance (GHC.Base.Monad f, GHC.Base.Monad g) => GHC.Base.Monad (f GHC.Generics.:*: g)
instance (GHC.Base.MonadPlus f, GHC.Base.MonadPlus g) => GHC.Base.MonadPlus (f GHC.Generics.:*: g)
instance (GHC.Base.Applicative f, GHC.Base.Applicative g) => GHC.Base.Applicative (f GHC.Generics.:.: g)
instance (GHC.Base.Alternative f, GHC.Base.Applicative g) => GHC.Base.Alternative (f GHC.Generics.:.: g)


-- | A class for monoids (types with an associative binary operation that
grhas an identity) with various general-purpose instances.
module Data.Monoid

-- | The class of monoids (types with an associative binary operation that
grhas an identity). Instances should satisfy the following laws:
gr
gr<ul>
gr<li><pre>x <a>&lt;&gt;</a> <a>mempty</a> = x</pre></li>
gr<li><pre><a>mempty</a> <a>&lt;&gt;</a> x = x</pre></li>
gr<li><tt>x <a>&lt;&gt;</a> (y <a>&lt;&gt;</a> z) = (x <a>&lt;&gt;</a>
gry) <a>&lt;&gt;</a> z</tt> (<a>Semigroup</a> law)</li>
gr<li><pre><a>mconcat</a> = <a>foldr</a> '(&lt;&gt;)'
gr<a>mempty</a></pre></li>
gr</ul>
gr
grThe method names refer to the monoid of lists under concatenation, but
grthere are many other instances.
gr
grSome types can be viewed as a monoid in more than one way, e.g. both
graddition and multiplication on numbers. In such cases we often define
gr<tt>newtype</tt>s and make those instances of <a>Monoid</a>, e.g.
gr<tt>Sum</tt> and <tt>Product</tt>.
gr
gr<b>NOTE</b>: <a>Semigroup</a> is a superclass of <a>Monoid</a> since
gr<i>base-4.11.0.0</i>.
class Semigroup a => Monoid a

-- | Identity of <a>mappend</a>
mempty :: Monoid a => a

-- | An associative operation
gr
gr<b>NOTE</b>: This method is redundant and has the default
grimplementation <tt><a>mappend</a> = '(&lt;&gt;)'</tt> since
gr<i>base-4.11.0.0</i>.
mappend :: Monoid a => a -> a -> a

-- | Fold a list using the monoid.
gr
grFor most types, the default definition for <a>mconcat</a> will be
grused, but the function is included in the class definition so that an
groptimized version can be provided for specific types.
mconcat :: Monoid a => [a] -> a

-- | An associative operation.
(<>) :: Semigroup a => a -> a -> a
infixr 6 <>

-- | The dual of a <a>Monoid</a>, obtained by swapping the arguments of
gr<a>mappend</a>.
gr
gr<pre>
gr&gt;&gt;&gt; getDual (mappend (Dual "Hello") (Dual "World"))
gr"WorldHello"
gr</pre>
newtype Dual a
Dual :: a -> Dual a
[getDual] :: Dual a -> a

-- | The monoid of endomorphisms under composition.
gr
gr<pre>
gr&gt;&gt;&gt; let computation = Endo ("Hello, " ++) &lt;&gt; Endo (++ "!")
gr
gr&gt;&gt;&gt; appEndo computation "Haskell"
gr"Hello, Haskell!"
gr</pre>
newtype Endo a
Endo :: a -> a -> Endo a
[appEndo] :: Endo a -> a -> a

-- | Boolean monoid under conjunction (<a>&amp;&amp;</a>).
gr
gr<pre>
gr&gt;&gt;&gt; getAll (All True &lt;&gt; mempty &lt;&gt; All False)
grFalse
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; getAll (mconcat (map (\x -&gt; All (even x)) [2,4,6,7,8]))
grFalse
gr</pre>
newtype All
All :: Bool -> All
[getAll] :: All -> Bool

-- | Boolean monoid under disjunction (<a>||</a>).
gr
gr<pre>
gr&gt;&gt;&gt; getAny (Any True &lt;&gt; mempty &lt;&gt; Any False)
grTrue
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; getAny (mconcat (map (\x -&gt; Any (even x)) [2,4,6,7,8]))
grTrue
gr</pre>
newtype Any
Any :: Bool -> Any
[getAny] :: Any -> Bool

-- | Monoid under addition.
gr
gr<pre>
gr&gt;&gt;&gt; getSum (Sum 1 &lt;&gt; Sum 2 &lt;&gt; mempty)
gr3
gr</pre>
newtype Sum a
Sum :: a -> Sum a
[getSum] :: Sum a -> a

-- | Monoid under multiplication.
gr
gr<pre>
gr&gt;&gt;&gt; getProduct (Product 3 &lt;&gt; Product 4 &lt;&gt; mempty)
gr12
gr</pre>
newtype Product a
Product :: a -> Product a
[getProduct] :: Product a -> a

-- | Maybe monoid returning the leftmost non-Nothing value.
gr
gr<tt><a>First</a> a</tt> is isomorphic to <tt><a>Alt</a> <a>Maybe</a>
gra</tt>, but precedes it historically.
gr
gr<pre>
gr&gt;&gt;&gt; getFirst (First (Just "hello") &lt;&gt; First Nothing &lt;&gt; First (Just "world"))
grJust "hello"
gr</pre>
newtype First a
First :: Maybe a -> First a
[getFirst] :: First a -> Maybe a

-- | Maybe monoid returning the rightmost non-Nothing value.
gr
gr<tt><a>Last</a> a</tt> is isomorphic to <tt><a>Dual</a> (<a>First</a>
gra)</tt>, and thus to <tt><a>Dual</a> (<a>Alt</a> <a>Maybe</a> a)</tt>
gr
gr<pre>
gr&gt;&gt;&gt; getLast (Last (Just "hello") &lt;&gt; Last Nothing &lt;&gt; Last (Just "world"))
grJust "world"
gr</pre>
newtype Last a
Last :: Maybe a -> Last a
[getLast] :: Last a -> Maybe a

-- | Monoid under <a>&lt;|&gt;</a>.
newtype Alt f a
Alt :: f a -> Alt f a
[getAlt] :: Alt f a -> f a
instance GHC.Base.Monad Data.Monoid.Last
instance GHC.Base.Applicative Data.Monoid.Last
instance GHC.Base.Functor Data.Monoid.Last
instance GHC.Generics.Generic1 Data.Monoid.Last
instance GHC.Generics.Generic (Data.Monoid.Last a)
instance GHC.Show.Show a => GHC.Show.Show (Data.Monoid.Last a)
instance GHC.Read.Read a => GHC.Read.Read (Data.Monoid.Last a)
instance GHC.Classes.Ord a => GHC.Classes.Ord (Data.Monoid.Last a)
instance GHC.Classes.Eq a => GHC.Classes.Eq (Data.Monoid.Last a)
instance GHC.Base.Monad Data.Monoid.First
instance GHC.Base.Applicative Data.Monoid.First
instance GHC.Base.Functor Data.Monoid.First
instance GHC.Generics.Generic1 Data.Monoid.First
instance GHC.Generics.Generic (Data.Monoid.First a)
instance GHC.Show.Show a => GHC.Show.Show (Data.Monoid.First a)
instance GHC.Read.Read a => GHC.Read.Read (Data.Monoid.First a)
instance GHC.Classes.Ord a => GHC.Classes.Ord (Data.Monoid.First a)
instance GHC.Classes.Eq a => GHC.Classes.Eq (Data.Monoid.First a)
instance GHC.Base.Semigroup (Data.Monoid.Last a)
instance GHC.Base.Monoid (Data.Monoid.Last a)
instance GHC.Base.Semigroup (Data.Monoid.First a)
instance GHC.Base.Monoid (Data.Monoid.First a)


-- | Class of data structures that can be folded to a summary value.
module Data.Foldable

-- | Data structures that can be folded.
gr
grFor example, given a data type
gr
gr<pre>
grdata Tree a = Empty | Leaf a | Node (Tree a) a (Tree a)
gr</pre>
gr
gra suitable instance would be
gr
gr<pre>
grinstance Foldable Tree where
gr   foldMap f Empty = mempty
gr   foldMap f (Leaf x) = f x
gr   foldMap f (Node l k r) = foldMap f l `mappend` f k `mappend` foldMap f r
gr</pre>
gr
grThis is suitable even for abstract types, as the monoid is assumed to
grsatisfy the monoid laws. Alternatively, one could define
gr<tt>foldr</tt>:
gr
gr<pre>
grinstance Foldable Tree where
gr   foldr f z Empty = z
gr   foldr f z (Leaf x) = f x z
gr   foldr f z (Node l k r) = foldr f (f k (foldr f z r)) l
gr</pre>
gr
gr<tt>Foldable</tt> instances are expected to satisfy the following
grlaws:
gr
gr<pre>
grfoldr f z t = appEndo (foldMap (Endo . f) t ) z
gr</pre>
gr
gr<pre>
grfoldl f z t = appEndo (getDual (foldMap (Dual . Endo . flip f) t)) z
gr</pre>
gr
gr<pre>
grfold = foldMap id
gr</pre>
gr
gr<pre>
grlength = getSum . foldMap (Sum . const  1)
gr</pre>
gr
gr<tt>sum</tt>, <tt>product</tt>, <tt>maximum</tt>, and <tt>minimum</tt>
grshould all be essentially equivalent to <tt>foldMap</tt> forms, such
gras
gr
gr<pre>
grsum = getSum . foldMap Sum
gr</pre>
gr
grbut may be less defined.
gr
grIf the type is also a <a>Functor</a> instance, it should satisfy
gr
gr<pre>
grfoldMap f = fold . fmap f
gr</pre>
gr
grwhich implies that
gr
gr<pre>
grfoldMap f . fmap g = foldMap (f . g)
gr</pre>
class Foldable t

-- | Combine the elements of a structure using a monoid.
fold :: (Foldable t, Monoid m) => t m -> m

-- | Map each element of the structure to a monoid, and combine the
grresults.
foldMap :: (Foldable t, Monoid m) => (a -> m) -> t a -> m

-- | Right-associative fold of a structure.
gr
grIn the case of lists, <a>foldr</a>, when applied to a binary operator,
gra starting value (typically the right-identity of the operator), and a
grlist, reduces the list using the binary operator, from right to left:
gr
gr<pre>
grfoldr f z [x1, x2, ..., xn] == x1 `f` (x2 `f` ... (xn `f` z)...)
gr</pre>
gr
grNote that, since the head of the resulting expression is produced by
gran application of the operator to the first element of the list,
gr<a>foldr</a> can produce a terminating expression from an infinite
grlist.
gr
grFor a general <a>Foldable</a> structure this should be semantically
gridentical to,
gr
gr<pre>
grfoldr f z = <a>foldr</a> f z . <a>toList</a>
gr</pre>
foldr :: Foldable t => (a -> b -> b) -> b -> t a -> b

-- | Right-associative fold of a structure, but with strict application of
grthe operator.
foldr' :: Foldable t => (a -> b -> b) -> b -> t a -> b

-- | Left-associative fold of a structure.
gr
grIn the case of lists, <a>foldl</a>, when applied to a binary operator,
gra starting value (typically the left-identity of the operator), and a
grlist, reduces the list using the binary operator, from left to right:
gr
gr<pre>
grfoldl f z [x1, x2, ..., xn] == (...((z `f` x1) `f` x2) `f`...) `f` xn
gr</pre>
gr
grNote that to produce the outermost application of the operator the
grentire input list must be traversed. This means that <a>foldl'</a>
grwill diverge if given an infinite list.
gr
grAlso note that if you want an efficient left-fold, you probably want
grto use <a>foldl'</a> instead of <a>foldl</a>. The reason for this is
grthat latter does not force the "inner" results (e.g. <tt>z <tt>f</tt>
grx1</tt> in the above example) before applying them to the operator
gr(e.g. to <tt>(<tt>f</tt> x2)</tt>). This results in a thunk chain
gr<tt>O(n)</tt> elements long, which then must be evaluated from the
groutside-in.
gr
grFor a general <a>Foldable</a> structure this should be semantically
gridentical to,
gr
gr<pre>
grfoldl f z = <a>foldl</a> f z . <a>toList</a>
gr</pre>
foldl :: Foldable t => (b -> a -> b) -> b -> t a -> b

-- | Left-associative fold of a structure but with strict application of
grthe operator.
gr
grThis ensures that each step of the fold is forced to weak head normal
grform before being applied, avoiding the collection of thunks that
grwould otherwise occur. This is often what you want to strictly reduce
gra finite list to a single, monolithic result (e.g. <a>length</a>).
gr
grFor a general <a>Foldable</a> structure this should be semantically
gridentical to,
gr
gr<pre>
grfoldl f z = <a>foldl'</a> f z . <a>toList</a>
gr</pre>
foldl' :: Foldable t => (b -> a -> b) -> b -> t a -> b

-- | A variant of <a>foldr</a> that has no base case, and thus may only be
grapplied to non-empty structures.
gr
gr<pre>
gr<a>foldr1</a> f = <a>foldr1</a> f . <a>toList</a>
gr</pre>
foldr1 :: Foldable t => (a -> a -> a) -> t a -> a

-- | A variant of <a>foldl</a> that has no base case, and thus may only be
grapplied to non-empty structures.
gr
gr<pre>
gr<a>foldl1</a> f = <a>foldl1</a> f . <a>toList</a>
gr</pre>
foldl1 :: Foldable t => (a -> a -> a) -> t a -> a

-- | List of elements of a structure, from left to right.
toList :: Foldable t => t a -> [a]

-- | Test whether the structure is empty. The default implementation is
groptimized for structures that are similar to cons-lists, because there
gris no general way to do better.
null :: Foldable t => t a -> Bool

-- | Returns the size/length of a finite structure as an <a>Int</a>. The
grdefault implementation is optimized for structures that are similar to
grcons-lists, because there is no general way to do better.
length :: Foldable t => t a -> Int

-- | Does the element occur in the structure?
elem :: (Foldable t, Eq a) => a -> t a -> Bool

-- | The largest element of a non-empty structure.
maximum :: forall a. (Foldable t, Ord a) => t a -> a

-- | The least element of a non-empty structure.
minimum :: forall a. (Foldable t, Ord a) => t a -> a

-- | The <a>sum</a> function computes the sum of the numbers of a
grstructure.
sum :: (Foldable t, Num a) => t a -> a

-- | The <a>product</a> function computes the product of the numbers of a
grstructure.
product :: (Foldable t, Num a) => t a -> a

-- | Monadic fold over the elements of a structure, associating to the
grright, i.e. from right to left.
foldrM :: (Foldable t, Monad m) => (a -> b -> m b) -> b -> t a -> m b

-- | Monadic fold over the elements of a structure, associating to the
grleft, i.e. from left to right.
foldlM :: (Foldable t, Monad m) => (b -> a -> m b) -> b -> t a -> m b

-- | Map each element of a structure to an action, evaluate these actions
grfrom left to right, and ignore the results. For a version that doesn't
grignore the results see <a>traverse</a>.
traverse_ :: (Foldable t, Applicative f) => (a -> f b) -> t a -> f ()

-- | <a>for_</a> is <a>traverse_</a> with its arguments flipped. For a
grversion that doesn't ignore the results see <a>for</a>.
gr
gr<pre>
gr&gt;&gt;&gt; for_ [1..4] print
gr1
gr2
gr3
gr4
gr</pre>
for_ :: (Foldable t, Applicative f) => t a -> (a -> f b) -> f ()

-- | Evaluate each action in the structure from left to right, and ignore
grthe results. For a version that doesn't ignore the results see
gr<a>sequenceA</a>.
sequenceA_ :: (Foldable t, Applicative f) => t (f a) -> f ()

-- | The sum of a collection of actions, generalizing <a>concat</a>.
gr
grasum [Just <a>Hello</a>, Nothing, Just <a>World</a>] Just <a>Hello</a>
asum :: (Foldable t, Alternative f) => t (f a) -> f a

-- | Map each element of a structure to a monadic action, evaluate these
gractions from left to right, and ignore the results. For a version that
grdoesn't ignore the results see <a>mapM</a>.
gr
grAs of base 4.8.0.0, <a>mapM_</a> is just <a>traverse_</a>, specialized
grto <a>Monad</a>.
mapM_ :: (Foldable t, Monad m) => (a -> m b) -> t a -> m ()

-- | <a>forM_</a> is <a>mapM_</a> with its arguments flipped. For a version
grthat doesn't ignore the results see <a>forM</a>.
gr
grAs of base 4.8.0.0, <a>forM_</a> is just <a>for_</a>, specialized to
gr<a>Monad</a>.
forM_ :: (Foldable t, Monad m) => t a -> (a -> m b) -> m ()

-- | Evaluate each monadic action in the structure from left to right, and
grignore the results. For a version that doesn't ignore the results see
gr<a>sequence</a>.
gr
grAs of base 4.8.0.0, <a>sequence_</a> is just <a>sequenceA_</a>,
grspecialized to <a>Monad</a>.
sequence_ :: (Foldable t, Monad m) => t (m a) -> m ()

-- | The sum of a collection of actions, generalizing <a>concat</a>. As of
grbase 4.8.0.0, <a>msum</a> is just <a>asum</a>, specialized to
gr<a>MonadPlus</a>.
msum :: (Foldable t, MonadPlus m) => t (m a) -> m a

-- | The concatenation of all the elements of a container of lists.
concat :: Foldable t => t [a] -> [a]

-- | Map a function over all the elements of a container and concatenate
grthe resulting lists.
concatMap :: Foldable t => (a -> [b]) -> t a -> [b]

-- | <a>and</a> returns the conjunction of a container of Bools. For the
grresult to be <a>True</a>, the container must be finite; <a>False</a>,
grhowever, results from a <a>False</a> value finitely far from the left
grend.
and :: Foldable t => t Bool -> Bool

-- | <a>or</a> returns the disjunction of a container of Bools. For the
grresult to be <a>False</a>, the container must be finite; <a>True</a>,
grhowever, results from a <a>True</a> value finitely far from the left
grend.
or :: Foldable t => t Bool -> Bool

-- | Determines whether any element of the structure satisfies the
grpredicate.
any :: Foldable t => (a -> Bool) -> t a -> Bool

-- | Determines whether all elements of the structure satisfy the
grpredicate.
all :: Foldable t => (a -> Bool) -> t a -> Bool

-- | The largest element of a non-empty structure with respect to the given
grcomparison function.
maximumBy :: Foldable t => (a -> a -> Ordering) -> t a -> a

-- | The least element of a non-empty structure with respect to the given
grcomparison function.
minimumBy :: Foldable t => (a -> a -> Ordering) -> t a -> a

-- | <a>notElem</a> is the negation of <a>elem</a>.
notElem :: (Foldable t, Eq a) => a -> t a -> Bool
infix 4 `notElem`

-- | The <a>find</a> function takes a predicate and a structure and returns
grthe leftmost element of the structure matching the predicate, or
gr<a>Nothing</a> if there is no such element.
find :: Foldable t => (a -> Bool) -> t a -> Maybe a
instance Data.Foldable.Foldable GHC.Generics.V1
instance Data.Foldable.Foldable GHC.Generics.Par1
instance Data.Foldable.Foldable f => Data.Foldable.Foldable (GHC.Generics.Rec1 f)
instance Data.Foldable.Foldable (GHC.Generics.K1 i c)
instance Data.Foldable.Foldable f => Data.Foldable.Foldable (GHC.Generics.M1 i c f)
instance (Data.Foldable.Foldable f, Data.Foldable.Foldable g) => Data.Foldable.Foldable (f GHC.Generics.:+: g)
instance (Data.Foldable.Foldable f, Data.Foldable.Foldable g) => Data.Foldable.Foldable (f GHC.Generics.:*: g)
instance (Data.Foldable.Foldable f, Data.Foldable.Foldable g) => Data.Foldable.Foldable (f GHC.Generics.:.: g)
instance Data.Foldable.Foldable (GHC.Generics.URec (GHC.Ptr.Ptr ()))
instance Data.Foldable.Foldable (GHC.Generics.URec GHC.Types.Char)
instance Data.Foldable.Foldable (GHC.Generics.URec GHC.Types.Double)
instance Data.Foldable.Foldable (GHC.Generics.URec GHC.Types.Float)
instance Data.Foldable.Foldable (GHC.Generics.URec GHC.Types.Int)
instance Data.Foldable.Foldable (GHC.Generics.URec GHC.Types.Word)
instance Data.Foldable.Foldable GHC.Base.Maybe
instance Data.Foldable.Foldable []
instance Data.Foldable.Foldable GHC.Base.NonEmpty
instance Data.Foldable.Foldable (Data.Either.Either a)
instance Data.Foldable.Foldable ((,) a)
instance Data.Foldable.Foldable (GHC.Arr.Array i)
instance Data.Foldable.Foldable Data.Proxy.Proxy
instance Data.Foldable.Foldable Data.Semigroup.Internal.Dual
instance Data.Foldable.Foldable Data.Semigroup.Internal.Sum
instance Data.Foldable.Foldable Data.Semigroup.Internal.Product
instance Data.Foldable.Foldable Data.Monoid.First
instance Data.Foldable.Foldable Data.Monoid.Last
instance Data.Foldable.Foldable GHC.Generics.U1


module Data.Functor.Const

-- | The <a>Const</a> functor.
newtype Const a b
Const :: a -> Const a b
[getConst] :: Const a b -> a
instance forall a k (b :: k). Foreign.Storable.Storable a => Foreign.Storable.Storable (Data.Functor.Const.Const a b)
instance forall a k (b :: k). GHC.Float.RealFloat a => GHC.Float.RealFloat (Data.Functor.Const.Const a b)
instance forall a k (b :: k). GHC.Real.RealFrac a => GHC.Real.RealFrac (Data.Functor.Const.Const a b)
instance forall a k (b :: k). GHC.Real.Real a => GHC.Real.Real (Data.Functor.Const.Const a b)
instance forall a k (b :: k). GHC.Classes.Ord a => GHC.Classes.Ord (Data.Functor.Const.Const a b)
instance forall a k (b :: k). GHC.Num.Num a => GHC.Num.Num (Data.Functor.Const.Const a b)
instance forall a k (b :: k). GHC.Base.Monoid a => GHC.Base.Monoid (Data.Functor.Const.Const a b)
instance forall a k (b :: k). GHC.Base.Semigroup a => GHC.Base.Semigroup (Data.Functor.Const.Const a b)
instance forall a k (b :: k). GHC.Arr.Ix a => GHC.Arr.Ix (Data.Functor.Const.Const a b)
instance forall a k (b :: k). GHC.Real.Integral a => GHC.Real.Integral (Data.Functor.Const.Const a b)
instance GHC.Generics.Generic1 (Data.Functor.Const.Const a)
instance forall a k (b :: k). GHC.Generics.Generic (Data.Functor.Const.Const a b)
instance forall a k (b :: k). GHC.Real.Fractional a => GHC.Real.Fractional (Data.Functor.Const.Const a b)
instance forall a k (b :: k). GHC.Float.Floating a => GHC.Float.Floating (Data.Functor.Const.Const a b)
instance forall a k (b :: k). Data.Bits.FiniteBits a => Data.Bits.FiniteBits (Data.Functor.Const.Const a b)
instance forall a k (b :: k). GHC.Classes.Eq a => GHC.Classes.Eq (Data.Functor.Const.Const a b)
instance forall a k (b :: k). GHC.Enum.Enum a => GHC.Enum.Enum (Data.Functor.Const.Const a b)
instance forall a k (b :: k). GHC.Enum.Bounded a => GHC.Enum.Bounded (Data.Functor.Const.Const a b)
instance forall a k (b :: k). Data.Bits.Bits a => Data.Bits.Bits (Data.Functor.Const.Const a b)
instance forall k a (b :: k). GHC.Read.Read a => GHC.Read.Read (Data.Functor.Const.Const a b)
instance forall k a (b :: k). GHC.Show.Show a => GHC.Show.Show (Data.Functor.Const.Const a b)
instance Data.Foldable.Foldable (Data.Functor.Const.Const m)
instance GHC.Base.Functor (Data.Functor.Const.Const m)
instance GHC.Base.Monoid m => GHC.Base.Applicative (Data.Functor.Const.Const m)


-- | This provides a type-indexed type representation mechanism, similar to
grthat described by,
gr
gr<ul>
gr<li>Simon Peyton-Jones, Stephanie Weirich, Richard Eisenberg,
grDimitrios Vytiniotis. "A reflection on types." /Proc. Philip Wadler's
gr60th birthday Festschrift/, Edinburgh (April 2016).</li>
gr</ul>
gr
grThe interface provides <tt>TypeRep</tt>, a type representation which
grcan be safely decomposed and composed. See <a>Data.Dynamic</a> for an
grexample of this.
module Type.Reflection

-- | The class <a>Typeable</a> allows a concrete representation of a type
grto be calculated.
class Typeable (a :: k)
typeRep :: Typeable a => TypeRep a

-- | Use a <a>TypeRep</a> as <a>Typeable</a> evidence.
withTypeable :: forall (a :: k) (r :: TYPE rep). () => TypeRep a -> (Typeable a => r) -> r

-- | Propositional equality. If <tt>a :~: b</tt> is inhabited by some
grterminating value, then the type <tt>a</tt> is the same as the type
gr<tt>b</tt>. To use this equality in practice, pattern-match on the
gr<tt>a :~: b</tt> to get out the <tt>Refl</tt> constructor; in the body
grof the pattern-match, the compiler knows that <tt>a ~ b</tt>.
data a (:~:) b
[Refl] :: a :~: a

-- | Kind heterogeneous propositional equality. Like <a>:~:</a>, <tt>a :~~:
grb</tt> is inhabited by a terminating value if and only if <tt>a</tt>
gris the same type as <tt>b</tt>.
data (a :: k1) (:~~:) (b :: k2)
[HRefl] :: a :~~: a

-- | A concrete representation of a (monomorphic) type. <a>TypeRep</a>
grsupports reasonably efficient equality.
data TypeRep (a :: k)
typeOf :: Typeable a => a -> TypeRep a

-- | A type application.
gr
grFor instance,
gr
gr<pre>
grtypeRep @(Maybe Int) === App (typeRep @Maybe) (typeRep @Int)
gr</pre>
gr
grNote that this will also match a function type,
gr
gr<pre>
grtypeRep @(Int# -&gt; Char)
gr  ===
grApp (App arrow (typeRep @Int#)) (typeRep @Char)
gr</pre>
gr
grwhere <tt>arrow :: TypeRep ((-&gt;) :: TYPE IntRep -&gt; Type -&gt;
grType)</tt>.

-- | Pattern match on a type constructor

-- | Pattern match on a type constructor including its instantiated kind
grvariables.
gr
grFor instance,
gr
gr<pre>
grApp (Con' proxyTyCon ks) intRep = typeRep @(Proxy @Int)
gr</pre>
gr
grwill bring into scope,
gr
gr<pre>
grproxyTyCon :: TyCon
grks         == [someTypeRep <tt>Type] :: [SomeTypeRep]
grintRep     == typeRep </tt>Int
gr</pre>

-- | The function type constructor.
gr
grFor instance,
gr
gr<pre>
grtypeRep @(Int -&gt; Char) === Fun (typeRep @Int) (typeRep @Char)
gr</pre>

-- | Observe the type constructor of a type representation
typeRepTyCon :: TypeRep a -> TyCon

-- | Helper to fully evaluate <a>TypeRep</a> for use as
gr<tt>NFData(rnf)</tt> implementation
rnfTypeRep :: TypeRep a -> ()

-- | Type equality
eqTypeRep :: forall k1 k2 (a :: k1) (b :: k2). TypeRep a -> TypeRep b -> Maybe (a :~~: b)

-- | Observe the kind of a type.
typeRepKind :: TypeRep (a :: k) -> TypeRep k
splitApps :: TypeRep a -> (TyCon, [SomeTypeRep])

-- | A non-indexed type representation.
data SomeTypeRep
[SomeTypeRep] :: forall k (a :: k). !(TypeRep a) -> SomeTypeRep

-- | Takes a value of type <tt>a</tt> and returns a concrete representation
grof that type.
someTypeRep :: forall proxy a. Typeable a => proxy a -> SomeTypeRep

-- | Observe the type constructor of a quantified type representation.
someTypeRepTyCon :: SomeTypeRep -> TyCon

-- | Helper to fully evaluate <a>SomeTypeRep</a> for use as
gr<tt>NFData(rnf)</tt> implementation
rnfSomeTypeRep :: SomeTypeRep -> ()
data TyCon
tyConPackage :: TyCon -> String
tyConModule :: TyCon -> String
tyConName :: TyCon -> String
rnfTyCon :: TyCon -> ()
data Module
moduleName :: Module -> String
modulePackage :: Module -> String

-- | Helper to fully evaluate <a>TyCon</a> for use as <tt>NFData(rnf)</tt>
grimplementation
rnfModule :: Module -> ()


-- | The <a>Typeable</a> class reifies types to some extent by associating
grtype representations to types. These type representations can be
grcompared, and one can in turn define a type-safe cast operation. To
grthis end, an unsafe cast is guarded by a test for type
gr(representation) equivalence. The module <a>Data.Dynamic</a> uses
grTypeable for an implementation of dynamics. The module
gr<a>Data.Data</a> uses Typeable and type-safe cast (but not dynamics)
grto support the "Scrap your boilerplate" style of generic programming.
gr
gr<h2>Compatibility Notes</h2>
gr
grSince GHC 8.2, GHC has supported type-indexed type representations.
gr<a>Data.Typeable</a> provides type representations which are qualified
grover this index, providing an interface very similar to the
gr<a>Typeable</a> notion seen in previous releases. For the type-indexed
grinterface, see <a>Type.Reflection</a>.
gr
grSince GHC 7.8, <a>Typeable</a> is poly-kinded. The changes required
grfor this might break some old programs involving <a>Typeable</a>. More
grdetails on this, including how to fix your code, can be found on the
gr<a>PolyTypeable wiki page</a>
module Data.Typeable

-- | The class <a>Typeable</a> allows a concrete representation of a type
grto be calculated.
class Typeable (a :: k)

-- | Observe a type representation for the type of a value.
typeOf :: forall a. Typeable a => a -> TypeRep

-- | Takes a value of type <tt>a</tt> and returns a concrete representation
grof that type.
typeRep :: forall proxy a. Typeable a => proxy a -> TypeRep

-- | Propositional equality. If <tt>a :~: b</tt> is inhabited by some
grterminating value, then the type <tt>a</tt> is the same as the type
gr<tt>b</tt>. To use this equality in practice, pattern-match on the
gr<tt>a :~: b</tt> to get out the <tt>Refl</tt> constructor; in the body
grof the pattern-match, the compiler knows that <tt>a ~ b</tt>.
data a (:~:) b
[Refl] :: a :~: a

-- | Kind heterogeneous propositional equality. Like <a>:~:</a>, <tt>a :~~:
grb</tt> is inhabited by a terminating value if and only if <tt>a</tt>
gris the same type as <tt>b</tt>.
data (a :: k1) (:~~:) (b :: k2)
[HRefl] :: a :~~: a

-- | The type-safe cast operation
cast :: forall a b. (Typeable a, Typeable b) => a -> Maybe b

-- | Extract a witness of equality of two types
eqT :: forall a b. (Typeable a, Typeable b) => Maybe (a :~: b)

-- | A flexible variation parameterised in a type constructor
gcast :: forall a b c. (Typeable a, Typeable b) => c a -> Maybe (c b)

-- | Cast over <tt>k1 -&gt; k2</tt>
gcast1 :: forall c t t' a. (Typeable t, Typeable t') => c (t a) -> Maybe (c (t' a))

-- | Cast over <tt>k1 -&gt; k2 -&gt; k3</tt>
gcast2 :: forall c t t' a b. (Typeable t, Typeable t') => c (t a b) -> Maybe (c (t' a b))

-- | <a>Proxy</a> is a type that holds no data, but has a phantom parameter
grof arbitrary type (or even kind). Its use is to provide type
grinformation, even though there is no value available of that type (or
grit may be too costly to create one).
gr
grHistorically, <tt><a>Proxy</a> :: <a>Proxy</a> a</tt> is a safer
gralternative to the <tt>'undefined :: a'</tt> idiom.
gr
gr<pre>
gr&gt;&gt;&gt; Proxy :: Proxy (Void, Int -&gt; Int)
grProxy
gr</pre>
gr
grProxy can even hold types of higher kinds,
gr
gr<pre>
gr&gt;&gt;&gt; Proxy :: Proxy Either
grProxy
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; Proxy :: Proxy Functor
grProxy
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; Proxy :: Proxy complicatedStructure
grProxy
gr</pre>
data Proxy t
Proxy :: Proxy t

-- | A quantified type representation.
type TypeRep = SomeTypeRep

-- | Force a <a>TypeRep</a> to normal form.
rnfTypeRep :: TypeRep -> ()

-- | Show a type representation
showsTypeRep :: TypeRep -> ShowS

-- | Build a function type.
mkFunTy :: TypeRep -> TypeRep -> TypeRep

-- | Applies a type to a function type. Returns: <tt>Just u</tt> if the
grfirst argument represents a function of type <tt>t -&gt; u</tt> and
grthe second argument represents a function of type <tt>t</tt>.
grOtherwise, returns <tt>Nothing</tt>.
funResultTy :: TypeRep -> TypeRep -> Maybe TypeRep

-- | Splits a type constructor application. Note that if the type
grconstructor is polymorphic, this will not return the kinds that were
grused.
splitTyConApp :: TypeRep -> (TyCon, [TypeRep])

-- | Observe the argument types of a type representation
typeRepArgs :: TypeRep -> [TypeRep]

-- | Observe the type constructor of a quantified type representation.
typeRepTyCon :: TypeRep -> TyCon

-- | Takes a value of type <tt>a</tt> and returns a concrete representation
grof that type.
typeRepFingerprint :: TypeRep -> Fingerprint
data TyCon
tyConPackage :: TyCon -> String
tyConModule :: TyCon -> String
tyConName :: TyCon -> String
rnfTyCon :: TyCon -> ()
tyConFingerprint :: TyCon -> Fingerprint
typeOf1 :: forall t (a :: *). Typeable t => t a -> TypeRep
typeOf2 :: forall t (a :: *) (b :: *). Typeable t => t a b -> TypeRep
typeOf3 :: forall t (a :: *) (b :: *) (c :: *). Typeable t => t a b c -> TypeRep
typeOf4 :: forall t (a :: *) (b :: *) (c :: *) (d :: *). Typeable t => t a b c d -> TypeRep
typeOf5 :: forall t (a :: *) (b :: *) (c :: *) (d :: *) (e :: *). Typeable t => t a b c d e -> TypeRep
typeOf6 :: forall t (a :: *) (b :: *) (c :: *) (d :: *) (e :: *) (f :: *). Typeable t => t a b c d e f -> TypeRep
typeOf7 :: forall t (a :: *) (b :: *) (c :: *) (d :: *) (e :: *) (f :: *) (g :: *). Typeable t => t a b c d e f g -> TypeRep


-- | The <a>ForeignPtr</a> type and operations. This module is part of the
grForeign Function Interface (FFI) and will usually be imported via the
gr<a>Foreign</a> module.
gr
grUnsafe API Only.
module Foreign.ForeignPtr.Unsafe

-- | This function extracts the pointer component of a foreign pointer.
grThis is a potentially dangerous operations, as if the argument to
gr<a>unsafeForeignPtrToPtr</a> is the last usage occurrence of the given
grforeign pointer, then its finalizer(s) will be run, which potentially
grinvalidates the plain pointer just obtained. Hence,
gr<a>touchForeignPtr</a> must be used wherever it has to be guaranteed
grthat the pointer lives on - i.e., has another usage occurrence.
gr
grTo avoid subtle coding errors, hand written marshalling code should
grpreferably use <a>withForeignPtr</a> rather than combinations of
gr<a>unsafeForeignPtrToPtr</a> and <a>touchForeignPtr</a>. However, the
grlatter routines are occasionally preferred in tool generated
grmarshalling code.
unsafeForeignPtrToPtr :: ForeignPtr a -> Ptr a


-- | The <a>ForeignPtr</a> type and operations. This module is part of the
grForeign Function Interface (FFI) and will usually be imported via the
gr<a>Foreign</a> module.
gr
grSafe API Only.

-- | <i>Deprecated: Safe is now the default, please use Foreign.ForeignPtr
grinstead</i>
module Foreign.ForeignPtr.Safe

-- | The type <a>ForeignPtr</a> represents references to objects that are
grmaintained in a foreign language, i.e., that are not part of the data
grstructures usually managed by the Haskell storage manager. The
gressential difference between <a>ForeignPtr</a>s and vanilla memory
grreferences of type <tt>Ptr a</tt> is that the former may be associated
grwith <i>finalizers</i>. A finalizer is a routine that is invoked when
grthe Haskell storage manager detects that - within the Haskell heap and
grstack - there are no more references left that are pointing to the
gr<a>ForeignPtr</a>. Typically, the finalizer will, then, invoke
grroutines in the foreign language that free the resources bound by the
grforeign object.
gr
grThe <a>ForeignPtr</a> is parameterised in the same way as <a>Ptr</a>.
grThe type argument of <a>ForeignPtr</a> should normally be an instance
grof class <a>Storable</a>.
data ForeignPtr a

-- | A finalizer is represented as a pointer to a foreign function that, at
grfinalisation time, gets as an argument a plain pointer variant of the
grforeign pointer that the finalizer is associated with.
gr
grNote that the foreign function <i>must</i> use the <tt>ccall</tt>
grcalling convention.
type FinalizerPtr a = FunPtr (Ptr a -> IO ())
type FinalizerEnvPtr env a = FunPtr (Ptr env -> Ptr a -> IO ())

-- | Turns a plain memory reference into a foreign pointer, and associates
gra finalizer with the reference. The finalizer will be executed after
grthe last reference to the foreign object is dropped. There is no
grguarantee of promptness, however the finalizer will be executed before
grthe program exits.
newForeignPtr :: FinalizerPtr a -> Ptr a -> IO (ForeignPtr a)

-- | Turns a plain memory reference into a foreign pointer that may be
grassociated with finalizers by using <a>addForeignPtrFinalizer</a>.
newForeignPtr_ :: Ptr a -> IO (ForeignPtr a)

-- | This function adds a finalizer to the given foreign object. The
grfinalizer will run <i>before</i> all other finalizers for the same
grobject which have already been registered.
addForeignPtrFinalizer :: FinalizerPtr a -> ForeignPtr a -> IO ()

-- | This variant of <a>newForeignPtr</a> adds a finalizer that expects an
grenvironment in addition to the finalized pointer. The environment that
grwill be passed to the finalizer is fixed by the second argument to
gr<a>newForeignPtrEnv</a>.
newForeignPtrEnv :: FinalizerEnvPtr env a -> Ptr env -> Ptr a -> IO (ForeignPtr a)

-- | Like <a>addForeignPtrFinalizerEnv</a> but allows the finalizer to be
grpassed an additional environment parameter to be passed to the
grfinalizer. The environment passed to the finalizer is fixed by the
grsecond argument to <a>addForeignPtrFinalizerEnv</a>
addForeignPtrFinalizerEnv :: FinalizerEnvPtr env a -> Ptr env -> ForeignPtr a -> IO ()

-- | This is a way to look at the pointer living inside a foreign object.
grThis function takes a function which is applied to that pointer. The
grresulting <a>IO</a> action is then executed. The foreign object is
grkept alive at least during the whole action, even if it is not used
grdirectly inside. Note that it is not safe to return the pointer from
grthe action and use it after the action completes. All uses of the
grpointer should be inside the <a>withForeignPtr</a> bracket. The reason
grfor this unsafeness is the same as for <a>unsafeForeignPtrToPtr</a>
grbelow: the finalizer may run earlier than expected, because the
grcompiler can only track usage of the <a>ForeignPtr</a> object, not a
gr<a>Ptr</a> object made from it.
gr
grThis function is normally used for marshalling data to or from the
grobject pointed to by the <a>ForeignPtr</a>, using the operations from
grthe <a>Storable</a> class.
withForeignPtr :: ForeignPtr a -> (Ptr a -> IO b) -> IO b

-- | Causes the finalizers associated with a foreign pointer to be run
grimmediately.
finalizeForeignPtr :: ForeignPtr a -> IO ()

-- | This function ensures that the foreign object in question is alive at
grthe given place in the sequence of IO actions. In particular
gr<a>withForeignPtr</a> does a <a>touchForeignPtr</a> after it executes
grthe user action.
gr
grNote that this function should not be used to express dependencies
grbetween finalizers on <a>ForeignPtr</a>s. For example, if the
grfinalizer for a <a>ForeignPtr</a> <tt>F1</tt> calls
gr<a>touchForeignPtr</a> on a second <a>ForeignPtr</a> <tt>F2</tt>, then
grthe only guarantee is that the finalizer for <tt>F2</tt> is never
grstarted before the finalizer for <tt>F1</tt>. They might be started
grtogether if for example both <tt>F1</tt> and <tt>F2</tt> are otherwise
grunreachable, and in that case the scheduler might end up running the
grfinalizer for <tt>F2</tt> first.
gr
grIn general, it is not recommended to use finalizers on separate
grobjects with ordering constraints between them. To express the
grordering robustly requires explicit synchronisation using
gr<tt>MVar</tt>s between the finalizers, but even then the runtime
grsometimes runs multiple finalizers sequentially in a single thread
gr(for performance reasons), so synchronisation between finalizers could
grresult in artificial deadlock. Another alternative is to use explicit
grreference counting.
touchForeignPtr :: ForeignPtr a -> IO ()

-- | This function casts a <a>ForeignPtr</a> parameterised by one type into
granother type.
castForeignPtr :: ForeignPtr a -> ForeignPtr b

-- | Allocate some memory and return a <a>ForeignPtr</a> to it. The memory
grwill be released automatically when the <a>ForeignPtr</a> is
grdiscarded.
gr
gr<a>mallocForeignPtr</a> is equivalent to
gr
gr<pre>
grdo { p &lt;- malloc; newForeignPtr finalizerFree p }
gr</pre>
gr
gralthough it may be implemented differently internally: you may not
grassume that the memory returned by <a>mallocForeignPtr</a> has been
grallocated with <a>malloc</a>.
gr
grGHC notes: <a>mallocForeignPtr</a> has a heavily optimised
grimplementation in GHC. It uses pinned memory in the garbage collected
grheap, so the <a>ForeignPtr</a> does not require a finalizer to free
grthe memory. Use of <a>mallocForeignPtr</a> and associated functions is
grstrongly recommended in preference to <tt>newForeignPtr</tt> with a
grfinalizer.
mallocForeignPtr :: Storable a => IO (ForeignPtr a)

-- | This function is similar to <a>mallocForeignPtr</a>, except that the
grsize of the memory required is given explicitly as a number of bytes.
mallocForeignPtrBytes :: Int -> IO (ForeignPtr a)

-- | This function is similar to <a>mallocArray</a>, but yields a memory
grarea that has a finalizer attached that releases the memory area. As
grwith <a>mallocForeignPtr</a>, it is not guaranteed that the block of
grmemory was allocated by <a>malloc</a>.
mallocForeignPtrArray :: Storable a => Int -> IO (ForeignPtr a)

-- | This function is similar to <a>mallocArray0</a>, but yields a memory
grarea that has a finalizer attached that releases the memory area. As
grwith <a>mallocForeignPtr</a>, it is not guaranteed that the block of
grmemory was allocated by <a>malloc</a>.
mallocForeignPtrArray0 :: Storable a => Int -> IO (ForeignPtr a)


-- | The <a>ForeignPtr</a> type and operations. This module is part of the
grForeign Function Interface (FFI) and will usually be imported via the
gr<a>Foreign</a> module.
gr
grFor non-portable support of Haskell finalizers, see the
gr<a>Foreign.Concurrent</a> module.
module Foreign.ForeignPtr

-- | The type <a>ForeignPtr</a> represents references to objects that are
grmaintained in a foreign language, i.e., that are not part of the data
grstructures usually managed by the Haskell storage manager. The
gressential difference between <a>ForeignPtr</a>s and vanilla memory
grreferences of type <tt>Ptr a</tt> is that the former may be associated
grwith <i>finalizers</i>. A finalizer is a routine that is invoked when
grthe Haskell storage manager detects that - within the Haskell heap and
grstack - there are no more references left that are pointing to the
gr<a>ForeignPtr</a>. Typically, the finalizer will, then, invoke
grroutines in the foreign language that free the resources bound by the
grforeign object.
gr
grThe <a>ForeignPtr</a> is parameterised in the same way as <a>Ptr</a>.
grThe type argument of <a>ForeignPtr</a> should normally be an instance
grof class <a>Storable</a>.
data ForeignPtr a

-- | A finalizer is represented as a pointer to a foreign function that, at
grfinalisation time, gets as an argument a plain pointer variant of the
grforeign pointer that the finalizer is associated with.
gr
grNote that the foreign function <i>must</i> use the <tt>ccall</tt>
grcalling convention.
type FinalizerPtr a = FunPtr (Ptr a -> IO ())
type FinalizerEnvPtr env a = FunPtr (Ptr env -> Ptr a -> IO ())

-- | Turns a plain memory reference into a foreign pointer, and associates
gra finalizer with the reference. The finalizer will be executed after
grthe last reference to the foreign object is dropped. There is no
grguarantee of promptness, however the finalizer will be executed before
grthe program exits.
newForeignPtr :: FinalizerPtr a -> Ptr a -> IO (ForeignPtr a)

-- | Turns a plain memory reference into a foreign pointer that may be
grassociated with finalizers by using <a>addForeignPtrFinalizer</a>.
newForeignPtr_ :: Ptr a -> IO (ForeignPtr a)

-- | This function adds a finalizer to the given foreign object. The
grfinalizer will run <i>before</i> all other finalizers for the same
grobject which have already been registered.
addForeignPtrFinalizer :: FinalizerPtr a -> ForeignPtr a -> IO ()

-- | This variant of <a>newForeignPtr</a> adds a finalizer that expects an
grenvironment in addition to the finalized pointer. The environment that
grwill be passed to the finalizer is fixed by the second argument to
gr<a>newForeignPtrEnv</a>.
newForeignPtrEnv :: FinalizerEnvPtr env a -> Ptr env -> Ptr a -> IO (ForeignPtr a)

-- | Like <a>addForeignPtrFinalizerEnv</a> but allows the finalizer to be
grpassed an additional environment parameter to be passed to the
grfinalizer. The environment passed to the finalizer is fixed by the
grsecond argument to <a>addForeignPtrFinalizerEnv</a>
addForeignPtrFinalizerEnv :: FinalizerEnvPtr env a -> Ptr env -> ForeignPtr a -> IO ()

-- | This is a way to look at the pointer living inside a foreign object.
grThis function takes a function which is applied to that pointer. The
grresulting <a>IO</a> action is then executed. The foreign object is
grkept alive at least during the whole action, even if it is not used
grdirectly inside. Note that it is not safe to return the pointer from
grthe action and use it after the action completes. All uses of the
grpointer should be inside the <a>withForeignPtr</a> bracket. The reason
grfor this unsafeness is the same as for <a>unsafeForeignPtrToPtr</a>
grbelow: the finalizer may run earlier than expected, because the
grcompiler can only track usage of the <a>ForeignPtr</a> object, not a
gr<a>Ptr</a> object made from it.
gr
grThis function is normally used for marshalling data to or from the
grobject pointed to by the <a>ForeignPtr</a>, using the operations from
grthe <a>Storable</a> class.
withForeignPtr :: ForeignPtr a -> (Ptr a -> IO b) -> IO b

-- | Causes the finalizers associated with a foreign pointer to be run
grimmediately.
finalizeForeignPtr :: ForeignPtr a -> IO ()

-- | This function ensures that the foreign object in question is alive at
grthe given place in the sequence of IO actions. In particular
gr<a>withForeignPtr</a> does a <a>touchForeignPtr</a> after it executes
grthe user action.
gr
grNote that this function should not be used to express dependencies
grbetween finalizers on <a>ForeignPtr</a>s. For example, if the
grfinalizer for a <a>ForeignPtr</a> <tt>F1</tt> calls
gr<a>touchForeignPtr</a> on a second <a>ForeignPtr</a> <tt>F2</tt>, then
grthe only guarantee is that the finalizer for <tt>F2</tt> is never
grstarted before the finalizer for <tt>F1</tt>. They might be started
grtogether if for example both <tt>F1</tt> and <tt>F2</tt> are otherwise
grunreachable, and in that case the scheduler might end up running the
grfinalizer for <tt>F2</tt> first.
gr
grIn general, it is not recommended to use finalizers on separate
grobjects with ordering constraints between them. To express the
grordering robustly requires explicit synchronisation using
gr<tt>MVar</tt>s between the finalizers, but even then the runtime
grsometimes runs multiple finalizers sequentially in a single thread
gr(for performance reasons), so synchronisation between finalizers could
grresult in artificial deadlock. Another alternative is to use explicit
grreference counting.
touchForeignPtr :: ForeignPtr a -> IO ()

-- | This function casts a <a>ForeignPtr</a> parameterised by one type into
granother type.
castForeignPtr :: ForeignPtr a -> ForeignPtr b

-- | Advances the given address by the given offset in bytes.
gr
grThe new <a>ForeignPtr</a> shares the finalizer of the original,
grequivalent from a finalization standpoint to just creating another
grreference to the original. That is, the finalizer will not be called
grbefore the new <a>ForeignPtr</a> is unreachable, nor will it be called
gran additional time due to this call, and the finalizer will be called
grwith the same address that it would have had this call not happened,
gr*not* the new address.
plusForeignPtr :: ForeignPtr a -> Int -> ForeignPtr b

-- | Allocate some memory and return a <a>ForeignPtr</a> to it. The memory
grwill be released automatically when the <a>ForeignPtr</a> is
grdiscarded.
gr
gr<a>mallocForeignPtr</a> is equivalent to
gr
gr<pre>
grdo { p &lt;- malloc; newForeignPtr finalizerFree p }
gr</pre>
gr
gralthough it may be implemented differently internally: you may not
grassume that the memory returned by <a>mallocForeignPtr</a> has been
grallocated with <a>malloc</a>.
gr
grGHC notes: <a>mallocForeignPtr</a> has a heavily optimised
grimplementation in GHC. It uses pinned memory in the garbage collected
grheap, so the <a>ForeignPtr</a> does not require a finalizer to free
grthe memory. Use of <a>mallocForeignPtr</a> and associated functions is
grstrongly recommended in preference to <tt>newForeignPtr</tt> with a
grfinalizer.
mallocForeignPtr :: Storable a => IO (ForeignPtr a)

-- | This function is similar to <a>mallocForeignPtr</a>, except that the
grsize of the memory required is given explicitly as a number of bytes.
mallocForeignPtrBytes :: Int -> IO (ForeignPtr a)

-- | This function is similar to <a>mallocArray</a>, but yields a memory
grarea that has a finalizer attached that releases the memory area. As
grwith <a>mallocForeignPtr</a>, it is not guaranteed that the block of
grmemory was allocated by <a>malloc</a>.
mallocForeignPtrArray :: Storable a => Int -> IO (ForeignPtr a)

-- | This function is similar to <a>mallocArray0</a>, but yields a memory
grarea that has a finalizer attached that releases the memory area. As
grwith <a>mallocForeignPtr</a>, it is not guaranteed that the block of
grmemory was allocated by <a>malloc</a>.
mallocForeignPtrArray0 :: Storable a => Int -> IO (ForeignPtr a)


-- | Buffers used in the IO system
module GHC.IO.Buffer

-- | A mutable array of bytes that can be passed to foreign functions.
gr
grThe buffer is represented by a record, where the record contains the
grraw buffer and the start/end points of the filled portion. The buffer
grcontents itself is mutable, but the rest of the record is immutable.
grThis is a slightly odd mix, but it turns out to be quite practical: by
grmaking all the buffer metadata immutable, we can have operations on
grbuffer metadata outside of the IO monad.
gr
grThe "live" elements of the buffer are those between the <a>bufL</a>
grand <a>bufR</a> offsets. In an empty buffer, <a>bufL</a> is equal to
gr<a>bufR</a>, but they might not be zero: for example, the buffer might
grcorrespond to a memory-mapped file and in which case <a>bufL</a> will
grpoint to the next location to be written, which is not necessarily the
grbeginning of the file.
data Buffer e
Buffer :: !(RawBuffer e) -> BufferState -> !Int -> !Int -> !Int -> Buffer e
[bufRaw] :: Buffer e -> !(RawBuffer e)
[bufState] :: Buffer e -> BufferState
[bufSize] :: Buffer e -> !Int
[bufL] :: Buffer e -> !Int
[bufR] :: Buffer e -> !Int
data BufferState
ReadBuffer :: BufferState
WriteBuffer :: BufferState
type CharBuffer = Buffer Char
type CharBufElem = Char
newByteBuffer :: Int -> BufferState -> IO (Buffer Word8)
newCharBuffer :: Int -> BufferState -> IO CharBuffer
newBuffer :: Int -> Int -> BufferState -> IO (Buffer e)
emptyBuffer :: RawBuffer e -> Int -> BufferState -> Buffer e
bufferRemove :: Int -> Buffer e -> Buffer e
bufferAdd :: Int -> Buffer e -> Buffer e

-- | slides the contents of the buffer to the beginning
slideContents :: Buffer Word8 -> IO (Buffer Word8)
bufferAdjustL :: Int -> Buffer e -> Buffer e
isEmptyBuffer :: Buffer e -> Bool
isFullBuffer :: Buffer e -> Bool
isFullCharBuffer :: Buffer e -> Bool
isWriteBuffer :: Buffer e -> Bool
bufferElems :: Buffer e -> Int
bufferAvailable :: Buffer e -> Int
summaryBuffer :: Buffer a -> String
withBuffer :: Buffer e -> (Ptr e -> IO a) -> IO a
withRawBuffer :: RawBuffer e -> (Ptr e -> IO a) -> IO a
checkBuffer :: Buffer a -> IO ()
type RawBuffer e = ForeignPtr e
readWord8Buf :: RawBuffer Word8 -> Int -> IO Word8
writeWord8Buf :: RawBuffer Word8 -> Int -> Word8 -> IO ()
type RawCharBuffer = RawBuffer CharBufElem
peekCharBuf :: RawCharBuffer -> Int -> IO Char
readCharBuf :: RawCharBuffer -> Int -> IO (Char, Int)
writeCharBuf :: RawCharBuffer -> Int -> Char -> IO Int
readCharBufPtr :: Ptr CharBufElem -> Int -> IO (Char, Int)
writeCharBufPtr :: Ptr CharBufElem -> Int -> Char -> IO Int
charSize :: Int
instance GHC.Classes.Eq GHC.IO.Buffer.BufferState


-- | Types for text encoding/decoding
module GHC.IO.Encoding.Types
data BufferCodec from to state
BufferCodec :: CodeBuffer from to -> Buffer from -> Buffer to -> IO (Buffer from, Buffer to) -> IO () -> IO state -> state -> IO () -> BufferCodec from to state

-- | The <tt>encode</tt> function translates elements of the buffer
gr<tt>from</tt> to the buffer <tt>to</tt>. It should translate as many
grelements as possible given the sizes of the buffers, including
grtranslating zero elements if there is either not enough room in
gr<tt>to</tt>, or <tt>from</tt> does not contain a complete multibyte
grsequence.
gr
grIf multiple CodingProgress returns are possible, OutputUnderflow must
grbe preferred to InvalidSequence. This allows GHC's IO library to
grassume that if we observe InvalidSequence there is at least a single
grelement available in the output buffer.
gr
grThe fact that as many elements as possible are translated is used by
grthe IO library in order to report translation errors at the point they
gractually occur, rather than when the buffer is translated.
[encode] :: BufferCodec from to state -> CodeBuffer from to

-- | The <tt>recover</tt> function is used to continue decoding in the
grpresence of invalid or unrepresentable sequences. This includes both
grthose detected by <tt>encode</tt> returning <tt>InvalidSequence</tt>
grand those that occur because the input byte sequence appears to be
grtruncated.
gr
grProgress will usually be made by skipping the first element of the
gr<tt>from</tt> buffer. This function should only be called if you are
grcertain that you wish to do this skipping and if the <tt>to</tt>
grbuffer has at least one element of free space. Because this function
grdeals with decoding failure, it assumes that the from buffer has at
grleast one element.
gr
gr<tt>recover</tt> may raise an exception rather than skipping anything.
gr
grCurrently, some implementations of <tt>recover</tt> may mutate the
grinput buffer. In particular, this feature is used to implement
grtransliteration.
[recover] :: BufferCodec from to state -> Buffer from -> Buffer to -> IO (Buffer from, Buffer to)

-- | Resources associated with the encoding may now be released. The
gr<tt>encode</tt> function may not be called again after calling
gr<tt>close</tt>.
[close] :: BufferCodec from to state -> IO ()

-- | Return the current state of the codec.
gr
grMany codecs are not stateful, and in these case the state can be
grrepresented as '()'. Other codecs maintain a state. For example,
grUTF-16 recognises a BOM (byte-order-mark) character at the beginning
grof the input, and remembers thereafter whether to use big-endian or
grlittle-endian mode. In this case, the state of the codec would include
grtwo pieces of information: whether we are at the beginning of the
grstream (the BOM only occurs at the beginning), and if not, whether to
gruse the big or little-endian encoding.
[getState] :: BufferCodec from to state -> IO state
[setState] :: BufferCodec from to state -> state -> IO ()

-- | A <a>TextEncoding</a> is a specification of a conversion scheme
grbetween sequences of bytes and sequences of Unicode characters.
gr
grFor example, UTF-8 is an encoding of Unicode characters into a
grsequence of bytes. The <a>TextEncoding</a> for UTF-8 is <tt>utf8</tt>.
data TextEncoding
TextEncoding :: String -> IO (TextDecoder dstate) -> IO (TextEncoder estate) -> TextEncoding

-- | a string that can be passed to <tt>mkTextEncoding</tt> to create an
grequivalent <a>TextEncoding</a>.
[textEncodingName] :: TextEncoding -> String

-- | Creates a means of decoding bytes into characters: the result must not
grbe shared between several byte sequences or simultaneously across
grthreads
[mkTextDecoder] :: TextEncoding -> IO (TextDecoder dstate)

-- | Creates a means of encode characters into bytes: the result must not
grbe shared between several character sequences or simultaneously across
grthreads
[mkTextEncoder] :: TextEncoding -> IO (TextEncoder estate)
type TextEncoder state = BufferCodec CharBufElem Word8 state
type TextDecoder state = BufferCodec Word8 CharBufElem state
type CodeBuffer from to = Buffer from -> Buffer to -> IO (CodingProgress, Buffer from, Buffer to)
type EncodeBuffer = CodeBuffer Char Word8
type DecodeBuffer = CodeBuffer Word8 Char

data CodingProgress

-- | Stopped because the input contains insufficient available elements, or
grall of the input sequence has been successfully translated.
InputUnderflow :: CodingProgress

-- | Stopped because the output contains insufficient free elements
OutputUnderflow :: CodingProgress

-- | Stopped because there are sufficient free elements in the output to
groutput at least one encoded ASCII character, but the input contains an
grinvalid or unrepresentable sequence
InvalidSequence :: CodingProgress
instance GHC.Show.Show GHC.IO.Encoding.Types.CodingProgress
instance GHC.Classes.Eq GHC.IO.Encoding.Types.CodingProgress
instance GHC.Show.Show GHC.IO.Encoding.Types.TextEncoding


-- | Mutable references in the IO monad.
module Data.IORef

-- | A mutable variable in the <a>IO</a> monad
data IORef a

-- | Build a new <a>IORef</a>
newIORef :: a -> IO (IORef a)

-- | Read the value of an <a>IORef</a>
readIORef :: IORef a -> IO a

-- | Write a new value into an <a>IORef</a>
writeIORef :: IORef a -> a -> IO ()

-- | Mutate the contents of an <a>IORef</a>.
gr
grBe warned that <a>modifyIORef</a> does not apply the function
grstrictly. This means if the program calls <a>modifyIORef</a> many
grtimes, but seldomly uses the value, thunks will pile up in memory
grresulting in a space leak. This is a common mistake made when using an
grIORef as a counter. For example, the following will likely produce a
grstack overflow:
gr
gr<pre>
grref &lt;- newIORef 0
grreplicateM_ 1000000 $ modifyIORef ref (+1)
grreadIORef ref &gt;&gt;= print
gr</pre>
gr
grTo avoid this problem, use <a>modifyIORef'</a> instead.
modifyIORef :: IORef a -> (a -> a) -> IO ()

-- | Strict version of <a>modifyIORef</a>
modifyIORef' :: IORef a -> (a -> a) -> IO ()

-- | Atomically modifies the contents of an <a>IORef</a>.
gr
grThis function is useful for using <a>IORef</a> in a safe way in a
grmultithreaded program. If you only have one <a>IORef</a>, then using
gr<a>atomicModifyIORef</a> to access and modify it will prevent race
grconditions.
gr
grExtending the atomicity to multiple <a>IORef</a>s is problematic, so
grit is recommended that if you need to do anything more complicated
grthen using <a>MVar</a> instead is a good idea.
gr
gr<a>atomicModifyIORef</a> does not apply the function strictly. This is
grimportant to know even if all you are doing is replacing the value.
grFor example, this will leak memory:
gr
gr<pre>
grref &lt;- newIORef '1'
grforever $ atomicModifyIORef ref (\_ -&gt; ('2', ()))
gr</pre>
gr
grUse <a>atomicModifyIORef'</a> or <a>atomicWriteIORef</a> to avoid this
grproblem.
atomicModifyIORef :: IORef a -> (a -> (a, b)) -> IO b

-- | Strict version of <a>atomicModifyIORef</a>. This forces both the value
grstored in the <a>IORef</a> as well as the value returned.
atomicModifyIORef' :: IORef a -> (a -> (a, b)) -> IO b

-- | Variant of <a>writeIORef</a> with the "barrier to reordering" property
grthat <a>atomicModifyIORef</a> has.
atomicWriteIORef :: IORef a -> a -> IO ()

-- | Make a <a>Weak</a> pointer to an <a>IORef</a>, using the second
grargument as a finalizer to run when <a>IORef</a> is garbage-collected
mkWeakIORef :: IORef a -> IO () -> IO (Weak (IORef a))


-- | Type classes for I/O providers.
module GHC.IO.Device

-- | A low-level I/O provider where the data is bytes in memory.
class RawIO a

-- | Read up to the specified number of bytes, returning the number of
grbytes actually read. This function should only block if there is no
grdata available. If there is not enough data available, then the
grfunction should just return the available data. A return value of zero
grindicates that the end of the data stream (e.g. end of file) has been
grreached.
read :: RawIO a => a -> Ptr Word8 -> Int -> IO Int

-- | Read up to the specified number of bytes, returning the number of
grbytes actually read, or <a>Nothing</a> if the end of the stream has
grbeen reached.
readNonBlocking :: RawIO a => a -> Ptr Word8 -> Int -> IO (Maybe Int)

-- | Write the specified number of bytes.
write :: RawIO a => a -> Ptr Word8 -> Int -> IO ()

-- | Write up to the specified number of bytes without blocking. Returns
grthe actual number of bytes written.
writeNonBlocking :: RawIO a => a -> Ptr Word8 -> Int -> IO Int

-- | I/O operations required for implementing a <tt>Handle</tt>.
class IODevice a

-- | <tt>ready dev write msecs</tt> returns <a>True</a> if the device has
grdata to read (if <tt>write</tt> is <a>False</a>) or space to write new
grdata (if <tt>write</tt> is <a>True</a>). <tt>msecs</tt> specifies how
grlong to wait, in milliseconds.
ready :: IODevice a => a -> Bool -> Int -> IO Bool

-- | closes the device. Further operations on the device should produce
grexceptions.
close :: IODevice a => a -> IO ()

-- | returns <a>True</a> if the device is a terminal or console.
isTerminal :: IODevice a => a -> IO Bool

-- | returns <a>True</a> if the device supports <a>seek</a> operations.
isSeekable :: IODevice a => a -> IO Bool

-- | seek to the specified position in the data.
seek :: IODevice a => a -> SeekMode -> Integer -> IO ()

-- | return the current position in the data.
tell :: IODevice a => a -> IO Integer

-- | return the size of the data.
getSize :: IODevice a => a -> IO Integer

-- | change the size of the data.
setSize :: IODevice a => a -> Integer -> IO ()

-- | for terminal devices, changes whether characters are echoed on the
grdevice.
setEcho :: IODevice a => a -> Bool -> IO ()

-- | returns the current echoing status.
getEcho :: IODevice a => a -> IO Bool

-- | some devices (e.g. terminals) support a "raw" mode where characters
grentered are immediately made available to the program. If available,
grthis operations enables raw mode.
setRaw :: IODevice a => a -> Bool -> IO ()

-- | returns the <a>IODeviceType</a> corresponding to this device.
devType :: IODevice a => a -> IO IODeviceType

-- | duplicates the device, if possible. The new device is expected to
grshare a file pointer with the original device (like Unix
gr<tt>dup</tt>).
dup :: IODevice a => a -> IO a

-- | <tt>dup2 source target</tt> replaces the target device with the source
grdevice. The target device is closed first, if necessary, and then it
gris made into a duplicate of the first device (like Unix
gr<tt>dup2</tt>).
dup2 :: IODevice a => a -> a -> IO a

-- | Type of a device that can be used to back a <a>Handle</a> (see also
gr<a>mkFileHandle</a>). The standard libraries provide creation of
gr<a>Handle</a>s via Posix file operations with file descriptors (see
gr<a>mkHandleFromFD</a>) with FD being the underlying <a>IODevice</a>
grinstance.
gr
grUsers may provide custom instances of <a>IODevice</a> which are
grexpected to conform the following rules:
data IODeviceType

-- | The standard libraries do not have direct support for this device
grtype, but a user implementation is expected to provide a list of file
grnames in the directory, in any order, separated by <tt>'\0'</tt>
grcharacters, excluding the <tt>"."</tt> and <tt>".."</tt> names. See
gralso <a>getDirectoryContents</a>. Seek operations are not supported on
grdirectories (other than to the zero position).
Directory :: IODeviceType

-- | A duplex communications channel (results in creation of a duplex
gr<a>Handle</a>). The standard libraries use this device type when
grcreating <a>Handle</a>s for open sockets.
Stream :: IODeviceType

-- | A file that may be read or written, and also may be seekable.
RegularFile :: IODeviceType

-- | A "raw" (disk) device which supports block binary read and write
groperations and may be seekable only to positions of certain
grgranularity (block- aligned).
RawDevice :: IODeviceType

-- | A mode that determines the effect of <tt>hSeek</tt> <tt>hdl mode
gri</tt>.
data SeekMode

-- | the position of <tt>hdl</tt> is set to <tt>i</tt>.
AbsoluteSeek :: SeekMode

-- | the position of <tt>hdl</tt> is set to offset <tt>i</tt> from the
grcurrent position.
RelativeSeek :: SeekMode

-- | the position of <tt>hdl</tt> is set to offset <tt>i</tt> from the end
grof the file.
SeekFromEnd :: SeekMode
instance GHC.Show.Show GHC.IO.Device.SeekMode
instance GHC.Read.Read GHC.IO.Device.SeekMode
instance GHC.Enum.Enum GHC.IO.Device.SeekMode
instance GHC.Arr.Ix GHC.IO.Device.SeekMode
instance GHC.Classes.Ord GHC.IO.Device.SeekMode
instance GHC.Classes.Eq GHC.IO.Device.SeekMode
instance GHC.Classes.Eq GHC.IO.Device.IODeviceType


-- | Class of buffered IO devices
module GHC.IO.BufferedIO

-- | The purpose of <a>BufferedIO</a> is to provide a common interface for
grI/O devices that can read and write data through a buffer. Devices
grthat implement <a>BufferedIO</a> include ordinary files, memory-mapped
grfiles, and bytestrings. The underlying device implementing a
gr<tt>Handle</tt> must provide <a>BufferedIO</a>.
class BufferedIO dev

-- | allocate a new buffer. The size of the buffer is at the discretion of
grthe device; e.g. for a memory-mapped file the buffer will probably
grcover the entire file.
newBuffer :: BufferedIO dev => dev -> BufferState -> IO (Buffer Word8)

-- | reads bytes into the buffer, blocking if there are no bytes available.
grReturns the number of bytes read (zero indicates end-of-file), and the
grnew buffer.
fillReadBuffer :: BufferedIO dev => dev -> Buffer Word8 -> IO (Int, Buffer Word8)

-- | reads bytes into the buffer without blocking. Returns the number of
grbytes read (Nothing indicates end-of-file), and the new buffer.
fillReadBuffer0 :: BufferedIO dev => dev -> Buffer Word8 -> IO (Maybe Int, Buffer Word8)

-- | Prepares an empty write buffer. This lets the device decide how to set
grup a write buffer: the buffer may need to point to a specific location
grin memory, for example. This is typically used by the client when
grswitching from reading to writing on a buffered read/write device.
gr
grThere is no corresponding operation for read buffers, because before
grreading the client will always call <a>fillReadBuffer</a>.
emptyWriteBuffer :: BufferedIO dev => dev -> Buffer Word8 -> IO (Buffer Word8)

-- | Flush all the data from the supplied write buffer out to the device.
grThe returned buffer should be empty, and ready for writing.
flushWriteBuffer :: BufferedIO dev => dev -> Buffer Word8 -> IO (Buffer Word8)

-- | Flush data from the supplied write buffer out to the device without
grblocking. Returns the number of bytes written and the remaining
grbuffer.
flushWriteBuffer0 :: BufferedIO dev => dev -> Buffer Word8 -> IO (Int, Buffer Word8)
readBuf :: RawIO dev => dev -> Buffer Word8 -> IO (Int, Buffer Word8)
readBufNonBlocking :: RawIO dev => dev -> Buffer Word8 -> IO (Maybe Int, Buffer Word8)
writeBuf :: RawIO dev => dev -> Buffer Word8 -> IO (Buffer Word8)
writeBufNonBlocking :: RawIO dev => dev -> Buffer Word8 -> IO (Int, Buffer Word8)


-- | Types for specifying how text encoding/decoding fails
module GHC.IO.Encoding.Failure

-- | The <a>CodingFailureMode</a> is used to construct
gr<tt>TextEncoding</tt>s, and specifies how they handle illegal
grsequences.
data CodingFailureMode

-- | Throw an error when an illegal sequence is encountered
ErrorOnCodingFailure :: CodingFailureMode

-- | Attempt to ignore and recover if an illegal sequence is encountered
IgnoreCodingFailure :: CodingFailureMode

-- | Replace with the closest visual match upon an illegal sequence
TransliterateCodingFailure :: CodingFailureMode

-- | Use the private-use escape mechanism to attempt to allow illegal
grsequences to be roundtripped.
RoundtripFailure :: CodingFailureMode
codingFailureModeSuffix :: CodingFailureMode -> String

-- | Some characters are actually "surrogate" codepoints defined for use in
grUTF-16. We need to signal an invalid character if we detect them when
grencoding a sequence of <a>Char</a>s into <a>Word8</a>s because they
grwon't give valid Unicode.
gr
grWe may also need to signal an invalid character if we detect them when
grencoding a sequence of <a>Char</a>s into <a>Word8</a>s because the
gr<a>RoundtripFailure</a> mode creates these to round-trip bytes through
grour internal UTF-16 encoding.
isSurrogate :: Char -> Bool
recoverDecode :: CodingFailureMode -> Buffer Word8 -> Buffer Char -> IO (Buffer Word8, Buffer Char)
recoverEncode :: CodingFailureMode -> Buffer Char -> Buffer Word8 -> IO (Buffer Char, Buffer Word8)
instance GHC.Show.Show GHC.IO.Encoding.Failure.CodingFailureMode


-- | UTF-8 Codec for the IO library
gr
grPortions Copyright : (c) Tom Harper 2008-2009, (c) Bryan O'Sullivan
gr2009, (c) Duncan Coutts 2009
module GHC.IO.Encoding.UTF8
utf8 :: TextEncoding

mkUTF8 :: CodingFailureMode -> TextEncoding
utf8_bom :: TextEncoding
mkUTF8_bom :: CodingFailureMode -> TextEncoding


-- | UTF-32 Codecs for the IO library
gr
grPortions Copyright : (c) Tom Harper 2008-2009, (c) Bryan O'Sullivan
gr2009, (c) Duncan Coutts 2009
module GHC.IO.Encoding.UTF32
utf32 :: TextEncoding

mkUTF32 :: CodingFailureMode -> TextEncoding
utf32_decode :: IORef (Maybe DecodeBuffer) -> DecodeBuffer
utf32_encode :: IORef Bool -> EncodeBuffer
utf32be :: TextEncoding

mkUTF32be :: CodingFailureMode -> TextEncoding
utf32be_decode :: DecodeBuffer
utf32be_encode :: EncodeBuffer
utf32le :: TextEncoding

mkUTF32le :: CodingFailureMode -> TextEncoding
utf32le_decode :: DecodeBuffer
utf32le_encode :: EncodeBuffer


-- | UTF-16 Codecs for the IO library
gr
grPortions Copyright : (c) Tom Harper 2008-2009, (c) Bryan O'Sullivan
gr2009, (c) Duncan Coutts 2009
module GHC.IO.Encoding.UTF16
utf16 :: TextEncoding

mkUTF16 :: CodingFailureMode -> TextEncoding
utf16_decode :: IORef (Maybe DecodeBuffer) -> DecodeBuffer
utf16_encode :: IORef Bool -> EncodeBuffer
utf16be :: TextEncoding

mkUTF16be :: CodingFailureMode -> TextEncoding
utf16be_decode :: DecodeBuffer
utf16be_encode :: EncodeBuffer
utf16le :: TextEncoding

mkUTF16le :: CodingFailureMode -> TextEncoding
utf16le_decode :: DecodeBuffer
utf16le_encode :: EncodeBuffer


-- | Single-byte encodings that map directly to Unicode code points.
gr
grPortions Copyright : (c) Tom Harper 2008-2009, (c) Bryan O'Sullivan
gr2009, (c) Duncan Coutts 2009
module GHC.IO.Encoding.Latin1
latin1 :: TextEncoding

mkLatin1 :: CodingFailureMode -> TextEncoding
latin1_checked :: TextEncoding

mkLatin1_checked :: CodingFailureMode -> TextEncoding

ascii :: TextEncoding

mkAscii :: CodingFailureMode -> TextEncoding
latin1_decode :: DecodeBuffer
ascii_decode :: DecodeBuffer
latin1_encode :: EncodeBuffer
latin1_checked_encode :: EncodeBuffer
ascii_encode :: EncodeBuffer


-- | Routines for testing return values and raising a <a>userError</a>
grexception in case of values indicating an error state.
module Foreign.Marshal.Error

-- | Execute an <a>IO</a> action, throwing a <a>userError</a> if the
grpredicate yields <a>True</a> when applied to the result returned by
grthe <a>IO</a> action. If no exception is raised, return the result of
grthe computation.
throwIf :: (a -> Bool) -> (a -> String) -> IO a -> IO a

-- | Like <a>throwIf</a>, but discarding the result
throwIf_ :: (a -> Bool) -> (a -> String) -> IO a -> IO ()

-- | Guards against negative result values
throwIfNeg :: (Ord a, Num a) => (a -> String) -> IO a -> IO a

-- | Like <a>throwIfNeg</a>, but discarding the result
throwIfNeg_ :: (Ord a, Num a) => (a -> String) -> IO a -> IO ()

-- | Guards against null pointers
throwIfNull :: String -> IO (Ptr a) -> IO (Ptr a)

-- | Discard the return value of an <a>IO</a> action

-- | <i>Deprecated: use <a>void</a> instead</i>
void :: IO a -> IO ()


-- | The module <a>Foreign.Marshal.Alloc</a> provides operations to
grallocate and deallocate blocks of raw memory (i.e., unstructured
grchunks of memory outside of the area maintained by the Haskell storage
grmanager). These memory blocks are commonly used to pass compound data
grstructures to foreign functions or to provide space in which compound
grresult values are obtained from foreign functions.
gr
grIf any of the allocation functions fails, an exception is thrown. In
grsome cases, memory exhaustion may mean the process is terminated. If
gr<a>free</a> or <a>reallocBytes</a> is applied to a memory area that
grhas been allocated with <a>alloca</a> or <a>allocaBytes</a>, the
grbehaviour is undefined. Any further access to memory areas allocated
grwith <a>alloca</a> or <a>allocaBytes</a>, after the computation that
grwas passed to the allocation function has terminated, leads to
grundefined behaviour. Any further access to the memory area referenced
grby a pointer passed to <a>realloc</a>, <a>reallocBytes</a>, or
gr<a>free</a> entails undefined behaviour.
gr
grAll storage allocated by functions that allocate based on a <i>size in
grbytes</i> must be sufficiently aligned for any of the basic foreign
grtypes that fits into the newly allocated storage. All storage
grallocated by functions that allocate based on a specific type must be
grsufficiently aligned for that type. Array allocation routines need to
grobey the same alignment constraints for each array element.
module Foreign.Marshal.Alloc

-- | <tt><a>alloca</a> f</tt> executes the computation <tt>f</tt>, passing
gras argument a pointer to a temporarily allocated block of memory
grsufficient to hold values of type <tt>a</tt>.
gr
grThe memory is freed when <tt>f</tt> terminates (either normally or via
gran exception), so the pointer passed to <tt>f</tt> must <i>not</i> be
grused after this.
alloca :: Storable a => (Ptr a -> IO b) -> IO b

-- | <tt><a>allocaBytes</a> n f</tt> executes the computation <tt>f</tt>,
grpassing as argument a pointer to a temporarily allocated block of
grmemory of <tt>n</tt> bytes. The block of memory is sufficiently
graligned for any of the basic foreign types that fits into a memory
grblock of the allocated size.
gr
grThe memory is freed when <tt>f</tt> terminates (either normally or via
gran exception), so the pointer passed to <tt>f</tt> must <i>not</i> be
grused after this.
allocaBytes :: Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned :: Int -> Int -> (Ptr a -> IO b) -> IO b

-- | Allocate a block of memory that is sufficient to hold values of type
gr<tt>a</tt>. The size of the area allocated is determined by the
gr<a>sizeOf</a> method from the instance of <a>Storable</a> for the
grappropriate type.
gr
grThe memory may be deallocated using <a>free</a> or
gr<a>finalizerFree</a> when no longer required.
malloc :: Storable a => IO (Ptr a)

-- | Allocate a block of memory of the given number of bytes. The block of
grmemory is sufficiently aligned for any of the basic foreign types that
grfits into a memory block of the allocated size.
gr
grThe memory may be deallocated using <a>free</a> or
gr<a>finalizerFree</a> when no longer required.
mallocBytes :: Int -> IO (Ptr a)

-- | Like <a>malloc</a> but memory is filled with bytes of value zero.
calloc :: Storable a => IO (Ptr a)

-- | Llike <a>mallocBytes</a> but memory is filled with bytes of value
grzero.
callocBytes :: Int -> IO (Ptr a)

-- | Resize a memory area that was allocated with <a>malloc</a> or
gr<a>mallocBytes</a> to the size needed to store values of type
gr<tt>b</tt>. The returned pointer may refer to an entirely different
grmemory area, but will be suitably aligned to hold values of type
gr<tt>b</tt>. The contents of the referenced memory area will be the
grsame as of the original pointer up to the minimum of the original size
grand the size of values of type <tt>b</tt>.
gr
grIf the argument to <a>realloc</a> is <a>nullPtr</a>, <a>realloc</a>
grbehaves like <a>malloc</a>.
realloc :: Storable b => Ptr a -> IO (Ptr b)

-- | Resize a memory area that was allocated with <a>malloc</a> or
gr<a>mallocBytes</a> to the given size. The returned pointer may refer
grto an entirely different memory area, but will be sufficiently aligned
grfor any of the basic foreign types that fits into a memory block of
grthe given size. The contents of the referenced memory area will be the
grsame as of the original pointer up to the minimum of the original size
grand the given size.
gr
grIf the pointer argument to <a>reallocBytes</a> is <a>nullPtr</a>,
gr<a>reallocBytes</a> behaves like <a>malloc</a>. If the requested size
gris 0, <a>reallocBytes</a> behaves like <a>free</a>.
reallocBytes :: Ptr a -> Int -> IO (Ptr a)

-- | Free a block of memory that was allocated with <a>malloc</a>,
gr<a>mallocBytes</a>, <a>realloc</a>, <a>reallocBytes</a>, <a>new</a> or
grany of the <tt>new</tt><i>X</i> functions in
gr<a>Foreign.Marshal.Array</a> or <a>Foreign.C.String</a>.
free :: Ptr a -> IO ()

-- | A pointer to a foreign function equivalent to <a>free</a>, which may
grbe used as a finalizer (cf <a>ForeignPtr</a>) for storage allocated
grwith <a>malloc</a>, <a>mallocBytes</a>, <a>realloc</a> or
gr<a>reallocBytes</a>.
finalizerFree :: FinalizerPtr a


-- | Utilities for primitive marshaling
module Foreign.Marshal.Utils

-- | <tt><a>with</a> val f</tt> executes the computation <tt>f</tt>,
grpassing as argument a pointer to a temporarily allocated block of
grmemory into which <tt>val</tt> has been marshalled (the combination of
gr<a>alloca</a> and <a>poke</a>).
gr
grThe memory is freed when <tt>f</tt> terminates (either normally or via
gran exception), so the pointer passed to <tt>f</tt> must <i>not</i> be
grused after this.
with :: Storable a => a -> (Ptr a -> IO b) -> IO b

-- | Allocate a block of memory and marshal a value into it (the
grcombination of <a>malloc</a> and <a>poke</a>). The size of the area
grallocated is determined by the <a>sizeOf</a> method from the instance
grof <a>Storable</a> for the appropriate type.
gr
grThe memory may be deallocated using <a>free</a> or
gr<a>finalizerFree</a> when no longer required.
new :: Storable a => a -> IO (Ptr a)

-- | Convert a Haskell <a>Bool</a> to its numeric representation
fromBool :: Num a => Bool -> a

-- | Convert a Boolean in numeric representation to a Haskell value
toBool :: (Eq a, Num a) => a -> Bool

-- | Allocate storage and marshal a storable value wrapped into a
gr<a>Maybe</a>
gr
gr<ul>
gr<li>the <a>nullPtr</a> is used to represent <a>Nothing</a></li>
gr</ul>
maybeNew :: (a -> IO (Ptr b)) -> (Maybe a -> IO (Ptr b))

-- | Converts a <tt>withXXX</tt> combinator into one marshalling a value
grwrapped into a <a>Maybe</a>, using <a>nullPtr</a> to represent
gr<a>Nothing</a>.
maybeWith :: (a -> (Ptr b -> IO c) -> IO c) -> (Maybe a -> (Ptr b -> IO c) -> IO c)

-- | Convert a peek combinator into a one returning <a>Nothing</a> if
grapplied to a <a>nullPtr</a>
maybePeek :: (Ptr a -> IO b) -> Ptr a -> IO (Maybe b)

-- | Replicates a <tt>withXXX</tt> combinator over a list of objects,
gryielding a list of marshalled objects
withMany :: (a -> (b -> res) -> res) -> [a] -> ([b] -> res) -> res

-- | Copies the given number of bytes from the second area (source) into
grthe first (destination); the copied areas may <i>not</i> overlap
copyBytes :: Ptr a -> Ptr a -> Int -> IO ()

-- | Copies the given number of bytes from the second area (source) into
grthe first (destination); the copied areas <i>may</i> overlap
moveBytes :: Ptr a -> Ptr a -> Int -> IO ()

-- | Fill a given number of bytes in memory area with a byte value.
fillBytes :: Ptr a -> Word8 -> Int -> IO ()


-- | Marshalling support: routines allocating, storing, and retrieving
grHaskell lists that are represented as arrays in the foreign language
module Foreign.Marshal.Array

-- | Allocate storage for the given number of elements of a storable type
gr(like <a>malloc</a>, but for multiple elements).
mallocArray :: Storable a => Int -> IO (Ptr a)

-- | Like <a>mallocArray</a>, but add an extra position to hold a special
grtermination element.
mallocArray0 :: Storable a => Int -> IO (Ptr a)

-- | Temporarily allocate space for the given number of elements (like
gr<a>alloca</a>, but for multiple elements).
allocaArray :: Storable a => Int -> (Ptr a -> IO b) -> IO b

-- | Like <a>allocaArray</a>, but add an extra position to hold a special
grtermination element.
allocaArray0 :: Storable a => Int -> (Ptr a -> IO b) -> IO b

-- | Adjust the size of an array
reallocArray :: Storable a => Ptr a -> Int -> IO (Ptr a)

-- | Adjust the size of an array including an extra position for the end
grmarker.
reallocArray0 :: Storable a => Ptr a -> Int -> IO (Ptr a)

-- | Like <a>mallocArray</a>, but allocated memory is filled with bytes of
grvalue zero.
callocArray :: Storable a => Int -> IO (Ptr a)

-- | Like <a>callocArray0</a>, but allocated memory is filled with bytes of
grvalue zero.
callocArray0 :: Storable a => Int -> IO (Ptr a)

-- | Convert an array of given length into a Haskell list. The
grimplementation is tail-recursive and so uses constant stack space.
peekArray :: Storable a => Int -> Ptr a -> IO [a]

-- | Convert an array terminated by the given end marker into a Haskell
grlist
peekArray0 :: (Storable a, Eq a) => a -> Ptr a -> IO [a]

-- | Write the list elements consecutive into memory
pokeArray :: Storable a => Ptr a -> [a] -> IO ()

-- | Write the list elements consecutive into memory and terminate them
grwith the given marker element
pokeArray0 :: Storable a => a -> Ptr a -> [a] -> IO ()

-- | Write a list of storable elements into a newly allocated, consecutive
grsequence of storable values (like <a>new</a>, but for multiple
grelements).
newArray :: Storable a => [a] -> IO (Ptr a)

-- | Write a list of storable elements into a newly allocated, consecutive
grsequence of storable values, where the end is fixed by the given end
grmarker
newArray0 :: Storable a => a -> [a] -> IO (Ptr a)

-- | Temporarily store a list of storable values in memory (like
gr<a>with</a>, but for multiple elements).
withArray :: Storable a => [a] -> (Ptr a -> IO b) -> IO b

-- | Like <a>withArray</a>, but a terminator indicates where the array ends
withArray0 :: Storable a => a -> [a] -> (Ptr a -> IO b) -> IO b

-- | Like <a>withArray</a>, but the action gets the number of values as an
gradditional parameter
withArrayLen :: Storable a => [a] -> (Int -> Ptr a -> IO b) -> IO b

-- | Like <a>withArrayLen</a>, but a terminator indicates where the array
grends
withArrayLen0 :: Storable a => a -> [a] -> (Int -> Ptr a -> IO b) -> IO b

-- | Copy the given number of elements from the second array (source) into
grthe first array (destination); the copied areas may <i>not</i> overlap
copyArray :: Storable a => Ptr a -> Ptr a -> Int -> IO ()

-- | Copy the given number of elements from the second array (source) into
grthe first array (destination); the copied areas <i>may</i> overlap
moveArray :: Storable a => Ptr a -> Ptr a -> Int -> IO ()

-- | Return the number of elements in an array, excluding the terminator
lengthArray0 :: (Storable a, Eq a) => a -> Ptr a -> IO Int

-- | Advance a pointer into an array by the given number of elements
advancePtr :: Storable a => Ptr a -> Int -> Ptr a


-- | Foreign marshalling support for CStrings with configurable encodings
module GHC.Foreign

-- | Marshal a NUL terminated C string into a Haskell string.
peekCString :: TextEncoding -> CString -> IO String

-- | Marshal a C string with explicit length into a Haskell string.
peekCStringLen :: TextEncoding -> CStringLen -> IO String

-- | Marshal a Haskell string into a NUL terminated C string.
gr
gr<ul>
gr<li>the Haskell string may <i>not</i> contain any NUL characters</li>
gr<li>new storage is allocated for the C string and must be explicitly
grfreed using <a>free</a> or <a>finalizerFree</a>.</li>
gr</ul>
newCString :: TextEncoding -> String -> IO CString

-- | Marshal a Haskell string into a C string (ie, character array) with
grexplicit length information.
gr
gr<ul>
gr<li>new storage is allocated for the C string and must be explicitly
grfreed using <a>free</a> or <a>finalizerFree</a>.</li>
gr</ul>
newCStringLen :: TextEncoding -> String -> IO CStringLen

-- | Marshal a Haskell string into a NUL terminated C string using
grtemporary storage.
gr
gr<ul>
gr<li>the Haskell string may <i>not</i> contain any NUL characters</li>
gr<li>the memory is freed when the subcomputation terminates (either
grnormally or via an exception), so the pointer to the temporary storage
grmust <i>not</i> be used after this.</li>
gr</ul>
withCString :: TextEncoding -> String -> (CString -> IO a) -> IO a

-- | Marshal a Haskell string into a C string (ie, character array) in
grtemporary storage, with explicit length information.
gr
gr<ul>
gr<li>the memory is freed when the subcomputation terminates (either
grnormally or via an exception), so the pointer to the temporary storage
grmust <i>not</i> be used after this.</li>
gr</ul>
withCStringLen :: TextEncoding -> String -> (CStringLen -> IO a) -> IO a

-- | Marshal a list of Haskell strings into an array of NUL terminated C
grstrings using temporary storage.
gr
gr<ul>
gr<li>the Haskell strings may <i>not</i> contain any NUL characters</li>
gr<li>the memory is freed when the subcomputation terminates (either
grnormally or via an exception), so the pointer to the temporary storage
grmust <i>not</i> be used after this.</li>
gr</ul>
withCStringsLen :: TextEncoding -> [String] -> (Int -> Ptr CString -> IO a) -> IO a

-- | Determines whether a character can be accurately encoded in a
gr<a>CString</a>.
gr
grPretty much anyone who uses this function is in a state of sin because
grwhether or not a character is encodable will, in general, depend on
grthe context in which it occurs.
charIsRepresentable :: TextEncoding -> Char -> IO Bool


-- | Utilities for primitive marshalling of C strings.
gr
grThe marshalling converts each Haskell character, representing a
grUnicode code point, to one or more bytes in a manner that, by default,
gris determined by the current locale. As a consequence, no guarantees
grcan be made about the relative length of a Haskell string and its
grcorresponding C string, and therefore all the marshalling routines
grinclude memory allocation. The translation between Unicode and the
grencoding of the current locale may be lossy.
module Foreign.C.String

-- | A C string is a reference to an array of C characters terminated by
grNUL.
type CString = Ptr CChar

-- | A string with explicit length information in bytes instead of a
grterminating NUL (allowing NUL characters in the middle of the string).
type CStringLen = (Ptr CChar, Int)

-- | Marshal a NUL terminated C string into a Haskell string.
peekCString :: CString -> IO String

-- | Marshal a C string with explicit length into a Haskell string.
peekCStringLen :: CStringLen -> IO String

-- | Marshal a Haskell string into a NUL terminated C string.
gr
gr<ul>
gr<li>the Haskell string may <i>not</i> contain any NUL characters</li>
gr<li>new storage is allocated for the C string and must be explicitly
grfreed using <a>free</a> or <a>finalizerFree</a>.</li>
gr</ul>
newCString :: String -> IO CString

-- | Marshal a Haskell string into a C string (ie, character array) with
grexplicit length information.
gr
gr<ul>
gr<li>new storage is allocated for the C string and must be explicitly
grfreed using <a>free</a> or <a>finalizerFree</a>.</li>
gr</ul>
newCStringLen :: String -> IO CStringLen

-- | Marshal a Haskell string into a NUL terminated C string using
grtemporary storage.
gr
gr<ul>
gr<li>the Haskell string may <i>not</i> contain any NUL characters</li>
gr<li>the memory is freed when the subcomputation terminates (either
grnormally or via an exception), so the pointer to the temporary storage
grmust <i>not</i> be used after this.</li>
gr</ul>
withCString :: String -> (CString -> IO a) -> IO a

-- | Marshal a Haskell string into a C string (ie, character array) in
grtemporary storage, with explicit length information.
gr
gr<ul>
gr<li>the memory is freed when the subcomputation terminates (either
grnormally or via an exception), so the pointer to the temporary storage
grmust <i>not</i> be used after this.</li>
gr</ul>
withCStringLen :: String -> (CStringLen -> IO a) -> IO a
charIsRepresentable :: Char -> IO Bool

-- | Convert a Haskell character to a C character. This function is only
grsafe on the first 256 characters.
castCharToCChar :: Char -> CChar

-- | Convert a C byte, representing a Latin-1 character, to the
grcorresponding Haskell character.
castCCharToChar :: CChar -> Char

-- | Convert a Haskell character to a C <tt>unsigned char</tt>. This
grfunction is only safe on the first 256 characters.
castCharToCUChar :: Char -> CUChar

-- | Convert a C <tt>unsigned char</tt>, representing a Latin-1 character,
grto the corresponding Haskell character.
castCUCharToChar :: CUChar -> Char

-- | Convert a Haskell character to a C <tt>signed char</tt>. This function
gris only safe on the first 256 characters.
castCharToCSChar :: Char -> CSChar

-- | Convert a C <tt>signed char</tt>, representing a Latin-1 character, to
grthe corresponding Haskell character.
castCSCharToChar :: CSChar -> Char

-- | Marshal a NUL terminated C string into a Haskell string.
peekCAString :: CString -> IO String

-- | Marshal a C string with explicit length into a Haskell string.
peekCAStringLen :: CStringLen -> IO String

-- | Marshal a Haskell string into a NUL terminated C string.
gr
gr<ul>
gr<li>the Haskell string may <i>not</i> contain any NUL characters</li>
gr<li>new storage is allocated for the C string and must be explicitly
grfreed using <a>free</a> or <a>finalizerFree</a>.</li>
gr</ul>
newCAString :: String -> IO CString

-- | Marshal a Haskell string into a C string (ie, character array) with
grexplicit length information.
gr
gr<ul>
gr<li>new storage is allocated for the C string and must be explicitly
grfreed using <a>free</a> or <a>finalizerFree</a>.</li>
gr</ul>
newCAStringLen :: String -> IO CStringLen

-- | Marshal a Haskell string into a NUL terminated C string using
grtemporary storage.
gr
gr<ul>
gr<li>the Haskell string may <i>not</i> contain any NUL characters</li>
gr<li>the memory is freed when the subcomputation terminates (either
grnormally or via an exception), so the pointer to the temporary storage
grmust <i>not</i> be used after this.</li>
gr</ul>
withCAString :: String -> (CString -> IO a) -> IO a

-- | Marshal a Haskell string into a C string (ie, character array) in
grtemporary storage, with explicit length information.
gr
gr<ul>
gr<li>the memory is freed when the subcomputation terminates (either
grnormally or via an exception), so the pointer to the temporary storage
grmust <i>not</i> be used after this.</li>
gr</ul>
withCAStringLen :: String -> (CStringLen -> IO a) -> IO a

-- | A C wide string is a reference to an array of C wide characters
grterminated by NUL.
type CWString = Ptr CWchar

-- | A wide character string with explicit length information in
gr<a>CWchar</a>s instead of a terminating NUL (allowing NUL characters
grin the middle of the string).
type CWStringLen = (Ptr CWchar, Int)

-- | Marshal a NUL terminated C wide string into a Haskell string.
peekCWString :: CWString -> IO String

-- | Marshal a C wide string with explicit length into a Haskell string.
peekCWStringLen :: CWStringLen -> IO String

-- | Marshal a Haskell string into a NUL terminated C wide string.
gr
gr<ul>
gr<li>the Haskell string may <i>not</i> contain any NUL characters</li>
gr<li>new storage is allocated for the C wide string and must be
grexplicitly freed using <a>free</a> or <a>finalizerFree</a>.</li>
gr</ul>
newCWString :: String -> IO CWString

-- | Marshal a Haskell string into a C wide string (ie, wide character
grarray) with explicit length information.
gr
gr<ul>
gr<li>new storage is allocated for the C wide string and must be
grexplicitly freed using <a>free</a> or <a>finalizerFree</a>.</li>
gr</ul>
newCWStringLen :: String -> IO CWStringLen

-- | Marshal a Haskell string into a NUL terminated C wide string using
grtemporary storage.
gr
gr<ul>
gr<li>the Haskell string may <i>not</i> contain any NUL characters</li>
gr<li>the memory is freed when the subcomputation terminates (either
grnormally or via an exception), so the pointer to the temporary storage
grmust <i>not</i> be used after this.</li>
gr</ul>
withCWString :: String -> (CWString -> IO a) -> IO a

-- | Marshal a Haskell string into a C wide string (i.e. wide character
grarray) in temporary storage, with explicit length information.
gr
gr<ul>
gr<li>the memory is freed when the subcomputation terminates (either
grnormally or via an exception), so the pointer to the temporary storage
grmust <i>not</i> be used after this.</li>
gr</ul>
withCWStringLen :: String -> (CWStringLen -> IO a) -> IO a


-- | Marshalling support. Unsafe API.
module Foreign.Marshal.Unsafe

-- | Sometimes an external entity is a pure function, except that it passes
grarguments and/or results via pointers. The function
gr<tt>unsafeLocalState</tt> permits the packaging of such entities as
grpure functions.
gr
grThe only IO operations allowed in the IO action passed to
gr<tt>unsafeLocalState</tt> are (a) local allocation (<tt>alloca</tt>,
gr<tt>allocaBytes</tt> and derived operations such as <tt>withArray</tt>
grand <tt>withCString</tt>), and (b) pointer operations
gr(<tt>Foreign.Storable</tt> and <tt>Foreign.Ptr</tt>) on the pointers
grto local storage, and (c) foreign functions whose only observable
greffect is to read and/or write the locally allocated memory. Passing
gran IO operation that does not obey these rules results in undefined
grbehaviour.
gr
grIt is expected that this operation will be replaced in a future
grrevision of Haskell.
unsafeLocalState :: IO a -> a


-- | FFI datatypes and operations that use or require concurrency (GHC
gronly).
module Foreign.Concurrent

-- | Turns a plain memory reference into a foreign object by associating a
grfinalizer - given by the monadic operation - with the reference. The
grstorage manager will start the finalizer, in a separate thread, some
grtime after the last reference to the <tt>ForeignPtr</tt> is dropped.
grThere is no guarantee of promptness, and in fact there is no guarantee
grthat the finalizer will eventually run at all.
gr
grNote that references from a finalizer do not necessarily prevent
granother object from being finalized. If A's finalizer refers to B
gr(perhaps using <tt>touchForeignPtr</tt>, then the only guarantee is
grthat B's finalizer will never be started before A's. If both A and B
grare unreachable, then both finalizers will start together. See
gr<tt>touchForeignPtr</tt> for more on finalizer ordering.
newForeignPtr :: Ptr a -> IO () -> IO (ForeignPtr a)

-- | This function adds a finalizer to the given <tt>ForeignPtr</tt>. The
grfinalizer will run <i>before</i> all other finalizers for the same
grobject which have already been registered.
gr
grThis is a variant of
gr<tt>Foreign.ForeignPtr.addForeignPtrFinalizer</tt>, where the
grfinalizer is an arbitrary <tt>IO</tt> action. When it is invoked, the
grfinalizer will run in a new thread.
gr
grNB. Be very careful with these finalizers. One common trap is that if
gra finalizer references another finalized value, it does not prevent
grthat value from being finalized. In particular, <tt>Handle</tt>s are
grfinalized objects, so a finalizer should not refer to a
gr<tt>Handle</tt> (including <tt>stdout</tt>, <tt>stdin</tt> or
gr<tt>stderr</tt>).
addForeignPtrFinalizer :: ForeignPtr a -> IO () -> IO ()


-- | C-specific Marshalling support: Handling of C "errno" error codes.
module Foreign.C.Error

-- | Haskell representation for <tt>errno</tt> values. The implementation
gris deliberately exposed, to allow users to add their own definitions
grof <a>Errno</a> values.
newtype Errno
Errno :: CInt -> Errno
eOK :: Errno
e2BIG :: Errno
eACCES :: Errno
eADDRINUSE :: Errno
eADDRNOTAVAIL :: Errno
eADV :: Errno
eAFNOSUPPORT :: Errno
eAGAIN :: Errno
eALREADY :: Errno
eBADF :: Errno
eBADMSG :: Errno
eBADRPC :: Errno
eBUSY :: Errno
eCHILD :: Errno
eCOMM :: Errno
eCONNABORTED :: Errno
eCONNREFUSED :: Errno
eCONNRESET :: Errno
eDEADLK :: Errno
eDESTADDRREQ :: Errno
eDIRTY :: Errno
eDOM :: Errno
eDQUOT :: Errno
eEXIST :: Errno
eFAULT :: Errno
eFBIG :: Errno
eFTYPE :: Errno
eHOSTDOWN :: Errno
eHOSTUNREACH :: Errno
eIDRM :: Errno
eILSEQ :: Errno
eINPROGRESS :: Errno
eINTR :: Errno
eINVAL :: Errno
eIO :: Errno
eISCONN :: Errno
eISDIR :: Errno
eLOOP :: Errno
eMFILE :: Errno
eMLINK :: Errno
eMSGSIZE :: Errno
eMULTIHOP :: Errno
eNAMETOOLONG :: Errno
eNETDOWN :: Errno
eNETRESET :: Errno
eNETUNREACH :: Errno
eNFILE :: Errno
eNOBUFS :: Errno
eNODATA :: Errno
eNODEV :: Errno
eNOENT :: Errno
eNOEXEC :: Errno
eNOLCK :: Errno
eNOLINK :: Errno
eNOMEM :: Errno
eNOMSG :: Errno
eNONET :: Errno
eNOPROTOOPT :: Errno
eNOSPC :: Errno
eNOSR :: Errno
eNOSTR :: Errno
eNOSYS :: Errno
eNOTBLK :: Errno
eNOTCONN :: Errno
eNOTDIR :: Errno
eNOTEMPTY :: Errno
eNOTSOCK :: Errno

eNOTSUP :: Errno
eNOTTY :: Errno
eNXIO :: Errno
eOPNOTSUPP :: Errno
ePERM :: Errno
ePFNOSUPPORT :: Errno
ePIPE :: Errno
ePROCLIM :: Errno
ePROCUNAVAIL :: Errno
ePROGMISMATCH :: Errno
ePROGUNAVAIL :: Errno
ePROTO :: Errno
ePROTONOSUPPORT :: Errno
ePROTOTYPE :: Errno
eRANGE :: Errno
eREMCHG :: Errno
eREMOTE :: Errno
eROFS :: Errno
eRPCMISMATCH :: Errno
eRREMOTE :: Errno
eSHUTDOWN :: Errno
eSOCKTNOSUPPORT :: Errno
eSPIPE :: Errno
eSRCH :: Errno
eSRMNT :: Errno
eSTALE :: Errno
eTIME :: Errno
eTIMEDOUT :: Errno
eTOOMANYREFS :: Errno
eTXTBSY :: Errno
eUSERS :: Errno
eWOULDBLOCK :: Errno
eXDEV :: Errno

-- | Yield <a>True</a> if the given <a>Errno</a> value is valid on the
grsystem. This implies that the <a>Eq</a> instance of <a>Errno</a> is
gralso system dependent as it is only defined for valid values of
gr<a>Errno</a>.
isValidErrno :: Errno -> Bool

-- | Get the current value of <tt>errno</tt> in the current thread.
getErrno :: IO Errno

-- | Reset the current thread's <tt>errno</tt> value to <a>eOK</a>.
resetErrno :: IO ()

-- | Construct an <a>IOError</a> based on the given <a>Errno</a> value. The
groptional information can be used to improve the accuracy of error
grmessages.
errnoToIOError :: String -> Errno -> Maybe Handle -> Maybe String -> IOError

-- | Throw an <a>IOError</a> corresponding to the current value of
gr<a>getErrno</a>.
throwErrno :: String -> IO a

-- | Throw an <a>IOError</a> corresponding to the current value of
gr<a>getErrno</a> if the result value of the <a>IO</a> action meets the
grgiven predicate.
throwErrnoIf :: (a -> Bool) -> String -> IO a -> IO a

-- | as <a>throwErrnoIf</a>, but discards the result of the <a>IO</a>
graction after error handling.
throwErrnoIf_ :: (a -> Bool) -> String -> IO a -> IO ()

-- | as <a>throwErrnoIf</a>, but retry the <a>IO</a> action when it yields
grthe error code <a>eINTR</a> - this amounts to the standard retry loop
grfor interrupted POSIX system calls.
throwErrnoIfRetry :: (a -> Bool) -> String -> IO a -> IO a

-- | as <a>throwErrnoIfRetry</a>, but discards the result.
throwErrnoIfRetry_ :: (a -> Bool) -> String -> IO a -> IO ()

-- | Throw an <a>IOError</a> corresponding to the current value of
gr<a>getErrno</a> if the <a>IO</a> action returns a result of
gr<tt>-1</tt>.
throwErrnoIfMinus1 :: (Eq a, Num a) => String -> IO a -> IO a

-- | as <a>throwErrnoIfMinus1</a>, but discards the result.
throwErrnoIfMinus1_ :: (Eq a, Num a) => String -> IO a -> IO ()

-- | Throw an <a>IOError</a> corresponding to the current value of
gr<a>getErrno</a> if the <a>IO</a> action returns a result of
gr<tt>-1</tt>, but retries in case of an interrupted operation.
throwErrnoIfMinus1Retry :: (Eq a, Num a) => String -> IO a -> IO a

-- | as <a>throwErrnoIfMinus1</a>, but discards the result.
throwErrnoIfMinus1Retry_ :: (Eq a, Num a) => String -> IO a -> IO ()

-- | Throw an <a>IOError</a> corresponding to the current value of
gr<a>getErrno</a> if the <a>IO</a> action returns <a>nullPtr</a>.
throwErrnoIfNull :: String -> IO (Ptr a) -> IO (Ptr a)

-- | Throw an <a>IOError</a> corresponding to the current value of
gr<a>getErrno</a> if the <a>IO</a> action returns <a>nullPtr</a>, but
grretry in case of an interrupted operation.
throwErrnoIfNullRetry :: String -> IO (Ptr a) -> IO (Ptr a)

-- | as <a>throwErrnoIfRetry</a>, but additionally if the operation yields
grthe error code <a>eAGAIN</a> or <a>eWOULDBLOCK</a>, an alternative
graction is executed before retrying.
throwErrnoIfRetryMayBlock :: (a -> Bool) -> String -> IO a -> IO b -> IO a

-- | as <a>throwErrnoIfRetryMayBlock</a>, but discards the result.
throwErrnoIfRetryMayBlock_ :: (a -> Bool) -> String -> IO a -> IO b -> IO ()

-- | as <a>throwErrnoIfMinus1Retry</a>, but checks for operations that
grwould block.
throwErrnoIfMinus1RetryMayBlock :: (Eq a, Num a) => String -> IO a -> IO b -> IO a

-- | as <a>throwErrnoIfMinus1RetryMayBlock</a>, but discards the result.
throwErrnoIfMinus1RetryMayBlock_ :: (Eq a, Num a) => String -> IO a -> IO b -> IO ()

-- | as <a>throwErrnoIfNullRetry</a>, but checks for operations that would
grblock.
throwErrnoIfNullRetryMayBlock :: String -> IO (Ptr a) -> IO b -> IO (Ptr a)

-- | as <a>throwErrno</a>, but exceptions include the given path when
grappropriate.
throwErrnoPath :: String -> FilePath -> IO a

-- | as <a>throwErrnoIf</a>, but exceptions include the given path when
grappropriate.
throwErrnoPathIf :: (a -> Bool) -> String -> FilePath -> IO a -> IO a

-- | as <a>throwErrnoIf_</a>, but exceptions include the given path when
grappropriate.
throwErrnoPathIf_ :: (a -> Bool) -> String -> FilePath -> IO a -> IO ()

-- | as <a>throwErrnoIfNull</a>, but exceptions include the given path when
grappropriate.
throwErrnoPathIfNull :: String -> FilePath -> IO (Ptr a) -> IO (Ptr a)

-- | as <a>throwErrnoIfMinus1</a>, but exceptions include the given path
grwhen appropriate.
throwErrnoPathIfMinus1 :: (Eq a, Num a) => String -> FilePath -> IO a -> IO a

-- | as <a>throwErrnoIfMinus1_</a>, but exceptions include the given path
grwhen appropriate.
throwErrnoPathIfMinus1_ :: (Eq a, Num a) => String -> FilePath -> IO a -> IO ()
instance GHC.Classes.Eq Foreign.C.Error.Errno


-- | Bundles the C specific FFI library functionality
module Foreign.C


-- | This module contains support for pooled memory management. Under this
grscheme, (re-)allocations belong to a given pool, and everything in a
grpool is deallocated when the pool itself is deallocated. This is
gruseful when <a>alloca</a> with its implicit allocation and
grdeallocation is not flexible enough, but explicit uses of
gr<a>malloc</a> and <a>free</a> are too awkward.
module Foreign.Marshal.Pool

-- | A memory pool.
data Pool

-- | Allocate a fresh memory pool.
newPool :: IO Pool

-- | Deallocate a memory pool and everything which has been allocated in
grthe pool itself.
freePool :: Pool -> IO ()

-- | Execute an action with a fresh memory pool, which gets automatically
grdeallocated (including its contents) after the action has finished.
withPool :: (Pool -> IO b) -> IO b

-- | Allocate space for storable type in the given pool. The size of the
grarea allocated is determined by the <a>sizeOf</a> method from the
grinstance of <a>Storable</a> for the appropriate type.
pooledMalloc :: Storable a => Pool -> IO (Ptr a)

-- | Allocate the given number of bytes of storage in the pool.
pooledMallocBytes :: Pool -> Int -> IO (Ptr a)

-- | Adjust the storage area for an element in the pool to the given size
grof the required type.
pooledRealloc :: Storable a => Pool -> Ptr a -> IO (Ptr a)

-- | Adjust the storage area for an element in the pool to the given size.
pooledReallocBytes :: Pool -> Ptr a -> Int -> IO (Ptr a)

-- | Allocate storage for the given number of elements of a storable type
grin the pool.
pooledMallocArray :: Storable a => Pool -> Int -> IO (Ptr a)

-- | Allocate storage for the given number of elements of a storable type
grin the pool, but leave room for an extra element to signal the end of
grthe array.
pooledMallocArray0 :: Storable a => Pool -> Int -> IO (Ptr a)

-- | Adjust the size of an array in the given pool.
pooledReallocArray :: Storable a => Pool -> Ptr a -> Int -> IO (Ptr a)

-- | Adjust the size of an array with an end marker in the given pool.
pooledReallocArray0 :: Storable a => Pool -> Ptr a -> Int -> IO (Ptr a)

-- | Allocate storage for a value in the given pool and marshal the value
grinto this storage.
pooledNew :: Storable a => Pool -> a -> IO (Ptr a)

-- | Allocate consecutive storage for a list of values in the given pool
grand marshal these values into it.
pooledNewArray :: Storable a => Pool -> [a] -> IO (Ptr a)

-- | Allocate consecutive storage for a list of values in the given pool
grand marshal these values into it, terminating the end with the given
grmarker.
pooledNewArray0 :: Storable a => Pool -> a -> [a] -> IO (Ptr a)


-- | Marshalling support
gr
grSafe API Only.

-- | <i>Deprecated: Safe is now the default, please use Foreign.Marshal
grinstead</i>
module Foreign.Marshal.Safe


-- | Marshalling support
module Foreign.Marshal


-- | A collection of data types, classes, and functions for interfacing
grwith another programming language.
gr
grSafe API Only.

-- | <i>Deprecated: Safe is now the default, please use Foreign instead</i>
module Foreign.Safe


-- | A collection of data types, classes, and functions for interfacing
grwith another programming language.
module Foreign


-- | POSIX data types: Haskell equivalents of the types defined by the
gr<tt>&lt;sys/types.h&gt;</tt> C header on a POSIX system.
module System.Posix.Types
newtype CDev
CDev :: Word64 -> CDev
newtype CIno
CIno :: Word64 -> CIno
newtype {-# CTYPE "mode_t" #-} CMode
CMode :: Word32 -> CMode
newtype COff
COff :: Int64 -> COff
newtype CPid
CPid :: Int32 -> CPid
newtype CSsize
CSsize :: Int64 -> CSsize
newtype CGid
CGid :: Word32 -> CGid
newtype CNlink
CNlink :: Word64 -> CNlink
newtype CUid
CUid :: Word32 -> CUid
newtype CCc
CCc :: Word8 -> CCc
newtype CSpeed
CSpeed :: Word32 -> CSpeed
newtype CTcflag
CTcflag :: Word32 -> CTcflag
newtype CRLim
CRLim :: Word64 -> CRLim

newtype {-# CTYPE "blksize_t" #-} CBlkSize
CBlkSize :: Int64 -> CBlkSize

newtype {-# CTYPE "blkcnt_t" #-} CBlkCnt
CBlkCnt :: Int64 -> CBlkCnt

newtype {-# CTYPE "clockid_t" #-} CClockId
CClockId :: Int32 -> CClockId

newtype {-# CTYPE "fsblkcnt_t" #-} CFsBlkCnt
CFsBlkCnt :: Word64 -> CFsBlkCnt

newtype {-# CTYPE "fsfilcnt_t" #-} CFsFilCnt
CFsFilCnt :: Word64 -> CFsFilCnt

newtype {-# CTYPE "id_t" #-} CId
CId :: Word32 -> CId

newtype {-# CTYPE "key_t" #-} CKey
CKey :: Int32 -> CKey

newtype {-# CTYPE "timer_t" #-} CTimer
CTimer :: (Ptr ()) -> CTimer
newtype Fd
Fd :: CInt -> Fd
type LinkCount = CNlink
type UserID = CUid
type GroupID = CGid
type ByteCount = CSize
type ClockTick = CClock
type EpochTime = CTime
type FileOffset = COff
type ProcessID = CPid
type ProcessGroupID = CPid
type DeviceID = CDev
type FileID = CIno
type FileMode = CMode
type Limit = CLong
instance GHC.Show.Show System.Posix.Types.Fd
instance GHC.Read.Read System.Posix.Types.Fd
instance Data.Bits.FiniteBits System.Posix.Types.Fd
instance Data.Bits.Bits System.Posix.Types.Fd
instance GHC.Real.Integral System.Posix.Types.Fd
instance GHC.Enum.Bounded System.Posix.Types.Fd
instance GHC.Real.Real System.Posix.Types.Fd
instance Foreign.Storable.Storable System.Posix.Types.Fd
instance GHC.Enum.Enum System.Posix.Types.Fd
instance GHC.Num.Num System.Posix.Types.Fd
instance GHC.Classes.Ord System.Posix.Types.Fd
instance GHC.Classes.Eq System.Posix.Types.Fd
instance GHC.Show.Show System.Posix.Types.CTimer
instance Foreign.Storable.Storable System.Posix.Types.CTimer
instance GHC.Classes.Ord System.Posix.Types.CTimer
instance GHC.Classes.Eq System.Posix.Types.CTimer
instance GHC.Show.Show System.Posix.Types.CKey
instance GHC.Read.Read System.Posix.Types.CKey
instance Data.Bits.FiniteBits System.Posix.Types.CKey
instance Data.Bits.Bits System.Posix.Types.CKey
instance GHC.Real.Integral System.Posix.Types.CKey
instance GHC.Enum.Bounded System.Posix.Types.CKey
instance GHC.Real.Real System.Posix.Types.CKey
instance Foreign.Storable.Storable System.Posix.Types.CKey
instance GHC.Enum.Enum System.Posix.Types.CKey
instance GHC.Num.Num System.Posix.Types.CKey
instance GHC.Classes.Ord System.Posix.Types.CKey
instance GHC.Classes.Eq System.Posix.Types.CKey
instance GHC.Show.Show System.Posix.Types.CId
instance GHC.Read.Read System.Posix.Types.CId
instance Data.Bits.FiniteBits System.Posix.Types.CId
instance Data.Bits.Bits System.Posix.Types.CId
instance GHC.Real.Integral System.Posix.Types.CId
instance GHC.Enum.Bounded System.Posix.Types.CId
instance GHC.Real.Real System.Posix.Types.CId
instance Foreign.Storable.Storable System.Posix.Types.CId
instance GHC.Enum.Enum System.Posix.Types.CId
instance GHC.Num.Num System.Posix.Types.CId
instance GHC.Classes.Ord System.Posix.Types.CId
instance GHC.Classes.Eq System.Posix.Types.CId
instance GHC.Show.Show System.Posix.Types.CFsFilCnt
instance GHC.Read.Read System.Posix.Types.CFsFilCnt
instance Data.Bits.FiniteBits System.Posix.Types.CFsFilCnt
instance Data.Bits.Bits System.Posix.Types.CFsFilCnt
instance GHC.Real.Integral System.Posix.Types.CFsFilCnt
instance GHC.Enum.Bounded System.Posix.Types.CFsFilCnt
instance GHC.Real.Real System.Posix.Types.CFsFilCnt
instance Foreign.Storable.Storable System.Posix.Types.CFsFilCnt
instance GHC.Enum.Enum System.Posix.Types.CFsFilCnt
instance GHC.Num.Num System.Posix.Types.CFsFilCnt
instance GHC.Classes.Ord System.Posix.Types.CFsFilCnt
instance GHC.Classes.Eq System.Posix.Types.CFsFilCnt
instance GHC.Show.Show System.Posix.Types.CFsBlkCnt
instance GHC.Read.Read System.Posix.Types.CFsBlkCnt
instance Data.Bits.FiniteBits System.Posix.Types.CFsBlkCnt
instance Data.Bits.Bits System.Posix.Types.CFsBlkCnt
instance GHC.Real.Integral System.Posix.Types.CFsBlkCnt
instance GHC.Enum.Bounded System.Posix.Types.CFsBlkCnt
instance GHC.Real.Real System.Posix.Types.CFsBlkCnt
instance Foreign.Storable.Storable System.Posix.Types.CFsBlkCnt
instance GHC.Enum.Enum System.Posix.Types.CFsBlkCnt
instance GHC.Num.Num System.Posix.Types.CFsBlkCnt
instance GHC.Classes.Ord System.Posix.Types.CFsBlkCnt
instance GHC.Classes.Eq System.Posix.Types.CFsBlkCnt
instance GHC.Show.Show System.Posix.Types.CClockId
instance GHC.Read.Read System.Posix.Types.CClockId
instance Data.Bits.FiniteBits System.Posix.Types.CClockId
instance Data.Bits.Bits System.Posix.Types.CClockId
instance GHC.Real.Integral System.Posix.Types.CClockId
instance GHC.Enum.Bounded System.Posix.Types.CClockId
instance GHC.Real.Real System.Posix.Types.CClockId
instance Foreign.Storable.Storable System.Posix.Types.CClockId
instance GHC.Enum.Enum System.Posix.Types.CClockId
instance GHC.Num.Num System.Posix.Types.CClockId
instance GHC.Classes.Ord System.Posix.Types.CClockId
instance GHC.Classes.Eq System.Posix.Types.CClockId
instance GHC.Show.Show System.Posix.Types.CBlkCnt
instance GHC.Read.Read System.Posix.Types.CBlkCnt
instance Data.Bits.FiniteBits System.Posix.Types.CBlkCnt
instance Data.Bits.Bits System.Posix.Types.CBlkCnt
instance GHC.Real.Integral System.Posix.Types.CBlkCnt
instance GHC.Enum.Bounded System.Posix.Types.CBlkCnt
instance GHC.Real.Real System.Posix.Types.CBlkCnt
instance Foreign.Storable.Storable System.Posix.Types.CBlkCnt
instance GHC.Enum.Enum System.Posix.Types.CBlkCnt
instance GHC.Num.Num System.Posix.Types.CBlkCnt
instance GHC.Classes.Ord System.Posix.Types.CBlkCnt
instance GHC.Classes.Eq System.Posix.Types.CBlkCnt
instance GHC.Show.Show System.Posix.Types.CBlkSize
instance GHC.Read.Read System.Posix.Types.CBlkSize
instance Data.Bits.FiniteBits System.Posix.Types.CBlkSize
instance Data.Bits.Bits System.Posix.Types.CBlkSize
instance GHC.Real.Integral System.Posix.Types.CBlkSize
instance GHC.Enum.Bounded System.Posix.Types.CBlkSize
instance GHC.Real.Real System.Posix.Types.CBlkSize
instance Foreign.Storable.Storable System.Posix.Types.CBlkSize
instance GHC.Enum.Enum System.Posix.Types.CBlkSize
instance GHC.Num.Num System.Posix.Types.CBlkSize
instance GHC.Classes.Ord System.Posix.Types.CBlkSize
instance GHC.Classes.Eq System.Posix.Types.CBlkSize
instance GHC.Show.Show System.Posix.Types.CRLim
instance GHC.Read.Read System.Posix.Types.CRLim
instance Data.Bits.FiniteBits System.Posix.Types.CRLim
instance Data.Bits.Bits System.Posix.Types.CRLim
instance GHC.Real.Integral System.Posix.Types.CRLim
instance GHC.Enum.Bounded System.Posix.Types.CRLim
instance GHC.Real.Real System.Posix.Types.CRLim
instance Foreign.Storable.Storable System.Posix.Types.CRLim
instance GHC.Enum.Enum System.Posix.Types.CRLim
instance GHC.Num.Num System.Posix.Types.CRLim
instance GHC.Classes.Ord System.Posix.Types.CRLim
instance GHC.Classes.Eq System.Posix.Types.CRLim
instance GHC.Show.Show System.Posix.Types.CTcflag
instance GHC.Read.Read System.Posix.Types.CTcflag
instance Data.Bits.FiniteBits System.Posix.Types.CTcflag
instance Data.Bits.Bits System.Posix.Types.CTcflag
instance GHC.Real.Integral System.Posix.Types.CTcflag
instance GHC.Enum.Bounded System.Posix.Types.CTcflag
instance GHC.Real.Real System.Posix.Types.CTcflag
instance Foreign.Storable.Storable System.Posix.Types.CTcflag
instance GHC.Enum.Enum System.Posix.Types.CTcflag
instance GHC.Num.Num System.Posix.Types.CTcflag
instance GHC.Classes.Ord System.Posix.Types.CTcflag
instance GHC.Classes.Eq System.Posix.Types.CTcflag
instance GHC.Show.Show System.Posix.Types.CSpeed
instance GHC.Read.Read System.Posix.Types.CSpeed
instance GHC.Real.Real System.Posix.Types.CSpeed
instance Foreign.Storable.Storable System.Posix.Types.CSpeed
instance GHC.Enum.Enum System.Posix.Types.CSpeed
instance GHC.Num.Num System.Posix.Types.CSpeed
instance GHC.Classes.Ord System.Posix.Types.CSpeed
instance GHC.Classes.Eq System.Posix.Types.CSpeed
instance GHC.Show.Show System.Posix.Types.CCc
instance GHC.Read.Read System.Posix.Types.CCc
instance GHC.Real.Real System.Posix.Types.CCc
instance Foreign.Storable.Storable System.Posix.Types.CCc
instance GHC.Enum.Enum System.Posix.Types.CCc
instance GHC.Num.Num System.Posix.Types.CCc
instance GHC.Classes.Ord System.Posix.Types.CCc
instance GHC.Classes.Eq System.Posix.Types.CCc
instance GHC.Show.Show System.Posix.Types.CUid
instance GHC.Read.Read System.Posix.Types.CUid
instance Data.Bits.FiniteBits System.Posix.Types.CUid
instance Data.Bits.Bits System.Posix.Types.CUid
instance GHC.Real.Integral System.Posix.Types.CUid
instance GHC.Enum.Bounded System.Posix.Types.CUid
instance GHC.Real.Real System.Posix.Types.CUid
instance Foreign.Storable.Storable System.Posix.Types.CUid
instance GHC.Enum.Enum System.Posix.Types.CUid
instance GHC.Num.Num System.Posix.Types.CUid
instance GHC.Classes.Ord System.Posix.Types.CUid
instance GHC.Classes.Eq System.Posix.Types.CUid
instance GHC.Show.Show System.Posix.Types.CNlink
instance GHC.Read.Read System.Posix.Types.CNlink
instance Data.Bits.FiniteBits System.Posix.Types.CNlink
instance Data.Bits.Bits System.Posix.Types.CNlink
instance GHC.Real.Integral System.Posix.Types.CNlink
instance GHC.Enum.Bounded System.Posix.Types.CNlink
instance GHC.Real.Real System.Posix.Types.CNlink
instance Foreign.Storable.Storable System.Posix.Types.CNlink
instance GHC.Enum.Enum System.Posix.Types.CNlink
instance GHC.Num.Num System.Posix.Types.CNlink
instance GHC.Classes.Ord System.Posix.Types.CNlink
instance GHC.Classes.Eq System.Posix.Types.CNlink
instance GHC.Show.Show System.Posix.Types.CGid
instance GHC.Read.Read System.Posix.Types.CGid
instance Data.Bits.FiniteBits System.Posix.Types.CGid
instance Data.Bits.Bits System.Posix.Types.CGid
instance GHC.Real.Integral System.Posix.Types.CGid
instance GHC.Enum.Bounded System.Posix.Types.CGid
instance GHC.Real.Real System.Posix.Types.CGid
instance Foreign.Storable.Storable System.Posix.Types.CGid
instance GHC.Enum.Enum System.Posix.Types.CGid
instance GHC.Num.Num System.Posix.Types.CGid
instance GHC.Classes.Ord System.Posix.Types.CGid
instance GHC.Classes.Eq System.Posix.Types.CGid
instance GHC.Show.Show System.Posix.Types.CSsize
instance GHC.Read.Read System.Posix.Types.CSsize
instance Data.Bits.FiniteBits System.Posix.Types.CSsize
instance Data.Bits.Bits System.Posix.Types.CSsize
instance GHC.Real.Integral System.Posix.Types.CSsize
instance GHC.Enum.Bounded System.Posix.Types.CSsize
instance GHC.Real.Real System.Posix.Types.CSsize
instance Foreign.Storable.Storable System.Posix.Types.CSsize
instance GHC.Enum.Enum System.Posix.Types.CSsize
instance GHC.Num.Num System.Posix.Types.CSsize
instance GHC.Classes.Ord System.Posix.Types.CSsize
instance GHC.Classes.Eq System.Posix.Types.CSsize
instance GHC.Show.Show System.Posix.Types.CPid
instance GHC.Read.Read System.Posix.Types.CPid
instance Data.Bits.FiniteBits System.Posix.Types.CPid
instance Data.Bits.Bits System.Posix.Types.CPid
instance GHC.Real.Integral System.Posix.Types.CPid
instance GHC.Enum.Bounded System.Posix.Types.CPid
instance GHC.Real.Real System.Posix.Types.CPid
instance Foreign.Storable.Storable System.Posix.Types.CPid
instance GHC.Enum.Enum System.Posix.Types.CPid
instance GHC.Num.Num System.Posix.Types.CPid
instance GHC.Classes.Ord System.Posix.Types.CPid
instance GHC.Classes.Eq System.Posix.Types.CPid
instance GHC.Show.Show System.Posix.Types.COff
instance GHC.Read.Read System.Posix.Types.COff
instance Data.Bits.FiniteBits System.Posix.Types.COff
instance Data.Bits.Bits System.Posix.Types.COff
instance GHC.Real.Integral System.Posix.Types.COff
instance GHC.Enum.Bounded System.Posix.Types.COff
instance GHC.Real.Real System.Posix.Types.COff
instance Foreign.Storable.Storable System.Posix.Types.COff
instance GHC.Enum.Enum System.Posix.Types.COff
instance GHC.Num.Num System.Posix.Types.COff
instance GHC.Classes.Ord System.Posix.Types.COff
instance GHC.Classes.Eq System.Posix.Types.COff
instance GHC.Show.Show System.Posix.Types.CMode
instance GHC.Read.Read System.Posix.Types.CMode
instance Data.Bits.FiniteBits System.Posix.Types.CMode
instance Data.Bits.Bits System.Posix.Types.CMode
instance GHC.Real.Integral System.Posix.Types.CMode
instance GHC.Enum.Bounded System.Posix.Types.CMode
instance GHC.Real.Real System.Posix.Types.CMode
instance Foreign.Storable.Storable System.Posix.Types.CMode
instance GHC.Enum.Enum System.Posix.Types.CMode
instance GHC.Num.Num System.Posix.Types.CMode
instance GHC.Classes.Ord System.Posix.Types.CMode
instance GHC.Classes.Eq System.Posix.Types.CMode
instance GHC.Show.Show System.Posix.Types.CIno
instance GHC.Read.Read System.Posix.Types.CIno
instance Data.Bits.FiniteBits System.Posix.Types.CIno
instance Data.Bits.Bits System.Posix.Types.CIno
instance GHC.Real.Integral System.Posix.Types.CIno
instance GHC.Enum.Bounded System.Posix.Types.CIno
instance GHC.Real.Real System.Posix.Types.CIno
instance Foreign.Storable.Storable System.Posix.Types.CIno
instance GHC.Enum.Enum System.Posix.Types.CIno
instance GHC.Num.Num System.Posix.Types.CIno
instance GHC.Classes.Ord System.Posix.Types.CIno
instance GHC.Classes.Eq System.Posix.Types.CIno
instance GHC.Show.Show System.Posix.Types.CDev
instance GHC.Read.Read System.Posix.Types.CDev
instance Data.Bits.FiniteBits System.Posix.Types.CDev
instance Data.Bits.Bits System.Posix.Types.CDev
instance GHC.Real.Integral System.Posix.Types.CDev
instance GHC.Enum.Bounded System.Posix.Types.CDev
instance GHC.Real.Real System.Posix.Types.CDev
instance Foreign.Storable.Storable System.Posix.Types.CDev
instance GHC.Enum.Enum System.Posix.Types.CDev
instance GHC.Num.Num System.Posix.Types.CDev
instance GHC.Classes.Ord System.Posix.Types.CDev
instance GHC.Classes.Eq System.Posix.Types.CDev


-- | The Dynamic interface provides basic support for dynamic types.
gr
grOperations for injecting values of arbitrary type into a dynamically
grtyped value, Dynamic, are provided, together with operations for
grconverting dynamic values into a concrete (monomorphic) type.
module Data.Dynamic

-- | A value of type <a>Dynamic</a> is an object encapsulated together with
grits type.
gr
grA <a>Dynamic</a> may only represent a monomorphic value; an attempt to
grcreate a value of type <a>Dynamic</a> from a polymorphically-typed
grexpression will result in an ambiguity error (see <a>toDyn</a>).
gr
gr<a>Show</a>ing a value of type <a>Dynamic</a> returns a pretty-printed
grrepresentation of the object's type; useful for debugging.
data Dynamic
[Dynamic] :: forall a. TypeRep a -> a -> Dynamic

-- | Converts an arbitrary value into an object of type <a>Dynamic</a>.
gr
grThe type of the object must be an instance of <a>Typeable</a>, which
grensures that only monomorphically-typed objects may be converted to
gr<a>Dynamic</a>. To convert a polymorphic object into <a>Dynamic</a>,
grgive it a monomorphic type signature. For example:
gr
gr<pre>
grtoDyn (id :: Int -&gt; Int)
gr</pre>
toDyn :: Typeable a => a -> Dynamic

-- | Converts a <a>Dynamic</a> object back into an ordinary Haskell value
grof the correct type. See also <a>fromDynamic</a>.
fromDyn :: Typeable a => Dynamic -> a -> a

-- | Converts a <a>Dynamic</a> object back into an ordinary Haskell value
grof the correct type. See also <a>fromDyn</a>.
fromDynamic :: forall a. Typeable a => Dynamic -> Maybe a
dynApply :: Dynamic -> Dynamic -> Maybe Dynamic
dynApp :: Dynamic -> Dynamic -> Dynamic
dynTypeRep :: Dynamic -> SomeTypeRep

-- | The class <a>Typeable</a> allows a concrete representation of a type
grto be calculated.
class Typeable (a :: k)
instance GHC.Show.Show Data.Dynamic.Dynamic
instance GHC.Exception.Exception Data.Dynamic.Dynamic


-- | Basic concurrency stuff.
module GHC.Conc.Sync

-- | A <a>ThreadId</a> is an abstract type representing a handle to a
grthread. <a>ThreadId</a> is an instance of <a>Eq</a>, <a>Ord</a> and
gr<a>Show</a>, where the <a>Ord</a> instance implements an arbitrary
grtotal ordering over <a>ThreadId</a>s. The <a>Show</a> instance lets
gryou convert an arbitrary-valued <a>ThreadId</a> to string form;
grshowing a <a>ThreadId</a> value is occasionally useful when debugging
gror diagnosing the behaviour of a concurrent program.
gr
gr<i>Note</i>: in GHC, if you have a <a>ThreadId</a>, you essentially
grhave a pointer to the thread itself. This means the thread itself
grcan't be garbage collected until you drop the <a>ThreadId</a>. This
grmisfeature will hopefully be corrected at a later date.
data ThreadId
ThreadId :: ThreadId# -> ThreadId

-- | Creates a new thread to run the <a>IO</a> computation passed as the
grfirst argument, and returns the <a>ThreadId</a> of the newly created
grthread.
gr
grThe new thread will be a lightweight, <i>unbound</i> thread. Foreign
grcalls made by this thread are not guaranteed to be made by any
grparticular OS thread; if you need foreign calls to be made by a
grparticular OS thread, then use <a>forkOS</a> instead.
gr
grThe new thread inherits the <i>masked</i> state of the parent (see
gr<a>mask</a>).
gr
grThe newly created thread has an exception handler that discards the
grexceptions <a>BlockedIndefinitelyOnMVar</a>,
gr<a>BlockedIndefinitelyOnSTM</a>, and <a>ThreadKilled</a>, and passes
grall other exceptions to the uncaught exception handler.
forkIO :: IO () -> IO ThreadId

-- | Like <a>forkIO</a>, but the child thread is passed a function that can
grbe used to unmask asynchronous exceptions. This function is typically
grused in the following way
gr
gr<pre>
gr... mask_ $ forkIOWithUnmask $ \unmask -&gt;
gr               catch (unmask ...) handler
gr</pre>
gr
grso that the exception handler in the child thread is established with
grasynchronous exceptions masked, meanwhile the main body of the child
grthread is executed in the unmasked state.
gr
grNote that the unmask function passed to the child thread should only
grbe used in that thread; the behaviour is undefined if it is invoked in
gra different thread.
forkIOWithUnmask :: ((forall a. IO a -> IO a) -> IO ()) -> IO ThreadId

-- | Like <a>forkIO</a>, but lets you specify on which capability the
grthread should run. Unlike a <a>forkIO</a> thread, a thread created by
gr<a>forkOn</a> will stay on the same capability for its entire lifetime
gr(<a>forkIO</a> threads can migrate between capabilities according to
grthe scheduling policy). <a>forkOn</a> is useful for overriding the
grscheduling policy when you know in advance how best to distribute the
grthreads.
gr
grThe <a>Int</a> argument specifies a <i>capability number</i> (see
gr<a>getNumCapabilities</a>). Typically capabilities correspond to
grphysical processors, but the exact behaviour is
grimplementation-dependent. The value passed to <a>forkOn</a> is
grinterpreted modulo the total number of capabilities as returned by
gr<a>getNumCapabilities</a>.
gr
grGHC note: the number of capabilities is specified by the <tt>+RTS
gr-N</tt> option when the program is started. Capabilities can be fixed
grto actual processor cores with <tt>+RTS -qa</tt> if the underlying
groperating system supports that, although in practice this is usually
grunnecessary (and may actually degrade performance in some cases -
grexperimentation is recommended).
forkOn :: Int -> IO () -> IO ThreadId

-- | Like <a>forkIOWithUnmask</a>, but the child thread is pinned to the
grgiven CPU, as with <a>forkOn</a>.
forkOnWithUnmask :: Int -> ((forall a. IO a -> IO a) -> IO ()) -> IO ThreadId

-- | the value passed to the <tt>+RTS -N</tt> flag. This is the number of
grHaskell threads that can run truly simultaneously at any given time,
grand is typically set to the number of physical processor cores on the
grmachine.
gr
grStrictly speaking it is better to use <a>getNumCapabilities</a>,
grbecause the number of capabilities might vary at runtime.
numCapabilities :: Int

-- | Returns the number of Haskell threads that can run truly
grsimultaneously (on separate physical processors) at any given time. To
grchange this value, use <a>setNumCapabilities</a>.
getNumCapabilities :: IO Int

-- | Set the number of Haskell threads that can run truly simultaneously
gr(on separate physical processors) at any given time. The number passed
grto <a>forkOn</a> is interpreted modulo this value. The initial value
gris given by the <tt>+RTS -N</tt> runtime flag.
gr
grThis is also the number of threads that will participate in parallel
grgarbage collection. It is strongly recommended that the number of
grcapabilities is not set larger than the number of physical processor
grcores, and it may often be beneficial to leave one or more cores free
grto avoid contention with other processes in the machine.
setNumCapabilities :: Int -> IO ()

-- | Returns the number of CPUs that the machine has
getNumProcessors :: IO Int

-- | Returns the number of sparks currently in the local spark pool
numSparks :: IO Int
childHandler :: SomeException -> IO ()

-- | Returns the <a>ThreadId</a> of the calling thread (GHC only).
myThreadId :: IO ThreadId

-- | <a>killThread</a> raises the <a>ThreadKilled</a> exception in the
grgiven thread (GHC only).
gr
gr<pre>
grkillThread tid = throwTo tid ThreadKilled
gr</pre>
killThread :: ThreadId -> IO ()

-- | <a>throwTo</a> raises an arbitrary exception in the target thread (GHC
gronly).
gr
grException delivery synchronizes between the source and target thread:
gr<a>throwTo</a> does not return until the exception has been raised in
grthe target thread. The calling thread can thus be certain that the
grtarget thread has received the exception. Exception delivery is also
gratomic with respect to other exceptions. Atomicity is a useful
grproperty to have when dealing with race conditions: e.g. if there are
grtwo threads that can kill each other, it is guaranteed that only one
grof the threads will get to kill the other.
gr
grWhatever work the target thread was doing when the exception was
grraised is not lost: the computation is suspended until required by
granother thread.
gr
grIf the target thread is currently making a foreign call, then the
grexception will not be raised (and hence <a>throwTo</a> will not
grreturn) until the call has completed. This is the case regardless of
grwhether the call is inside a <a>mask</a> or not. However, in GHC a
grforeign call can be annotated as <tt>interruptible</tt>, in which case
gra <a>throwTo</a> will cause the RTS to attempt to cause the call to
grreturn; see the GHC documentation for more details.
gr
grImportant note: the behaviour of <a>throwTo</a> differs from that
grdescribed in the paper "Asynchronous exceptions in Haskell"
gr(<a>http://research.microsoft.com/~simonpj/Papers/asynch-exns.htm</a>).
grIn the paper, <a>throwTo</a> is non-blocking; but the library
grimplementation adopts a more synchronous design in which
gr<a>throwTo</a> does not return until the exception is received by the
grtarget thread. The trade-off is discussed in Section 9 of the paper.
grLike any blocking operation, <a>throwTo</a> is therefore interruptible
gr(see Section 5.3 of the paper). Unlike other interruptible operations,
grhowever, <a>throwTo</a> is <i>always</i> interruptible, even if it
grdoes not actually block.
gr
grThere is no guarantee that the exception will be delivered promptly,
gralthough the runtime will endeavour to ensure that arbitrary delays
grdon't occur. In GHC, an exception can only be raised when a thread
grreaches a <i>safe point</i>, where a safe point is where memory
grallocation occurs. Some loops do not perform any memory allocation
grinside the loop and therefore cannot be interrupted by a
gr<a>throwTo</a>.
gr
grIf the target of <a>throwTo</a> is the calling thread, then the
grbehaviour is the same as <a>throwIO</a>, except that the exception is
grthrown as an asynchronous exception. This means that if there is an
grenclosing pure computation, which would be the case if the current IO
groperation is inside <a>unsafePerformIO</a> or
gr<a>unsafeInterleaveIO</a>, that computation is not permanently
grreplaced by the exception, but is suspended as if it had received an
grasynchronous exception.
gr
grNote that if <a>throwTo</a> is called with the current thread as the
grtarget, the exception will be thrown even if the thread is currently
grinside <a>mask</a> or <a>uninterruptibleMask</a>.
throwTo :: Exception e => ThreadId -> e -> IO ()
par :: a -> b -> b
infixr 0 `par`
pseq :: a -> b -> b
infixr 0 `pseq`

-- | Internal function used by the RTS to run sparks.
runSparks :: IO ()

-- | The <a>yield</a> action allows (forces, in a co-operative multitasking
grimplementation) a context-switch to any other currently runnable
grthreads (if any), and is occasionally useful when implementing
grconcurrency abstractions.
yield :: IO ()

-- | <a>labelThread</a> stores a string as identifier for this thread if
gryou built a RTS with debugging support. This identifier will be used
grin the debugging output to make distinction of different threads
greasier (otherwise you only have the thread state object's address in
grthe heap).
gr
grOther applications like the graphical Concurrent Haskell Debugger
gr(<a>http://www.informatik.uni-kiel.de/~fhu/chd/</a>) may choose to
groverload <a>labelThread</a> for their purposes as well.
labelThread :: ThreadId -> String -> IO ()

-- | Make a weak pointer to a <a>ThreadId</a>. It can be important to do
grthis if you want to hold a reference to a <a>ThreadId</a> while still
grallowing the thread to receive the <tt>BlockedIndefinitely</tt> family
grof exceptions (e.g. <a>BlockedIndefinitelyOnMVar</a>). Holding a
grnormal <a>ThreadId</a> reference will prevent the delivery of
gr<tt>BlockedIndefinitely</tt> exceptions because the reference could be
grused as the target of <a>throwTo</a> at any time, which would unblock
grthe thread.
gr
grHolding a <tt>Weak ThreadId</tt>, on the other hand, will not prevent
grthe thread from receiving <tt>BlockedIndefinitely</tt> exceptions. It
gris still possible to throw an exception to a <tt>Weak ThreadId</tt>,
grbut the caller must use <tt>deRefWeak</tt> first to determine whether
grthe thread still exists.
mkWeakThreadId :: ThreadId -> IO (Weak ThreadId)

-- | The current status of a thread
data ThreadStatus

-- | the thread is currently runnable or running
ThreadRunning :: ThreadStatus

-- | the thread has finished
ThreadFinished :: ThreadStatus

-- | the thread is blocked on some resource
ThreadBlocked :: BlockReason -> ThreadStatus

-- | the thread received an uncaught exception
ThreadDied :: ThreadStatus
data BlockReason

-- | blocked on <a>MVar</a>
BlockedOnMVar :: BlockReason

-- | blocked on a computation in progress by another thread
BlockedOnBlackHole :: BlockReason

-- | blocked in <a>throwTo</a>
BlockedOnException :: BlockReason

-- | blocked in <a>retry</a> in an STM transaction
BlockedOnSTM :: BlockReason

-- | currently in a foreign call
BlockedOnForeignCall :: BlockReason

-- | blocked on some other resource. Without <tt>-threaded</tt>, I/O and
gr<tt>threadDelay</tt> show up as <a>BlockedOnOther</a>, with
gr<tt>-threaded</tt> they show up as <a>BlockedOnMVar</a>.
BlockedOnOther :: BlockReason
threadStatus :: ThreadId -> IO ThreadStatus

-- | Returns the number of the capability on which the thread is currently
grrunning, and a boolean indicating whether the thread is locked to that
grcapability or not. A thread is locked to a capability if it was
grcreated with <tt>forkOn</tt>.
threadCapability :: ThreadId -> IO (Int, Bool)

-- | Make a StablePtr that can be passed to the C function
gr<tt>hs_try_putmvar()</tt>. The RTS wants a <a>StablePtr</a> to the
grunderlying <a>MVar#</a>, but a <a>StablePtr#</a> can only refer to
grlifted types, so we have to cheat by coercing.
newStablePtrPrimMVar :: MVar () -> IO (StablePtr PrimMVar)
data PrimMVar

-- | Every thread has an allocation counter that tracks how much memory has
grbeen allocated by the thread. The counter is initialized to zero, and
gr<a>setAllocationCounter</a> sets the current value. The allocation
grcounter counts *down*, so in the absence of a call to
gr<a>setAllocationCounter</a> its value is the negation of the number of
grbytes of memory allocated by the thread.
gr
grThere are two things that you can do with this counter:
gr
gr<ul>
gr<li>Use it as a simple profiling mechanism, with
gr<a>getAllocationCounter</a>.</li>
gr<li>Use it as a resource limit. See <a>enableAllocationLimit</a>.</li>
gr</ul>
gr
grAllocation accounting is accurate only to about 4Kbytes.
setAllocationCounter :: Int64 -> IO ()

-- | Return the current value of the allocation counter for the current
grthread.
getAllocationCounter :: IO Int64

-- | Enables the allocation counter to be treated as a limit for the
grcurrent thread. When the allocation limit is enabled, if the
grallocation counter counts down below zero, the thread will be sent the
gr<a>AllocationLimitExceeded</a> asynchronous exception. When this
grhappens, the counter is reinitialised (by default to 100K, but tunable
grwith the <tt>+RTS -xq</tt> option) so that it can handle the exception
grand perform any necessary clean up. If it exhausts this additional
grallowance, another <a>AllocationLimitExceeded</a> exception is sent,
grand so forth. Like other asynchronous exceptions, the
gr<a>AllocationLimitExceeded</a> exception is deferred while the thread
gris inside <a>mask</a> or an exception handler in <a>catch</a>.
gr
grNote that memory allocation is unrelated to <i>live memory</i>, also
grknown as <i>heap residency</i>. A thread can allocate a large amount
grof memory and retain anything between none and all of it. It is better
grto think of the allocation limit as a limit on <i>CPU time</i>, rather
grthan a limit on memory.
gr
grCompared to using timeouts, allocation limits don't count time spent
grblocked or in foreign calls.
enableAllocationLimit :: IO ()

-- | Disable allocation limit processing for the current thread.
disableAllocationLimit :: IO ()

-- | A monad supporting atomic memory transactions.
newtype STM a
STM :: (State# RealWorld -> (# State# RealWorld, a #)) -> STM a

-- | Perform a series of STM actions atomically.
gr
grUsing <a>atomically</a> inside an <a>unsafePerformIO</a> or
gr<a>unsafeInterleaveIO</a> subverts some of guarantees that STM
grprovides. It makes it possible to run a transaction inside of another
grtransaction, depending on when the thunk is evaluated. If a nested
grtransaction is attempted, an exception is thrown by the runtime. It is
grpossible to safely use <a>atomically</a> inside <a>unsafePerformIO</a>
gror <a>unsafeInterleaveIO</a>, but the typechecker does not rule out
grprograms that may attempt nested transactions, meaning that the
grprogrammer must take special care to prevent these.
gr
grHowever, there are functions for creating transactional variables that
grcan always be safely called in <a>unsafePerformIO</a>. See:
gr<a>newTVarIO</a>, <tt>newTChanIO</tt>, <tt>newBroadcastTChanIO</tt>,
gr<tt>newTQueueIO</tt>, <tt>newTBQueueIO</tt>, and <tt>newTMVarIO</tt>.
gr
grUsing <a>unsafePerformIO</a> inside of <a>atomically</a> is also
grdangerous but for different reasons. See <a>unsafeIOToSTM</a> for more
gron this.
atomically :: STM a -> IO a

-- | Retry execution of the current memory transaction because it has seen
grvalues in <a>TVar</a>s which mean that it should not continue (e.g.
grthe <a>TVar</a>s represent a shared buffer that is now empty). The
grimplementation may block the thread until one of the <a>TVar</a>s that
grit has read from has been updated. (GHC only)
retry :: STM a

-- | Compose two alternative STM actions (GHC only).
gr
grIf the first action completes without retrying then it forms the
grresult of the <a>orElse</a>. Otherwise, if the first action retries,
grthen the second action is tried in its place. If both actions retry
grthen the <a>orElse</a> as a whole retries.
orElse :: STM a -> STM a -> STM a

-- | A variant of <a>throw</a> that can only be used within the <a>STM</a>
grmonad.
gr
grThrowing an exception in <tt>STM</tt> aborts the transaction and
grpropagates the exception.
gr
grAlthough <a>throwSTM</a> has a type that is an instance of the type of
gr<a>throw</a>, the two functions are subtly different:
gr
gr<pre>
grthrow e    `seq` x  ===&gt; throw e
grthrowSTM e `seq` x  ===&gt; x
gr</pre>
gr
grThe first example will cause the exception <tt>e</tt> to be raised,
grwhereas the second one won't. In fact, <a>throwSTM</a> will only cause
gran exception to be raised when it is used within the <a>STM</a> monad.
grThe <a>throwSTM</a> variant should be used in preference to
gr<a>throw</a> to raise an exception within the <a>STM</a> monad because
grit guarantees ordering with respect to other <a>STM</a> operations,
grwhereas <a>throw</a> does not.
throwSTM :: Exception e => e -> STM a

-- | Exception handling within STM actions.
catchSTM :: Exception e => STM a -> (e -> STM a) -> STM a

-- | <a>alwaysSucceeds</a> adds a new invariant that must be true when
grpassed to <a>alwaysSucceeds</a>, at the end of the current
grtransaction, and at the end of every subsequent transaction. If it
grfails at any of those points then the transaction violating it is
graborted and the exception raised by the invariant is propagated.
alwaysSucceeds :: STM a -> STM ()

-- | <a>always</a> is a variant of <a>alwaysSucceeds</a> in which the
grinvariant is expressed as an <tt>STM Bool</tt> action that must return
gr<tt>True</tt>. Returning <tt>False</tt> or raising an exception are
grboth treated as invariant failures.
always :: STM Bool -> STM ()

-- | Shared memory locations that support atomic memory transactions.
data TVar a
TVar :: (TVar# RealWorld a) -> TVar a

-- | Create a new <a>TVar</a> holding a value supplied
newTVar :: a -> STM (TVar a)

-- | <tt>IO</tt> version of <a>newTVar</a>. This is useful for creating
grtop-level <a>TVar</a>s using <a>unsafePerformIO</a>, because using
gr<a>atomically</a> inside <a>unsafePerformIO</a> isn't possible.
newTVarIO :: a -> IO (TVar a)

-- | Return the current value stored in a <a>TVar</a>.
readTVar :: TVar a -> STM a

-- | Return the current value stored in a <a>TVar</a>. This is equivalent
grto
gr
gr<pre>
grreadTVarIO = atomically . readTVar
gr</pre>
gr
grbut works much faster, because it doesn't perform a complete
grtransaction, it just reads the current value of the <a>TVar</a>.
readTVarIO :: TVar a -> IO a

-- | Write the supplied value into a <a>TVar</a>.
writeTVar :: TVar a -> a -> STM ()

-- | Unsafely performs IO in the STM monad. Beware: this is a highly
grdangerous thing to do.
gr
gr<ul>
gr<li>The STM implementation will often run transactions multiple times,
grso you need to be prepared for this if your IO has any side
greffects.</li>
gr<li>The STM implementation will abort transactions that are known to
grbe invalid and need to be restarted. This may happen in the middle of
gr<a>unsafeIOToSTM</a>, so make sure you don't acquire any resources
grthat need releasing (exception handlers are ignored when aborting the
grtransaction). That includes doing any IO using Handles, for example.
grGetting this wrong will probably lead to random deadlocks.</li>
gr<li>The transaction may have seen an inconsistent view of memory when
grthe IO runs. Invariants that you expect to be true throughout your
grprogram may not be true inside a transaction, due to the way
grtransactions are implemented. Normally this wouldn't be visible to the
grprogrammer, but using <a>unsafeIOToSTM</a> can expose it.</li>
gr</ul>
unsafeIOToSTM :: IO a -> STM a

-- | Provide an <a>IO</a> action with the current value of an <a>MVar</a>.
grThe <a>MVar</a> will be empty for the duration that the action is
grrunning.
withMVar :: MVar a -> (a -> IO b) -> IO b

-- | Modify the value of an <a>MVar</a>.
modifyMVar_ :: MVar a -> (a -> IO a) -> IO ()
setUncaughtExceptionHandler :: (SomeException -> IO ()) -> IO ()
getUncaughtExceptionHandler :: IO (SomeException -> IO ())
reportError :: SomeException -> IO ()
reportStackOverflow :: IO ()
reportHeapOverflow :: IO ()
sharedCAF :: a -> (Ptr a -> IO (Ptr a)) -> IO a
instance GHC.Show.Show GHC.Conc.Sync.ThreadStatus
instance GHC.Classes.Ord GHC.Conc.Sync.ThreadStatus
instance GHC.Classes.Eq GHC.Conc.Sync.ThreadStatus
instance GHC.Show.Show GHC.Conc.Sync.BlockReason
instance GHC.Classes.Ord GHC.Conc.Sync.BlockReason
instance GHC.Classes.Eq GHC.Conc.Sync.BlockReason
instance GHC.Classes.Eq (GHC.Conc.Sync.TVar a)
instance GHC.Base.Functor GHC.Conc.Sync.STM
instance GHC.Base.Applicative GHC.Conc.Sync.STM
instance GHC.Base.Monad GHC.Conc.Sync.STM
instance GHC.Base.Alternative GHC.Conc.Sync.STM
instance GHC.Base.MonadPlus GHC.Conc.Sync.STM
instance GHC.Show.Show GHC.Conc.Sync.ThreadId
instance GHC.Classes.Eq GHC.Conc.Sync.ThreadId
instance GHC.Classes.Ord GHC.Conc.Sync.ThreadId


-- | Extensible exceptions, except for multiple handlers.
module Control.Exception.Base

-- | The <tt>SomeException</tt> type is the root of the exception type
grhierarchy. When an exception of type <tt>e</tt> is thrown, behind the
grscenes it is encapsulated in a <tt>SomeException</tt>.
data SomeException
SomeException :: e -> SomeException

-- | Any type that you wish to throw or catch as an exception must be an
grinstance of the <tt>Exception</tt> class. The simplest case is a new
grexception type directly below the root:
gr
gr<pre>
grdata MyException = ThisException | ThatException
gr    deriving Show
gr
grinstance Exception MyException
gr</pre>
gr
grThe default method definitions in the <tt>Exception</tt> class do what
grwe need in this case. You can now throw and catch
gr<tt>ThisException</tt> and <tt>ThatException</tt> as exceptions:
gr
gr<pre>
gr*Main&gt; throw ThisException `catch` \e -&gt; putStrLn ("Caught " ++ show (e :: MyException))
grCaught ThisException
gr</pre>
gr
grIn more complicated examples, you may wish to define a whole hierarchy
grof exceptions:
gr
gr<pre>
gr---------------------------------------------------------------------
gr-- Make the root exception type for all the exceptions in a compiler
gr
grdata SomeCompilerException = forall e . Exception e =&gt; SomeCompilerException e
gr
grinstance Show SomeCompilerException where
gr    show (SomeCompilerException e) = show e
gr
grinstance Exception SomeCompilerException
gr
grcompilerExceptionToException :: Exception e =&gt; e -&gt; SomeException
grcompilerExceptionToException = toException . SomeCompilerException
gr
grcompilerExceptionFromException :: Exception e =&gt; SomeException -&gt; Maybe e
grcompilerExceptionFromException x = do
gr    SomeCompilerException a &lt;- fromException x
gr    cast a
gr
gr---------------------------------------------------------------------
gr-- Make a subhierarchy for exceptions in the frontend of the compiler
gr
grdata SomeFrontendException = forall e . Exception e =&gt; SomeFrontendException e
gr
grinstance Show SomeFrontendException where
gr    show (SomeFrontendException e) = show e
gr
grinstance Exception SomeFrontendException where
gr    toException = compilerExceptionToException
gr    fromException = compilerExceptionFromException
gr
grfrontendExceptionToException :: Exception e =&gt; e -&gt; SomeException
grfrontendExceptionToException = toException . SomeFrontendException
gr
grfrontendExceptionFromException :: Exception e =&gt; SomeException -&gt; Maybe e
grfrontendExceptionFromException x = do
gr    SomeFrontendException a &lt;- fromException x
gr    cast a
gr
gr---------------------------------------------------------------------
gr-- Make an exception type for a particular frontend compiler exception
gr
grdata MismatchedParentheses = MismatchedParentheses
gr    deriving Show
gr
grinstance Exception MismatchedParentheses where
gr    toException   = frontendExceptionToException
gr    fromException = frontendExceptionFromException
gr</pre>
gr
grWe can now catch a <tt>MismatchedParentheses</tt> exception as
gr<tt>MismatchedParentheses</tt>, <tt>SomeFrontendException</tt> or
gr<tt>SomeCompilerException</tt>, but not other types, e.g.
gr<tt>IOException</tt>:
gr
gr<pre>
gr*Main&gt; throw MismatchedParentheses `catch` \e -&gt; putStrLn ("Caught " ++ show (e :: MismatchedParentheses))
grCaught MismatchedParentheses
gr*Main&gt; throw MismatchedParentheses `catch` \e -&gt; putStrLn ("Caught " ++ show (e :: SomeFrontendException))
grCaught MismatchedParentheses
gr*Main&gt; throw MismatchedParentheses `catch` \e -&gt; putStrLn ("Caught " ++ show (e :: SomeCompilerException))
grCaught MismatchedParentheses
gr*Main&gt; throw MismatchedParentheses `catch` \e -&gt; putStrLn ("Caught " ++ show (e :: IOException))
gr*** Exception: MismatchedParentheses
gr</pre>
class (Typeable e, Show e) => Exception e
toException :: Exception e => e -> SomeException
fromException :: Exception e => SomeException -> Maybe e

-- | Render this exception value in a human-friendly manner.
gr
grDefault implementation: <tt><a>show</a></tt>.
displayException :: Exception e => e -> String

-- | Exceptions that occur in the <tt>IO</tt> monad. An
gr<tt>IOException</tt> records a more specific error type, a descriptive
grstring and maybe the handle that was used when the error was flagged.
data IOException

-- | Arithmetic exceptions.
data ArithException
Overflow :: ArithException
Underflow :: ArithException
LossOfPrecision :: ArithException
DivideByZero :: ArithException
Denormal :: ArithException

RatioZeroDenominator :: ArithException

-- | Exceptions generated by array operations
data ArrayException

-- | An attempt was made to index an array outside its declared bounds.
IndexOutOfBounds :: String -> ArrayException

-- | An attempt was made to evaluate an element of an array that had not
grbeen initialized.
UndefinedElement :: String -> ArrayException

-- | <a>assert</a> was applied to <a>False</a>.
newtype AssertionFailed
AssertionFailed :: String -> AssertionFailed

-- | Superclass for asynchronous exceptions.
data SomeAsyncException
SomeAsyncException :: e -> SomeAsyncException

-- | Asynchronous exceptions.
data AsyncException

-- | The current thread's stack exceeded its limit. Since an exception has
grbeen raised, the thread's stack will certainly be below its limit
gragain, but the programmer should take remedial action immediately.
StackOverflow :: AsyncException

-- | The program's heap is reaching its limit, and the program should take
graction to reduce the amount of live data it has. Notes:
gr
gr<ul>
gr<li>It is undefined which thread receives this exception. GHC
grcurrently throws this to the same thread that receives
gr<a>UserInterrupt</a>, but this may change in the future.</li>
gr<li>The GHC RTS currently can only recover from heap overflow if it
grdetects that an explicit memory limit (set via RTS flags). has been
grexceeded. Currently, failure to allocate memory from the operating
grsystem results in immediate termination of the program.</li>
gr</ul>
HeapOverflow :: AsyncException

-- | This exception is raised by another thread calling <a>killThread</a>,
gror by the system if it needs to terminate the thread for some reason.
ThreadKilled :: AsyncException

-- | This exception is raised by default in the main thread of the program
grwhen the user requests to terminate the program via the usual
grmechanism(s) (e.g. Control-C in the console).
UserInterrupt :: AsyncException

asyncExceptionToException :: Exception e => e -> SomeException

asyncExceptionFromException :: Exception e => SomeException -> Maybe e

-- | Thrown when the runtime system detects that the computation is
grguaranteed not to terminate. Note that there is no guarantee that the
grruntime system will notice whether any given computation is guaranteed
grto terminate or not.
data NonTermination
NonTermination :: NonTermination

-- | Thrown when the program attempts to call <tt>atomically</tt>, from the
gr<tt>stm</tt> package, inside another call to <tt>atomically</tt>.
data NestedAtomically
NestedAtomically :: NestedAtomically

-- | The thread is blocked on an <tt>MVar</tt>, but there are no other
grreferences to the <tt>MVar</tt> so it can't ever continue.
data BlockedIndefinitelyOnMVar
BlockedIndefinitelyOnMVar :: BlockedIndefinitelyOnMVar

-- | @since TODO
data FixIOException
FixIOException :: FixIOException

-- | The thread is waiting to retry an STM transaction, but there are no
grother references to any <tt>TVar</tt>s involved, so it can't ever
grcontinue.
data BlockedIndefinitelyOnSTM
BlockedIndefinitelyOnSTM :: BlockedIndefinitelyOnSTM

-- | This thread has exceeded its allocation limit. See
gr<a>setAllocationCounter</a> and <a>enableAllocationLimit</a>.
data AllocationLimitExceeded
AllocationLimitExceeded :: AllocationLimitExceeded

-- | Compaction found an object that cannot be compacted. Functions cannot
grbe compacted, nor can mutable objects or pinned objects. See
gr<a>compact</a>.
newtype CompactionFailed
CompactionFailed :: String -> CompactionFailed

-- | There are no runnable threads, so the program is deadlocked. The
gr<tt>Deadlock</tt> exception is raised in the main thread only.
data Deadlock
Deadlock :: Deadlock

-- | A class method without a definition (neither a default definition, nor
gra definition in the appropriate instance) was called. The
gr<tt>String</tt> gives information about which method it was.
newtype NoMethodError
NoMethodError :: String -> NoMethodError

-- | A pattern match failed. The <tt>String</tt> gives information about
grthe source location of the pattern.
newtype PatternMatchFail
PatternMatchFail :: String -> PatternMatchFail

-- | An uninitialised record field was used. The <tt>String</tt> gives
grinformation about the source location where the record was
grconstructed.
newtype RecConError
RecConError :: String -> RecConError

-- | A record selector was applied to a constructor without the appropriate
grfield. This can only happen with a datatype with multiple
grconstructors, where some fields are in one constructor but not
granother. The <tt>String</tt> gives information about the source
grlocation of the record selector.
newtype RecSelError
RecSelError :: String -> RecSelError

-- | A record update was performed on a constructor without the appropriate
grfield. This can only happen with a datatype with multiple
grconstructors, where some fields are in one constructor but not
granother. The <tt>String</tt> gives information about the source
grlocation of the record update.
newtype RecUpdError
RecUpdError :: String -> RecUpdError

-- | This is thrown when the user calls <a>error</a>. The first
gr<tt>String</tt> is the argument given to <a>error</a>, second
gr<tt>String</tt> is the location.
data ErrorCall
ErrorCallWithLocation :: String -> String -> ErrorCall

-- | An expression that didn't typecheck during compile time was called.
grThis is only possible with -fdefer-type-errors. The <tt>String</tt>
grgives details about the failed type check.
newtype TypeError
TypeError :: String -> TypeError

-- | A variant of <a>throw</a> that can only be used within the <a>IO</a>
grmonad.
gr
grAlthough <a>throwIO</a> has a type that is an instance of the type of
gr<a>throw</a>, the two functions are subtly different:
gr
gr<pre>
grthrow e   `seq` x  ===&gt; throw e
grthrowIO e `seq` x  ===&gt; x
gr</pre>
gr
grThe first example will cause the exception <tt>e</tt> to be raised,
grwhereas the second one won't. In fact, <a>throwIO</a> will only cause
gran exception to be raised when it is used within the <a>IO</a> monad.
grThe <a>throwIO</a> variant should be used in preference to
gr<a>throw</a> to raise an exception within the <a>IO</a> monad because
grit guarantees ordering with respect to other <a>IO</a> operations,
grwhereas <a>throw</a> does not.
throwIO :: Exception e => e -> IO a

-- | Throw an exception. Exceptions may be thrown from purely functional
grcode, but may only be caught within the <a>IO</a> monad.
throw :: Exception e => e -> a

-- | Raise an <a>IOError</a> in the <a>IO</a> monad.
ioError :: IOError -> IO a

-- | <a>throwTo</a> raises an arbitrary exception in the target thread (GHC
gronly).
gr
grException delivery synchronizes between the source and target thread:
gr<a>throwTo</a> does not return until the exception has been raised in
grthe target thread. The calling thread can thus be certain that the
grtarget thread has received the exception. Exception delivery is also
gratomic with respect to other exceptions. Atomicity is a useful
grproperty to have when dealing with race conditions: e.g. if there are
grtwo threads that can kill each other, it is guaranteed that only one
grof the threads will get to kill the other.
gr
grWhatever work the target thread was doing when the exception was
grraised is not lost: the computation is suspended until required by
granother thread.
gr
grIf the target thread is currently making a foreign call, then the
grexception will not be raised (and hence <a>throwTo</a> will not
grreturn) until the call has completed. This is the case regardless of
grwhether the call is inside a <a>mask</a> or not. However, in GHC a
grforeign call can be annotated as <tt>interruptible</tt>, in which case
gra <a>throwTo</a> will cause the RTS to attempt to cause the call to
grreturn; see the GHC documentation for more details.
gr
grImportant note: the behaviour of <a>throwTo</a> differs from that
grdescribed in the paper "Asynchronous exceptions in Haskell"
gr(<a>http://research.microsoft.com/~simonpj/Papers/asynch-exns.htm</a>).
grIn the paper, <a>throwTo</a> is non-blocking; but the library
grimplementation adopts a more synchronous design in which
gr<a>throwTo</a> does not return until the exception is received by the
grtarget thread. The trade-off is discussed in Section 9 of the paper.
grLike any blocking operation, <a>throwTo</a> is therefore interruptible
gr(see Section 5.3 of the paper). Unlike other interruptible operations,
grhowever, <a>throwTo</a> is <i>always</i> interruptible, even if it
grdoes not actually block.
gr
grThere is no guarantee that the exception will be delivered promptly,
gralthough the runtime will endeavour to ensure that arbitrary delays
grdon't occur. In GHC, an exception can only be raised when a thread
grreaches a <i>safe point</i>, where a safe point is where memory
grallocation occurs. Some loops do not perform any memory allocation
grinside the loop and therefore cannot be interrupted by a
gr<a>throwTo</a>.
gr
grIf the target of <a>throwTo</a> is the calling thread, then the
grbehaviour is the same as <a>throwIO</a>, except that the exception is
grthrown as an asynchronous exception. This means that if there is an
grenclosing pure computation, which would be the case if the current IO
groperation is inside <a>unsafePerformIO</a> or
gr<a>unsafeInterleaveIO</a>, that computation is not permanently
grreplaced by the exception, but is suspended as if it had received an
grasynchronous exception.
gr
grNote that if <a>throwTo</a> is called with the current thread as the
grtarget, the exception will be thrown even if the thread is currently
grinside <a>mask</a> or <a>uninterruptibleMask</a>.
throwTo :: Exception e => ThreadId -> e -> IO ()

-- | This is the simplest of the exception-catching functions. It takes a
grsingle argument, runs it, and if an exception is raised the "handler"
gris executed, with the value of the exception passed as an argument.
grOtherwise, the result is returned as normal. For example:
gr
gr<pre>
grcatch (readFile f)
gr      (\e -&gt; do let err = show (e :: IOException)
gr                hPutStr stderr ("Warning: Couldn't open " ++ f ++ ": " ++ err)
gr                return "")
gr</pre>
gr
grNote that we have to give a type signature to <tt>e</tt>, or the
grprogram will not typecheck as the type is ambiguous. While it is
grpossible to catch exceptions of any type, see the section "Catching
grall exceptions" (in <a>Control.Exception</a>) for an explanation of
grthe problems with doing so.
gr
grFor catching exceptions in pure (non-<a>IO</a>) expressions, see the
grfunction <a>evaluate</a>.
gr
grNote that due to Haskell's unspecified evaluation order, an expression
grmay throw one of several possible exceptions: consider the expression
gr<tt>(error "urk") + (1 `div` 0)</tt>. Does the expression throw
gr<tt>ErrorCall "urk"</tt>, or <tt>DivideByZero</tt>?
gr
grThe answer is "it might throw either"; the choice is
grnon-deterministic. If you are catching any type of exception then you
grmight catch either. If you are calling <tt>catch</tt> with type <tt>IO
grInt -&gt; (ArithException -&gt; IO Int) -&gt; IO Int</tt> then the
grhandler may get run with <tt>DivideByZero</tt> as an argument, or an
gr<tt>ErrorCall "urk"</tt> exception may be propogated further up. If
gryou call it again, you might get a the opposite behaviour. This is ok,
grbecause <a>catch</a> is an <a>IO</a> computation.
catch :: Exception e => IO a -> (e -> IO a) -> IO a

-- | The function <a>catchJust</a> is like <a>catch</a>, but it takes an
grextra argument which is an <i>exception predicate</i>, a function
grwhich selects which type of exceptions we're interested in.
gr
gr<pre>
grcatchJust (\e -&gt; if isDoesNotExistErrorType (ioeGetErrorType e) then Just () else Nothing)
gr          (readFile f)
gr          (\_ -&gt; do hPutStrLn stderr ("No such file: " ++ show f)
gr                    return "")
gr</pre>
gr
grAny other exceptions which are not matched by the predicate are
grre-raised, and may be caught by an enclosing <a>catch</a>,
gr<a>catchJust</a>, etc.
catchJust :: Exception e => (e -> Maybe b) -> IO a -> (b -> IO a) -> IO a

-- | A version of <a>catch</a> with the arguments swapped around; useful in
grsituations where the code for the handler is shorter. For example:
gr
gr<pre>
grdo handle (\NonTermination -&gt; exitWith (ExitFailure 1)) $
gr   ...
gr</pre>
handle :: Exception e => (e -> IO a) -> IO a -> IO a

-- | A version of <a>catchJust</a> with the arguments swapped around (see
gr<a>handle</a>).
handleJust :: Exception e => (e -> Maybe b) -> (b -> IO a) -> IO a -> IO a

-- | Similar to <a>catch</a>, but returns an <a>Either</a> result which is
gr<tt>(<a>Right</a> a)</tt> if no exception of type <tt>e</tt> was
grraised, or <tt>(<a>Left</a> ex)</tt> if an exception of type
gr<tt>e</tt> was raised and its value is <tt>ex</tt>. If any other type
grof exception is raised than it will be propogated up to the next
grenclosing exception handler.
gr
gr<pre>
grtry a = catch (Right `liftM` a) (return . Left)
gr</pre>
try :: Exception e => IO a -> IO (Either e a)

-- | A variant of <a>try</a> that takes an exception predicate to select
grwhich exceptions are caught (c.f. <a>catchJust</a>). If the exception
grdoes not match the predicate, it is re-thrown.
tryJust :: Exception e => (e -> Maybe b) -> IO a -> IO (Either b a)

-- | Like <a>finally</a>, but only performs the final action if there was
gran exception raised by the computation.
onException :: IO a -> IO b -> IO a

-- | Evaluate the argument to weak head normal form.
gr
gr<a>evaluate</a> is typically used to uncover any exceptions that a
grlazy value may contain, and possibly handle them.
gr
gr<a>evaluate</a> only evaluates to <i>weak head normal form</i>. If
grdeeper evaluation is needed, the <tt>force</tt> function from
gr<tt>Control.DeepSeq</tt> may be handy:
gr
gr<pre>
grevaluate $ force x
gr</pre>
gr
grThere is a subtle difference between <tt><a>evaluate</a> x</tt> and
gr<tt><a>return</a> <a>$!</a> x</tt>, analogous to the difference
grbetween <a>throwIO</a> and <a>throw</a>. If the lazy value <tt>x</tt>
grthrows an exception, <tt><a>return</a> <a>$!</a> x</tt> will fail to
grreturn an <a>IO</a> action and will throw an exception instead.
gr<tt><a>evaluate</a> x</tt>, on the other hand, always produces an
gr<a>IO</a> action; that action will throw an exception upon
gr<i>execution</i> iff <tt>x</tt> throws an exception upon
gr<i>evaluation</i>.
gr
grThe practical implication of this difference is that due to the
gr<i>imprecise exceptions</i> semantics,
gr
gr<pre>
gr(return $! error "foo") &gt;&gt; error "bar"
gr</pre>
gr
grmay throw either <tt>"foo"</tt> or <tt>"bar"</tt>, depending on the
groptimizations performed by the compiler. On the other hand,
gr
gr<pre>
grevaluate (error "foo") &gt;&gt; error "bar"
gr</pre>
gr
gris guaranteed to throw <tt>"foo"</tt>.
gr
grThe rule of thumb is to use <a>evaluate</a> to force or handle
grexceptions in lazy values. If, on the other hand, you are forcing a
grlazy value for efficiency reasons only and do not care about
grexceptions, you may use <tt><a>return</a> <a>$!</a> x</tt>.
evaluate :: a -> IO a

-- | This function maps one exception into another as proposed in the paper
gr"A semantics for imprecise exceptions".
mapException :: (Exception e1, Exception e2) => (e1 -> e2) -> a -> a

-- | Executes an IO computation with asynchronous exceptions <i>masked</i>.
grThat is, any thread which attempts to raise an exception in the
grcurrent thread with <a>throwTo</a> will be blocked until asynchronous
grexceptions are unmasked again.
gr
grThe argument passed to <a>mask</a> is a function that takes as its
grargument another function, which can be used to restore the prevailing
grmasking state within the context of the masked computation. For
grexample, a common way to use <a>mask</a> is to protect the acquisition
grof a resource:
gr
gr<pre>
grmask $ \restore -&gt; do
gr    x &lt;- acquire
gr    restore (do_something_with x) `onException` release
gr    release
gr</pre>
gr
grThis code guarantees that <tt>acquire</tt> is paired with
gr<tt>release</tt>, by masking asynchronous exceptions for the critical
grparts. (Rather than write this code yourself, it would be better to
gruse <a>bracket</a> which abstracts the general pattern).
gr
grNote that the <tt>restore</tt> action passed to the argument to
gr<a>mask</a> does not necessarily unmask asynchronous exceptions, it
grjust restores the masking state to that of the enclosing context. Thus
grif asynchronous exceptions are already masked, <a>mask</a> cannot be
grused to unmask exceptions again. This is so that if you call a library
grfunction with exceptions masked, you can be sure that the library call
grwill not be able to unmask exceptions again. If you are writing
grlibrary code and need to use asynchronous exceptions, the only way is
grto create a new thread; see <a>forkIOWithUnmask</a>.
gr
grAsynchronous exceptions may still be received while in the masked
grstate if the masked thread <i>blocks</i> in certain ways; see
gr<a>Control.Exception#interruptible</a>.
gr
grThreads created by <a>forkIO</a> inherit the <a>MaskingState</a> from
grthe parent; that is, to start a thread in the
gr<a>MaskedInterruptible</a> state, use <tt>mask_ $ forkIO ...</tt>.
grThis is particularly useful if you need to establish an exception
grhandler in the forked thread before any asynchronous exceptions are
grreceived. To create a a new thread in an unmasked state use
gr<a>forkIOWithUnmask</a>.
mask :: ((forall a. IO a -> IO a) -> IO b) -> IO b

-- | Like <a>mask</a>, but does not pass a <tt>restore</tt> action to the
grargument.
mask_ :: IO a -> IO a

-- | Like <a>mask</a>, but the masked computation is not interruptible (see
gr<a>Control.Exception#interruptible</a>). THIS SHOULD BE USED WITH
grGREAT CARE, because if a thread executing in
gr<a>uninterruptibleMask</a> blocks for any reason, then the thread (and
grpossibly the program, if this is the main thread) will be unresponsive
grand unkillable. This function should only be necessary if you need to
grmask exceptions around an interruptible operation, and you can
grguarantee that the interruptible operation will only block for a short
grperiod of time.
uninterruptibleMask :: ((forall a. IO a -> IO a) -> IO b) -> IO b

-- | Like <a>uninterruptibleMask</a>, but does not pass a <tt>restore</tt>
graction to the argument.
uninterruptibleMask_ :: IO a -> IO a

-- | Describes the behaviour of a thread when an asynchronous exception is
grreceived.
data MaskingState

-- | asynchronous exceptions are unmasked (the normal state)
Unmasked :: MaskingState

-- | the state during <a>mask</a>: asynchronous exceptions are masked, but
grblocking operations may still be interrupted
MaskedInterruptible :: MaskingState

-- | the state during <a>uninterruptibleMask</a>: asynchronous exceptions
grare masked, and blocking operations may not be interrupted
MaskedUninterruptible :: MaskingState

-- | Returns the <a>MaskingState</a> for the current thread.
getMaskingState :: IO MaskingState

-- | If the first argument evaluates to <a>True</a>, then the result is the
grsecond argument. Otherwise an <tt>AssertionFailed</tt> exception is
grraised, containing a <a>String</a> with the source file and line
grnumber of the call to <a>assert</a>.
gr
grAssertions can normally be turned on or off with a compiler flag (for
grGHC, assertions are normally on unless optimisation is turned on with
gr<tt>-O</tt> or the <tt>-fignore-asserts</tt> option is given). When
grassertions are turned off, the first argument to <a>assert</a> is
grignored, and the second argument is returned as the result.
assert :: Bool -> a -> a

-- | When you want to acquire a resource, do some work with it, and then
grrelease the resource, it is a good idea to use <a>bracket</a>, because
gr<a>bracket</a> will install the necessary exception handler to release
grthe resource in the event that an exception is raised during the
grcomputation. If an exception is raised, then <a>bracket</a> will
grre-raise the exception (after performing the release).
gr
grA common example is opening a file:
gr
gr<pre>
grbracket
gr  (openFile "filename" ReadMode)
gr  (hClose)
gr  (\fileHandle -&gt; do { ... })
gr</pre>
gr
grThe arguments to <a>bracket</a> are in this order so that we can
grpartially apply it, e.g.:
gr
gr<pre>
grwithFile name mode = bracket (openFile name mode) hClose
gr</pre>
bracket :: IO a -> (a -> IO b) -> (a -> IO c) -> IO c

-- | A variant of <a>bracket</a> where the return value from the first
grcomputation is not required.
bracket_ :: IO a -> IO b -> IO c -> IO c

-- | Like <a>bracket</a>, but only performs the final action if there was
gran exception raised by the in-between computation.
bracketOnError :: IO a -> (a -> IO b) -> (a -> IO c) -> IO c

-- | A specialised variant of <a>bracket</a> with just a computation to run
grafterward.
finally :: IO a -> IO b -> IO a
recSelError :: Addr# -> a
recConError :: Addr# -> a
irrefutPatError :: Addr# -> a
runtimeError :: Addr# -> a
nonExhaustiveGuardsError :: Addr# -> a
patError :: Addr# -> a
noMethodBindingError :: Addr# -> a
absentError :: Addr# -> a
typeError :: Addr# -> a
nonTermination :: SomeException
nestedAtomically :: SomeException
instance GHC.Show.Show Control.Exception.Base.NestedAtomically
instance GHC.Exception.Exception Control.Exception.Base.NestedAtomically
instance GHC.Show.Show Control.Exception.Base.NonTermination
instance GHC.Exception.Exception Control.Exception.Base.NonTermination
instance GHC.Show.Show Control.Exception.Base.TypeError
instance GHC.Exception.Exception Control.Exception.Base.TypeError
instance GHC.Show.Show Control.Exception.Base.NoMethodError
instance GHC.Exception.Exception Control.Exception.Base.NoMethodError
instance GHC.Show.Show Control.Exception.Base.RecUpdError
instance GHC.Exception.Exception Control.Exception.Base.RecUpdError
instance GHC.Show.Show Control.Exception.Base.RecConError
instance GHC.Exception.Exception Control.Exception.Base.RecConError
instance GHC.Show.Show Control.Exception.Base.RecSelError
instance GHC.Exception.Exception Control.Exception.Base.RecSelError
instance GHC.Show.Show Control.Exception.Base.PatternMatchFail
instance GHC.Exception.Exception Control.Exception.Base.PatternMatchFail


-- | Standard IO Errors.
module System.IO.Error

-- | The Haskell 2010 type for exceptions in the <a>IO</a> monad. Any I/O
groperation may raise an <a>IOError</a> instead of returning a result.
grFor a more general type of exception, including also those that arise
grin pure code, see <a>Exception</a>.
gr
grIn Haskell 2010, this is an opaque type.
type IOError = IOException

-- | Construct an <a>IOError</a> value with a string describing the error.
grThe <a>fail</a> method of the <a>IO</a> instance of the <a>Monad</a>
grclass raises a <a>userError</a>, thus:
gr
gr<pre>
grinstance Monad IO where
gr  ...
gr  fail s = ioError (userError s)
gr</pre>
userError :: String -> IOError

-- | Construct an <a>IOError</a> of the given type where the second
grargument describes the error location and the third and fourth
grargument contain the file handle and file path of the file involved in
grthe error if applicable.
mkIOError :: IOErrorType -> String -> Maybe Handle -> Maybe FilePath -> IOError

-- | Adds a location description and maybe a file path and file handle to
gran <a>IOError</a>. If any of the file handle or file path is not given
grthe corresponding value in the <a>IOError</a> remains unaltered.
annotateIOError :: IOError -> String -> Maybe Handle -> Maybe FilePath -> IOError

-- | An error indicating that an <a>IO</a> operation failed because one of
grits arguments already exists.
isAlreadyExistsError :: IOError -> Bool

-- | An error indicating that an <a>IO</a> operation failed because one of
grits arguments does not exist.
isDoesNotExistError :: IOError -> Bool

-- | An error indicating that an <a>IO</a> operation failed because one of
grits arguments is a single-use resource, which is already being used
gr(for example, opening the same file twice for writing might give this
grerror).
isAlreadyInUseError :: IOError -> Bool

-- | An error indicating that an <a>IO</a> operation failed because the
grdevice is full.
isFullError :: IOError -> Bool

-- | An error indicating that an <a>IO</a> operation failed because the end
grof file has been reached.
isEOFError :: IOError -> Bool

-- | An error indicating that an <a>IO</a> operation failed because the
groperation was not possible. Any computation which returns an <a>IO</a>
grresult may fail with <a>isIllegalOperation</a>. In some cases, an
grimplementation will not be able to distinguish between the possible
grerror causes. In this case it should fail with
gr<a>isIllegalOperation</a>.
isIllegalOperation :: IOError -> Bool

-- | An error indicating that an <a>IO</a> operation failed because the
gruser does not have sufficient operating system privilege to perform
grthat operation.
isPermissionError :: IOError -> Bool

-- | A programmer-defined error value constructed using <a>userError</a>.
isUserError :: IOError -> Bool
ioeGetErrorType :: IOError -> IOErrorType
ioeGetLocation :: IOError -> String
ioeGetErrorString :: IOError -> String
ioeGetHandle :: IOError -> Maybe Handle
ioeGetFileName :: IOError -> Maybe FilePath
ioeSetErrorType :: IOError -> IOErrorType -> IOError
ioeSetErrorString :: IOError -> String -> IOError
ioeSetLocation :: IOError -> String -> IOError
ioeSetHandle :: IOError -> Handle -> IOError
ioeSetFileName :: IOError -> FilePath -> IOError

-- | An abstract type that contains a value for each variant of
gr<a>IOError</a>.
data IOErrorType

-- | I/O error where the operation failed because one of its arguments
gralready exists.
alreadyExistsErrorType :: IOErrorType

-- | I/O error where the operation failed because one of its arguments does
grnot exist.
doesNotExistErrorType :: IOErrorType

-- | I/O error where the operation failed because one of its arguments is a
grsingle-use resource, which is already being used.
alreadyInUseErrorType :: IOErrorType

-- | I/O error where the operation failed because the device is full.
fullErrorType :: IOErrorType

-- | I/O error where the operation failed because the end of file has been
grreached.
eofErrorType :: IOErrorType

-- | I/O error where the operation is not possible.
illegalOperationErrorType :: IOErrorType

-- | I/O error where the operation failed because the user does not have
grsufficient operating system privilege to perform that operation.
permissionErrorType :: IOErrorType

-- | I/O error that is programmer-defined.
userErrorType :: IOErrorType

-- | I/O error where the operation failed because one of its arguments
gralready exists.
isAlreadyExistsErrorType :: IOErrorType -> Bool

-- | I/O error where the operation failed because one of its arguments does
grnot exist.
isDoesNotExistErrorType :: IOErrorType -> Bool

-- | I/O error where the operation failed because one of its arguments is a
grsingle-use resource, which is already being used.
isAlreadyInUseErrorType :: IOErrorType -> Bool

-- | I/O error where the operation failed because the device is full.
isFullErrorType :: IOErrorType -> Bool

-- | I/O error where the operation failed because the end of file has been
grreached.
isEOFErrorType :: IOErrorType -> Bool

-- | I/O error where the operation is not possible.
isIllegalOperationErrorType :: IOErrorType -> Bool

-- | I/O error where the operation failed because the user does not have
grsufficient operating system privilege to perform that operation.
isPermissionErrorType :: IOErrorType -> Bool

-- | I/O error that is programmer-defined.
isUserErrorType :: IOErrorType -> Bool

-- | Raise an <a>IOError</a> in the <a>IO</a> monad.
ioError :: IOError -> IO a

-- | The <a>catchIOError</a> function establishes a handler that receives
grany <a>IOError</a> raised in the action protected by
gr<a>catchIOError</a>. An <a>IOError</a> is caught by the most recent
grhandler established by one of the exception handling functions. These
grhandlers are not selective: all <a>IOError</a>s are caught. Exception
grpropagation must be explicitly provided in a handler by re-raising any
grunwanted exceptions. For example, in
gr
gr<pre>
grf = catchIOError g (\e -&gt; if IO.isEOFError e then return [] else ioError e)
gr</pre>
gr
grthe function <tt>f</tt> returns <tt>[]</tt> when an end-of-file
grexception (cf. <a>isEOFError</a>) occurs in <tt>g</tt>; otherwise, the
grexception is propagated to the next outer handler.
gr
grWhen an exception propagates outside the main program, the Haskell
grsystem prints the associated <a>IOError</a> value and exits the
grprogram.
gr
grNon-I/O exceptions are not caught by this variant; to catch all
grexceptions, use <a>catch</a> from <a>Control.Exception</a>.
catchIOError :: IO a -> (IOError -> IO a) -> IO a

-- | The construct <a>tryIOError</a> <tt>comp</tt> exposes IO errors which
groccur within a computation, and which are not fully handled.
gr
grNon-I/O exceptions are not caught by this variant; to catch all
grexceptions, use <a>try</a> from <a>Control.Exception</a>.
tryIOError :: IO a -> IO (Either IOError a)

-- | Catch any <a>IOError</a> that occurs in the computation and throw a
grmodified version.
modifyIOError :: (IOError -> IOError) -> IO a -> IO a


-- | This module provides support for raising and catching both built-in
grand user-defined exceptions.
gr
grIn addition to exceptions thrown by <a>IO</a> operations, exceptions
grmay be thrown by pure code (imprecise exceptions) or by external
grevents (asynchronous exceptions), but may only be caught in the
gr<a>IO</a> monad. For more details, see:
gr
gr<ul>
gr<li><i>A semantics for imprecise exceptions</i>, by Simon Peyton
grJones, Alastair Reid, Tony Hoare, Simon Marlow, Fergus Henderson, in
gr<i>PLDI'99</i>.</li>
gr<li><i>Asynchronous exceptions in Haskell</i>, by Simon Marlow, Simon
grPeyton Jones, Andy Moran and John Reppy, in <i>PLDI'01</i>.</li>
gr<li><i>An Extensible Dynamically-Typed Hierarchy of Exceptions</i>, by
grSimon Marlow, in <i>Haskell '06</i>.</li>
gr</ul>
module Control.Exception

-- | The <tt>SomeException</tt> type is the root of the exception type
grhierarchy. When an exception of type <tt>e</tt> is thrown, behind the
grscenes it is encapsulated in a <tt>SomeException</tt>.
data SomeException
SomeException :: e -> SomeException

-- | Any type that you wish to throw or catch as an exception must be an
grinstance of the <tt>Exception</tt> class. The simplest case is a new
grexception type directly below the root:
gr
gr<pre>
grdata MyException = ThisException | ThatException
gr    deriving Show
gr
grinstance Exception MyException
gr</pre>
gr
grThe default method definitions in the <tt>Exception</tt> class do what
grwe need in this case. You can now throw and catch
gr<tt>ThisException</tt> and <tt>ThatException</tt> as exceptions:
gr
gr<pre>
gr*Main&gt; throw ThisException `catch` \e -&gt; putStrLn ("Caught " ++ show (e :: MyException))
grCaught ThisException
gr</pre>
gr
grIn more complicated examples, you may wish to define a whole hierarchy
grof exceptions:
gr
gr<pre>
gr---------------------------------------------------------------------
gr-- Make the root exception type for all the exceptions in a compiler
gr
grdata SomeCompilerException = forall e . Exception e =&gt; SomeCompilerException e
gr
grinstance Show SomeCompilerException where
gr    show (SomeCompilerException e) = show e
gr
grinstance Exception SomeCompilerException
gr
grcompilerExceptionToException :: Exception e =&gt; e -&gt; SomeException
grcompilerExceptionToException = toException . SomeCompilerException
gr
grcompilerExceptionFromException :: Exception e =&gt; SomeException -&gt; Maybe e
grcompilerExceptionFromException x = do
gr    SomeCompilerException a &lt;- fromException x
gr    cast a
gr
gr---------------------------------------------------------------------
gr-- Make a subhierarchy for exceptions in the frontend of the compiler
gr
grdata SomeFrontendException = forall e . Exception e =&gt; SomeFrontendException e
gr
grinstance Show SomeFrontendException where
gr    show (SomeFrontendException e) = show e
gr
grinstance Exception SomeFrontendException where
gr    toException = compilerExceptionToException
gr    fromException = compilerExceptionFromException
gr
grfrontendExceptionToException :: Exception e =&gt; e -&gt; SomeException
grfrontendExceptionToException = toException . SomeFrontendException
gr
grfrontendExceptionFromException :: Exception e =&gt; SomeException -&gt; Maybe e
grfrontendExceptionFromException x = do
gr    SomeFrontendException a &lt;- fromException x
gr    cast a
gr
gr---------------------------------------------------------------------
gr-- Make an exception type for a particular frontend compiler exception
gr
grdata MismatchedParentheses = MismatchedParentheses
gr    deriving Show
gr
grinstance Exception MismatchedParentheses where
gr    toException   = frontendExceptionToException
gr    fromException = frontendExceptionFromException
gr</pre>
gr
grWe can now catch a <tt>MismatchedParentheses</tt> exception as
gr<tt>MismatchedParentheses</tt>, <tt>SomeFrontendException</tt> or
gr<tt>SomeCompilerException</tt>, but not other types, e.g.
gr<tt>IOException</tt>:
gr
gr<pre>
gr*Main&gt; throw MismatchedParentheses `catch` \e -&gt; putStrLn ("Caught " ++ show (e :: MismatchedParentheses))
grCaught MismatchedParentheses
gr*Main&gt; throw MismatchedParentheses `catch` \e -&gt; putStrLn ("Caught " ++ show (e :: SomeFrontendException))
grCaught MismatchedParentheses
gr*Main&gt; throw MismatchedParentheses `catch` \e -&gt; putStrLn ("Caught " ++ show (e :: SomeCompilerException))
grCaught MismatchedParentheses
gr*Main&gt; throw MismatchedParentheses `catch` \e -&gt; putStrLn ("Caught " ++ show (e :: IOException))
gr*** Exception: MismatchedParentheses
gr</pre>
class (Typeable e, Show e) => Exception e
toException :: Exception e => e -> SomeException
fromException :: Exception e => SomeException -> Maybe e

-- | Render this exception value in a human-friendly manner.
gr
grDefault implementation: <tt><a>show</a></tt>.
displayException :: Exception e => e -> String

-- | Exceptions that occur in the <tt>IO</tt> monad. An
gr<tt>IOException</tt> records a more specific error type, a descriptive
grstring and maybe the handle that was used when the error was flagged.
data IOException

-- | Arithmetic exceptions.
data ArithException
Overflow :: ArithException
Underflow :: ArithException
LossOfPrecision :: ArithException
DivideByZero :: ArithException
Denormal :: ArithException

RatioZeroDenominator :: ArithException

-- | Exceptions generated by array operations
data ArrayException

-- | An attempt was made to index an array outside its declared bounds.
IndexOutOfBounds :: String -> ArrayException

-- | An attempt was made to evaluate an element of an array that had not
grbeen initialized.
UndefinedElement :: String -> ArrayException

-- | <a>assert</a> was applied to <a>False</a>.
newtype AssertionFailed
AssertionFailed :: String -> AssertionFailed

-- | Superclass for asynchronous exceptions.
data SomeAsyncException
SomeAsyncException :: e -> SomeAsyncException

-- | Asynchronous exceptions.
data AsyncException

-- | The current thread's stack exceeded its limit. Since an exception has
grbeen raised, the thread's stack will certainly be below its limit
gragain, but the programmer should take remedial action immediately.
StackOverflow :: AsyncException

-- | The program's heap is reaching its limit, and the program should take
graction to reduce the amount of live data it has. Notes:
gr
gr<ul>
gr<li>It is undefined which thread receives this exception. GHC
grcurrently throws this to the same thread that receives
gr<a>UserInterrupt</a>, but this may change in the future.</li>
gr<li>The GHC RTS currently can only recover from heap overflow if it
grdetects that an explicit memory limit (set via RTS flags). has been
grexceeded. Currently, failure to allocate memory from the operating
grsystem results in immediate termination of the program.</li>
gr</ul>
HeapOverflow :: AsyncException

-- | This exception is raised by another thread calling <a>killThread</a>,
gror by the system if it needs to terminate the thread for some reason.
ThreadKilled :: AsyncException

-- | This exception is raised by default in the main thread of the program
grwhen the user requests to terminate the program via the usual
grmechanism(s) (e.g. Control-C in the console).
UserInterrupt :: AsyncException

asyncExceptionToException :: Exception e => e -> SomeException

asyncExceptionFromException :: Exception e => SomeException -> Maybe e

-- | Thrown when the runtime system detects that the computation is
grguaranteed not to terminate. Note that there is no guarantee that the
grruntime system will notice whether any given computation is guaranteed
grto terminate or not.
data NonTermination
NonTermination :: NonTermination

-- | Thrown when the program attempts to call <tt>atomically</tt>, from the
gr<tt>stm</tt> package, inside another call to <tt>atomically</tt>.
data NestedAtomically
NestedAtomically :: NestedAtomically

-- | The thread is blocked on an <tt>MVar</tt>, but there are no other
grreferences to the <tt>MVar</tt> so it can't ever continue.
data BlockedIndefinitelyOnMVar
BlockedIndefinitelyOnMVar :: BlockedIndefinitelyOnMVar

-- | The thread is waiting to retry an STM transaction, but there are no
grother references to any <tt>TVar</tt>s involved, so it can't ever
grcontinue.
data BlockedIndefinitelyOnSTM
BlockedIndefinitelyOnSTM :: BlockedIndefinitelyOnSTM

-- | This thread has exceeded its allocation limit. See
gr<a>setAllocationCounter</a> and <a>enableAllocationLimit</a>.
data AllocationLimitExceeded
AllocationLimitExceeded :: AllocationLimitExceeded

-- | Compaction found an object that cannot be compacted. Functions cannot
grbe compacted, nor can mutable objects or pinned objects. See
gr<a>compact</a>.
newtype CompactionFailed
CompactionFailed :: String -> CompactionFailed

-- | There are no runnable threads, so the program is deadlocked. The
gr<tt>Deadlock</tt> exception is raised in the main thread only.
data Deadlock
Deadlock :: Deadlock

-- | A class method without a definition (neither a default definition, nor
gra definition in the appropriate instance) was called. The
gr<tt>String</tt> gives information about which method it was.
newtype NoMethodError
NoMethodError :: String -> NoMethodError

-- | A pattern match failed. The <tt>String</tt> gives information about
grthe source location of the pattern.
newtype PatternMatchFail
PatternMatchFail :: String -> PatternMatchFail

-- | An uninitialised record field was used. The <tt>String</tt> gives
grinformation about the source location where the record was
grconstructed.
newtype RecConError
RecConError :: String -> RecConError

-- | A record selector was applied to a constructor without the appropriate
grfield. This can only happen with a datatype with multiple
grconstructors, where some fields are in one constructor but not
granother. The <tt>String</tt> gives information about the source
grlocation of the record selector.
newtype RecSelError
RecSelError :: String -> RecSelError

-- | A record update was performed on a constructor without the appropriate
grfield. This can only happen with a datatype with multiple
grconstructors, where some fields are in one constructor but not
granother. The <tt>String</tt> gives information about the source
grlocation of the record update.
newtype RecUpdError
RecUpdError :: String -> RecUpdError

-- | This is thrown when the user calls <a>error</a>. The first
gr<tt>String</tt> is the argument given to <a>error</a>, second
gr<tt>String</tt> is the location.
data ErrorCall
ErrorCallWithLocation :: String -> String -> ErrorCall

-- | An expression that didn't typecheck during compile time was called.
grThis is only possible with -fdefer-type-errors. The <tt>String</tt>
grgives details about the failed type check.
newtype TypeError
TypeError :: String -> TypeError

-- | Throw an exception. Exceptions may be thrown from purely functional
grcode, but may only be caught within the <a>IO</a> monad.
throw :: Exception e => e -> a

-- | A variant of <a>throw</a> that can only be used within the <a>IO</a>
grmonad.
gr
grAlthough <a>throwIO</a> has a type that is an instance of the type of
gr<a>throw</a>, the two functions are subtly different:
gr
gr<pre>
grthrow e   `seq` x  ===&gt; throw e
grthrowIO e `seq` x  ===&gt; x
gr</pre>
gr
grThe first example will cause the exception <tt>e</tt> to be raised,
grwhereas the second one won't. In fact, <a>throwIO</a> will only cause
gran exception to be raised when it is used within the <a>IO</a> monad.
grThe <a>throwIO</a> variant should be used in preference to
gr<a>throw</a> to raise an exception within the <a>IO</a> monad because
grit guarantees ordering with respect to other <a>IO</a> operations,
grwhereas <a>throw</a> does not.
throwIO :: Exception e => e -> IO a

-- | Raise an <a>IOError</a> in the <a>IO</a> monad.
ioError :: IOError -> IO a

-- | <a>throwTo</a> raises an arbitrary exception in the target thread (GHC
gronly).
gr
grException delivery synchronizes between the source and target thread:
gr<a>throwTo</a> does not return until the exception has been raised in
grthe target thread. The calling thread can thus be certain that the
grtarget thread has received the exception. Exception delivery is also
gratomic with respect to other exceptions. Atomicity is a useful
grproperty to have when dealing with race conditions: e.g. if there are
grtwo threads that can kill each other, it is guaranteed that only one
grof the threads will get to kill the other.
gr
grWhatever work the target thread was doing when the exception was
grraised is not lost: the computation is suspended until required by
granother thread.
gr
grIf the target thread is currently making a foreign call, then the
grexception will not be raised (and hence <a>throwTo</a> will not
grreturn) until the call has completed. This is the case regardless of
grwhether the call is inside a <a>mask</a> or not. However, in GHC a
grforeign call can be annotated as <tt>interruptible</tt>, in which case
gra <a>throwTo</a> will cause the RTS to attempt to cause the call to
grreturn; see the GHC documentation for more details.
gr
grImportant note: the behaviour of <a>throwTo</a> differs from that
grdescribed in the paper "Asynchronous exceptions in Haskell"
gr(<a>http://research.microsoft.com/~simonpj/Papers/asynch-exns.htm</a>).
grIn the paper, <a>throwTo</a> is non-blocking; but the library
grimplementation adopts a more synchronous design in which
gr<a>throwTo</a> does not return until the exception is received by the
grtarget thread. The trade-off is discussed in Section 9 of the paper.
grLike any blocking operation, <a>throwTo</a> is therefore interruptible
gr(see Section 5.3 of the paper). Unlike other interruptible operations,
grhowever, <a>throwTo</a> is <i>always</i> interruptible, even if it
grdoes not actually block.
gr
grThere is no guarantee that the exception will be delivered promptly,
gralthough the runtime will endeavour to ensure that arbitrary delays
grdon't occur. In GHC, an exception can only be raised when a thread
grreaches a <i>safe point</i>, where a safe point is where memory
grallocation occurs. Some loops do not perform any memory allocation
grinside the loop and therefore cannot be interrupted by a
gr<a>throwTo</a>.
gr
grIf the target of <a>throwTo</a> is the calling thread, then the
grbehaviour is the same as <a>throwIO</a>, except that the exception is
grthrown as an asynchronous exception. This means that if there is an
grenclosing pure computation, which would be the case if the current IO
groperation is inside <a>unsafePerformIO</a> or
gr<a>unsafeInterleaveIO</a>, that computation is not permanently
grreplaced by the exception, but is suspended as if it had received an
grasynchronous exception.
gr
grNote that if <a>throwTo</a> is called with the current thread as the
grtarget, the exception will be thrown even if the thread is currently
grinside <a>mask</a> or <a>uninterruptibleMask</a>.
throwTo :: Exception e => ThreadId -> e -> IO ()

-- | This is the simplest of the exception-catching functions. It takes a
grsingle argument, runs it, and if an exception is raised the "handler"
gris executed, with the value of the exception passed as an argument.
grOtherwise, the result is returned as normal. For example:
gr
gr<pre>
grcatch (readFile f)
gr      (\e -&gt; do let err = show (e :: IOException)
gr                hPutStr stderr ("Warning: Couldn't open " ++ f ++ ": " ++ err)
gr                return "")
gr</pre>
gr
grNote that we have to give a type signature to <tt>e</tt>, or the
grprogram will not typecheck as the type is ambiguous. While it is
grpossible to catch exceptions of any type, see the section "Catching
grall exceptions" (in <a>Control.Exception</a>) for an explanation of
grthe problems with doing so.
gr
grFor catching exceptions in pure (non-<a>IO</a>) expressions, see the
grfunction <a>evaluate</a>.
gr
grNote that due to Haskell's unspecified evaluation order, an expression
grmay throw one of several possible exceptions: consider the expression
gr<tt>(error "urk") + (1 `div` 0)</tt>. Does the expression throw
gr<tt>ErrorCall "urk"</tt>, or <tt>DivideByZero</tt>?
gr
grThe answer is "it might throw either"; the choice is
grnon-deterministic. If you are catching any type of exception then you
grmight catch either. If you are calling <tt>catch</tt> with type <tt>IO
grInt -&gt; (ArithException -&gt; IO Int) -&gt; IO Int</tt> then the
grhandler may get run with <tt>DivideByZero</tt> as an argument, or an
gr<tt>ErrorCall "urk"</tt> exception may be propogated further up. If
gryou call it again, you might get a the opposite behaviour. This is ok,
grbecause <a>catch</a> is an <a>IO</a> computation.
catch :: Exception e => IO a -> (e -> IO a) -> IO a

-- | Sometimes you want to catch two different sorts of exception. You
grcould do something like
gr
gr<pre>
grf = expr `catch` \ (ex :: ArithException) -&gt; handleArith ex
gr         `catch` \ (ex :: IOException)    -&gt; handleIO    ex
gr</pre>
gr
grHowever, there are a couple of problems with this approach. The first
gris that having two exception handlers is inefficient. However, the
grmore serious issue is that the second exception handler will catch
grexceptions in the first, e.g. in the example above, if
gr<tt>handleArith</tt> throws an <tt>IOException</tt> then the second
grexception handler will catch it.
gr
grInstead, we provide a function <a>catches</a>, which would be used
grthus:
gr
gr<pre>
grf = expr `catches` [Handler (\ (ex :: ArithException) -&gt; handleArith ex),
gr                    Handler (\ (ex :: IOException)    -&gt; handleIO    ex)]
gr</pre>
catches :: IO a -> [Handler a] -> IO a

-- | You need this when using <a>catches</a>.
data Handler a
Handler :: (e -> IO a) -> Handler a

-- | The function <a>catchJust</a> is like <a>catch</a>, but it takes an
grextra argument which is an <i>exception predicate</i>, a function
grwhich selects which type of exceptions we're interested in.
gr
gr<pre>
grcatchJust (\e -&gt; if isDoesNotExistErrorType (ioeGetErrorType e) then Just () else Nothing)
gr          (readFile f)
gr          (\_ -&gt; do hPutStrLn stderr ("No such file: " ++ show f)
gr                    return "")
gr</pre>
gr
grAny other exceptions which are not matched by the predicate are
grre-raised, and may be caught by an enclosing <a>catch</a>,
gr<a>catchJust</a>, etc.
catchJust :: Exception e => (e -> Maybe b) -> IO a -> (b -> IO a) -> IO a

-- | A version of <a>catch</a> with the arguments swapped around; useful in
grsituations where the code for the handler is shorter. For example:
gr
gr<pre>
grdo handle (\NonTermination -&gt; exitWith (ExitFailure 1)) $
gr   ...
gr</pre>
handle :: Exception e => (e -> IO a) -> IO a -> IO a

-- | A version of <a>catchJust</a> with the arguments swapped around (see
gr<a>handle</a>).
handleJust :: Exception e => (e -> Maybe b) -> (b -> IO a) -> IO a -> IO a

-- | Similar to <a>catch</a>, but returns an <a>Either</a> result which is
gr<tt>(<a>Right</a> a)</tt> if no exception of type <tt>e</tt> was
grraised, or <tt>(<a>Left</a> ex)</tt> if an exception of type
gr<tt>e</tt> was raised and its value is <tt>ex</tt>. If any other type
grof exception is raised than it will be propogated up to the next
grenclosing exception handler.
gr
gr<pre>
grtry a = catch (Right `liftM` a) (return . Left)
gr</pre>
try :: Exception e => IO a -> IO (Either e a)

-- | A variant of <a>try</a> that takes an exception predicate to select
grwhich exceptions are caught (c.f. <a>catchJust</a>). If the exception
grdoes not match the predicate, it is re-thrown.
tryJust :: Exception e => (e -> Maybe b) -> IO a -> IO (Either b a)

-- | Evaluate the argument to weak head normal form.
gr
gr<a>evaluate</a> is typically used to uncover any exceptions that a
grlazy value may contain, and possibly handle them.
gr
gr<a>evaluate</a> only evaluates to <i>weak head normal form</i>. If
grdeeper evaluation is needed, the <tt>force</tt> function from
gr<tt>Control.DeepSeq</tt> may be handy:
gr
gr<pre>
grevaluate $ force x
gr</pre>
gr
grThere is a subtle difference between <tt><a>evaluate</a> x</tt> and
gr<tt><a>return</a> <a>$!</a> x</tt>, analogous to the difference
grbetween <a>throwIO</a> and <a>throw</a>. If the lazy value <tt>x</tt>
grthrows an exception, <tt><a>return</a> <a>$!</a> x</tt> will fail to
grreturn an <a>IO</a> action and will throw an exception instead.
gr<tt><a>evaluate</a> x</tt>, on the other hand, always produces an
gr<a>IO</a> action; that action will throw an exception upon
gr<i>execution</i> iff <tt>x</tt> throws an exception upon
gr<i>evaluation</i>.
gr
grThe practical implication of this difference is that due to the
gr<i>imprecise exceptions</i> semantics,
gr
gr<pre>
gr(return $! error "foo") &gt;&gt; error "bar"
gr</pre>
gr
grmay throw either <tt>"foo"</tt> or <tt>"bar"</tt>, depending on the
groptimizations performed by the compiler. On the other hand,
gr
gr<pre>
grevaluate (error "foo") &gt;&gt; error "bar"
gr</pre>
gr
gris guaranteed to throw <tt>"foo"</tt>.
gr
grThe rule of thumb is to use <a>evaluate</a> to force or handle
grexceptions in lazy values. If, on the other hand, you are forcing a
grlazy value for efficiency reasons only and do not care about
grexceptions, you may use <tt><a>return</a> <a>$!</a> x</tt>.
evaluate :: a -> IO a

-- | This function maps one exception into another as proposed in the paper
gr"A semantics for imprecise exceptions".
mapException :: (Exception e1, Exception e2) => (e1 -> e2) -> a -> a

-- | Executes an IO computation with asynchronous exceptions <i>masked</i>.
grThat is, any thread which attempts to raise an exception in the
grcurrent thread with <a>throwTo</a> will be blocked until asynchronous
grexceptions are unmasked again.
gr
grThe argument passed to <a>mask</a> is a function that takes as its
grargument another function, which can be used to restore the prevailing
grmasking state within the context of the masked computation. For
grexample, a common way to use <a>mask</a> is to protect the acquisition
grof a resource:
gr
gr<pre>
grmask $ \restore -&gt; do
gr    x &lt;- acquire
gr    restore (do_something_with x) `onException` release
gr    release
gr</pre>
gr
grThis code guarantees that <tt>acquire</tt> is paired with
gr<tt>release</tt>, by masking asynchronous exceptions for the critical
grparts. (Rather than write this code yourself, it would be better to
gruse <a>bracket</a> which abstracts the general pattern).
gr
grNote that the <tt>restore</tt> action passed to the argument to
gr<a>mask</a> does not necessarily unmask asynchronous exceptions, it
grjust restores the masking state to that of the enclosing context. Thus
grif asynchronous exceptions are already masked, <a>mask</a> cannot be
grused to unmask exceptions again. This is so that if you call a library
grfunction with exceptions masked, you can be sure that the library call
grwill not be able to unmask exceptions again. If you are writing
grlibrary code and need to use asynchronous exceptions, the only way is
grto create a new thread; see <a>forkIOWithUnmask</a>.
gr
grAsynchronous exceptions may still be received while in the masked
grstate if the masked thread <i>blocks</i> in certain ways; see
gr<a>Control.Exception#interruptible</a>.
gr
grThreads created by <a>forkIO</a> inherit the <a>MaskingState</a> from
grthe parent; that is, to start a thread in the
gr<a>MaskedInterruptible</a> state, use <tt>mask_ $ forkIO ...</tt>.
grThis is particularly useful if you need to establish an exception
grhandler in the forked thread before any asynchronous exceptions are
grreceived. To create a a new thread in an unmasked state use
gr<a>forkIOWithUnmask</a>.
mask :: ((forall a. IO a -> IO a) -> IO b) -> IO b

-- | Like <a>mask</a>, but does not pass a <tt>restore</tt> action to the
grargument.
mask_ :: IO a -> IO a

-- | Like <a>mask</a>, but the masked computation is not interruptible (see
gr<a>Control.Exception#interruptible</a>). THIS SHOULD BE USED WITH
grGREAT CARE, because if a thread executing in
gr<a>uninterruptibleMask</a> blocks for any reason, then the thread (and
grpossibly the program, if this is the main thread) will be unresponsive
grand unkillable. This function should only be necessary if you need to
grmask exceptions around an interruptible operation, and you can
grguarantee that the interruptible operation will only block for a short
grperiod of time.
uninterruptibleMask :: ((forall a. IO a -> IO a) -> IO b) -> IO b

-- | Like <a>uninterruptibleMask</a>, but does not pass a <tt>restore</tt>
graction to the argument.
uninterruptibleMask_ :: IO a -> IO a

-- | Describes the behaviour of a thread when an asynchronous exception is
grreceived.
data MaskingState

-- | asynchronous exceptions are unmasked (the normal state)
Unmasked :: MaskingState

-- | the state during <a>mask</a>: asynchronous exceptions are masked, but
grblocking operations may still be interrupted
MaskedInterruptible :: MaskingState

-- | the state during <a>uninterruptibleMask</a>: asynchronous exceptions
grare masked, and blocking operations may not be interrupted
MaskedUninterruptible :: MaskingState

-- | Returns the <a>MaskingState</a> for the current thread.
getMaskingState :: IO MaskingState

-- | Allow asynchronous exceptions to be raised even inside <a>mask</a>,
grmaking the operation interruptible (see the discussion of
gr"Interruptible operations" in <a>Exception</a>).
gr
grWhen called outside <a>mask</a>, or inside <a>uninterruptibleMask</a>,
grthis function has no effect.
interruptible :: IO a -> IO a

-- | When invoked inside <a>mask</a>, this function allows a masked
grasynchronous exception to be raised, if one exists. It is equivalent
grto performing an interruptible operation (see #interruptible), but
grdoes not involve any actual blocking.
gr
grWhen called outside <a>mask</a>, or inside <a>uninterruptibleMask</a>,
grthis function has no effect.
allowInterrupt :: IO ()

-- | If the first argument evaluates to <a>True</a>, then the result is the
grsecond argument. Otherwise an <tt>AssertionFailed</tt> exception is
grraised, containing a <a>String</a> with the source file and line
grnumber of the call to <a>assert</a>.
gr
grAssertions can normally be turned on or off with a compiler flag (for
grGHC, assertions are normally on unless optimisation is turned on with
gr<tt>-O</tt> or the <tt>-fignore-asserts</tt> option is given). When
grassertions are turned off, the first argument to <a>assert</a> is
grignored, and the second argument is returned as the result.
assert :: Bool -> a -> a

-- | When you want to acquire a resource, do some work with it, and then
grrelease the resource, it is a good idea to use <a>bracket</a>, because
gr<a>bracket</a> will install the necessary exception handler to release
grthe resource in the event that an exception is raised during the
grcomputation. If an exception is raised, then <a>bracket</a> will
grre-raise the exception (after performing the release).
gr
grA common example is opening a file:
gr
gr<pre>
grbracket
gr  (openFile "filename" ReadMode)
gr  (hClose)
gr  (\fileHandle -&gt; do { ... })
gr</pre>
gr
grThe arguments to <a>bracket</a> are in this order so that we can
grpartially apply it, e.g.:
gr
gr<pre>
grwithFile name mode = bracket (openFile name mode) hClose
gr</pre>
bracket :: IO a -> (a -> IO b) -> (a -> IO c) -> IO c

-- | A variant of <a>bracket</a> where the return value from the first
grcomputation is not required.
bracket_ :: IO a -> IO b -> IO c -> IO c

-- | Like <a>bracket</a>, but only performs the final action if there was
gran exception raised by the in-between computation.
bracketOnError :: IO a -> (a -> IO b) -> (a -> IO c) -> IO c

-- | A specialised variant of <a>bracket</a> with just a computation to run
grafterward.
finally :: IO a -> IO b -> IO a

-- | Like <a>finally</a>, but only performs the final action if there was
gran exception raised by the computation.
onException :: IO a -> IO b -> IO a
instance GHC.Base.Functor Control.Exception.Handler


-- | "Unsafe" IO operations.
module System.IO.Unsafe

-- | This is the "back door" into the <a>IO</a> monad, allowing <a>IO</a>
grcomputation to be performed at any time. For this to be safe, the
gr<a>IO</a> computation should be free of side effects and independent
grof its environment.
gr
grIf the I/O computation wrapped in <a>unsafePerformIO</a> performs side
greffects, then the relative order in which those side effects take
grplace (relative to the main I/O trunk, or other calls to
gr<a>unsafePerformIO</a>) is indeterminate. Furthermore, when using
gr<a>unsafePerformIO</a> to cause side-effects, you should take the
grfollowing precautions to ensure the side effects are performed as many
grtimes as you expect them to be. Note that these precautions are
grnecessary for GHC, but may not be sufficient, and other compilers may
grrequire different precautions:
gr
gr<ul>
gr<li>Use <tt>{-# NOINLINE foo #-}</tt> as a pragma on any function
gr<tt>foo</tt> that calls <a>unsafePerformIO</a>. If the call is
grinlined, the I/O may be performed more than once.</li>
gr<li>Use the compiler flag <tt>-fno-cse</tt> to prevent common
grsub-expression elimination being performed on the module, which might
grcombine two side effects that were meant to be separate. A good
grexample is using multiple global variables (like <tt>test</tt> in the
grexample below).</li>
gr<li>Make sure that the either you switch off let-floating
gr(<tt>-fno-full-laziness</tt>), or that the call to
gr<a>unsafePerformIO</a> cannot float outside a lambda. For example, if
gryou say: <tt> f x = unsafePerformIO (newIORef []) </tt> you may get
gronly one reference cell shared between all calls to <tt>f</tt>. Better
grwould be <tt> f x = unsafePerformIO (newIORef [x]) </tt> because now
grit can't float outside the lambda.</li>
gr</ul>
gr
grIt is less well known that <a>unsafePerformIO</a> is not type safe.
grFor example:
gr
gr<pre>
grtest :: IORef [a]
grtest = unsafePerformIO $ newIORef []
gr
grmain = do
gr        writeIORef test [42]
gr        bang &lt;- readIORef test
gr        print (bang :: [Char])
gr</pre>
gr
grThis program will core dump. This problem with polymorphic references
gris well known in the ML community, and does not arise with normal
grmonadic use of references. There is no easy way to make it impossible
gronce you use <a>unsafePerformIO</a>. Indeed, it is possible to write
gr<tt>coerce :: a -&gt; b</tt> with the help of <a>unsafePerformIO</a>.
grSo be careful!
unsafePerformIO :: IO a -> a

-- | This version of <a>unsafePerformIO</a> is more efficient because it
gromits the check that the IO is only being performed by a single
grthread. Hence, when you use <a>unsafeDupablePerformIO</a>, there is a
grpossibility that the IO action may be performed multiple times (on a
grmultiprocessor), and you should therefore ensure that it gives the
grsame results each time. It may even happen that one of the duplicated
grIO actions is only run partially, and then interrupted in the middle
grwithout an exception being raised. Therefore, functions like
gr<tt>bracket</tt> cannot be used safely within
gr<a>unsafeDupablePerformIO</a>.
unsafeDupablePerformIO :: IO a -> a

-- | <a>unsafeInterleaveIO</a> allows an <a>IO</a> computation to be
grdeferred lazily. When passed a value of type <tt>IO a</tt>, the
gr<a>IO</a> will only be performed when the value of the <tt>a</tt> is
grdemanded. This is used to implement lazy file reading, see
gr<a>hGetContents</a>.
unsafeInterleaveIO :: IO a -> IO a

-- | A slightly faster version of <a>fixIO</a> that may not be safe to use
grwith multiple threads. The unsafety arises when used like this:
gr
gr<pre>
grunsafeFixIO $ \r -&gt; do
gr   forkIO (print r)
gr   return (...)
gr</pre>
gr
grIn this case, the child thread will receive a <tt>NonTermination</tt>
grexception instead of waiting for the value of <tt>r</tt> to be
grcomputed.
unsafeFixIO :: (a -> IO a) -> IO a


-- | Text codecs for I/O
module GHC.IO.Encoding
data BufferCodec from to state
BufferCodec :: CodeBuffer from to -> Buffer from -> Buffer to -> IO (Buffer from, Buffer to) -> IO () -> IO state -> state -> IO () -> BufferCodec from to state

-- | The <tt>encode</tt> function translates elements of the buffer
gr<tt>from</tt> to the buffer <tt>to</tt>. It should translate as many
grelements as possible given the sizes of the buffers, including
grtranslating zero elements if there is either not enough room in
gr<tt>to</tt>, or <tt>from</tt> does not contain a complete multibyte
grsequence.
gr
grIf multiple CodingProgress returns are possible, OutputUnderflow must
grbe preferred to InvalidSequence. This allows GHC's IO library to
grassume that if we observe InvalidSequence there is at least a single
grelement available in the output buffer.
gr
grThe fact that as many elements as possible are translated is used by
grthe IO library in order to report translation errors at the point they
gractually occur, rather than when the buffer is translated.
[encode] :: BufferCodec from to state -> CodeBuffer from to

-- | The <tt>recover</tt> function is used to continue decoding in the
grpresence of invalid or unrepresentable sequences. This includes both
grthose detected by <tt>encode</tt> returning <tt>InvalidSequence</tt>
grand those that occur because the input byte sequence appears to be
grtruncated.
gr
grProgress will usually be made by skipping the first element of the
gr<tt>from</tt> buffer. This function should only be called if you are
grcertain that you wish to do this skipping and if the <tt>to</tt>
grbuffer has at least one element of free space. Because this function
grdeals with decoding failure, it assumes that the from buffer has at
grleast one element.
gr
gr<tt>recover</tt> may raise an exception rather than skipping anything.
gr
grCurrently, some implementations of <tt>recover</tt> may mutate the
grinput buffer. In particular, this feature is used to implement
grtransliteration.
[recover] :: BufferCodec from to state -> Buffer from -> Buffer to -> IO (Buffer from, Buffer to)

-- | Resources associated with the encoding may now be released. The
gr<tt>encode</tt> function may not be called again after calling
gr<tt>close</tt>.
[close] :: BufferCodec from to state -> IO ()

-- | Return the current state of the codec.
gr
grMany codecs are not stateful, and in these case the state can be
grrepresented as '()'. Other codecs maintain a state. For example,
grUTF-16 recognises a BOM (byte-order-mark) character at the beginning
grof the input, and remembers thereafter whether to use big-endian or
grlittle-endian mode. In this case, the state of the codec would include
grtwo pieces of information: whether we are at the beginning of the
grstream (the BOM only occurs at the beginning), and if not, whether to
gruse the big or little-endian encoding.
[getState] :: BufferCodec from to state -> IO state
[setState] :: BufferCodec from to state -> state -> IO ()

-- | A <a>TextEncoding</a> is a specification of a conversion scheme
grbetween sequences of bytes and sequences of Unicode characters.
gr
grFor example, UTF-8 is an encoding of Unicode characters into a
grsequence of bytes. The <a>TextEncoding</a> for UTF-8 is <tt>utf8</tt>.
data TextEncoding
TextEncoding :: String -> IO (TextDecoder dstate) -> IO (TextEncoder estate) -> TextEncoding

-- | a string that can be passed to <tt>mkTextEncoding</tt> to create an
grequivalent <a>TextEncoding</a>.
[textEncodingName] :: TextEncoding -> String

-- | Creates a means of decoding bytes into characters: the result must not
grbe shared between several byte sequences or simultaneously across
grthreads
[mkTextDecoder] :: TextEncoding -> IO (TextDecoder dstate)

-- | Creates a means of encode characters into bytes: the result must not
grbe shared between several character sequences or simultaneously across
grthreads
[mkTextEncoder] :: TextEncoding -> IO (TextEncoder estate)
type TextEncoder state = BufferCodec CharBufElem Word8 state
type TextDecoder state = BufferCodec Word8 CharBufElem state

data CodingProgress

-- | Stopped because the input contains insufficient available elements, or
grall of the input sequence has been successfully translated.
InputUnderflow :: CodingProgress

-- | Stopped because the output contains insufficient free elements
OutputUnderflow :: CodingProgress

-- | Stopped because there are sufficient free elements in the output to
groutput at least one encoded ASCII character, but the input contains an
grinvalid or unrepresentable sequence
InvalidSequence :: CodingProgress

-- | The Latin1 (ISO8859-1) encoding. This encoding maps bytes directly to
grthe first 256 Unicode code points, and is thus not a complete Unicode
grencoding. An attempt to write a character greater than '\255' to a
gr<tt>Handle</tt> using the <a>latin1</a> encoding will result in an
grerror.
latin1 :: TextEncoding
latin1_encode :: CharBuffer -> Buffer Word8 -> IO (CharBuffer, Buffer Word8)
latin1_decode :: Buffer Word8 -> CharBuffer -> IO (Buffer Word8, CharBuffer)

-- | The UTF-8 Unicode encoding
utf8 :: TextEncoding

-- | The UTF-8 Unicode encoding, with a byte-order-mark (BOM; the byte
grsequence 0xEF 0xBB 0xBF). This encoding behaves like <a>utf8</a>,
grexcept that on input, the BOM sequence is ignored at the beginning of
grthe stream, and on output, the BOM sequence is prepended.
gr
grThe byte-order-mark is strictly unnecessary in UTF-8, but is sometimes
grused to identify the encoding of a file.
utf8_bom :: TextEncoding

-- | The UTF-16 Unicode encoding (a byte-order-mark should be used to
grindicate endianness).
utf16 :: TextEncoding

-- | The UTF-16 Unicode encoding (litte-endian)
utf16le :: TextEncoding

-- | The UTF-16 Unicode encoding (big-endian)
utf16be :: TextEncoding

-- | The UTF-32 Unicode encoding (a byte-order-mark should be used to
grindicate endianness).
utf32 :: TextEncoding

-- | The UTF-32 Unicode encoding (litte-endian)
utf32le :: TextEncoding

-- | The UTF-32 Unicode encoding (big-endian)
utf32be :: TextEncoding

initLocaleEncoding :: TextEncoding

-- | The Unicode encoding of the current locale
getLocaleEncoding :: IO TextEncoding

-- | The Unicode encoding of the current locale, but allowing arbitrary
grundecodable bytes to be round-tripped through it.
gr
grThis <a>TextEncoding</a> is used to decode and encode command line
grarguments and environment variables on non-Windows platforms.
gr
grOn Windows, this encoding *should not* be used if possible because the
gruse of code pages is deprecated: Strings should be retrieved via the
gr"wide" W-family of UTF-16 APIs instead
getFileSystemEncoding :: IO TextEncoding

-- | The Unicode encoding of the current locale, but where undecodable
grbytes are replaced with their closest visual match. Used for the
gr<tt>CString</tt> marshalling functions in <a>Foreign.C.String</a>
getForeignEncoding :: IO TextEncoding

setLocaleEncoding :: TextEncoding -> IO ()

setFileSystemEncoding :: TextEncoding -> IO ()

setForeignEncoding :: TextEncoding -> IO ()

-- | An encoding in which Unicode code points are translated to bytes by
grtaking the code point modulo 256. When decoding, bytes are translated
grdirectly into the equivalent code point.
gr
grThis encoding never fails in either direction. However, encoding
grdiscards information, so encode followed by decode is not the
gridentity.
char8 :: TextEncoding

-- | Look up the named Unicode encoding. May fail with
gr
gr<ul>
gr<li><tt>isDoesNotExistError</tt> if the encoding is unknown</li>
gr</ul>
gr
grThe set of known encodings is system-dependent, but includes at least:
gr
gr<ul>
gr<li><pre>UTF-8</pre></li>
gr<li><tt>UTF-16</tt>, <tt>UTF-16BE</tt>, <tt>UTF-16LE</tt></li>
gr<li><tt>UTF-32</tt>, <tt>UTF-32BE</tt>, <tt>UTF-32LE</tt></li>
gr</ul>
gr
grThere is additional notation (borrowed from GNU iconv) for specifying
grhow illegal characters are handled:
gr
gr<ul>
gr<li>a suffix of <tt>//IGNORE</tt>, e.g. <tt>UTF-8//IGNORE</tt>, will
grcause all illegal sequences on input to be ignored, and on output will
grdrop all code points that have no representation in the target
grencoding.</li>
gr<li>a suffix of <tt>//TRANSLIT</tt> will choose a replacement
grcharacter for illegal sequences or code points.</li>
gr<li>a suffix of <tt>//ROUNDTRIP</tt> will use a PEP383-style escape
grmechanism to represent any invalid bytes in the input as Unicode
grcodepoints (specifically, as lone surrogates, which are normally
grinvalid in UTF-32). Upon output, these special codepoints are detected
grand turned back into the corresponding original byte.</li>
gr</ul>
gr
grIn theory, this mechanism allows arbitrary data to be roundtripped via
gra <a>String</a> with no loss of data. In practice, there are two
grlimitations to be aware of:
gr
gr<ol>
gr<li>This only stands a chance of working for an encoding which is an
grASCII superset, as for security reasons we refuse to escape any bytes
grsmaller than 128. Many encodings of interest are ASCII supersets (in
grparticular, you can assume that the locale encoding is an ASCII
grsuperset) but many (such as UTF-16) are not.</li>
gr<li>If the underlying encoding is not itself roundtrippable, this
grmechanism can fail. Roundtrippable encodings are those which have an
grinjective mapping into Unicode. Almost all encodings meet this
grcriteria, but some do not. Notably, Shift-JIS (CP932) and Big5 contain
grseveral different encodings of the same Unicode codepoint.</li>
gr</ol>
gr
grOn Windows, you can access supported code pages with the prefix
gr<tt>CP</tt>; for example, <tt>"CP1250"</tt>.
mkTextEncoding :: String -> IO TextEncoding

-- | Internal encoding of argv
argvEncoding :: IO TextEncoding


-- | Access to GHC's call-stack simulation
module GHC.Stack.CCS

-- | Returns a <tt>[String]</tt> representing the current call stack. This
grcan be useful for debugging.
gr
grThe implementation uses the call-stack simulation maintained by the
grprofiler, so it only works if the program was compiled with
gr<tt>-prof</tt> and contains suitable SCC annotations (e.g. by using
gr<tt>-fprof-auto</tt>). Otherwise, the list returned is likely to be
grempty or uninformative.
currentCallStack :: IO [String]

-- | Get the stack trace attached to an object.
whoCreated :: a -> IO [String]

-- | A cost-centre stack from GHC's cost-center profiler.
data CostCentreStack

-- | A cost-centre from GHC's cost-center profiler.
data CostCentre

-- | Returns the current <a>CostCentreStack</a> (value is <tt>nullPtr</tt>
grif the current program was not compiled with profiling support). Takes
gra dummy argument which can be used to avoid the call to
gr<tt>getCurrentCCS</tt> being floated out by the simplifier, which
grwould result in an uninformative stack (<a>CAF</a>).
getCurrentCCS :: dummy -> IO (Ptr CostCentreStack)

-- | Get the <a>CostCentreStack</a> associated with the given value.
getCCSOf :: a -> IO (Ptr CostCentreStack)

-- | Run a computation with an empty cost-center stack. For example, this
gris used by the interpreter to run an interpreted computation without
grthe call stack showing that it was invoked from GHC.
clearCCS :: IO a -> IO a

-- | Get the <a>CostCentre</a> at the head of a <a>CostCentreStack</a>.
ccsCC :: Ptr CostCentreStack -> IO (Ptr CostCentre)

-- | Get the tail of a <a>CostCentreStack</a>.
ccsParent :: Ptr CostCentreStack -> IO (Ptr CostCentreStack)

-- | Get the label of a <a>CostCentre</a>.
ccLabel :: Ptr CostCentre -> IO CString

-- | Get the module of a <a>CostCentre</a>.
ccModule :: Ptr CostCentre -> IO CString

-- | Get the source span of a <a>CostCentre</a>.
ccSrcSpan :: Ptr CostCentre -> IO CString

-- | Format a <a>CostCentreStack</a> as a list of lines.
ccsToStrings :: Ptr CostCentreStack -> IO [String]
renderStack :: [String] -> String


-- | Access to GHC's call-stack simulation
module GHC.Stack

-- | Like the function <a>error</a>, but appends a stack trace to the error
grmessage if one is available.

-- | <i>Deprecated: <a>error</a> appends the call stack now</i>
errorWithStackTrace :: String -> a

-- | Returns a <tt>[String]</tt> representing the current call stack. This
grcan be useful for debugging.
gr
grThe implementation uses the call-stack simulation maintained by the
grprofiler, so it only works if the program was compiled with
gr<tt>-prof</tt> and contains suitable SCC annotations (e.g. by using
gr<tt>-fprof-auto</tt>). Otherwise, the list returned is likely to be
grempty or uninformative.
currentCallStack :: IO [String]

-- | Get the stack trace attached to an object.
whoCreated :: a -> IO [String]

-- | <a>CallStack</a>s are a lightweight method of obtaining a partial
grcall-stack at any point in the program.
gr
grA function can request its call-site with the <a>HasCallStack</a>
grconstraint. For example, we can define
gr
gr<pre>
grputStrLnWithCallStack :: HasCallStack =&gt; String -&gt; IO ()
gr</pre>
gr
gras a variant of <tt>putStrLn</tt> that will get its call-site and
grprint it, along with the string given as argument. We can access the
grcall-stack inside <tt>putStrLnWithCallStack</tt> with
gr<a>callStack</a>.
gr
gr<pre>
grputStrLnWithCallStack :: HasCallStack =&gt; String -&gt; IO ()
grputStrLnWithCallStack msg = do
gr  putStrLn msg
gr  putStrLn (prettyCallStack callStack)
gr</pre>
gr
grThus, if we call <tt>putStrLnWithCallStack</tt> we will get a
grformatted call-stack alongside our string.
gr
gr<pre>
gr&gt;&gt;&gt; putStrLnWithCallStack "hello"
grhello
grCallStack (from HasCallStack):
gr  putStrLnWithCallStack, called at &lt;interactive&gt;:2:1 in interactive:Ghci1
gr</pre>
gr
grGHC solves <a>HasCallStack</a> constraints in three steps:
gr
gr<ol>
gr<li>If there is a <a>CallStack</a> in scope -- i.e. the enclosing
grfunction has a <a>HasCallStack</a> constraint -- GHC will append the
grnew call-site to the existing <a>CallStack</a>.</li>
gr<li>If there is no <a>CallStack</a> in scope -- e.g. in the GHCi
grsession above -- and the enclosing definition does not have an
grexplicit type signature, GHC will infer a <a>HasCallStack</a>
grconstraint for the enclosing definition (subject to the monomorphism
grrestriction).</li>
gr<li>If there is no <a>CallStack</a> in scope and the enclosing
grdefinition has an explicit type signature, GHC will solve the
gr<a>HasCallStack</a> constraint for the singleton <a>CallStack</a>
grcontaining just the current call-site.</li>
gr</ol>
gr
gr<a>CallStack</a>s do not interact with the RTS and do not require
grcompilation with <tt>-prof</tt>. On the other hand, as they are built
grup explicitly via the <a>HasCallStack</a> constraints, they will
grgenerally not contain as much information as the simulated call-stacks
grmaintained by the RTS.
gr
grA <a>CallStack</a> is a <tt>[(String, SrcLoc)]</tt>. The
gr<tt>String</tt> is the name of function that was called, the
gr<a>SrcLoc</a> is the call-site. The list is ordered with the most
grrecently called function at the head.
gr
grNOTE: The intrepid user may notice that <a>HasCallStack</a> is just an
gralias for an implicit parameter <tt>?callStack :: CallStack</tt>. This
gris an implementation detail and <b>should not</b> be considered part
grof the <a>CallStack</a> API, we may decide to change the
grimplementation in the future.
data CallStack

-- | Request a CallStack.
gr
grNOTE: The implicit parameter <tt>?callStack :: CallStack</tt> is an
grimplementation detail and <b>should not</b> be considered part of the
gr<a>CallStack</a> API, we may decide to change the implementation in
grthe future.
type HasCallStack = (?callStack :: CallStack)

-- | Return the current <a>CallStack</a>.
gr
grDoes *not* include the call-site of <a>callStack</a>.
callStack :: HasCallStack => CallStack

-- | The empty <a>CallStack</a>.
emptyCallStack :: CallStack

-- | Freeze a call-stack, preventing any further call-sites from being
grappended.
gr
gr<pre>
grpushCallStack callSite (freezeCallStack callStack) = freezeCallStack callStack
gr</pre>
freezeCallStack :: CallStack -> CallStack

-- | Convert a list of call-sites to a <a>CallStack</a>.
fromCallSiteList :: [([Char], SrcLoc)] -> CallStack

-- | Extract a list of call-sites from the <a>CallStack</a>.
gr
grThe list is ordered by most recent call.
getCallStack :: CallStack -> [([Char], SrcLoc)]

-- | Pop the most recent call-site off the <a>CallStack</a>.
gr
grThis function, like <a>pushCallStack</a>, has no effect on a frozen
gr<a>CallStack</a>.
popCallStack :: CallStack -> CallStack

-- | Pretty print a <a>CallStack</a>.
prettyCallStack :: CallStack -> String

-- | Push a call-site onto the stack.
gr
grThis function has no effect on a frozen <a>CallStack</a>.
pushCallStack :: ([Char], SrcLoc) -> CallStack -> CallStack

-- | Perform some computation without adding new entries to the
gr<a>CallStack</a>.
withFrozenCallStack :: HasCallStack => (HasCallStack => a) -> a

-- | A single location in the source code.
data SrcLoc
SrcLoc :: [Char] -> [Char] -> [Char] -> Int -> Int -> Int -> Int -> SrcLoc
[srcLocPackage] :: SrcLoc -> [Char]
[srcLocModule] :: SrcLoc -> [Char]
[srcLocFile] :: SrcLoc -> [Char]
[srcLocStartLine] :: SrcLoc -> Int
[srcLocStartCol] :: SrcLoc -> Int
[srcLocEndLine] :: SrcLoc -> Int
[srcLocEndCol] :: SrcLoc -> Int

-- | Pretty print a <a>SrcLoc</a>.
prettySrcLoc :: SrcLoc -> String

-- | A cost-centre stack from GHC's cost-center profiler.
data CostCentreStack

-- | A cost-centre from GHC's cost-center profiler.
data CostCentre

-- | Returns the current <a>CostCentreStack</a> (value is <tt>nullPtr</tt>
grif the current program was not compiled with profiling support). Takes
gra dummy argument which can be used to avoid the call to
gr<tt>getCurrentCCS</tt> being floated out by the simplifier, which
grwould result in an uninformative stack (<a>CAF</a>).
getCurrentCCS :: dummy -> IO (Ptr CostCentreStack)

-- | Get the <a>CostCentreStack</a> associated with the given value.
getCCSOf :: a -> IO (Ptr CostCentreStack)

-- | Run a computation with an empty cost-center stack. For example, this
gris used by the interpreter to run an interpreted computation without
grthe call stack showing that it was invoked from GHC.
clearCCS :: IO a -> IO a

-- | Get the <a>CostCentre</a> at the head of a <a>CostCentreStack</a>.
ccsCC :: Ptr CostCentreStack -> IO (Ptr CostCentre)

-- | Get the tail of a <a>CostCentreStack</a>.
ccsParent :: Ptr CostCentreStack -> IO (Ptr CostCentreStack)

-- | Get the label of a <a>CostCentre</a>.
ccLabel :: Ptr CostCentre -> IO CString

-- | Get the module of a <a>CostCentre</a>.
ccModule :: Ptr CostCentre -> IO CString

-- | Get the source span of a <a>CostCentre</a>.
ccSrcSpan :: Ptr CostCentre -> IO CString

-- | Format a <a>CostCentreStack</a> as a list of lines.
ccsToStrings :: Ptr CostCentreStack -> IO [String]
renderStack :: [String] -> String

module GHC.Environment

-- | Computation <a>getFullArgs</a> is the "raw" version of
gr<tt>getArgs</tt>, similar to <tt>argv</tt> in other languages. It
grreturns a list of the program's command line arguments, starting with
grthe program name, and including those normally eaten by the RTS (+RTS
gr... -RTS).
getFullArgs :: IO [String]


-- | An <tt><a>MVar</a> t</tt> is mutable location that is either empty or
grcontains a value of type <tt>t</tt>. It has two fundamental
groperations: <a>putMVar</a> which fills an <a>MVar</a> if it is empty
grand blocks otherwise, and <a>takeMVar</a> which empties an <a>MVar</a>
grif it is full and blocks otherwise. They can be used in multiple
grdifferent ways:
gr
gr<ol>
gr<li>As synchronized mutable variables,</li>
gr<li>As channels, with <a>takeMVar</a> and <a>putMVar</a> as receive
grand send, and</li>
gr<li>As a binary semaphore <tt><a>MVar</a> ()</tt>, with
gr<a>takeMVar</a> and <a>putMVar</a> as wait and signal.</li>
gr</ol>
gr
grThey were introduced in the paper <a>"Concurrent Haskell"</a> by Simon
grPeyton Jones, Andrew Gordon and Sigbjorn Finne, though some details of
grtheir implementation have since then changed (in particular, a put on
gra full <a>MVar</a> used to error, but now merely blocks.)
gr
gr<h3>Applicability</h3>
gr
gr<a>MVar</a>s offer more flexibility than <tt>IORef</tt>s, but less
grflexibility than <tt>STM</tt>. They are appropriate for building
grsynchronization primitives and performing simple interthread
grcommunication; however they are very simple and susceptible to race
grconditions, deadlocks or uncaught exceptions. Do not use them if you
grneed perform larger atomic operations such as reading from multiple
grvariables: use <tt>STM</tt> instead.
gr
grIn particular, the "bigger" functions in this module (<a>swapMVar</a>,
gr<a>withMVar</a>, <a>modifyMVar_</a> and <a>modifyMVar</a>) are simply
grthe composition of a <a>takeMVar</a> followed by a <a>putMVar</a> with
grexception safety. These only have atomicity guarantees if all other
grthreads perform a <a>takeMVar</a> before a <a>putMVar</a> as well;
grotherwise, they may block.
gr
gr<h3>Fairness</h3>
gr
grNo thread can be blocked indefinitely on an <a>MVar</a> unless another
grthread holds that <a>MVar</a> indefinitely. One usual implementation
grof this fairness guarantee is that threads blocked on an <a>MVar</a>
grare served in a first-in-first-out fashion, but this is not guaranteed
grin the semantics.
gr
gr<h3>Gotchas</h3>
gr
grLike many other Haskell data structures, <a>MVar</a>s are lazy. This
grmeans that if you place an expensive unevaluated thunk inside an
gr<a>MVar</a>, it will be evaluated by the thread that consumes it, not
grthe thread that produced it. Be sure to <a>evaluate</a> values to be
grplaced in an <a>MVar</a> to the appropriate normal form, or utilize a
grstrict MVar provided by the strict-concurrency package.
gr
gr<h3>Ordering</h3>
gr
gr<a>MVar</a> operations are always observed to take place in the order
grthey are written in the program, regardless of the memory model of the
grunderlying machine. This is in contrast to <tt>IORef</tt> operations
grwhich may appear out-of-order to another thread in some cases.
gr
gr<h3>Example</h3>
gr
grConsider the following concurrent data structure, a skip channel. This
gris a channel for an intermittent source of high bandwidth information
gr(for example, mouse movement events.) Writing to the channel never
grblocks, and reading from the channel only returns the most recent
grvalue, or blocks if there are no new values. Multiple readers are
grsupported with a <tt>dupSkipChan</tt> operation.
gr
grA skip channel is a pair of <a>MVar</a>s. The first <a>MVar</a>
grcontains the current value, and a list of semaphores that need to be
grnotified when it changes. The second <a>MVar</a> is a semaphore for
grthis particular reader: it is full if there is a value in the channel
grthat this reader has not read yet, and empty otherwise.
gr
gr<pre>
grdata SkipChan a = SkipChan (MVar (a, [MVar ()])) (MVar ())
gr
grnewSkipChan :: IO (SkipChan a)
grnewSkipChan = do
gr    sem &lt;- newEmptyMVar
gr    main &lt;- newMVar (undefined, [sem])
gr    return (SkipChan main sem)
gr
grputSkipChan :: SkipChan a -&gt; a -&gt; IO ()
grputSkipChan (SkipChan main _) v = do
gr    (_, sems) &lt;- takeMVar main
gr    putMVar main (v, [])
gr    mapM_ (sem -&gt; putMVar sem ()) sems
gr
grgetSkipChan :: SkipChan a -&gt; IO a
grgetSkipChan (SkipChan main sem) = do
gr    takeMVar sem
gr    (v, sems) &lt;- takeMVar main
gr    putMVar main (v, sem:sems)
gr    return v
gr
grdupSkipChan :: SkipChan a -&gt; IO (SkipChan a)
grdupSkipChan (SkipChan main _) = do
gr    sem &lt;- newEmptyMVar
gr    (v, sems) &lt;- takeMVar main
gr    putMVar main (v, sem:sems)
gr    return (SkipChan main sem)
gr</pre>
gr
grThis example was adapted from the original Concurrent Haskell paper.
grFor more examples of <a>MVar</a>s being used to build higher-level
grsynchronization primitives, see <a>Chan</a> and <a>QSem</a>.
module Control.Concurrent.MVar

-- | An <a>MVar</a> (pronounced "em-var") is a synchronising variable, used
grfor communication between concurrent threads. It can be thought of as
gra a box, which may be empty or full.
data MVar a

-- | Create an <a>MVar</a> which is initially empty.
newEmptyMVar :: IO (MVar a)

-- | Create an <a>MVar</a> which contains the supplied value.
newMVar :: a -> IO (MVar a)

-- | Return the contents of the <a>MVar</a>. If the <a>MVar</a> is
grcurrently empty, <a>takeMVar</a> will wait until it is full. After a
gr<a>takeMVar</a>, the <a>MVar</a> is left empty.
gr
grThere are two further important properties of <a>takeMVar</a>:
gr
gr<ul>
gr<li><a>takeMVar</a> is single-wakeup. That is, if there are multiple
grthreads blocked in <a>takeMVar</a>, and the <a>MVar</a> becomes full,
gronly one thread will be woken up. The runtime guarantees that the
grwoken thread completes its <a>takeMVar</a> operation.</li>
gr<li>When multiple threads are blocked on an <a>MVar</a>, they are
grwoken up in FIFO order. This is useful for providing fairness
grproperties of abstractions built using <a>MVar</a>s.</li>
gr</ul>
takeMVar :: MVar a -> IO a

-- | Put a value into an <a>MVar</a>. If the <a>MVar</a> is currently full,
gr<a>putMVar</a> will wait until it becomes empty.
gr
grThere are two further important properties of <a>putMVar</a>:
gr
gr<ul>
gr<li><a>putMVar</a> is single-wakeup. That is, if there are multiple
grthreads blocked in <a>putMVar</a>, and the <a>MVar</a> becomes empty,
gronly one thread will be woken up. The runtime guarantees that the
grwoken thread completes its <a>putMVar</a> operation.</li>
gr<li>When multiple threads are blocked on an <a>MVar</a>, they are
grwoken up in FIFO order. This is useful for providing fairness
grproperties of abstractions built using <a>MVar</a>s.</li>
gr</ul>
putMVar :: MVar a -> a -> IO ()

-- | Atomically read the contents of an <a>MVar</a>. If the <a>MVar</a> is
grcurrently empty, <a>readMVar</a> will wait until it is full.
gr<a>readMVar</a> is guaranteed to receive the next <a>putMVar</a>.
gr
gr<a>readMVar</a> is multiple-wakeup, so when multiple readers are
grblocked on an <a>MVar</a>, all of them are woken up at the same time.
gr
gr<i>Compatibility note:</i> Prior to base 4.7, <a>readMVar</a> was a
grcombination of <a>takeMVar</a> and <a>putMVar</a>. This mean that in
grthe presence of other threads attempting to <a>putMVar</a>,
gr<a>readMVar</a> could block. Furthermore, <a>readMVar</a> would not
grreceive the next <a>putMVar</a> if there was already a pending thread
grblocked on <a>takeMVar</a>. The old behavior can be recovered by
grimplementing 'readMVar as follows:
gr
gr<pre>
grreadMVar :: MVar a -&gt; IO a
grreadMVar m =
gr  mask_ $ do
gr    a &lt;- takeMVar m
gr    putMVar m a
gr    return a
gr</pre>
readMVar :: MVar a -> IO a

-- | Take a value from an <a>MVar</a>, put a new value into the <a>MVar</a>
grand return the value taken. This function is atomic only if there are
grno other producers for this <a>MVar</a>.
swapMVar :: MVar a -> a -> IO a

-- | A non-blocking version of <a>takeMVar</a>. The <a>tryTakeMVar</a>
grfunction returns immediately, with <a>Nothing</a> if the <a>MVar</a>
grwas empty, or <tt><a>Just</a> a</tt> if the <a>MVar</a> was full with
grcontents <tt>a</tt>. After <a>tryTakeMVar</a>, the <a>MVar</a> is left
grempty.
tryTakeMVar :: MVar a -> IO (Maybe a)

-- | A non-blocking version of <a>putMVar</a>. The <a>tryPutMVar</a>
grfunction attempts to put the value <tt>a</tt> into the <a>MVar</a>,
grreturning <a>True</a> if it was successful, or <a>False</a> otherwise.
tryPutMVar :: MVar a -> a -> IO Bool

-- | Check whether a given <a>MVar</a> is empty.
gr
grNotice that the boolean value returned is just a snapshot of the state
grof the MVar. By the time you get to react on its result, the MVar may
grhave been filled (or emptied) - so be extremely careful when using
grthis operation. Use <a>tryTakeMVar</a> instead if possible.
isEmptyMVar :: MVar a -> IO Bool

-- | <a>withMVar</a> is an exception-safe wrapper for operating on the
grcontents of an <a>MVar</a>. This operation is exception-safe: it will
grreplace the original contents of the <a>MVar</a> if an exception is
grraised (see <a>Control.Exception</a>). However, it is only atomic if
grthere are no other producers for this <a>MVar</a>.
withMVar :: MVar a -> (a -> IO b) -> IO b

-- | Like <a>withMVar</a>, but the <tt>IO</tt> action in the second
grargument is executed with asynchronous exceptions masked.
withMVarMasked :: MVar a -> (a -> IO b) -> IO b

-- | An exception-safe wrapper for modifying the contents of an
gr<a>MVar</a>. Like <a>withMVar</a>, <a>modifyMVar</a> will replace the
groriginal contents of the <a>MVar</a> if an exception is raised during
grthe operation. This function is only atomic if there are no other
grproducers for this <a>MVar</a>.
modifyMVar_ :: MVar a -> (a -> IO a) -> IO ()

-- | A slight variation on <a>modifyMVar_</a> that allows a value to be
grreturned (<tt>b</tt>) in addition to the modified value of the
gr<a>MVar</a>.
modifyMVar :: MVar a -> (a -> IO (a, b)) -> IO b

-- | Like <a>modifyMVar_</a>, but the <tt>IO</tt> action in the second
grargument is executed with asynchronous exceptions masked.
modifyMVarMasked_ :: MVar a -> (a -> IO a) -> IO ()

-- | Like <a>modifyMVar</a>, but the <tt>IO</tt> action in the second
grargument is executed with asynchronous exceptions masked.
modifyMVarMasked :: MVar a -> (a -> IO (a, b)) -> IO b

-- | A non-blocking version of <a>readMVar</a>. The <a>tryReadMVar</a>
grfunction returns immediately, with <a>Nothing</a> if the <a>MVar</a>
grwas empty, or <tt><a>Just</a> a</tt> if the <a>MVar</a> was full with
grcontents <tt>a</tt>.
tryReadMVar :: MVar a -> IO (Maybe a)

-- | Make a <a>Weak</a> pointer to an <a>MVar</a>, using the second
grargument as a finalizer to run when <a>MVar</a> is garbage-collected
mkWeakMVar :: MVar a -> IO () -> IO (Weak (MVar a))

-- | <i>Deprecated: use <a>mkWeakMVar</a> instead</i>
addMVarFinalizer :: MVar a -> IO () -> IO ()

module GHC.Conc.Signal
type Signal = CInt
type HandlerFun = ForeignPtr Word8 -> IO ()
setHandler :: Signal -> Maybe (HandlerFun, Dynamic) -> IO (Maybe (HandlerFun, Dynamic))
runHandlers :: ForeignPtr Word8 -> Signal -> IO ()
runHandlersPtr :: Ptr Word8 -> Signal -> IO ()


-- | Basic concurrency stuff.
module GHC.Conc.IO
ensureIOManagerIsRunning :: IO ()
ioManagerCapabilitiesChanged :: IO ()

-- | Suspends the current thread for a given number of microseconds (GHC
gronly).
gr
grThere is no guarantee that the thread will be rescheduled promptly
grwhen the delay has expired, but the thread will never continue to run
gr<i>earlier</i> than specified.
threadDelay :: Int -> IO ()

-- | Set the value of returned TVar to True after a given number of
grmicroseconds. The caveats associated with threadDelay also apply.
registerDelay :: Int -> IO (TVar Bool)

-- | Block the current thread until data is available to read on the given
grfile descriptor (GHC only).
gr
grThis will throw an <tt>IOError</tt> if the file descriptor was closed
grwhile this thread was blocked. To safely close a file descriptor that
grhas been used with <a>threadWaitRead</a>, use <a>closeFdWith</a>.
threadWaitRead :: Fd -> IO ()

-- | Block the current thread until data can be written to the given file
grdescriptor (GHC only).
gr
grThis will throw an <tt>IOError</tt> if the file descriptor was closed
grwhile this thread was blocked. To safely close a file descriptor that
grhas been used with <a>threadWaitWrite</a>, use <a>closeFdWith</a>.
threadWaitWrite :: Fd -> IO ()

-- | Returns an STM action that can be used to wait for data to read from a
grfile descriptor. The second returned value is an IO action that can be
grused to deregister interest in the file descriptor.
threadWaitReadSTM :: Fd -> IO (STM (), IO ())

-- | Returns an STM action that can be used to wait until data can be
grwritten to a file descriptor. The second returned value is an IO
graction that can be used to deregister interest in the file descriptor.
threadWaitWriteSTM :: Fd -> IO (STM (), IO ())

-- | Close a file descriptor in a concurrency-safe way (GHC only). If you
grare using <a>threadWaitRead</a> or <a>threadWaitWrite</a> to perform
grblocking I/O, you <i>must</i> use this function to close file
grdescriptors, or blocked threads may not be woken.
gr
grAny threads that are blocked on the file descriptor via
gr<a>threadWaitRead</a> or <a>threadWaitWrite</a> will be unblocked by
grhaving IO exceptions thrown.
closeFdWith :: (Fd -> IO ()) -> Fd -> IO ()


-- | Handle operations implemented by file descriptors (FDs)
module GHC.IO.Handle.FD

-- | A handle managing input from the Haskell program's standard input
grchannel.
stdin :: Handle

-- | A handle managing output to the Haskell program's standard output
grchannel.
stdout :: Handle

-- | A handle managing output to the Haskell program's standard error
grchannel.
stderr :: Handle

-- | Computation <a>openFile</a> <tt>file mode</tt> allocates and returns a
grnew, open handle to manage the file <tt>file</tt>. It manages input if
gr<tt>mode</tt> is <a>ReadMode</a>, output if <tt>mode</tt> is
gr<a>WriteMode</a> or <a>AppendMode</a>, and both input and output if
grmode is <a>ReadWriteMode</a>.
gr
grIf the file does not exist and it is opened for output, it should be
grcreated as a new file. If <tt>mode</tt> is <a>WriteMode</a> and the
grfile already exists, then it should be truncated to zero length. Some
groperating systems delete empty files, so there is no guarantee that
grthe file will exist following an <a>openFile</a> with <tt>mode</tt>
gr<a>WriteMode</a> unless it is subsequently written to successfully.
grThe handle is positioned at the end of the file if <tt>mode</tt> is
gr<a>AppendMode</a>, and otherwise at the beginning (in which case its
grinternal position is 0). The initial buffer mode is
grimplementation-dependent.
gr
grThis operation may fail with:
gr
gr<ul>
gr<li><tt>isAlreadyInUseError</tt> if the file is already open and
grcannot be reopened;</li>
gr<li><tt>isDoesNotExistError</tt> if the file does not exist; or</li>
gr<li><tt>isPermissionError</tt> if the user does not have permission to
gropen the file.</li>
gr</ul>
gr
grNote: if you will be working with files containing binary data, you'll
grwant to be using <a>openBinaryFile</a>.
openFile :: FilePath -> IOMode -> IO Handle

-- | Like <a>openFile</a>, but open the file in binary mode. On Windows,
grreading a file in text mode (which is the default) will translate CRLF
grto LF, and writing will translate LF to CRLF. This is usually what you
grwant with text files. With binary files this is undesirable; also, as
grusual under Microsoft operating systems, text mode treats control-Z as
grEOF. Binary mode turns off all special treatment of end-of-line and
grend-of-file characters. (See also <tt>hSetBinaryMode</tt>.)
openBinaryFile :: FilePath -> IOMode -> IO Handle

-- | Like <a>openFile</a>, but opens the file in ordinary blocking mode.
grThis can be useful for opening a FIFO for writing: if we open in
grnon-blocking mode then the open will fail if there are no readers,
grwhereas a blocking open will block until a reader appear.
openFileBlocking :: FilePath -> IOMode -> IO Handle
mkHandleFromFD :: FD -> IODeviceType -> FilePath -> IOMode -> Bool -> Maybe TextEncoding -> IO Handle

-- | Turn an existing file descriptor into a Handle. This is used by
grvarious external libraries to make Handles.
gr
grMakes a binary Handle. This is for historical reasons; it should
grprobably be a text Handle with the default encoding and newline
grtranslation instead.
fdToHandle :: FD -> IO Handle

-- | Old API kept to avoid breaking clients
fdToHandle' :: CInt -> Maybe IODeviceType -> Bool -> FilePath -> IOMode -> Bool -> IO Handle

-- | Turn an existing Handle into a file descriptor. This function throws
gran IOError if the Handle does not reference a file descriptor.
handleToFd :: Handle -> IO FD

module GHC.IO.Handle.Lock

-- | Exception thrown by <a>hLock</a> on non-Windows platforms that don't
grsupport <tt>flock</tt>.
data FileLockingNotSupported
FileLockingNotSupported :: FileLockingNotSupported

-- | Indicates a mode in which a file should be locked.
data LockMode
SharedLock :: LockMode
ExclusiveLock :: LockMode

-- | If a <a>Handle</a> references a file descriptor, attempt to lock
grcontents of the underlying file in appropriate mode. If the file is
gralready locked in incompatible mode, this function blocks until the
grlock is established. The lock is automatically released upon closing a
gr<a>Handle</a>.
gr
grThings to be aware of:
gr
gr1) This function may block inside a C call. If it does, in order to be
grable to interrupt it with asynchronous exceptions and/or for other
grthreads to continue working, you MUST use threaded version of the
grruntime system.
gr
gr2) The implementation uses <tt>LockFileEx</tt> on Windows and
gr<tt>flock</tt> otherwise, hence all of their caveats also apply here.
gr
gr3) On non-Windows plaftorms that don't support <tt>flock</tt> (e.g.
grSolaris) this function throws <tt>FileLockingNotImplemented</tt>. We
grdeliberately choose to not provide fcntl based locking instead because
grof its broken semantics.
hLock :: Handle -> LockMode -> IO ()

-- | Non-blocking version of <a>hLock</a>.
hTryLock :: Handle -> LockMode -> IO Bool

-- | Release a lock taken with <a>hLock</a> or <a>hTryLock</a>.
hUnlock :: Handle -> IO ()
instance GHC.Show.Show GHC.IO.Handle.Lock.FileLockingNotSupported
instance GHC.Exception.Exception GHC.IO.Handle.Lock.FileLockingNotSupported


-- | External API for GHC's Handle implementation
module GHC.IO.Handle

-- | Haskell defines operations to read and write characters from and to
grfiles, represented by values of type <tt>Handle</tt>. Each value of
grthis type is a <i>handle</i>: a record used by the Haskell run-time
grsystem to <i>manage</i> I/O with file system objects. A handle has at
grleast the following properties:
gr
gr<ul>
gr<li>whether it manages input or output or both;</li>
gr<li>whether it is <i>open</i>, <i>closed</i> or
gr<i>semi-closed</i>;</li>
gr<li>whether the object is seekable;</li>
gr<li>whether buffering is disabled, or enabled on a line or block
grbasis;</li>
gr<li>a buffer (whose length may be zero).</li>
gr</ul>
gr
grMost handles will also have a current I/O position indicating where
grthe next input or output operation will occur. A handle is
gr<i>readable</i> if it manages only input or both input and output;
grlikewise, it is <i>writable</i> if it manages only output or both
grinput and output. A handle is <i>open</i> when first allocated. Once
grit is closed it can no longer be used for either input or output,
grthough an implementation cannot re-use its storage while references
grremain to it. Handles are in the <a>Show</a> and <a>Eq</a> classes.
grThe string produced by showing a handle is system dependent; it should
grinclude enough information to identify the handle for debugging. A
grhandle is equal according to <a>==</a> only to itself; no attempt is
grmade to compare the internal state of different handles for equality.
data Handle

-- | Three kinds of buffering are supported: line-buffering,
grblock-buffering or no-buffering. These modes have the following
greffects. For output, items are written out, or <i>flushed</i>, from
grthe internal buffer according to the buffer mode:
gr
gr<ul>
gr<li><i>line-buffering</i>: the entire output buffer is flushed
grwhenever a newline is output, the buffer overflows, a <a>hFlush</a> is
grissued, or the handle is closed.</li>
gr<li><i>block-buffering</i>: the entire buffer is written out whenever
grit overflows, a <a>hFlush</a> is issued, or the handle is closed.</li>
gr<li><i>no-buffering</i>: output is written immediately, and never
grstored in the buffer.</li>
gr</ul>
gr
grAn implementation is free to flush the buffer more frequently, but not
grless frequently, than specified above. The output buffer is emptied as
grsoon as it has been written out.
gr
grSimilarly, input occurs according to the buffer mode for the handle:
gr
gr<ul>
gr<li><i>line-buffering</i>: when the buffer for the handle is not
grempty, the next item is obtained from the buffer; otherwise, when the
grbuffer is empty, characters up to and including the next newline
grcharacter are read into the buffer. No characters are available until
grthe newline character is available or the buffer is full.</li>
gr<li><i>block-buffering</i>: when the buffer for the handle becomes
grempty, the next block of data is read into the buffer.</li>
gr<li><i>no-buffering</i>: the next input item is read and returned. The
gr<a>hLookAhead</a> operation implies that even a no-buffered handle may
grrequire a one-character buffer.</li>
gr</ul>
gr
grThe default buffering mode when a handle is opened is
grimplementation-dependent and may depend on the file system object
grwhich is attached to that handle. For most implementations, physical
grfiles will normally be block-buffered and terminals will normally be
grline-buffered.
data BufferMode

-- | buffering is disabled if possible.
NoBuffering :: BufferMode

-- | line-buffering should be enabled if possible.
LineBuffering :: BufferMode

-- | block-buffering should be enabled if possible. The size of the buffer
gris <tt>n</tt> items if the argument is <a>Just</a> <tt>n</tt> and is
grotherwise implementation-dependent.
BlockBuffering :: (Maybe Int) -> BufferMode

-- | makes a new <a>Handle</a>
mkFileHandle :: (IODevice dev, BufferedIO dev, Typeable dev) => dev -> FilePath -> IOMode -> Maybe TextEncoding -> NewlineMode -> IO Handle

-- | like <a>mkFileHandle</a>, except that a <a>Handle</a> is created with
grtwo independent buffers, one for reading and one for writing. Used for
grfull-duplex streams, such as network sockets.
mkDuplexHandle :: (IODevice dev, BufferedIO dev, Typeable dev) => dev -> FilePath -> Maybe TextEncoding -> NewlineMode -> IO Handle

-- | For a handle <tt>hdl</tt> which attached to a physical file,
gr<a>hFileSize</a> <tt>hdl</tt> returns the size of that file in 8-bit
grbytes.
hFileSize :: Handle -> IO Integer

-- | <a>hSetFileSize</a> <tt>hdl</tt> <tt>size</tt> truncates the physical
grfile with handle <tt>hdl</tt> to <tt>size</tt> bytes.
hSetFileSize :: Handle -> Integer -> IO ()

-- | For a readable handle <tt>hdl</tt>, <a>hIsEOF</a> <tt>hdl</tt> returns
gr<a>True</a> if no further input can be taken from <tt>hdl</tt> or for
gra physical file, if the current I/O position is equal to the length of
grthe file. Otherwise, it returns <a>False</a>.
gr
grNOTE: <a>hIsEOF</a> may block, because it has to attempt to read from
grthe stream to determine whether there is any more data to be read.
hIsEOF :: Handle -> IO Bool

-- | The computation <a>isEOF</a> is identical to <a>hIsEOF</a>, except
grthat it works only on <a>stdin</a>.
isEOF :: IO Bool

-- | Computation <a>hLookAhead</a> returns the next character from the
grhandle without removing it from the input buffer, blocking until a
grcharacter is available.
gr
grThis operation may fail with:
gr
gr<ul>
gr<li><tt>isEOFError</tt> if the end of file has been reached.</li>
gr</ul>
hLookAhead :: Handle -> IO Char

-- | Computation <a>hSetBuffering</a> <tt>hdl mode</tt> sets the mode of
grbuffering for handle <tt>hdl</tt> on subsequent reads and writes.
gr
grIf the buffer mode is changed from <a>BlockBuffering</a> or
gr<a>LineBuffering</a> to <a>NoBuffering</a>, then
gr
gr<ul>
gr<li>if <tt>hdl</tt> is writable, the buffer is flushed as for
gr<a>hFlush</a>;</li>
gr<li>if <tt>hdl</tt> is not writable, the contents of the buffer is
grdiscarded.</li>
gr</ul>
gr
grThis operation may fail with:
gr
gr<ul>
gr<li><tt>isPermissionError</tt> if the handle has already been used for
grreading or writing and the implementation does not allow the buffering
grmode to be changed.</li>
gr</ul>
hSetBuffering :: Handle -> BufferMode -> IO ()

-- | Select binary mode (<a>True</a>) or text mode (<a>False</a>) on a open
grhandle. (See also <a>openBinaryFile</a>.)
gr
grThis has the same effect as calling <a>hSetEncoding</a> with
gr<a>char8</a>, together with <a>hSetNewlineMode</a> with
gr<a>noNewlineTranslation</a>.
hSetBinaryMode :: Handle -> Bool -> IO ()

-- | The action <a>hSetEncoding</a> <tt>hdl</tt> <tt>encoding</tt> changes
grthe text encoding for the handle <tt>hdl</tt> to <tt>encoding</tt>.
grThe default encoding when a <a>Handle</a> is created is
gr<tt>localeEncoding</tt>, namely the default encoding for the current
grlocale.
gr
grTo create a <a>Handle</a> with no encoding at all, use
gr<a>openBinaryFile</a>. To stop further encoding or decoding on an
grexisting <a>Handle</a>, use <a>hSetBinaryMode</a>.
gr
gr<a>hSetEncoding</a> may need to flush buffered data in order to change
grthe encoding.
hSetEncoding :: Handle -> TextEncoding -> IO ()

-- | Return the current <a>TextEncoding</a> for the specified
gr<a>Handle</a>, or <a>Nothing</a> if the <a>Handle</a> is in binary
grmode.
gr
grNote that the <a>TextEncoding</a> remembers nothing about the state of
grthe encoder/decoder in use on this <a>Handle</a>. For example, if the
grencoding in use is UTF-16, then using <a>hGetEncoding</a> and
gr<a>hSetEncoding</a> to save and restore the encoding may result in an
grextra byte-order-mark being written to the file.
hGetEncoding :: Handle -> IO (Maybe TextEncoding)

-- | The action <a>hFlush</a> <tt>hdl</tt> causes any items buffered for
groutput in handle <tt>hdl</tt> to be sent immediately to the operating
grsystem.
gr
grThis operation may fail with:
gr
gr<ul>
gr<li><tt>isFullError</tt> if the device is full;</li>
gr<li><tt>isPermissionError</tt> if a system resource limit would be
grexceeded. It is unspecified whether the characters in the buffer are
grdiscarded or retained under these circumstances.</li>
gr</ul>
hFlush :: Handle -> IO ()

-- | The action <a>hFlushAll</a> <tt>hdl</tt> flushes all buffered data in
gr<tt>hdl</tt>, including any buffered read data. Buffered read data is
grflushed by seeking the file position back to the point before the
grbufferred data was read, and hence only works if <tt>hdl</tt> is
grseekable (see <a>hIsSeekable</a>).
gr
grThis operation may fail with:
gr
gr<ul>
gr<li><tt>isFullError</tt> if the device is full;</li>
gr<li><tt>isPermissionError</tt> if a system resource limit would be
grexceeded. It is unspecified whether the characters in the buffer are
grdiscarded or retained under these circumstances;</li>
gr<li><tt>isIllegalOperation</tt> if <tt>hdl</tt> has buffered read
grdata, and is not seekable.</li>
gr</ul>
hFlushAll :: Handle -> IO ()

-- | Returns a duplicate of the original handle, with its own buffer. The
grtwo Handles will share a file pointer, however. The original handle's
grbuffer is flushed, including discarding any input data, before the
grhandle is duplicated.
hDuplicate :: Handle -> IO Handle

-- | Makes the second handle a duplicate of the first handle. The second
grhandle will be closed first, if it is not already.
gr
grThis can be used to retarget the standard Handles, for example:
gr
gr<pre>
grdo h &lt;- openFile "mystdout" WriteMode
gr   hDuplicateTo h stdout
gr</pre>
hDuplicateTo :: Handle -> Handle -> IO ()

-- | Computation <a>hClose</a> <tt>hdl</tt> makes handle <tt>hdl</tt>
grclosed. Before the computation finishes, if <tt>hdl</tt> is writable
grits buffer is flushed as for <a>hFlush</a>. Performing <a>hClose</a>
gron a handle that has already been closed has no effect; doing so is
grnot an error. All other operations on a closed handle will fail. If
gr<a>hClose</a> fails for any reason, any further operations (apart from
gr<a>hClose</a>) on the handle will still fail as if <tt>hdl</tt> had
grbeen successfully closed.
hClose :: Handle -> IO ()
hClose_help :: Handle__ -> IO (Handle__, Maybe SomeException)

-- | Indicates a mode in which a file should be locked.
data LockMode
SharedLock :: LockMode
ExclusiveLock :: LockMode

-- | If a <a>Handle</a> references a file descriptor, attempt to lock
grcontents of the underlying file in appropriate mode. If the file is
gralready locked in incompatible mode, this function blocks until the
grlock is established. The lock is automatically released upon closing a
gr<a>Handle</a>.
gr
grThings to be aware of:
gr
gr1) This function may block inside a C call. If it does, in order to be
grable to interrupt it with asynchronous exceptions and/or for other
grthreads to continue working, you MUST use threaded version of the
grruntime system.
gr
gr2) The implementation uses <tt>LockFileEx</tt> on Windows and
gr<tt>flock</tt> otherwise, hence all of their caveats also apply here.
gr
gr3) On non-Windows plaftorms that don't support <tt>flock</tt> (e.g.
grSolaris) this function throws <tt>FileLockingNotImplemented</tt>. We
grdeliberately choose to not provide fcntl based locking instead because
grof its broken semantics.
hLock :: Handle -> LockMode -> IO ()

-- | Non-blocking version of <a>hLock</a>.
hTryLock :: Handle -> LockMode -> IO Bool
type HandlePosition = Integer
data HandlePosn
HandlePosn :: Handle -> HandlePosition -> HandlePosn

-- | Computation <a>hGetPosn</a> <tt>hdl</tt> returns the current I/O
grposition of <tt>hdl</tt> as a value of the abstract type
gr<a>HandlePosn</a>.
hGetPosn :: Handle -> IO HandlePosn

-- | If a call to <a>hGetPosn</a> <tt>hdl</tt> returns a position
gr<tt>p</tt>, then computation <a>hSetPosn</a> <tt>p</tt> sets the
grposition of <tt>hdl</tt> to the position it held at the time of the
grcall to <a>hGetPosn</a>.
gr
grThis operation may fail with:
gr
gr<ul>
gr<li><tt>isPermissionError</tt> if a system resource limit would be
grexceeded.</li>
gr</ul>
hSetPosn :: HandlePosn -> IO ()

-- | A mode that determines the effect of <tt>hSeek</tt> <tt>hdl mode
gri</tt>.
data SeekMode

-- | the position of <tt>hdl</tt> is set to <tt>i</tt>.
AbsoluteSeek :: SeekMode

-- | the position of <tt>hdl</tt> is set to offset <tt>i</tt> from the
grcurrent position.
RelativeSeek :: SeekMode

-- | the position of <tt>hdl</tt> is set to offset <tt>i</tt> from the end
grof the file.
SeekFromEnd :: SeekMode

-- | Computation <a>hSeek</a> <tt>hdl mode i</tt> sets the position of
grhandle <tt>hdl</tt> depending on <tt>mode</tt>. The offset <tt>i</tt>
gris given in terms of 8-bit bytes.
gr
grIf <tt>hdl</tt> is block- or line-buffered, then seeking to a position
grwhich is not in the current buffer will first cause any items in the
groutput buffer to be written to the device, and then cause the input
grbuffer to be discarded. Some handles may not be seekable (see
gr<a>hIsSeekable</a>), or only support a subset of the possible
grpositioning operations (for instance, it may only be possible to seek
grto the end of a tape, or to a positive offset from the beginning or
grcurrent position). It is not possible to set a negative I/O position,
gror for a physical file, an I/O position beyond the current
grend-of-file.
gr
grThis operation may fail with:
gr
gr<ul>
gr<li><tt>isIllegalOperationError</tt> if the Handle is not seekable, or
grdoes not support the requested seek mode.</li>
gr<li><tt>isPermissionError</tt> if a system resource limit would be
grexceeded.</li>
gr</ul>
hSeek :: Handle -> SeekMode -> Integer -> IO ()

-- | Computation <a>hTell</a> <tt>hdl</tt> returns the current position of
grthe handle <tt>hdl</tt>, as the number of bytes from the beginning of
grthe file. The value returned may be subsequently passed to
gr<a>hSeek</a> to reposition the handle to the current position.
gr
grThis operation may fail with:
gr
gr<ul>
gr<li><tt>isIllegalOperationError</tt> if the Handle is not
grseekable.</li>
gr</ul>
hTell :: Handle -> IO Integer
hIsOpen :: Handle -> IO Bool
hIsClosed :: Handle -> IO Bool
hIsReadable :: Handle -> IO Bool
hIsWritable :: Handle -> IO Bool

-- | Computation <a>hGetBuffering</a> <tt>hdl</tt> returns the current
grbuffering mode for <tt>hdl</tt>.
hGetBuffering :: Handle -> IO BufferMode
hIsSeekable :: Handle -> IO Bool

-- | Set the echoing status of a handle connected to a terminal.
hSetEcho :: Handle -> Bool -> IO ()

-- | Get the echoing status of a handle connected to a terminal.
hGetEcho :: Handle -> IO Bool

-- | Is the handle connected to a terminal?
hIsTerminalDevice :: Handle -> IO Bool

-- | Set the <a>NewlineMode</a> on the specified <a>Handle</a>. All
grbuffered data is flushed first.
hSetNewlineMode :: Handle -> NewlineMode -> IO ()

-- | The representation of a newline in the external file or stream.
data Newline

-- | '\n'
LF :: Newline

-- | '\r\n'
CRLF :: Newline

-- | Specifies the translation, if any, of newline characters between
grinternal Strings and the external file or stream. Haskell Strings are
grassumed to represent newlines with the '\n' character; the newline
grmode specifies how to translate '\n' on output, and what to translate
grinto '\n' on input.
data NewlineMode
NewlineMode :: Newline -> Newline -> NewlineMode

-- | the representation of newlines on input
[inputNL] :: NewlineMode -> Newline

-- | the representation of newlines on output
[outputNL] :: NewlineMode -> Newline

-- | The native newline representation for the current platform: <a>LF</a>
gron Unix systems, <a>CRLF</a> on Windows.
nativeNewline :: Newline

-- | Do no newline translation at all.
gr
gr<pre>
grnoNewlineTranslation  = NewlineMode { inputNL  = LF, outputNL = LF }
gr</pre>
noNewlineTranslation :: NewlineMode

-- | Map '\r\n' into '\n' on input, and '\n' to the native newline
grrepresetnation on output. This mode can be used on any platform, and
grworks with text files using any newline convention. The downside is
grthat <tt>readFile &gt;&gt;= writeFile</tt> might yield a different
grfile.
gr
gr<pre>
gruniversalNewlineMode  = NewlineMode { inputNL  = CRLF,
gr                                      outputNL = nativeNewline }
gr</pre>
universalNewlineMode :: NewlineMode

-- | Use the native newline representation on both input and output
gr
gr<pre>
grnativeNewlineMode  = NewlineMode { inputNL  = nativeNewline
gr                                   outputNL = nativeNewline }
gr</pre>
nativeNewlineMode :: NewlineMode

-- | <a>hShow</a> is in the <a>IO</a> monad, and gives more comprehensive
groutput than the (pure) instance of <a>Show</a> for <a>Handle</a>.
hShow :: Handle -> IO String

-- | Computation <a>hWaitForInput</a> <tt>hdl t</tt> waits until input is
gravailable on handle <tt>hdl</tt>. It returns <a>True</a> as soon as
grinput is available on <tt>hdl</tt>, or <a>False</a> if no input is
gravailable within <tt>t</tt> milliseconds. Note that
gr<a>hWaitForInput</a> waits until one or more full <i>characters</i>
grare available, which means that it needs to do decoding, and hence may
grfail with a decoding error.
gr
grIf <tt>t</tt> is less than zero, then <tt>hWaitForInput</tt> waits
grindefinitely.
gr
grThis operation may fail with:
gr
gr<ul>
gr<li><a>isEOFError</a> if the end of file has been reached.</li>
gr<li>a decoding error, if the input begins with an invalid byte
grsequence in this Handle's encoding.</li>
gr</ul>
gr
grNOTE for GHC users: unless you use the <tt>-threaded</tt> flag,
gr<tt>hWaitForInput hdl t</tt> where <tt>t &gt;= 0</tt> will block all
grother Haskell threads for the duration of the call. It behaves like a
gr<tt>safe</tt> foreign call in this respect.
hWaitForInput :: Handle -> Int -> IO Bool

-- | Computation <a>hGetChar</a> <tt>hdl</tt> reads a character from the
grfile or channel managed by <tt>hdl</tt>, blocking until a character is
gravailable.
gr
grThis operation may fail with:
gr
gr<ul>
gr<li><a>isEOFError</a> if the end of file has been reached.</li>
gr</ul>
hGetChar :: Handle -> IO Char

-- | Computation <a>hGetLine</a> <tt>hdl</tt> reads a line from the file or
grchannel managed by <tt>hdl</tt>.
gr
grThis operation may fail with:
gr
gr<ul>
gr<li><a>isEOFError</a> if the end of file is encountered when reading
grthe <i>first</i> character of the line.</li>
gr</ul>
gr
grIf <a>hGetLine</a> encounters end-of-file at any other point while
grreading in a line, it is treated as a line terminator and the
gr(partial) line is returned.
hGetLine :: Handle -> IO String

-- | Computation <a>hGetContents</a> <tt>hdl</tt> returns the list of
grcharacters corresponding to the unread portion of the channel or file
grmanaged by <tt>hdl</tt>, which is put into an intermediate state,
gr<i>semi-closed</i>. In this state, <tt>hdl</tt> is effectively closed,
grbut items are read from <tt>hdl</tt> on demand and accumulated in a
grspecial list returned by <a>hGetContents</a> <tt>hdl</tt>.
gr
grAny operation that fails because a handle is closed, also fails if a
grhandle is semi-closed. The only exception is <tt>hClose</tt>. A
grsemi-closed handle becomes closed:
gr
gr<ul>
gr<li>if <tt>hClose</tt> is applied to it;</li>
gr<li>if an I/O error occurs when reading an item from the handle;</li>
gr<li>or once the entire contents of the handle has been read.</li>
gr</ul>
gr
grOnce a semi-closed handle becomes closed, the contents of the
grassociated list becomes fixed. The contents of this final list is only
grpartially specified: it will contain at least all the items of the
grstream that were evaluated prior to the handle becoming closed.
gr
grAny I/O errors encountered while a handle is semi-closed are simply
grdiscarded.
gr
grThis operation may fail with:
gr
gr<ul>
gr<li><a>isEOFError</a> if the end of file has been reached.</li>
gr</ul>
hGetContents :: Handle -> IO String

-- | Computation <a>hPutChar</a> <tt>hdl ch</tt> writes the character
gr<tt>ch</tt> to the file or channel managed by <tt>hdl</tt>. Characters
grmay be buffered if buffering is enabled for <tt>hdl</tt>.
gr
grThis operation may fail with:
gr
gr<ul>
gr<li><a>isFullError</a> if the device is full; or</li>
gr<li><a>isPermissionError</a> if another system resource limit would be
grexceeded.</li>
gr</ul>
hPutChar :: Handle -> Char -> IO ()

-- | Computation <a>hPutStr</a> <tt>hdl s</tt> writes the string <tt>s</tt>
grto the file or channel managed by <tt>hdl</tt>.
gr
grThis operation may fail with:
gr
gr<ul>
gr<li><a>isFullError</a> if the device is full; or</li>
gr<li><a>isPermissionError</a> if another system resource limit would be
grexceeded.</li>
gr</ul>
hPutStr :: Handle -> String -> IO ()

-- | <a>hGetBuf</a> <tt>hdl buf count</tt> reads data from the handle
gr<tt>hdl</tt> into the buffer <tt>buf</tt> until either EOF is reached
gror <tt>count</tt> 8-bit bytes have been read. It returns the number of
grbytes actually read. This may be zero if EOF was reached before any
grdata was read (or if <tt>count</tt> is zero).
gr
gr<a>hGetBuf</a> never raises an EOF exception, instead it returns a
grvalue smaller than <tt>count</tt>.
gr
grIf the handle is a pipe or socket, and the writing end is closed,
gr<a>hGetBuf</a> will behave as if EOF was reached.
gr
gr<a>hGetBuf</a> ignores the prevailing <tt>TextEncoding</tt> and
gr<a>NewlineMode</a> on the <a>Handle</a>, and reads bytes directly.
hGetBuf :: Handle -> Ptr a -> Int -> IO Int

-- | <a>hGetBufNonBlocking</a> <tt>hdl buf count</tt> reads data from the
grhandle <tt>hdl</tt> into the buffer <tt>buf</tt> until either EOF is
grreached, or <tt>count</tt> 8-bit bytes have been read, or there is no
grmore data available to read immediately.
gr
gr<a>hGetBufNonBlocking</a> is identical to <a>hGetBuf</a>, except that
grit will never block waiting for data to become available, instead it
grreturns only whatever data is available. To wait for data to arrive
grbefore calling <a>hGetBufNonBlocking</a>, use <a>hWaitForInput</a>.
gr
grIf the handle is a pipe or socket, and the writing end is closed,
gr<a>hGetBufNonBlocking</a> will behave as if EOF was reached.
gr
gr<a>hGetBufNonBlocking</a> ignores the prevailing <tt>TextEncoding</tt>
grand <a>NewlineMode</a> on the <a>Handle</a>, and reads bytes directly.
gr
grNOTE: on Windows, this function does not work correctly; it behaves
gridentically to <a>hGetBuf</a>.
hGetBufNonBlocking :: Handle -> Ptr a -> Int -> IO Int

-- | <a>hPutBuf</a> <tt>hdl buf count</tt> writes <tt>count</tt> 8-bit
grbytes from the buffer <tt>buf</tt> to the handle <tt>hdl</tt>. It
grreturns ().
gr
gr<a>hPutBuf</a> ignores any text encoding that applies to the
gr<a>Handle</a>, writing the bytes directly to the underlying file or
grdevice.
gr
gr<a>hPutBuf</a> ignores the prevailing <tt>TextEncoding</tt> and
gr<a>NewlineMode</a> on the <a>Handle</a>, and writes bytes directly.
gr
grThis operation may fail with:
gr
gr<ul>
gr<li><a>ResourceVanished</a> if the handle is a pipe or socket, and the
grreading end is closed. (If this is a POSIX system, and the program has
grnot asked to ignore SIGPIPE, then a SIGPIPE may be delivered instead,
grwhose default action is to terminate the program).</li>
gr</ul>
hPutBuf :: Handle -> Ptr a -> Int -> IO ()
hPutBufNonBlocking :: Handle -> Ptr a -> Int -> IO Int
instance GHC.Classes.Eq GHC.IO.Handle.HandlePosn
instance GHC.Show.Show GHC.IO.Handle.HandlePosn


-- | The standard IO library.
module System.IO

-- | A value of type <tt><a>IO</a> a</tt> is a computation which, when
grperformed, does some I/O before returning a value of type <tt>a</tt>.
gr
grThere is really only one way to "perform" an I/O action: bind it to
gr<tt>Main.main</tt> in your program. When your program is run, the I/O
grwill be performed. It isn't possible to perform I/O from an arbitrary
grfunction, unless that function is itself in the <a>IO</a> monad and
grcalled at some point, directly or indirectly, from <tt>Main.main</tt>.
gr
gr<a>IO</a> is a monad, so <a>IO</a> actions can be combined using
greither the do-notation or the <tt>&gt;&gt;</tt> and <tt>&gt;&gt;=</tt>
groperations from the <tt>Monad</tt> class.
data IO a

-- | The implementation of <tt>mfix</tt> for <a>IO</a>. If the function
grpassed to <a>fixIO</a> inspects its argument, the resulting action
grwill throw <a>FixIOException</a>.
fixIO :: (a -> IO a) -> IO a

-- | File and directory names are values of type <a>String</a>, whose
grprecise meaning is operating system dependent. Files can be opened,
gryielding a handle which can then be used to operate on the contents of
grthat file.
type FilePath = String

-- | Haskell defines operations to read and write characters from and to
grfiles, represented by values of type <tt>Handle</tt>. Each value of
grthis type is a <i>handle</i>: a record used by the Haskell run-time
grsystem to <i>manage</i> I/O with file system objects. A handle has at
grleast the following properties:
gr
gr<ul>
gr<li>whether it manages input or output or both;</li>
gr<li>whether it is <i>open</i>, <i>closed</i> or
gr<i>semi-closed</i>;</li>
gr<li>whether the object is seekable;</li>
gr<li>whether buffering is disabled, or enabled on a line or block
grbasis;</li>
gr<li>a buffer (whose length may be zero).</li>
gr</ul>
gr
grMost handles will also have a current I/O position indicating where
grthe next input or output operation will occur. A handle is
gr<i>readable</i> if it manages only input or both input and output;
grlikewise, it is <i>writable</i> if it manages only output or both
grinput and output. A handle is <i>open</i> when first allocated. Once
grit is closed it can no longer be used for either input or output,
grthough an implementation cannot re-use its storage while references
grremain to it. Handles are in the <a>Show</a> and <a>Eq</a> classes.
grThe string produced by showing a handle is system dependent; it should
grinclude enough information to identify the handle for debugging. A
grhandle is equal according to <a>==</a> only to itself; no attempt is
grmade to compare the internal state of different handles for equality.
data Handle

-- | A handle managing input from the Haskell program's standard input
grchannel.
stdin :: Handle

-- | A handle managing output to the Haskell program's standard output
grchannel.
stdout :: Handle

-- | A handle managing output to the Haskell program's standard error
grchannel.
stderr :: Handle

-- | <tt><a>withFile</a> name mode act</tt> opens a file using
gr<a>openFile</a> and passes the resulting handle to the computation
gr<tt>act</tt>. The handle will be closed on exit from <a>withFile</a>,
grwhether by normal termination or by raising an exception. If closing
grthe handle raises an exception, then this exception will be raised by
gr<a>withFile</a> rather than any exception raised by <tt>act</tt>.
withFile :: FilePath -> IOMode -> (Handle -> IO r) -> IO r

-- | Computation <a>openFile</a> <tt>file mode</tt> allocates and returns a
grnew, open handle to manage the file <tt>file</tt>. It manages input if
gr<tt>mode</tt> is <a>ReadMode</a>, output if <tt>mode</tt> is
gr<a>WriteMode</a> or <a>AppendMode</a>, and both input and output if
grmode is <a>ReadWriteMode</a>.
gr
grIf the file does not exist and it is opened for output, it should be
grcreated as a new file. If <tt>mode</tt> is <a>WriteMode</a> and the
grfile already exists, then it should be truncated to zero length. Some
groperating systems delete empty files, so there is no guarantee that
grthe file will exist following an <a>openFile</a> with <tt>mode</tt>
gr<a>WriteMode</a> unless it is subsequently written to successfully.
grThe handle is positioned at the end of the file if <tt>mode</tt> is
gr<a>AppendMode</a>, and otherwise at the beginning (in which case its
grinternal position is 0). The initial buffer mode is
grimplementation-dependent.
gr
grThis operation may fail with:
gr
gr<ul>
gr<li><tt>isAlreadyInUseError</tt> if the file is already open and
grcannot be reopened;</li>
gr<li><tt>isDoesNotExistError</tt> if the file does not exist; or</li>
gr<li><tt>isPermissionError</tt> if the user does not have permission to
gropen the file.</li>
gr</ul>
gr
grNote: if you will be working with files containing binary data, you'll
grwant to be using <a>openBinaryFile</a>.
openFile :: FilePath -> IOMode -> IO Handle

-- | See <a>openFile</a>
data IOMode
ReadMode :: IOMode
WriteMode :: IOMode
AppendMode :: IOMode
ReadWriteMode :: IOMode

-- | Computation <a>hClose</a> <tt>hdl</tt> makes handle <tt>hdl</tt>
grclosed. Before the computation finishes, if <tt>hdl</tt> is writable
grits buffer is flushed as for <a>hFlush</a>. Performing <a>hClose</a>
gron a handle that has already been closed has no effect; doing so is
grnot an error. All other operations on a closed handle will fail. If
gr<a>hClose</a> fails for any reason, any further operations (apart from
gr<a>hClose</a>) on the handle will still fail as if <tt>hdl</tt> had
grbeen successfully closed.
hClose :: Handle -> IO ()

-- | The <a>readFile</a> function reads a file and returns the contents of
grthe file as a string. The file is read lazily, on demand, as with
gr<a>getContents</a>.
readFile :: FilePath -> IO String

-- | The computation <a>writeFile</a> <tt>file str</tt> function writes the
grstring <tt>str</tt>, to the file <tt>file</tt>.
writeFile :: FilePath -> String -> IO ()

-- | The computation <a>appendFile</a> <tt>file str</tt> function appends
grthe string <tt>str</tt>, to the file <tt>file</tt>.
gr
grNote that <a>writeFile</a> and <a>appendFile</a> write a literal
grstring to a file. To write a value of any printable type, as with
gr<a>print</a>, use the <a>show</a> function to convert the value to a
grstring first.
gr
gr<pre>
grmain = appendFile "squares" (show [(x,x*x) | x &lt;- [0,0.1..2]])
gr</pre>
appendFile :: FilePath -> String -> IO ()

-- | For a handle <tt>hdl</tt> which attached to a physical file,
gr<a>hFileSize</a> <tt>hdl</tt> returns the size of that file in 8-bit
grbytes.
hFileSize :: Handle -> IO Integer

-- | <a>hSetFileSize</a> <tt>hdl</tt> <tt>size</tt> truncates the physical
grfile with handle <tt>hdl</tt> to <tt>size</tt> bytes.
hSetFileSize :: Handle -> Integer -> IO ()

-- | For a readable handle <tt>hdl</tt>, <a>hIsEOF</a> <tt>hdl</tt> returns
gr<a>True</a> if no further input can be taken from <tt>hdl</tt> or for
gra physical file, if the current I/O position is equal to the length of
grthe file. Otherwise, it returns <a>False</a>.
gr
grNOTE: <a>hIsEOF</a> may block, because it has to attempt to read from
grthe stream to determine whether there is any more data to be read.
hIsEOF :: Handle -> IO Bool

-- | The computation <a>isEOF</a> is identical to <a>hIsEOF</a>, except
grthat it works only on <a>stdin</a>.
isEOF :: IO Bool

-- | Three kinds of buffering are supported: line-buffering,
grblock-buffering or no-buffering. These modes have the following
greffects. For output, items are written out, or <i>flushed</i>, from
grthe internal buffer according to the buffer mode:
gr
gr<ul>
gr<li><i>line-buffering</i>: the entire output buffer is flushed
grwhenever a newline is output, the buffer overflows, a <a>hFlush</a> is
grissued, or the handle is closed.</li>
gr<li><i>block-buffering</i>: the entire buffer is written out whenever
grit overflows, a <a>hFlush</a> is issued, or the handle is closed.</li>
gr<li><i>no-buffering</i>: output is written immediately, and never
grstored in the buffer.</li>
gr</ul>
gr
grAn implementation is free to flush the buffer more frequently, but not
grless frequently, than specified above. The output buffer is emptied as
grsoon as it has been written out.
gr
grSimilarly, input occurs according to the buffer mode for the handle:
gr
gr<ul>
gr<li><i>line-buffering</i>: when the buffer for the handle is not
grempty, the next item is obtained from the buffer; otherwise, when the
grbuffer is empty, characters up to and including the next newline
grcharacter are read into the buffer. No characters are available until
grthe newline character is available or the buffer is full.</li>
gr<li><i>block-buffering</i>: when the buffer for the handle becomes
grempty, the next block of data is read into the buffer.</li>
gr<li><i>no-buffering</i>: the next input item is read and returned. The
gr<a>hLookAhead</a> operation implies that even a no-buffered handle may
grrequire a one-character buffer.</li>
gr</ul>
gr
grThe default buffering mode when a handle is opened is
grimplementation-dependent and may depend on the file system object
grwhich is attached to that handle. For most implementations, physical
grfiles will normally be block-buffered and terminals will normally be
grline-buffered.
data BufferMode

-- | buffering is disabled if possible.
NoBuffering :: BufferMode

-- | line-buffering should be enabled if possible.
LineBuffering :: BufferMode

-- | block-buffering should be enabled if possible. The size of the buffer
gris <tt>n</tt> items if the argument is <a>Just</a> <tt>n</tt> and is
grotherwise implementation-dependent.
BlockBuffering :: (Maybe Int) -> BufferMode

-- | Computation <a>hSetBuffering</a> <tt>hdl mode</tt> sets the mode of
grbuffering for handle <tt>hdl</tt> on subsequent reads and writes.
gr
grIf the buffer mode is changed from <a>BlockBuffering</a> or
gr<a>LineBuffering</a> to <a>NoBuffering</a>, then
gr
gr<ul>
gr<li>if <tt>hdl</tt> is writable, the buffer is flushed as for
gr<a>hFlush</a>;</li>
gr<li>if <tt>hdl</tt> is not writable, the contents of the buffer is
grdiscarded.</li>
gr</ul>
gr
grThis operation may fail with:
gr
gr<ul>
gr<li><tt>isPermissionError</tt> if the handle has already been used for
grreading or writing and the implementation does not allow the buffering
grmode to be changed.</li>
gr</ul>
hSetBuffering :: Handle -> BufferMode -> IO ()

-- | Computation <a>hGetBuffering</a> <tt>hdl</tt> returns the current
grbuffering mode for <tt>hdl</tt>.
hGetBuffering :: Handle -> IO BufferMode

-- | The action <a>hFlush</a> <tt>hdl</tt> causes any items buffered for
groutput in handle <tt>hdl</tt> to be sent immediately to the operating
grsystem.
gr
grThis operation may fail with:
gr
gr<ul>
gr<li><tt>isFullError</tt> if the device is full;</li>
gr<li><tt>isPermissionError</tt> if a system resource limit would be
grexceeded. It is unspecified whether the characters in the buffer are
grdiscarded or retained under these circumstances.</li>
gr</ul>
hFlush :: Handle -> IO ()

-- | Computation <a>hGetPosn</a> <tt>hdl</tt> returns the current I/O
grposition of <tt>hdl</tt> as a value of the abstract type
gr<a>HandlePosn</a>.
hGetPosn :: Handle -> IO HandlePosn

-- | If a call to <a>hGetPosn</a> <tt>hdl</tt> returns a position
gr<tt>p</tt>, then computation <a>hSetPosn</a> <tt>p</tt> sets the
grposition of <tt>hdl</tt> to the position it held at the time of the
grcall to <a>hGetPosn</a>.
gr
grThis operation may fail with:
gr
gr<ul>
gr<li><tt>isPermissionError</tt> if a system resource limit would be
grexceeded.</li>
gr</ul>
hSetPosn :: HandlePosn -> IO ()
data HandlePosn

-- | Computation <a>hSeek</a> <tt>hdl mode i</tt> sets the position of
grhandle <tt>hdl</tt> depending on <tt>mode</tt>. The offset <tt>i</tt>
gris given in terms of 8-bit bytes.
gr
grIf <tt>hdl</tt> is block- or line-buffered, then seeking to a position
grwhich is not in the current buffer will first cause any items in the
groutput buffer to be written to the device, and then cause the input
grbuffer to be discarded. Some handles may not be seekable (see
gr<a>hIsSeekable</a>), or only support a subset of the possible
grpositioning operations (for instance, it may only be possible to seek
grto the end of a tape, or to a positive offset from the beginning or
grcurrent position). It is not possible to set a negative I/O position,
gror for a physical file, an I/O position beyond the current
grend-of-file.
gr
grThis operation may fail with:
gr
gr<ul>
gr<li><tt>isIllegalOperationError</tt> if the Handle is not seekable, or
grdoes not support the requested seek mode.</li>
gr<li><tt>isPermissionError</tt> if a system resource limit would be
grexceeded.</li>
gr</ul>
hSeek :: Handle -> SeekMode -> Integer -> IO ()

-- | A mode that determines the effect of <tt>hSeek</tt> <tt>hdl mode
gri</tt>.
data SeekMode

-- | the position of <tt>hdl</tt> is set to <tt>i</tt>.
AbsoluteSeek :: SeekMode

-- | the position of <tt>hdl</tt> is set to offset <tt>i</tt> from the
grcurrent position.
RelativeSeek :: SeekMode

-- | the position of <tt>hdl</tt> is set to offset <tt>i</tt> from the end
grof the file.
SeekFromEnd :: SeekMode

-- | Computation <a>hTell</a> <tt>hdl</tt> returns the current position of
grthe handle <tt>hdl</tt>, as the number of bytes from the beginning of
grthe file. The value returned may be subsequently passed to
gr<a>hSeek</a> to reposition the handle to the current position.
gr
grThis operation may fail with:
gr
gr<ul>
gr<li><tt>isIllegalOperationError</tt> if the Handle is not
grseekable.</li>
gr</ul>
hTell :: Handle -> IO Integer
hIsOpen :: Handle -> IO Bool
hIsClosed :: Handle -> IO Bool
hIsReadable :: Handle -> IO Bool
hIsWritable :: Handle -> IO Bool
hIsSeekable :: Handle -> IO Bool

-- | Is the handle connected to a terminal?
hIsTerminalDevice :: Handle -> IO Bool

-- | Set the echoing status of a handle connected to a terminal.
hSetEcho :: Handle -> Bool -> IO ()

-- | Get the echoing status of a handle connected to a terminal.
hGetEcho :: Handle -> IO Bool

-- | <a>hShow</a> is in the <a>IO</a> monad, and gives more comprehensive
groutput than the (pure) instance of <a>Show</a> for <a>Handle</a>.
hShow :: Handle -> IO String

-- | Computation <a>hWaitForInput</a> <tt>hdl t</tt> waits until input is
gravailable on handle <tt>hdl</tt>. It returns <a>True</a> as soon as
grinput is available on <tt>hdl</tt>, or <a>False</a> if no input is
gravailable within <tt>t</tt> milliseconds. Note that
gr<a>hWaitForInput</a> waits until one or more full <i>characters</i>
grare available, which means that it needs to do decoding, and hence may
grfail with a decoding error.
gr
grIf <tt>t</tt> is less than zero, then <tt>hWaitForInput</tt> waits
grindefinitely.
gr
grThis operation may fail with:
gr
gr<ul>
gr<li><a>isEOFError</a> if the end of file has been reached.</li>
gr<li>a decoding error, if the input begins with an invalid byte
grsequence in this Handle's encoding.</li>
gr</ul>
gr
grNOTE for GHC users: unless you use the <tt>-threaded</tt> flag,
gr<tt>hWaitForInput hdl t</tt> where <tt>t &gt;= 0</tt> will block all
grother Haskell threads for the duration of the call. It behaves like a
gr<tt>safe</tt> foreign call in this respect.
hWaitForInput :: Handle -> Int -> IO Bool

-- | Computation <a>hReady</a> <tt>hdl</tt> indicates whether at least one
gritem is available for input from handle <tt>hdl</tt>.
gr
grThis operation may fail with:
gr
gr<ul>
gr<li><a>isEOFError</a> if the end of file has been reached.</li>
gr</ul>
hReady :: Handle -> IO Bool

-- | Computation <a>hGetChar</a> <tt>hdl</tt> reads a character from the
grfile or channel managed by <tt>hdl</tt>, blocking until a character is
gravailable.
gr
grThis operation may fail with:
gr
gr<ul>
gr<li><a>isEOFError</a> if the end of file has been reached.</li>
gr</ul>
hGetChar :: Handle -> IO Char

-- | Computation <a>hGetLine</a> <tt>hdl</tt> reads a line from the file or
grchannel managed by <tt>hdl</tt>.
gr
grThis operation may fail with:
gr
gr<ul>
gr<li><a>isEOFError</a> if the end of file is encountered when reading
grthe <i>first</i> character of the line.</li>
gr</ul>
gr
grIf <a>hGetLine</a> encounters end-of-file at any other point while
grreading in a line, it is treated as a line terminator and the
gr(partial) line is returned.
hGetLine :: Handle -> IO String

-- | Computation <a>hLookAhead</a> returns the next character from the
grhandle without removing it from the input buffer, blocking until a
grcharacter is available.
gr
grThis operation may fail with:
gr
gr<ul>
gr<li><tt>isEOFError</tt> if the end of file has been reached.</li>
gr</ul>
hLookAhead :: Handle -> IO Char

-- | Computation <a>hGetContents</a> <tt>hdl</tt> returns the list of
grcharacters corresponding to the unread portion of the channel or file
grmanaged by <tt>hdl</tt>, which is put into an intermediate state,
gr<i>semi-closed</i>. In this state, <tt>hdl</tt> is effectively closed,
grbut items are read from <tt>hdl</tt> on demand and accumulated in a
grspecial list returned by <a>hGetContents</a> <tt>hdl</tt>.
gr
grAny operation that fails because a handle is closed, also fails if a
grhandle is semi-closed. The only exception is <tt>hClose</tt>. A
grsemi-closed handle becomes closed:
gr
gr<ul>
gr<li>if <tt>hClose</tt> is applied to it;</li>
gr<li>if an I/O error occurs when reading an item from the handle;</li>
gr<li>or once the entire contents of the handle has been read.</li>
gr</ul>
gr
grOnce a semi-closed handle becomes closed, the contents of the
grassociated list becomes fixed. The contents of this final list is only
grpartially specified: it will contain at least all the items of the
grstream that were evaluated prior to the handle becoming closed.
gr
grAny I/O errors encountered while a handle is semi-closed are simply
grdiscarded.
gr
grThis operation may fail with:
gr
gr<ul>
gr<li><a>isEOFError</a> if the end of file has been reached.</li>
gr</ul>
hGetContents :: Handle -> IO String

-- | Computation <a>hPutChar</a> <tt>hdl ch</tt> writes the character
gr<tt>ch</tt> to the file or channel managed by <tt>hdl</tt>. Characters
grmay be buffered if buffering is enabled for <tt>hdl</tt>.
gr
grThis operation may fail with:
gr
gr<ul>
gr<li><a>isFullError</a> if the device is full; or</li>
gr<li><a>isPermissionError</a> if another system resource limit would be
grexceeded.</li>
gr</ul>
hPutChar :: Handle -> Char -> IO ()

-- | Computation <a>hPutStr</a> <tt>hdl s</tt> writes the string <tt>s</tt>
grto the file or channel managed by <tt>hdl</tt>.
gr
grThis operation may fail with:
gr
gr<ul>
gr<li><a>isFullError</a> if the device is full; or</li>
gr<li><a>isPermissionError</a> if another system resource limit would be
grexceeded.</li>
gr</ul>
hPutStr :: Handle -> String -> IO ()

-- | The same as <a>hPutStr</a>, but adds a newline character.
hPutStrLn :: Handle -> String -> IO ()

-- | Computation <a>hPrint</a> <tt>hdl t</tt> writes the string
grrepresentation of <tt>t</tt> given by the <a>shows</a> function to the
grfile or channel managed by <tt>hdl</tt> and appends a newline.
gr
grThis operation may fail with:
gr
gr<ul>
gr<li><a>isFullError</a> if the device is full; or</li>
gr<li><a>isPermissionError</a> if another system resource limit would be
grexceeded.</li>
gr</ul>
hPrint :: Show a => Handle -> a -> IO ()

-- | The <a>interact</a> function takes a function of type
gr<tt>String-&gt;String</tt> as its argument. The entire input from the
grstandard input device is passed to this function as its argument, and
grthe resulting string is output on the standard output device.
interact :: (String -> String) -> IO ()

-- | Write a character to the standard output device (same as
gr<a>hPutChar</a> <a>stdout</a>).
putChar :: Char -> IO ()

-- | Write a string to the standard output device (same as <a>hPutStr</a>
gr<a>stdout</a>).
putStr :: String -> IO ()

-- | The same as <a>putStr</a>, but adds a newline character.
putStrLn :: String -> IO ()

-- | The <a>print</a> function outputs a value of any printable type to the
grstandard output device. Printable types are those that are instances
grof class <a>Show</a>; <a>print</a> converts values to strings for
groutput using the <a>show</a> operation and adds a newline.
gr
grFor example, a program to print the first 20 integers and their powers
grof 2 could be written as:
gr
gr<pre>
grmain = print ([(n, 2^n) | n &lt;- [0..19]])
gr</pre>
print :: Show a => a -> IO ()

-- | Read a character from the standard input device (same as
gr<a>hGetChar</a> <a>stdin</a>).
getChar :: IO Char

-- | Read a line from the standard input device (same as <a>hGetLine</a>
gr<a>stdin</a>).
getLine :: IO String

-- | The <a>getContents</a> operation returns all user input as a single
grstring, which is read lazily as it is needed (same as
gr<a>hGetContents</a> <a>stdin</a>).
getContents :: IO String

-- | The <a>readIO</a> function is similar to <a>read</a> except that it
grsignals parse failure to the <a>IO</a> monad instead of terminating
grthe program.
readIO :: Read a => String -> IO a

-- | The <a>readLn</a> function combines <a>getLine</a> and <a>readIO</a>.
readLn :: Read a => IO a

-- | <tt><a>withBinaryFile</a> name mode act</tt> opens a file using
gr<a>openBinaryFile</a> and passes the resulting handle to the
grcomputation <tt>act</tt>. The handle will be closed on exit from
gr<a>withBinaryFile</a>, whether by normal termination or by raising an
grexception.
withBinaryFile :: FilePath -> IOMode -> (Handle -> IO r) -> IO r

-- | Like <a>openFile</a>, but open the file in binary mode. On Windows,
grreading a file in text mode (which is the default) will translate CRLF
grto LF, and writing will translate LF to CRLF. This is usually what you
grwant with text files. With binary files this is undesirable; also, as
grusual under Microsoft operating systems, text mode treats control-Z as
grEOF. Binary mode turns off all special treatment of end-of-line and
grend-of-file characters. (See also <tt>hSetBinaryMode</tt>.)
openBinaryFile :: FilePath -> IOMode -> IO Handle

-- | Select binary mode (<a>True</a>) or text mode (<a>False</a>) on a open
grhandle. (See also <a>openBinaryFile</a>.)
gr
grThis has the same effect as calling <a>hSetEncoding</a> with
gr<a>char8</a>, together with <a>hSetNewlineMode</a> with
gr<a>noNewlineTranslation</a>.
hSetBinaryMode :: Handle -> Bool -> IO ()

-- | <a>hPutBuf</a> <tt>hdl buf count</tt> writes <tt>count</tt> 8-bit
grbytes from the buffer <tt>buf</tt> to the handle <tt>hdl</tt>. It
grreturns ().
gr
gr<a>hPutBuf</a> ignores any text encoding that applies to the
gr<a>Handle</a>, writing the bytes directly to the underlying file or
grdevice.
gr
gr<a>hPutBuf</a> ignores the prevailing <tt>TextEncoding</tt> and
gr<a>NewlineMode</a> on the <a>Handle</a>, and writes bytes directly.
gr
grThis operation may fail with:
gr
gr<ul>
gr<li><a>ResourceVanished</a> if the handle is a pipe or socket, and the
grreading end is closed. (If this is a POSIX system, and the program has
grnot asked to ignore SIGPIPE, then a SIGPIPE may be delivered instead,
grwhose default action is to terminate the program).</li>
gr</ul>
hPutBuf :: Handle -> Ptr a -> Int -> IO ()

-- | <a>hGetBuf</a> <tt>hdl buf count</tt> reads data from the handle
gr<tt>hdl</tt> into the buffer <tt>buf</tt> until either EOF is reached
gror <tt>count</tt> 8-bit bytes have been read. It returns the number of
grbytes actually read. This may be zero if EOF was reached before any
grdata was read (or if <tt>count</tt> is zero).
gr
gr<a>hGetBuf</a> never raises an EOF exception, instead it returns a
grvalue smaller than <tt>count</tt>.
gr
grIf the handle is a pipe or socket, and the writing end is closed,
gr<a>hGetBuf</a> will behave as if EOF was reached.
gr
gr<a>hGetBuf</a> ignores the prevailing <tt>TextEncoding</tt> and
gr<a>NewlineMode</a> on the <a>Handle</a>, and reads bytes directly.
hGetBuf :: Handle -> Ptr a -> Int -> IO Int

-- | <a>hGetBufSome</a> <tt>hdl buf count</tt> reads data from the handle
gr<tt>hdl</tt> into the buffer <tt>buf</tt>. If there is any data
gravailable to read, then <a>hGetBufSome</a> returns it immediately; it
gronly blocks if there is no data to be read.
gr
grIt returns the number of bytes actually read. This may be zero if EOF
grwas reached before any data was read (or if <tt>count</tt> is zero).
gr
gr<a>hGetBufSome</a> never raises an EOF exception, instead it returns a
grvalue smaller than <tt>count</tt>.
gr
grIf the handle is a pipe or socket, and the writing end is closed,
gr<a>hGetBufSome</a> will behave as if EOF was reached.
gr
gr<a>hGetBufSome</a> ignores the prevailing <tt>TextEncoding</tt> and
gr<a>NewlineMode</a> on the <a>Handle</a>, and reads bytes directly.
hGetBufSome :: Handle -> Ptr a -> Int -> IO Int
hPutBufNonBlocking :: Handle -> Ptr a -> Int -> IO Int

-- | <a>hGetBufNonBlocking</a> <tt>hdl buf count</tt> reads data from the
grhandle <tt>hdl</tt> into the buffer <tt>buf</tt> until either EOF is
grreached, or <tt>count</tt> 8-bit bytes have been read, or there is no
grmore data available to read immediately.
gr
gr<a>hGetBufNonBlocking</a> is identical to <a>hGetBuf</a>, except that
grit will never block waiting for data to become available, instead it
grreturns only whatever data is available. To wait for data to arrive
grbefore calling <a>hGetBufNonBlocking</a>, use <a>hWaitForInput</a>.
gr
grIf the handle is a pipe or socket, and the writing end is closed,
gr<a>hGetBufNonBlocking</a> will behave as if EOF was reached.
gr
gr<a>hGetBufNonBlocking</a> ignores the prevailing <tt>TextEncoding</tt>
grand <a>NewlineMode</a> on the <a>Handle</a>, and reads bytes directly.
gr
grNOTE: on Windows, this function does not work correctly; it behaves
gridentically to <a>hGetBuf</a>.
hGetBufNonBlocking :: Handle -> Ptr a -> Int -> IO Int

-- | The function creates a temporary file in ReadWrite mode. The created
grfile isn't deleted automatically, so you need to delete it manually.
gr
grThe file is created with permissions such that only the current user
grcan read/write it.
gr
grWith some exceptions (see below), the file will be created securely in
grthe sense that an attacker should not be able to cause openTempFile to
groverwrite another file on the filesystem using your credentials, by
grputting symbolic links (on Unix) in the place where the temporary file
gris to be created. On Unix the <tt>O_CREAT</tt> and <tt>O_EXCL</tt>
grflags are used to prevent this attack, but note that <tt>O_EXCL</tt>
gris sometimes not supported on NFS filesystems, so if you rely on this
grbehaviour it is best to use local filesystems only.
openTempFile :: FilePath -> String -> IO (FilePath, Handle)

-- | Like <a>openTempFile</a>, but opens the file in binary mode. See
gr<a>openBinaryFile</a> for more comments.
openBinaryTempFile :: FilePath -> String -> IO (FilePath, Handle)

-- | Like <a>openTempFile</a>, but uses the default file permissions
openTempFileWithDefaultPermissions :: FilePath -> String -> IO (FilePath, Handle)

-- | Like <a>openBinaryTempFile</a>, but uses the default file permissions
openBinaryTempFileWithDefaultPermissions :: FilePath -> String -> IO (FilePath, Handle)

-- | The action <a>hSetEncoding</a> <tt>hdl</tt> <tt>encoding</tt> changes
grthe text encoding for the handle <tt>hdl</tt> to <tt>encoding</tt>.
grThe default encoding when a <a>Handle</a> is created is
gr<tt>localeEncoding</tt>, namely the default encoding for the current
grlocale.
gr
grTo create a <a>Handle</a> with no encoding at all, use
gr<a>openBinaryFile</a>. To stop further encoding or decoding on an
grexisting <a>Handle</a>, use <a>hSetBinaryMode</a>.
gr
gr<a>hSetEncoding</a> may need to flush buffered data in order to change
grthe encoding.
hSetEncoding :: Handle -> TextEncoding -> IO ()

-- | Return the current <a>TextEncoding</a> for the specified
gr<a>Handle</a>, or <a>Nothing</a> if the <a>Handle</a> is in binary
grmode.
gr
grNote that the <a>TextEncoding</a> remembers nothing about the state of
grthe encoder/decoder in use on this <a>Handle</a>. For example, if the
grencoding in use is UTF-16, then using <a>hGetEncoding</a> and
gr<a>hSetEncoding</a> to save and restore the encoding may result in an
grextra byte-order-mark being written to the file.
hGetEncoding :: Handle -> IO (Maybe TextEncoding)

-- | A <a>TextEncoding</a> is a specification of a conversion scheme
grbetween sequences of bytes and sequences of Unicode characters.
gr
grFor example, UTF-8 is an encoding of Unicode characters into a
grsequence of bytes. The <a>TextEncoding</a> for UTF-8 is <tt>utf8</tt>.
data TextEncoding

-- | The Latin1 (ISO8859-1) encoding. This encoding maps bytes directly to
grthe first 256 Unicode code points, and is thus not a complete Unicode
grencoding. An attempt to write a character greater than '\255' to a
gr<tt>Handle</tt> using the <a>latin1</a> encoding will result in an
grerror.
latin1 :: TextEncoding

-- | The UTF-8 Unicode encoding
utf8 :: TextEncoding

-- | The UTF-8 Unicode encoding, with a byte-order-mark (BOM; the byte
grsequence 0xEF 0xBB 0xBF). This encoding behaves like <a>utf8</a>,
grexcept that on input, the BOM sequence is ignored at the beginning of
grthe stream, and on output, the BOM sequence is prepended.
gr
grThe byte-order-mark is strictly unnecessary in UTF-8, but is sometimes
grused to identify the encoding of a file.
utf8_bom :: TextEncoding

-- | The UTF-16 Unicode encoding (a byte-order-mark should be used to
grindicate endianness).
utf16 :: TextEncoding

-- | The UTF-16 Unicode encoding (litte-endian)
utf16le :: TextEncoding

-- | The UTF-16 Unicode encoding (big-endian)
utf16be :: TextEncoding

-- | The UTF-32 Unicode encoding (a byte-order-mark should be used to
grindicate endianness).
utf32 :: TextEncoding

-- | The UTF-32 Unicode encoding (litte-endian)
utf32le :: TextEncoding

-- | The UTF-32 Unicode encoding (big-endian)
utf32be :: TextEncoding

-- | The Unicode encoding of the current locale
gr
grThis is the initial locale encoding: if it has been subsequently
grchanged by <a>setLocaleEncoding</a> this value will not reflect that
grchange.
localeEncoding :: TextEncoding

-- | An encoding in which Unicode code points are translated to bytes by
grtaking the code point modulo 256. When decoding, bytes are translated
grdirectly into the equivalent code point.
gr
grThis encoding never fails in either direction. However, encoding
grdiscards information, so encode followed by decode is not the
gridentity.
char8 :: TextEncoding

-- | Look up the named Unicode encoding. May fail with
gr
gr<ul>
gr<li><tt>isDoesNotExistError</tt> if the encoding is unknown</li>
gr</ul>
gr
grThe set of known encodings is system-dependent, but includes at least:
gr
gr<ul>
gr<li><pre>UTF-8</pre></li>
gr<li><tt>UTF-16</tt>, <tt>UTF-16BE</tt>, <tt>UTF-16LE</tt></li>
gr<li><tt>UTF-32</tt>, <tt>UTF-32BE</tt>, <tt>UTF-32LE</tt></li>
gr</ul>
gr
grThere is additional notation (borrowed from GNU iconv) for specifying
grhow illegal characters are handled:
gr
gr<ul>
gr<li>a suffix of <tt>//IGNORE</tt>, e.g. <tt>UTF-8//IGNORE</tt>, will
grcause all illegal sequences on input to be ignored, and on output will
grdrop all code points that have no representation in the target
grencoding.</li>
gr<li>a suffix of <tt>//TRANSLIT</tt> will choose a replacement
grcharacter for illegal sequences or code points.</li>
gr<li>a suffix of <tt>//ROUNDTRIP</tt> will use a PEP383-style escape
grmechanism to represent any invalid bytes in the input as Unicode
grcodepoints (specifically, as lone surrogates, which are normally
grinvalid in UTF-32). Upon output, these special codepoints are detected
grand turned back into the corresponding original byte.</li>
gr</ul>
gr
grIn theory, this mechanism allows arbitrary data to be roundtripped via
gra <a>String</a> with no loss of data. In practice, there are two
grlimitations to be aware of:
gr
gr<ol>
gr<li>This only stands a chance of working for an encoding which is an
grASCII superset, as for security reasons we refuse to escape any bytes
grsmaller than 128. Many encodings of interest are ASCII supersets (in
grparticular, you can assume that the locale encoding is an ASCII
grsuperset) but many (such as UTF-16) are not.</li>
gr<li>If the underlying encoding is not itself roundtrippable, this
grmechanism can fail. Roundtrippable encodings are those which have an
grinjective mapping into Unicode. Almost all encodings meet this
grcriteria, but some do not. Notably, Shift-JIS (CP932) and Big5 contain
grseveral different encodings of the same Unicode codepoint.</li>
gr</ol>
gr
grOn Windows, you can access supported code pages with the prefix
gr<tt>CP</tt>; for example, <tt>"CP1250"</tt>.
mkTextEncoding :: String -> IO TextEncoding

-- | Set the <a>NewlineMode</a> on the specified <a>Handle</a>. All
grbuffered data is flushed first.
hSetNewlineMode :: Handle -> NewlineMode -> IO ()

-- | The representation of a newline in the external file or stream.
data Newline

-- | '\n'
LF :: Newline

-- | '\r\n'
CRLF :: Newline

-- | The native newline representation for the current platform: <a>LF</a>
gron Unix systems, <a>CRLF</a> on Windows.
nativeNewline :: Newline

-- | Specifies the translation, if any, of newline characters between
grinternal Strings and the external file or stream. Haskell Strings are
grassumed to represent newlines with the '\n' character; the newline
grmode specifies how to translate '\n' on output, and what to translate
grinto '\n' on input.
data NewlineMode
NewlineMode :: Newline -> Newline -> NewlineMode

-- | the representation of newlines on input
[inputNL] :: NewlineMode -> Newline

-- | the representation of newlines on output
[outputNL] :: NewlineMode -> Newline

-- | Do no newline translation at all.
gr
gr<pre>
grnoNewlineTranslation  = NewlineMode { inputNL  = LF, outputNL = LF }
gr</pre>
noNewlineTranslation :: NewlineMode

-- | Map '\r\n' into '\n' on input, and '\n' to the native newline
grrepresetnation on output. This mode can be used on any platform, and
grworks with text files using any newline convention. The downside is
grthat <tt>readFile &gt;&gt;= writeFile</tt> might yield a different
grfile.
gr
gr<pre>
gruniversalNewlineMode  = NewlineMode { inputNL  = CRLF,
gr                                      outputNL = nativeNewline }
gr</pre>
universalNewlineMode :: NewlineMode

-- | Use the native newline representation on both input and output
gr
gr<pre>
grnativeNewlineMode  = NewlineMode { inputNL  = nativeNewline
gr                                   outputNL = nativeNewline }
gr</pre>
nativeNewlineMode :: NewlineMode

module GHC.Fingerprint
data Fingerprint
Fingerprint :: {-# UNPACK #-} !Word64 -> {-# UNPACK #-} !Word64 -> Fingerprint
fingerprint0 :: Fingerprint
fingerprintData :: Ptr Word8 -> Int -> IO Fingerprint
fingerprintString :: String -> Fingerprint
fingerprintFingerprints :: [Fingerprint] -> Fingerprint

-- | Computes the hash of a given file. This function loops over the
grhandle, running in constant memory.
getFileHash :: FilePath -> IO Fingerprint


-- | Monadic fixpoints.
gr
grFor a detailed discussion, see Levent Erkok's thesis, <i>Value
grRecursion in Monadic Computations</i>, Oregon Graduate Institute,
gr2002.
module Control.Monad.Fix

-- | Monads having fixed points with a 'knot-tying' semantics. Instances of
gr<a>MonadFix</a> should satisfy the following laws:
gr
gr<ul>
gr<li><i><i>purity</i></i> <tt><a>mfix</a> (<tt>return</tt> . h) =
gr<tt>return</tt> (<a>fix</a> h)</tt></li>
gr<li><i><i>left shrinking</i> (or <i>tightening</i>)</i>
gr<tt><a>mfix</a> (\x -&gt; a &gt;&gt;= \y -&gt; f x y) = a &gt;&gt;= \y
gr-&gt; <a>mfix</a> (\x -&gt; f x y)</tt></li>
gr<li><i><i>sliding</i></i> <tt><a>mfix</a> (<a>liftM</a> h . f) =
gr<a>liftM</a> h (<a>mfix</a> (f . h))</tt>, for strict <tt>h</tt>.</li>
gr<li><i><i>nesting</i></i> <tt><a>mfix</a> (\x -&gt; <a>mfix</a> (\y
gr-&gt; f x y)) = <a>mfix</a> (\x -&gt; f x x)</tt></li>
gr</ul>
gr
grThis class is used in the translation of the recursive <tt>do</tt>
grnotation supported by GHC and Hugs.
class (Monad m) => MonadFix m

-- | The fixed point of a monadic computation. <tt><a>mfix</a> f</tt>
grexecutes the action <tt>f</tt> only once, with the eventual output fed
grback as the input. Hence <tt>f</tt> should not be strict, for then
gr<tt><a>mfix</a> f</tt> would diverge.
mfix :: MonadFix m => (a -> m a) -> m a

-- | <tt><a>fix</a> f</tt> is the least fixed point of the function
gr<tt>f</tt>, i.e. the least defined <tt>x</tt> such that <tt>f x =
grx</tt>.
gr
grFor example, we can write the factorial function using direct
grrecursion as
gr
gr<pre>
gr&gt;&gt;&gt; let fac n = if n &lt;= 1 then 1 else n * fac (n-1) in fac 5
gr120
gr</pre>
gr
grThis uses the fact that Haskell’s <tt>let</tt> introduces recursive
grbindings. We can rewrite this definition using <a>fix</a>,
gr
gr<pre>
gr&gt;&gt;&gt; fix (\rec n -&gt; if n &lt;= 1 then 1 else n * rec (n-1)) 5
gr120
gr</pre>
gr
grInstead of making a recursive call, we introduce a dummy parameter
gr<tt>rec</tt>; when used within <a>fix</a>, this parameter then refers
grto <tt>fix'</tt> argument, hence the recursion is reintroduced.
fix :: (a -> a) -> a
instance Control.Monad.Fix.MonadFix GHC.Base.Maybe
instance Control.Monad.Fix.MonadFix []
instance Control.Monad.Fix.MonadFix GHC.Base.NonEmpty
instance Control.Monad.Fix.MonadFix GHC.Types.IO
instance Control.Monad.Fix.MonadFix ((->) r)
instance Control.Monad.Fix.MonadFix (Data.Either.Either e)
instance Control.Monad.Fix.MonadFix (GHC.ST.ST s)
instance Control.Monad.Fix.MonadFix Data.Semigroup.Internal.Dual
instance Control.Monad.Fix.MonadFix Data.Semigroup.Internal.Sum
instance Control.Monad.Fix.MonadFix Data.Semigroup.Internal.Product
instance Control.Monad.Fix.MonadFix Data.Monoid.First
instance Control.Monad.Fix.MonadFix Data.Monoid.Last
instance Control.Monad.Fix.MonadFix f => Control.Monad.Fix.MonadFix (Data.Semigroup.Internal.Alt f)
instance Control.Monad.Fix.MonadFix GHC.Generics.Par1
instance Control.Monad.Fix.MonadFix f => Control.Monad.Fix.MonadFix (GHC.Generics.Rec1 f)
instance Control.Monad.Fix.MonadFix f => Control.Monad.Fix.MonadFix (GHC.Generics.M1 i c f)
instance (Control.Monad.Fix.MonadFix f, Control.Monad.Fix.MonadFix g) => Control.Monad.Fix.MonadFix (f GHC.Generics.:*: g)


-- | The identity functor and monad.
gr
grThis trivial type constructor serves two purposes:
gr
gr<ul>
gr<li>It can be used with functions parameterized by functor or monad
grclasses.</li>
gr<li>It can be used as a base monad to which a series of monad
grtransformers may be applied to construct a composite monad. Most monad
grtransformer modules include the special case of applying the
grtransformer to <a>Identity</a>. For example, <tt>State s</tt> is an
grabbreviation for <tt>StateT s <a>Identity</a></tt>.</li>
gr</ul>
module Data.Functor.Identity

-- | Identity functor and monad. (a non-strict monad)
newtype Identity a
Identity :: a -> Identity a
[runIdentity] :: Identity a -> a
instance Foreign.Storable.Storable a => Foreign.Storable.Storable (Data.Functor.Identity.Identity a)
instance GHC.Float.RealFloat a => GHC.Float.RealFloat (Data.Functor.Identity.Identity a)
instance GHC.Real.RealFrac a => GHC.Real.RealFrac (Data.Functor.Identity.Identity a)
instance GHC.Real.Real a => GHC.Real.Real (Data.Functor.Identity.Identity a)
instance GHC.Classes.Ord a => GHC.Classes.Ord (Data.Functor.Identity.Identity a)
instance GHC.Num.Num a => GHC.Num.Num (Data.Functor.Identity.Identity a)
instance GHC.Base.Monoid a => GHC.Base.Monoid (Data.Functor.Identity.Identity a)
instance GHC.Base.Semigroup a => GHC.Base.Semigroup (Data.Functor.Identity.Identity a)
instance GHC.Arr.Ix a => GHC.Arr.Ix (Data.Functor.Identity.Identity a)
instance GHC.Real.Integral a => GHC.Real.Integral (Data.Functor.Identity.Identity a)
instance GHC.Generics.Generic1 Data.Functor.Identity.Identity
instance GHC.Generics.Generic (Data.Functor.Identity.Identity a)
instance GHC.Real.Fractional a => GHC.Real.Fractional (Data.Functor.Identity.Identity a)
instance GHC.Float.Floating a => GHC.Float.Floating (Data.Functor.Identity.Identity a)
instance Data.Bits.FiniteBits a => Data.Bits.FiniteBits (Data.Functor.Identity.Identity a)
instance GHC.Classes.Eq a => GHC.Classes.Eq (Data.Functor.Identity.Identity a)
instance GHC.Enum.Enum a => GHC.Enum.Enum (Data.Functor.Identity.Identity a)
instance GHC.Enum.Bounded a => GHC.Enum.Bounded (Data.Functor.Identity.Identity a)
instance Data.Bits.Bits a => Data.Bits.Bits (Data.Functor.Identity.Identity a)
instance GHC.Read.Read a => GHC.Read.Read (Data.Functor.Identity.Identity a)
instance GHC.Show.Show a => GHC.Show.Show (Data.Functor.Identity.Identity a)
instance Data.Foldable.Foldable Data.Functor.Identity.Identity
instance GHC.Base.Functor Data.Functor.Identity.Identity
instance GHC.Base.Applicative Data.Functor.Identity.Identity
instance GHC.Base.Monad Data.Functor.Identity.Identity
instance Control.Monad.Fix.MonadFix Data.Functor.Identity.Identity


-- | Basic arrow definitions, based on
gr
gr<ul>
gr<li><i>Generalising Monads to Arrows</i>, by John Hughes, <i>Science
grof Computer Programming</i> 37, pp67-111, May 2000.</li>
gr</ul>
gr
grplus a couple of definitions (<a>returnA</a> and <a>loop</a>) from
gr
gr<ul>
gr<li><i>A New Notation for Arrows</i>, by Ross Paterson, in <i>ICFP
gr2001</i>, Firenze, Italy, pp229-240.</li>
gr</ul>
gr
grThese papers and more information on arrows can be found at
gr<a>http://www.haskell.org/arrows/</a>.
module Control.Arrow

-- | The basic arrow class.
gr
grInstances should satisfy the following laws:
gr
gr<ul>
gr<li><pre><a>arr</a> id = <a>id</a></pre></li>
gr<li><pre><a>arr</a> (f &gt;&gt;&gt; g) = <a>arr</a> f &gt;&gt;&gt;
gr<a>arr</a> g</pre></li>
gr<li><pre><a>first</a> (<a>arr</a> f) = <a>arr</a> (<a>first</a>
grf)</pre></li>
gr<li><pre><a>first</a> (f &gt;&gt;&gt; g) = <a>first</a> f &gt;&gt;&gt;
gr<a>first</a> g</pre></li>
gr<li><pre><a>first</a> f &gt;&gt;&gt; <a>arr</a> <a>fst</a> =
gr<a>arr</a> <a>fst</a> &gt;&gt;&gt; f</pre></li>
gr<li><pre><a>first</a> f &gt;&gt;&gt; <a>arr</a> (<a>id</a> *** g) =
gr<a>arr</a> (<a>id</a> *** g) &gt;&gt;&gt; <a>first</a> f</pre></li>
gr<li><pre><a>first</a> (<a>first</a> f) &gt;&gt;&gt; <a>arr</a>
gr<tt>assoc</tt> = <a>arr</a> <tt>assoc</tt> &gt;&gt;&gt; <a>first</a>
grf</pre></li>
gr</ul>
gr
grwhere
gr
gr<pre>
grassoc ((a,b),c) = (a,(b,c))
gr</pre>
gr
grThe other combinators have sensible default definitions, which may be
groverridden for efficiency.
class Category a => Arrow a

-- | Lift a function to an arrow.
arr :: Arrow a => (b -> c) -> a b c

-- | Send the first component of the input through the argument arrow, and
grcopy the rest unchanged to the output.
first :: Arrow a => a b c -> a (b, d) (c, d)

-- | A mirror image of <a>first</a>.
gr
grThe default definition may be overridden with a more efficient version
grif desired.
second :: Arrow a => a b c -> a (d, b) (d, c)

-- | Split the input between the two argument arrows and combine their
groutput. Note that this is in general not a functor.
gr
grThe default definition may be overridden with a more efficient version
grif desired.
(***) :: Arrow a => a b c -> a b' c' -> a (b, b') (c, c')

-- | Fanout: send the input to both argument arrows and combine their
groutput.
gr
grThe default definition may be overridden with a more efficient version
grif desired.
(&&&) :: Arrow a => a b c -> a b c' -> a b (c, c')

-- | Kleisli arrows of a monad.
newtype Kleisli m a b
Kleisli :: a -> m b -> Kleisli m a b
[runKleisli] :: Kleisli m a b -> a -> m b

-- | The identity arrow, which plays the role of <a>return</a> in arrow
grnotation.
returnA :: Arrow a => a b b

-- | Precomposition with a pure function.
(^>>) :: Arrow a => (b -> c) -> a c d -> a b d
infixr 1 ^>>

-- | Postcomposition with a pure function.
(>>^) :: Arrow a => a b c -> (c -> d) -> a b d
infixr 1 >>^

-- | Left-to-right composition
(>>>) :: Category cat => cat a b -> cat b c -> cat a c
infixr 1 >>>

-- | Right-to-left composition
(<<<) :: Category cat => cat b c -> cat a b -> cat a c
infixr 1 <<<

-- | Precomposition with a pure function (right-to-left variant).
(<<^) :: Arrow a => a c d -> (b -> c) -> a b d
infixr 1 <<^

-- | Postcomposition with a pure function (right-to-left variant).
(^<<) :: Arrow a => (c -> d) -> a b c -> a b d
infixr 1 ^<<
class Arrow a => ArrowZero a
zeroArrow :: ArrowZero a => a b c

-- | A monoid on arrows.
class ArrowZero a => ArrowPlus a

-- | An associative operation with identity <a>zeroArrow</a>.
(<+>) :: ArrowPlus a => a b c -> a b c -> a b c

-- | Choice, for arrows that support it. This class underlies the
gr<tt>if</tt> and <tt>case</tt> constructs in arrow notation.
gr
grInstances should satisfy the following laws:
gr
gr<ul>
gr<li><pre><a>left</a> (<a>arr</a> f) = <a>arr</a> (<a>left</a>
grf)</pre></li>
gr<li><pre><a>left</a> (f &gt;&gt;&gt; g) = <a>left</a> f &gt;&gt;&gt;
gr<a>left</a> g</pre></li>
gr<li><pre>f &gt;&gt;&gt; <a>arr</a> <a>Left</a> = <a>arr</a>
gr<a>Left</a> &gt;&gt;&gt; <a>left</a> f</pre></li>
gr<li><pre><a>left</a> f &gt;&gt;&gt; <a>arr</a> (<a>id</a> +++ g) =
gr<a>arr</a> (<a>id</a> +++ g) &gt;&gt;&gt; <a>left</a> f</pre></li>
gr<li><pre><a>left</a> (<a>left</a> f) &gt;&gt;&gt; <a>arr</a>
gr<tt>assocsum</tt> = <a>arr</a> <tt>assocsum</tt> &gt;&gt;&gt;
gr<a>left</a> f</pre></li>
gr</ul>
gr
grwhere
gr
gr<pre>
grassocsum (Left (Left x)) = Left x
grassocsum (Left (Right y)) = Right (Left y)
grassocsum (Right z) = Right (Right z)
gr</pre>
gr
grThe other combinators have sensible default definitions, which may be
groverridden for efficiency.
class Arrow a => ArrowChoice a

-- | Feed marked inputs through the argument arrow, passing the rest
grthrough unchanged to the output.
left :: ArrowChoice a => a b c -> a (Either b d) (Either c d)

-- | A mirror image of <a>left</a>.
gr
grThe default definition may be overridden with a more efficient version
grif desired.
right :: ArrowChoice a => a b c -> a (Either d b) (Either d c)

-- | Split the input between the two argument arrows, retagging and merging
grtheir outputs. Note that this is in general not a functor.
gr
grThe default definition may be overridden with a more efficient version
grif desired.
(+++) :: ArrowChoice a => a b c -> a b' c' -> a (Either b b') (Either c c')

-- | Fanin: Split the input between the two argument arrows and merge their
groutputs.
gr
grThe default definition may be overridden with a more efficient version
grif desired.
(|||) :: ArrowChoice a => a b d -> a c d -> a (Either b c) d

-- | Some arrows allow application of arrow inputs to other inputs.
grInstances should satisfy the following laws:
gr
gr<ul>
gr<li><pre><a>first</a> (<a>arr</a> (\x -&gt; <a>arr</a> (\y -&gt;
gr(x,y)))) &gt;&gt;&gt; <a>app</a> = <a>id</a></pre></li>
gr<li><pre><a>first</a> (<a>arr</a> (g &gt;&gt;&gt;)) &gt;&gt;&gt;
gr<a>app</a> = <a>second</a> g &gt;&gt;&gt; <a>app</a></pre></li>
gr<li><pre><a>first</a> (<a>arr</a> (&gt;&gt;&gt; h)) &gt;&gt;&gt;
gr<a>app</a> = <a>app</a> &gt;&gt;&gt; h</pre></li>
gr</ul>
gr
grSuch arrows are equivalent to monads (see <a>ArrowMonad</a>).
class Arrow a => ArrowApply a
app :: ArrowApply a => a (a b c, b) c

-- | The <a>ArrowApply</a> class is equivalent to <a>Monad</a>: any monad
grgives rise to a <a>Kleisli</a> arrow, and any instance of
gr<a>ArrowApply</a> defines a monad.
newtype ArrowMonad a b
ArrowMonad :: (a () b) -> ArrowMonad a b

-- | Any instance of <a>ArrowApply</a> can be made into an instance of
gr<a>ArrowChoice</a> by defining <a>left</a> = <a>leftApp</a>.
leftApp :: ArrowApply a => a b c -> a (Either b d) (Either c d)

-- | The <a>loop</a> operator expresses computations in which an output
grvalue is fed back as input, although the computation occurs only once.
grIt underlies the <tt>rec</tt> value recursion construct in arrow
grnotation. <a>loop</a> should satisfy the following laws:
gr
gr<ul>
gr<li><i><i>extension</i></i> <tt><a>loop</a> (<a>arr</a> f) =
gr<a>arr</a> (\ b -&gt; <a>fst</a> (<a>fix</a> (\ (c,d) -&gt; f
gr(b,d))))</tt></li>
gr<li><i><i>left tightening</i></i> <tt><a>loop</a> (<a>first</a> h
gr&gt;&gt;&gt; f) = h &gt;&gt;&gt; <a>loop</a> f</tt></li>
gr<li><i><i>right tightening</i></i> <tt><a>loop</a> (f &gt;&gt;&gt;
gr<a>first</a> h) = <a>loop</a> f &gt;&gt;&gt; h</tt></li>
gr<li><i><i>sliding</i></i> <tt><a>loop</a> (f &gt;&gt;&gt; <a>arr</a>
gr(<a>id</a> *** k)) = <a>loop</a> (<a>arr</a> (<a>id</a> *** k)
gr&gt;&gt;&gt; f)</tt></li>
gr<li><i><i>vanishing</i></i> <tt><a>loop</a> (<a>loop</a> f) =
gr<a>loop</a> (<a>arr</a> unassoc &gt;&gt;&gt; f &gt;&gt;&gt; <a>arr</a>
grassoc)</tt></li>
gr<li><i><i>superposing</i></i> <tt><a>second</a> (<a>loop</a> f) =
gr<a>loop</a> (<a>arr</a> assoc &gt;&gt;&gt; <a>second</a> f
gr&gt;&gt;&gt; <a>arr</a> unassoc)</tt></li>
gr</ul>
gr
grwhere
gr
gr<pre>
grassoc ((a,b),c) = (a,(b,c))
grunassoc (a,(b,c)) = ((a,b),c)
gr</pre>
class Arrow a => ArrowLoop a
loop :: ArrowLoop a => a (b, d) (c, d) -> a b c
instance Control.Arrow.ArrowLoop (->)
instance Control.Monad.Fix.MonadFix m => Control.Arrow.ArrowLoop (Control.Arrow.Kleisli m)
instance Control.Arrow.Arrow a => GHC.Base.Functor (Control.Arrow.ArrowMonad a)
instance Control.Arrow.Arrow a => GHC.Base.Applicative (Control.Arrow.ArrowMonad a)
instance Control.Arrow.ArrowApply a => GHC.Base.Monad (Control.Arrow.ArrowMonad a)
instance Control.Arrow.ArrowPlus a => GHC.Base.Alternative (Control.Arrow.ArrowMonad a)
instance (Control.Arrow.ArrowApply a, Control.Arrow.ArrowPlus a) => GHC.Base.MonadPlus (Control.Arrow.ArrowMonad a)
instance Control.Arrow.ArrowApply (->)
instance GHC.Base.Monad m => Control.Arrow.ArrowApply (Control.Arrow.Kleisli m)
instance Control.Arrow.ArrowChoice (->)
instance GHC.Base.Monad m => Control.Arrow.ArrowChoice (Control.Arrow.Kleisli m)
instance GHC.Base.MonadPlus m => Control.Arrow.ArrowPlus (Control.Arrow.Kleisli m)
instance GHC.Base.MonadPlus m => Control.Arrow.ArrowZero (Control.Arrow.Kleisli m)
instance GHC.Base.Monad m => Control.Category.Category (Control.Arrow.Kleisli m)
instance GHC.Base.Monad m => Control.Arrow.Arrow (Control.Arrow.Kleisli m)
instance Control.Arrow.Arrow (->)


-- | This module describes a structure intermediate between a functor and a
grmonad (technically, a strong lax monoidal functor). Compared with
grmonads, this interface lacks the full power of the binding operation
gr<a>&gt;&gt;=</a>, but
gr
gr<ul>
gr<li>it has more instances.</li>
gr<li>it is sufficient for many uses, e.g. context-free parsing, or the
gr<a>Traversable</a> class.</li>
gr<li>instances can perform analysis of computations before they are
grexecuted, and thus produce shared optimizations.</li>
gr</ul>
gr
grThis interface was introduced for parsers by Niklas Röjemo, because it
gradmits more sharing than the monadic interface. The names here are
grmostly based on parsing work by Doaitse Swierstra.
gr
grFor more details, see <a>Applicative Programming with Effects</a>, by
grConor McBride and Ross Paterson.
module Control.Applicative

-- | A functor with application, providing operations to
gr
gr<ul>
gr<li>embed pure expressions (<a>pure</a>), and</li>
gr<li>sequence computations and combine their results (<a>&lt;*&gt;</a>
grand <a>liftA2</a>).</li>
gr</ul>
gr
grA minimal complete definition must include implementations of
gr<a>pure</a> and of either <a>&lt;*&gt;</a> or <a>liftA2</a>. If it
grdefines both, then they must behave the same as their default
grdefinitions:
gr
gr<pre>
gr(<a>&lt;*&gt;</a>) = <a>liftA2</a> <a>id</a>
gr</pre>
gr
gr<pre>
gr<a>liftA2</a> f x y = f <tt>&lt;$&gt;</tt> x <a>&lt;*&gt;</a> y
gr</pre>
gr
grFurther, any definition must satisfy the following:
gr
gr<ul>
gr<li><i><i>identity</i></i> <pre><a>pure</a> <a>id</a> <a>&lt;*&gt;</a>
grv = v</pre></li>
gr<li><i><i>composition</i></i> <pre><a>pure</a> (.) <a>&lt;*&gt;</a> u
gr<a>&lt;*&gt;</a> v <a>&lt;*&gt;</a> w = u <a>&lt;*&gt;</a> (v
gr<a>&lt;*&gt;</a> w)</pre></li>
gr<li><i><i>homomorphism</i></i> <pre><a>pure</a> f <a>&lt;*&gt;</a>
gr<a>pure</a> x = <a>pure</a> (f x)</pre></li>
gr<li><i><i>interchange</i></i> <pre>u <a>&lt;*&gt;</a> <a>pure</a> y =
gr<a>pure</a> (<a>$</a> y) <a>&lt;*&gt;</a> u</pre></li>
gr</ul>
gr
grThe other methods have the following default definitions, which may be
groverridden with equivalent specialized implementations:
gr
gr<ul>
gr<li><pre>u <a>*&gt;</a> v = (<a>id</a> <a>&lt;$</a> u)
gr<a>&lt;*&gt;</a> v</pre></li>
gr<li><pre>u <a>&lt;*</a> v = <a>liftA2</a> <a>const</a> u v</pre></li>
gr</ul>
gr
grAs a consequence of these laws, the <a>Functor</a> instance for
gr<tt>f</tt> will satisfy
gr
gr<ul>
gr<li><pre><a>fmap</a> f x = <a>pure</a> f <a>&lt;*&gt;</a> x</pre></li>
gr</ul>
gr
grIt may be useful to note that supposing
gr
gr<pre>
grforall x y. p (q x y) = f x . g y
gr</pre>
gr
grit follows from the above that
gr
gr<pre>
gr<a>liftA2</a> p (<a>liftA2</a> q u v) = <a>liftA2</a> f u . <a>liftA2</a> g v
gr</pre>
gr
grIf <tt>f</tt> is also a <a>Monad</a>, it should satisfy
gr
gr<ul>
gr<li><pre><a>pure</a> = <a>return</a></pre></li>
gr<li><pre>(<a>&lt;*&gt;</a>) = <a>ap</a></pre></li>
gr<li><pre>(<a>*&gt;</a>) = (<a>&gt;&gt;</a>)</pre></li>
gr</ul>
gr
gr(which implies that <a>pure</a> and <a>&lt;*&gt;</a> satisfy the
grapplicative functor laws).
class Functor f => Applicative f

-- | Lift a value.
pure :: Applicative f => a -> f a

-- | Sequential application.
gr
grA few functors support an implementation of <a>&lt;*&gt;</a> that is
grmore efficient than the default one.
(<*>) :: Applicative f => f (a -> b) -> f a -> f b

-- | Lift a binary function to actions.
gr
grSome functors support an implementation of <a>liftA2</a> that is more
grefficient than the default one. In particular, if <a>fmap</a> is an
grexpensive operation, it is likely better to use <a>liftA2</a> than to
gr<a>fmap</a> over the structure and then use <a>&lt;*&gt;</a>.
liftA2 :: Applicative f => (a -> b -> c) -> f a -> f b -> f c

-- | Sequence actions, discarding the value of the first argument.
(*>) :: Applicative f => f a -> f b -> f b

-- | Sequence actions, discarding the value of the second argument.
(<*) :: Applicative f => f a -> f b -> f a

-- | A monoid on applicative functors.
gr
grIf defined, <a>some</a> and <a>many</a> should be the least solutions
grof the equations:
gr
gr<ul>
gr<li><pre><a>some</a> v = (:) <tt>&lt;$&gt;</tt> v <a>&lt;*&gt;</a>
gr<a>many</a> v</pre></li>
gr<li><pre><a>many</a> v = <a>some</a> v <a>&lt;|&gt;</a> <a>pure</a>
gr[]</pre></li>
gr</ul>
class Applicative f => Alternative f

-- | The identity of <a>&lt;|&gt;</a>
empty :: Alternative f => f a

-- | An associative binary operation
(<|>) :: Alternative f => f a -> f a -> f a

-- | One or more.
some :: Alternative f => f a -> f [a]

-- | Zero or more.
many :: Alternative f => f a -> f [a]

-- | The <a>Const</a> functor.
newtype Const a b
Const :: a -> Const a b
[getConst] :: Const a b -> a
newtype WrappedMonad m a
WrapMonad :: m a -> WrappedMonad m a
[unwrapMonad] :: WrappedMonad m a -> m a
newtype WrappedArrow a b c
WrapArrow :: a b c -> WrappedArrow a b c
[unwrapArrow] :: WrappedArrow a b c -> a b c

-- | Lists, but with an <a>Applicative</a> functor based on zipping.
newtype ZipList a
ZipList :: [a] -> ZipList a
[getZipList] :: ZipList a -> [a]

-- | An infix synonym for <a>fmap</a>.
gr
grThe name of this operator is an allusion to <tt>$</tt>. Note the
grsimilarities between their types:
gr
gr<pre>
gr ($)  ::              (a -&gt; b) -&gt;   a -&gt;   b
gr(&lt;$&gt;) :: Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
gr</pre>
gr
grWhereas <tt>$</tt> is function application, <a>&lt;$&gt;</a> is
grfunction application lifted over a <a>Functor</a>.
gr
gr<h4><b>Examples</b></h4>
gr
grConvert from a <tt><tt>Maybe</tt> <tt>Int</tt></tt> to a
gr<tt><tt>Maybe</tt> <tt>String</tt></tt> using <tt>show</tt>:
gr
gr<pre>
gr&gt;&gt;&gt; show &lt;$&gt; Nothing
grNothing
gr
gr&gt;&gt;&gt; show &lt;$&gt; Just 3
grJust "3"
gr</pre>
gr
grConvert from an <tt><tt>Either</tt> <tt>Int</tt> <tt>Int</tt></tt> to
gran <tt><tt>Either</tt> <tt>Int</tt></tt> <tt>String</tt> using
gr<tt>show</tt>:
gr
gr<pre>
gr&gt;&gt;&gt; show &lt;$&gt; Left 17
grLeft 17
gr
gr&gt;&gt;&gt; show &lt;$&gt; Right 17
grRight "17"
gr</pre>
gr
grDouble each element of a list:
gr
gr<pre>
gr&gt;&gt;&gt; (*2) &lt;$&gt; [1,2,3]
gr[2,4,6]
gr</pre>
gr
grApply <tt>even</tt> to the second element of a pair:
gr
gr<pre>
gr&gt;&gt;&gt; even &lt;$&gt; (2,2)
gr(2,True)
gr</pre>
(<$>) :: Functor f => (a -> b) -> f a -> f b
infixl 4 <$>

-- | Replace all locations in the input with the same value. The default
grdefinition is <tt><a>fmap</a> . <a>const</a></tt>, but this may be
groverridden with a more efficient version.
(<$) :: Functor f => a -> f b -> f a
infixl 4 <$

-- | A variant of <a>&lt;*&gt;</a> with the arguments reversed.
(<**>) :: Applicative f => f a -> f (a -> b) -> f b
infixl 4 <**>

-- | Lift a function to actions. This function may be used as a value for
gr<a>fmap</a> in a <a>Functor</a> instance.
liftA :: Applicative f => (a -> b) -> f a -> f b

-- | Lift a ternary function to actions.
liftA3 :: Applicative f => (a -> b -> c -> d) -> f a -> f b -> f c -> f d

-- | One or none.
optional :: Alternative f => f a -> f (Maybe a)
instance GHC.Generics.Generic1 Control.Applicative.ZipList
instance GHC.Generics.Generic (Control.Applicative.ZipList a)
instance Data.Foldable.Foldable Control.Applicative.ZipList
instance GHC.Base.Functor Control.Applicative.ZipList
instance GHC.Read.Read a => GHC.Read.Read (Control.Applicative.ZipList a)
instance GHC.Classes.Ord a => GHC.Classes.Ord (Control.Applicative.ZipList a)
instance GHC.Classes.Eq a => GHC.Classes.Eq (Control.Applicative.ZipList a)
instance GHC.Show.Show a => GHC.Show.Show (Control.Applicative.ZipList a)
instance GHC.Generics.Generic1 (Control.Applicative.WrappedArrow a b)
instance GHC.Generics.Generic (Control.Applicative.WrappedArrow a b c)
instance GHC.Base.Monad m => GHC.Base.Monad (Control.Applicative.WrappedMonad m)
instance GHC.Generics.Generic1 (Control.Applicative.WrappedMonad m)
instance GHC.Generics.Generic (Control.Applicative.WrappedMonad m a)
instance GHC.Base.Applicative Control.Applicative.ZipList
instance GHC.Base.Alternative Control.Applicative.ZipList
instance Control.Arrow.Arrow a => GHC.Base.Functor (Control.Applicative.WrappedArrow a b)
instance Control.Arrow.Arrow a => GHC.Base.Applicative (Control.Applicative.WrappedArrow a b)
instance (Control.Arrow.ArrowZero a, Control.Arrow.ArrowPlus a) => GHC.Base.Alternative (Control.Applicative.WrappedArrow a b)
instance GHC.Base.Monad m => GHC.Base.Functor (Control.Applicative.WrappedMonad m)
instance GHC.Base.Monad m => GHC.Base.Applicative (Control.Applicative.WrappedMonad m)
instance GHC.Base.MonadPlus m => GHC.Base.Alternative (Control.Applicative.WrappedMonad m)


-- | Class of data structures that can be traversed from left to right,
grperforming an action on each element.
gr
grSee also
gr
gr<ul>
gr<li>"Applicative Programming with Effects", by Conor McBride and Ross
grPaterson, <i>Journal of Functional Programming</i> 18:1 (2008) 1-13,
gronline at
gr<a>http://www.soi.city.ac.uk/~ross/papers/Applicative.html</a>.</li>
gr<li>"The Essence of the Iterator Pattern", by Jeremy Gibbons and Bruno
grOliveira, in <i>Mathematically-Structured Functional Programming</i>,
gr2006, online at
gr<a>http://web.comlab.ox.ac.uk/oucl/work/jeremy.gibbons/publications/#iterator</a>.</li>
gr<li>"An Investigation of the Laws of Traversals", by Mauro Jaskelioff
grand Ondrej Rypacek, in <i>Mathematically-Structured Functional
grProgramming</i>, 2012, online at
gr<a>http://arxiv.org/pdf/1202.2919</a>.</li>
gr</ul>
module Data.Traversable

-- | Functors representing data structures that can be traversed from left
grto right.
gr
grA definition of <a>traverse</a> must satisfy the following laws:
gr
gr<ul>
gr<li><i><i>naturality</i></i> <tt>t . <a>traverse</a> f =
gr<a>traverse</a> (t . f)</tt> for every applicative transformation
gr<tt>t</tt></li>
gr<li><i><i>identity</i></i> <tt><a>traverse</a> Identity =
grIdentity</tt></li>
gr<li><i><i>composition</i></i> <tt><a>traverse</a> (Compose .
gr<a>fmap</a> g . f) = Compose . <a>fmap</a> (<a>traverse</a> g) .
gr<a>traverse</a> f</tt></li>
gr</ul>
gr
grA definition of <a>sequenceA</a> must satisfy the following laws:
gr
gr<ul>
gr<li><i><i>naturality</i></i> <tt>t . <a>sequenceA</a> =
gr<a>sequenceA</a> . <a>fmap</a> t</tt> for every applicative
grtransformation <tt>t</tt></li>
gr<li><i><i>identity</i></i> <tt><a>sequenceA</a> . <a>fmap</a> Identity
gr= Identity</tt></li>
gr<li><i><i>composition</i></i> <tt><a>sequenceA</a> . <a>fmap</a>
grCompose = Compose . <a>fmap</a> <a>sequenceA</a> .
gr<a>sequenceA</a></tt></li>
gr</ul>
gr
grwhere an <i>applicative transformation</i> is a function
gr
gr<pre>
grt :: (Applicative f, Applicative g) =&gt; f a -&gt; g a
gr</pre>
gr
grpreserving the <a>Applicative</a> operations, i.e.
gr
gr<ul>
gr<li><pre>t (<a>pure</a> x) = <a>pure</a> x</pre></li>
gr<li><pre>t (x <a>&lt;*&gt;</a> y) = t x <a>&lt;*&gt;</a> t
gry</pre></li>
gr</ul>
gr
grand the identity functor <tt>Identity</tt> and composition of functors
gr<tt>Compose</tt> are defined as
gr
gr<pre>
grnewtype Identity a = Identity a
gr
grinstance Functor Identity where
gr  fmap f (Identity x) = Identity (f x)
gr
grinstance Applicative Identity where
gr  pure x = Identity x
gr  Identity f &lt;*&gt; Identity x = Identity (f x)
gr
grnewtype Compose f g a = Compose (f (g a))
gr
grinstance (Functor f, Functor g) =&gt; Functor (Compose f g) where
gr  fmap f (Compose x) = Compose (fmap (fmap f) x)
gr
grinstance (Applicative f, Applicative g) =&gt; Applicative (Compose f g) where
gr  pure x = Compose (pure (pure x))
gr  Compose f &lt;*&gt; Compose x = Compose ((&lt;*&gt;) &lt;$&gt; f &lt;*&gt; x)
gr</pre>
gr
gr(The naturality law is implied by parametricity.)
gr
grInstances are similar to <a>Functor</a>, e.g. given a data type
gr
gr<pre>
grdata Tree a = Empty | Leaf a | Node (Tree a) a (Tree a)
gr</pre>
gr
gra suitable instance would be
gr
gr<pre>
grinstance Traversable Tree where
gr   traverse f Empty = pure Empty
gr   traverse f (Leaf x) = Leaf &lt;$&gt; f x
gr   traverse f (Node l k r) = Node &lt;$&gt; traverse f l &lt;*&gt; f k &lt;*&gt; traverse f r
gr</pre>
gr
grThis is suitable even for abstract types, as the laws for
gr<a>&lt;*&gt;</a> imply a form of associativity.
gr
grThe superclass instances should satisfy the following:
gr
gr<ul>
gr<li>In the <a>Functor</a> instance, <a>fmap</a> should be equivalent
grto traversal with the identity applicative functor
gr(<a>fmapDefault</a>).</li>
gr<li>In the <a>Foldable</a> instance, <a>foldMap</a> should be
grequivalent to traversal with a constant applicative functor
gr(<a>foldMapDefault</a>).</li>
gr</ul>
class (Functor t, Foldable t) => Traversable t

-- | Map each element of a structure to an action, evaluate these actions
grfrom left to right, and collect the results. For a version that
grignores the results see <a>traverse_</a>.
traverse :: (Traversable t, Applicative f) => (a -> f b) -> t a -> f (t b)

-- | Evaluate each action in the structure from left to right, and and
grcollect the results. For a version that ignores the results see
gr<a>sequenceA_</a>.
sequenceA :: (Traversable t, Applicative f) => t (f a) -> f (t a)

-- | Map each element of a structure to a monadic action, evaluate these
gractions from left to right, and collect the results. For a version
grthat ignores the results see <a>mapM_</a>.
mapM :: (Traversable t, Monad m) => (a -> m b) -> t a -> m (t b)

-- | Evaluate each monadic action in the structure from left to right, and
grcollect the results. For a version that ignores the results see
gr<a>sequence_</a>.
sequence :: (Traversable t, Monad m) => t (m a) -> m (t a)

-- | <a>for</a> is <a>traverse</a> with its arguments flipped. For a
grversion that ignores the results see <a>for_</a>.
for :: (Traversable t, Applicative f) => t a -> (a -> f b) -> f (t b)

-- | <a>forM</a> is <a>mapM</a> with its arguments flipped. For a version
grthat ignores the results see <a>forM_</a>.
forM :: (Traversable t, Monad m) => t a -> (a -> m b) -> m (t b)

-- | The <a>mapAccumL</a> function behaves like a combination of
gr<a>fmap</a> and <tt>foldl</tt>; it applies a function to each element
grof a structure, passing an accumulating parameter from left to right,
grand returning a final value of this accumulator together with the new
grstructure.
mapAccumL :: Traversable t => (a -> b -> (a, c)) -> a -> t b -> (a, t c)

-- | The <a>mapAccumR</a> function behaves like a combination of
gr<a>fmap</a> and <tt>foldr</tt>; it applies a function to each element
grof a structure, passing an accumulating parameter from right to left,
grand returning a final value of this accumulator together with the new
grstructure.
mapAccumR :: Traversable t => (a -> b -> (a, c)) -> a -> t b -> (a, t c)

-- | This function may be used as a value for <a>fmap</a> in a
gr<a>Functor</a> instance, provided that <a>traverse</a> is defined.
gr(Using <a>fmapDefault</a> with a <a>Traversable</a> instance defined
gronly by <a>sequenceA</a> will result in infinite recursion.)
gr
gr<pre>
gr<a>fmapDefault</a> f ≡ <a>runIdentity</a> . <a>traverse</a> (<a>Identity</a> . f)
gr</pre>
fmapDefault :: forall t a b. Traversable t => (a -> b) -> t a -> t b

-- | This function may be used as a value for <a>foldMap</a> in a
gr<a>Foldable</a> instance.
gr
gr<pre>
gr<a>foldMapDefault</a> f ≡ <a>getConst</a> . <a>traverse</a> (<a>Const</a> . f)
gr</pre>
foldMapDefault :: forall t m a. (Traversable t, Monoid m) => (a -> m) -> t a -> m
instance Data.Traversable.Traversable Data.Functor.Identity.Identity
instance Data.Traversable.Traversable GHC.Generics.V1
instance Data.Traversable.Traversable GHC.Generics.Par1
instance Data.Traversable.Traversable f => Data.Traversable.Traversable (GHC.Generics.Rec1 f)
instance Data.Traversable.Traversable (GHC.Generics.K1 i c)
instance Data.Traversable.Traversable f => Data.Traversable.Traversable (GHC.Generics.M1 i c f)
instance (Data.Traversable.Traversable f, Data.Traversable.Traversable g) => Data.Traversable.Traversable (f GHC.Generics.:+: g)
instance (Data.Traversable.Traversable f, Data.Traversable.Traversable g) => Data.Traversable.Traversable (f GHC.Generics.:*: g)
instance (Data.Traversable.Traversable f, Data.Traversable.Traversable g) => Data.Traversable.Traversable (f GHC.Generics.:.: g)
instance Data.Traversable.Traversable (GHC.Generics.URec (GHC.Ptr.Ptr ()))
instance Data.Traversable.Traversable (GHC.Generics.URec GHC.Types.Char)
instance Data.Traversable.Traversable (GHC.Generics.URec GHC.Types.Double)
instance Data.Traversable.Traversable (GHC.Generics.URec GHC.Types.Float)
instance Data.Traversable.Traversable (GHC.Generics.URec GHC.Types.Int)
instance Data.Traversable.Traversable (GHC.Generics.URec GHC.Types.Word)
instance Data.Traversable.Traversable GHC.Base.Maybe
instance Data.Traversable.Traversable []
instance Data.Traversable.Traversable GHC.Base.NonEmpty
instance Data.Traversable.Traversable (Data.Either.Either a)
instance Data.Traversable.Traversable ((,) a)
instance GHC.Arr.Ix i => Data.Traversable.Traversable (GHC.Arr.Array i)
instance Data.Traversable.Traversable Data.Proxy.Proxy
instance Data.Traversable.Traversable (Data.Functor.Const.Const m)
instance Data.Traversable.Traversable Data.Semigroup.Internal.Dual
instance Data.Traversable.Traversable Data.Semigroup.Internal.Sum
instance Data.Traversable.Traversable Data.Semigroup.Internal.Product
instance Data.Traversable.Traversable Data.Monoid.First
instance Data.Traversable.Traversable Data.Monoid.Last
instance Data.Traversable.Traversable Control.Applicative.ZipList
instance Data.Traversable.Traversable GHC.Generics.U1


-- | Operations on lists.
module Data.List

-- | Append two lists, i.e.,
gr
gr<pre>
gr[x1, ..., xm] ++ [y1, ..., yn] == [x1, ..., xm, y1, ..., yn]
gr[x1, ..., xm] ++ [y1, ...] == [x1, ..., xm, y1, ...]
gr</pre>
gr
grIf the first list is not finite, the result is the first list.
(++) :: [a] -> [a] -> [a]
infixr 5 ++

-- | Extract the first element of a list, which must be non-empty.
head :: [a] -> a

-- | Extract the last element of a list, which must be finite and
grnon-empty.
last :: [a] -> a

-- | Extract the elements after the head of a list, which must be
grnon-empty.
tail :: [a] -> [a]

-- | Return all the elements of a list except the last one. The list must
grbe non-empty.
init :: [a] -> [a]

-- | Decompose a list into its head and tail. If the list is empty, returns
gr<a>Nothing</a>. If the list is non-empty, returns <tt><a>Just</a> (x,
grxs)</tt>, where <tt>x</tt> is the head of the list and <tt>xs</tt> its
grtail.
uncons :: [a] -> Maybe (a, [a])

-- | Test whether the structure is empty. The default implementation is
groptimized for structures that are similar to cons-lists, because there
gris no general way to do better.
null :: Foldable t => t a -> Bool

-- | Returns the size/length of a finite structure as an <a>Int</a>. The
grdefault implementation is optimized for structures that are similar to
grcons-lists, because there is no general way to do better.
length :: Foldable t => t a -> Int

-- | <a>map</a> <tt>f xs</tt> is the list obtained by applying <tt>f</tt>
grto each element of <tt>xs</tt>, i.e.,
gr
gr<pre>
grmap f [x1, x2, ..., xn] == [f x1, f x2, ..., f xn]
grmap f [x1, x2, ...] == [f x1, f x2, ...]
gr</pre>
map :: (a -> b) -> [a] -> [b]

-- | <a>reverse</a> <tt>xs</tt> returns the elements of <tt>xs</tt> in
grreverse order. <tt>xs</tt> must be finite.
reverse :: [a] -> [a]

-- | The <a>intersperse</a> function takes an element and a list and
gr`intersperses' that element between the elements of the list. For
grexample,
gr
gr<pre>
gr&gt;&gt;&gt; intersperse ',' "abcde"
gr"a,b,c,d,e"
gr</pre>
intersperse :: a -> [a] -> [a]

-- | <a>intercalate</a> <tt>xs xss</tt> is equivalent to <tt>(<a>concat</a>
gr(<a>intersperse</a> xs xss))</tt>. It inserts the list <tt>xs</tt> in
grbetween the lists in <tt>xss</tt> and concatenates the result.
gr
gr<pre>
gr&gt;&gt;&gt; intercalate ", " ["Lorem", "ipsum", "dolor"]
gr"Lorem, ipsum, dolor"
gr</pre>
intercalate :: [a] -> [[a]] -> [a]

-- | The <a>transpose</a> function transposes the rows and columns of its
grargument. For example,
gr
gr<pre>
gr&gt;&gt;&gt; transpose [[1,2,3],[4,5,6]]
gr[[1,4],[2,5],[3,6]]
gr</pre>
gr
grIf some of the rows are shorter than the following rows, their
grelements are skipped:
gr
gr<pre>
gr&gt;&gt;&gt; transpose [[10,11],[20],[],[30,31,32]]
gr[[10,20,30],[11,31],[32]]
gr</pre>
transpose :: [[a]] -> [[a]]

-- | The <a>subsequences</a> function returns the list of all subsequences
grof the argument.
gr
gr<pre>
gr&gt;&gt;&gt; subsequences "abc"
gr["","a","b","ab","c","ac","bc","abc"]
gr</pre>
subsequences :: [a] -> [[a]]

-- | The <a>permutations</a> function returns the list of all permutations
grof the argument.
gr
gr<pre>
gr&gt;&gt;&gt; permutations "abc"
gr["abc","bac","cba","bca","cab","acb"]
gr</pre>
permutations :: [a] -> [[a]]

-- | Left-associative fold of a structure.
gr
grIn the case of lists, <a>foldl</a>, when applied to a binary operator,
gra starting value (typically the left-identity of the operator), and a
grlist, reduces the list using the binary operator, from left to right:
gr
gr<pre>
grfoldl f z [x1, x2, ..., xn] == (...((z `f` x1) `f` x2) `f`...) `f` xn
gr</pre>
gr
grNote that to produce the outermost application of the operator the
grentire input list must be traversed. This means that <a>foldl'</a>
grwill diverge if given an infinite list.
gr
grAlso note that if you want an efficient left-fold, you probably want
grto use <a>foldl'</a> instead of <a>foldl</a>. The reason for this is
grthat latter does not force the "inner" results (e.g. <tt>z <tt>f</tt>
grx1</tt> in the above example) before applying them to the operator
gr(e.g. to <tt>(<tt>f</tt> x2)</tt>). This results in a thunk chain
gr<tt>O(n)</tt> elements long, which then must be evaluated from the
groutside-in.
gr
grFor a general <a>Foldable</a> structure this should be semantically
gridentical to,
gr
gr<pre>
grfoldl f z = <a>foldl</a> f z . <a>toList</a>
gr</pre>
foldl :: Foldable t => (b -> a -> b) -> b -> t a -> b

-- | Left-associative fold of a structure but with strict application of
grthe operator.
gr
grThis ensures that each step of the fold is forced to weak head normal
grform before being applied, avoiding the collection of thunks that
grwould otherwise occur. This is often what you want to strictly reduce
gra finite list to a single, monolithic result (e.g. <a>length</a>).
gr
grFor a general <a>Foldable</a> structure this should be semantically
gridentical to,
gr
gr<pre>
grfoldl f z = <a>foldl'</a> f z . <a>toList</a>
gr</pre>
foldl' :: Foldable t => (b -> a -> b) -> b -> t a -> b

-- | A variant of <a>foldl</a> that has no base case, and thus may only be
grapplied to non-empty structures.
gr
gr<pre>
gr<a>foldl1</a> f = <a>foldl1</a> f . <a>toList</a>
gr</pre>
foldl1 :: Foldable t => (a -> a -> a) -> t a -> a

-- | A strict version of <a>foldl1</a>
foldl1' :: (a -> a -> a) -> [a] -> a

-- | Right-associative fold of a structure.
gr
grIn the case of lists, <a>foldr</a>, when applied to a binary operator,
gra starting value (typically the right-identity of the operator), and a
grlist, reduces the list using the binary operator, from right to left:
gr
gr<pre>
grfoldr f z [x1, x2, ..., xn] == x1 `f` (x2 `f` ... (xn `f` z)...)
gr</pre>
gr
grNote that, since the head of the resulting expression is produced by
gran application of the operator to the first element of the list,
gr<a>foldr</a> can produce a terminating expression from an infinite
grlist.
gr
grFor a general <a>Foldable</a> structure this should be semantically
gridentical to,
gr
gr<pre>
grfoldr f z = <a>foldr</a> f z . <a>toList</a>
gr</pre>
foldr :: Foldable t => (a -> b -> b) -> b -> t a -> b

-- | A variant of <a>foldr</a> that has no base case, and thus may only be
grapplied to non-empty structures.
gr
gr<pre>
gr<a>foldr1</a> f = <a>foldr1</a> f . <a>toList</a>
gr</pre>
foldr1 :: Foldable t => (a -> a -> a) -> t a -> a

-- | The concatenation of all the elements of a container of lists.
concat :: Foldable t => t [a] -> [a]

-- | Map a function over all the elements of a container and concatenate
grthe resulting lists.
concatMap :: Foldable t => (a -> [b]) -> t a -> [b]

-- | <a>and</a> returns the conjunction of a container of Bools. For the
grresult to be <a>True</a>, the container must be finite; <a>False</a>,
grhowever, results from a <a>False</a> value finitely far from the left
grend.
and :: Foldable t => t Bool -> Bool

-- | <a>or</a> returns the disjunction of a container of Bools. For the
grresult to be <a>False</a>, the container must be finite; <a>True</a>,
grhowever, results from a <a>True</a> value finitely far from the left
grend.
or :: Foldable t => t Bool -> Bool

-- | Determines whether any element of the structure satisfies the
grpredicate.
any :: Foldable t => (a -> Bool) -> t a -> Bool

-- | Determines whether all elements of the structure satisfy the
grpredicate.
all :: Foldable t => (a -> Bool) -> t a -> Bool

-- | The <a>sum</a> function computes the sum of the numbers of a
grstructure.
sum :: (Foldable t, Num a) => t a -> a

-- | The <a>product</a> function computes the product of the numbers of a
grstructure.
product :: (Foldable t, Num a) => t a -> a

-- | The largest element of a non-empty structure.
maximum :: forall a. (Foldable t, Ord a) => t a -> a

-- | The least element of a non-empty structure.
minimum :: forall a. (Foldable t, Ord a) => t a -> a

-- | <a>scanl</a> is similar to <a>foldl</a>, but returns a list of
grsuccessive reduced values from the left:
gr
gr<pre>
grscanl f z [x1, x2, ...] == [z, z `f` x1, (z `f` x1) `f` x2, ...]
gr</pre>
gr
grNote that
gr
gr<pre>
grlast (scanl f z xs) == foldl f z xs.
gr</pre>
scanl :: (b -> a -> b) -> b -> [a] -> [b]

-- | A strictly accumulating version of <a>scanl</a>
scanl' :: (b -> a -> b) -> b -> [a] -> [b]

-- | <a>scanl1</a> is a variant of <a>scanl</a> that has no starting value
grargument:
gr
gr<pre>
grscanl1 f [x1, x2, ...] == [x1, x1 `f` x2, ...]
gr</pre>
scanl1 :: (a -> a -> a) -> [a] -> [a]

-- | <a>scanr</a> is the right-to-left dual of <a>scanl</a>. Note that
gr
gr<pre>
grhead (scanr f z xs) == foldr f z xs.
gr</pre>
scanr :: (a -> b -> b) -> b -> [a] -> [b]

-- | <a>scanr1</a> is a variant of <a>scanr</a> that has no starting value
grargument.
scanr1 :: (a -> a -> a) -> [a] -> [a]

-- | The <a>mapAccumL</a> function behaves like a combination of
gr<a>fmap</a> and <tt>foldl</tt>; it applies a function to each element
grof a structure, passing an accumulating parameter from left to right,
grand returning a final value of this accumulator together with the new
grstructure.
mapAccumL :: Traversable t => (a -> b -> (a, c)) -> a -> t b -> (a, t c)

-- | The <a>mapAccumR</a> function behaves like a combination of
gr<a>fmap</a> and <tt>foldr</tt>; it applies a function to each element
grof a structure, passing an accumulating parameter from right to left,
grand returning a final value of this accumulator together with the new
grstructure.
mapAccumR :: Traversable t => (a -> b -> (a, c)) -> a -> t b -> (a, t c)

-- | <a>iterate</a> <tt>f x</tt> returns an infinite list of repeated
grapplications of <tt>f</tt> to <tt>x</tt>:
gr
gr<pre>
griterate f x == [x, f x, f (f x), ...]
gr</pre>
gr
grNote that <a>iterate</a> is lazy, potentially leading to thunk
grbuild-up if the consumer doesn't force each iterate. See 'iterate\''
grfor a strict variant of this function.
iterate :: (a -> a) -> a -> [a]

-- | 'iterate\'' is the strict version of <a>iterate</a>.
gr
grIt ensures that the result of each application of force to weak head
grnormal form before proceeding.
iterate' :: (a -> a) -> a -> [a]

-- | <a>repeat</a> <tt>x</tt> is an infinite list, with <tt>x</tt> the
grvalue of every element.
repeat :: a -> [a]

-- | <a>replicate</a> <tt>n x</tt> is a list of length <tt>n</tt> with
gr<tt>x</tt> the value of every element. It is an instance of the more
grgeneral <a>genericReplicate</a>, in which <tt>n</tt> may be of any
grintegral type.
replicate :: Int -> a -> [a]

-- | <a>cycle</a> ties a finite list into a circular one, or equivalently,
grthe infinite repetition of the original list. It is the identity on
grinfinite lists.
cycle :: [a] -> [a]

-- | The <a>unfoldr</a> function is a `dual' to <a>foldr</a>: while
gr<a>foldr</a> reduces a list to a summary value, <a>unfoldr</a> builds
gra list from a seed value. The function takes the element and returns
gr<a>Nothing</a> if it is done producing the list or returns <a>Just</a>
gr<tt>(a,b)</tt>, in which case, <tt>a</tt> is a prepended to the list
grand <tt>b</tt> is used as the next element in a recursive call. For
grexample,
gr
gr<pre>
griterate f == unfoldr (\x -&gt; Just (x, f x))
gr</pre>
gr
grIn some cases, <a>unfoldr</a> can undo a <a>foldr</a> operation:
gr
gr<pre>
grunfoldr f' (foldr f z xs) == xs
gr</pre>
gr
grif the following holds:
gr
gr<pre>
grf' (f x y) = Just (x,y)
grf' z       = Nothing
gr</pre>
gr
grA simple use of unfoldr:
gr
gr<pre>
gr&gt;&gt;&gt; unfoldr (\b -&gt; if b == 0 then Nothing else Just (b, b-1)) 10
gr[10,9,8,7,6,5,4,3,2,1]
gr</pre>
unfoldr :: (b -> Maybe (a, b)) -> b -> [a]

-- | <a>take</a> <tt>n</tt>, applied to a list <tt>xs</tt>, returns the
grprefix of <tt>xs</tt> of length <tt>n</tt>, or <tt>xs</tt> itself if
gr<tt>n &gt; <a>length</a> xs</tt>:
gr
gr<pre>
grtake 5 "Hello World!" == "Hello"
grtake 3 [1,2,3,4,5] == [1,2,3]
grtake 3 [1,2] == [1,2]
grtake 3 [] == []
grtake (-1) [1,2] == []
grtake 0 [1,2] == []
gr</pre>
gr
grIt is an instance of the more general <a>genericTake</a>, in which
gr<tt>n</tt> may be of any integral type.
take :: Int -> [a] -> [a]

-- | <a>drop</a> <tt>n xs</tt> returns the suffix of <tt>xs</tt> after the
grfirst <tt>n</tt> elements, or <tt>[]</tt> if <tt>n &gt; <a>length</a>
grxs</tt>:
gr
gr<pre>
grdrop 6 "Hello World!" == "World!"
grdrop 3 [1,2,3,4,5] == [4,5]
grdrop 3 [1,2] == []
grdrop 3 [] == []
grdrop (-1) [1,2] == [1,2]
grdrop 0 [1,2] == [1,2]
gr</pre>
gr
grIt is an instance of the more general <a>genericDrop</a>, in which
gr<tt>n</tt> may be of any integral type.
drop :: Int -> [a] -> [a]

-- | <a>splitAt</a> <tt>n xs</tt> returns a tuple where first element is
gr<tt>xs</tt> prefix of length <tt>n</tt> and second element is the
grremainder of the list:
gr
gr<pre>
grsplitAt 6 "Hello World!" == ("Hello ","World!")
grsplitAt 3 [1,2,3,4,5] == ([1,2,3],[4,5])
grsplitAt 1 [1,2,3] == ([1],[2,3])
grsplitAt 3 [1,2,3] == ([1,2,3],[])
grsplitAt 4 [1,2,3] == ([1,2,3],[])
grsplitAt 0 [1,2,3] == ([],[1,2,3])
grsplitAt (-1) [1,2,3] == ([],[1,2,3])
gr</pre>
gr
grIt is equivalent to <tt>(<a>take</a> n xs, <a>drop</a> n xs)</tt> when
gr<tt>n</tt> is not <tt>_|_</tt> (<tt>splitAt _|_ xs = _|_</tt>).
gr<a>splitAt</a> is an instance of the more general
gr<a>genericSplitAt</a>, in which <tt>n</tt> may be of any integral
grtype.
splitAt :: Int -> [a] -> ([a], [a])

-- | <a>takeWhile</a>, applied to a predicate <tt>p</tt> and a list
gr<tt>xs</tt>, returns the longest prefix (possibly empty) of
gr<tt>xs</tt> of elements that satisfy <tt>p</tt>:
gr
gr<pre>
grtakeWhile (&lt; 3) [1,2,3,4,1,2,3,4] == [1,2]
grtakeWhile (&lt; 9) [1,2,3] == [1,2,3]
grtakeWhile (&lt; 0) [1,2,3] == []
gr</pre>
takeWhile :: (a -> Bool) -> [a] -> [a]

-- | <a>dropWhile</a> <tt>p xs</tt> returns the suffix remaining after
gr<a>takeWhile</a> <tt>p xs</tt>:
gr
gr<pre>
grdropWhile (&lt; 3) [1,2,3,4,5,1,2,3] == [3,4,5,1,2,3]
grdropWhile (&lt; 9) [1,2,3] == []
grdropWhile (&lt; 0) [1,2,3] == [1,2,3]
gr</pre>
dropWhile :: (a -> Bool) -> [a] -> [a]

-- | The <a>dropWhileEnd</a> function drops the largest suffix of a list in
grwhich the given predicate holds for all elements. For example:
gr
gr<pre>
gr&gt;&gt;&gt; dropWhileEnd isSpace "foo\n"
gr"foo"
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; dropWhileEnd isSpace "foo bar"
gr"foo bar"
gr</pre>
gr
gr<pre>
grdropWhileEnd isSpace ("foo\n" ++ undefined) == "foo" ++ undefined
gr</pre>
dropWhileEnd :: (a -> Bool) -> [a] -> [a]

-- | <a>span</a>, applied to a predicate <tt>p</tt> and a list <tt>xs</tt>,
grreturns a tuple where first element is longest prefix (possibly empty)
grof <tt>xs</tt> of elements that satisfy <tt>p</tt> and second element
gris the remainder of the list:
gr
gr<pre>
grspan (&lt; 3) [1,2,3,4,1,2,3,4] == ([1,2],[3,4,1,2,3,4])
grspan (&lt; 9) [1,2,3] == ([1,2,3],[])
grspan (&lt; 0) [1,2,3] == ([],[1,2,3])
gr</pre>
gr
gr<a>span</a> <tt>p xs</tt> is equivalent to <tt>(<a>takeWhile</a> p xs,
gr<a>dropWhile</a> p xs)</tt>
span :: (a -> Bool) -> [a] -> ([a], [a])

-- | <a>break</a>, applied to a predicate <tt>p</tt> and a list
gr<tt>xs</tt>, returns a tuple where first element is longest prefix
gr(possibly empty) of <tt>xs</tt> of elements that <i>do not satisfy</i>
gr<tt>p</tt> and second element is the remainder of the list:
gr
gr<pre>
grbreak (&gt; 3) [1,2,3,4,1,2,3,4] == ([1,2,3],[4,1,2,3,4])
grbreak (&lt; 9) [1,2,3] == ([],[1,2,3])
grbreak (&gt; 9) [1,2,3] == ([1,2,3],[])
gr</pre>
gr
gr<a>break</a> <tt>p</tt> is equivalent to <tt><a>span</a> (<a>not</a> .
grp)</tt>.
break :: (a -> Bool) -> [a] -> ([a], [a])

-- | The <a>stripPrefix</a> function drops the given prefix from a list. It
grreturns <a>Nothing</a> if the list did not start with the prefix
grgiven, or <a>Just</a> the list after the prefix, if it does.
gr
gr<pre>
gr&gt;&gt;&gt; stripPrefix "foo" "foobar"
grJust "bar"
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; stripPrefix "foo" "foo"
grJust ""
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; stripPrefix "foo" "barfoo"
grNothing
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; stripPrefix "foo" "barfoobaz"
grNothing
gr</pre>
stripPrefix :: Eq a => [a] -> [a] -> Maybe [a]

-- | The <a>group</a> function takes a list and returns a list of lists
grsuch that the concatenation of the result is equal to the argument.
grMoreover, each sublist in the result contains only equal elements. For
grexample,
gr
gr<pre>
gr&gt;&gt;&gt; group "Mississippi"
gr["M","i","ss","i","ss","i","pp","i"]
gr</pre>
gr
grIt is a special case of <a>groupBy</a>, which allows the programmer to
grsupply their own equality test.
group :: Eq a => [a] -> [[a]]

-- | The <a>inits</a> function returns all initial segments of the
grargument, shortest first. For example,
gr
gr<pre>
gr&gt;&gt;&gt; inits "abc"
gr["","a","ab","abc"]
gr</pre>
gr
grNote that <a>inits</a> has the following strictness property:
gr<tt>inits (xs ++ _|_) = inits xs ++ _|_</tt>
gr
grIn particular, <tt>inits _|_ = [] : _|_</tt>
inits :: [a] -> [[a]]

-- | The <a>tails</a> function returns all final segments of the argument,
grlongest first. For example,
gr
gr<pre>
gr&gt;&gt;&gt; tails "abc"
gr["abc","bc","c",""]
gr</pre>
gr
grNote that <a>tails</a> has the following strictness property:
gr<tt>tails _|_ = _|_ : _|_</tt>
tails :: [a] -> [[a]]

-- | The <a>isPrefixOf</a> function takes two lists and returns <a>True</a>
griff the first list is a prefix of the second.
gr
gr<pre>
gr&gt;&gt;&gt; "Hello" `isPrefixOf` "Hello World!"
grTrue
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; "Hello" `isPrefixOf` "Wello Horld!"
grFalse
gr</pre>
isPrefixOf :: (Eq a) => [a] -> [a] -> Bool

-- | The <a>isSuffixOf</a> function takes two lists and returns <a>True</a>
griff the first list is a suffix of the second. The second list must be
grfinite.
gr
gr<pre>
gr&gt;&gt;&gt; "ld!" `isSuffixOf` "Hello World!"
grTrue
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; "World" `isSuffixOf` "Hello World!"
grFalse
gr</pre>
isSuffixOf :: (Eq a) => [a] -> [a] -> Bool

-- | The <a>isInfixOf</a> function takes two lists and returns <a>True</a>
griff the first list is contained, wholly and intact, anywhere within
grthe second.
gr
gr<pre>
gr&gt;&gt;&gt; isInfixOf "Haskell" "I really like Haskell."
grTrue
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; isInfixOf "Ial" "I really like Haskell."
grFalse
gr</pre>
isInfixOf :: (Eq a) => [a] -> [a] -> Bool

-- | The <a>isSubsequenceOf</a> function takes two lists and returns
gr<a>True</a> if all the elements of the first list occur, in order, in
grthe second. The elements do not have to occur consecutively.
gr
gr<tt><a>isSubsequenceOf</a> x y</tt> is equivalent to <tt><a>elem</a> x
gr(<a>subsequences</a> y)</tt>.
gr
gr<h4><b>Examples</b></h4>
gr
gr<pre>
gr&gt;&gt;&gt; isSubsequenceOf "GHC" "The Glorious Haskell Compiler"
grTrue
gr
gr&gt;&gt;&gt; isSubsequenceOf ['a','d'..'z'] ['a'..'z']
grTrue
gr
gr&gt;&gt;&gt; isSubsequenceOf [1..10] [10,9..0]
grFalse
gr</pre>
isSubsequenceOf :: (Eq a) => [a] -> [a] -> Bool

-- | Does the element occur in the structure?
elem :: (Foldable t, Eq a) => a -> t a -> Bool
infix 4 `elem`

-- | <a>notElem</a> is the negation of <a>elem</a>.
notElem :: (Foldable t, Eq a) => a -> t a -> Bool
infix 4 `notElem`

-- | <a>lookup</a> <tt>key assocs</tt> looks up a key in an association
grlist.
lookup :: (Eq a) => a -> [(a, b)] -> Maybe b

-- | The <a>find</a> function takes a predicate and a structure and returns
grthe leftmost element of the structure matching the predicate, or
gr<a>Nothing</a> if there is no such element.
find :: Foldable t => (a -> Bool) -> t a -> Maybe a

-- | <a>filter</a>, applied to a predicate and a list, returns the list of
grthose elements that satisfy the predicate; i.e.,
gr
gr<pre>
grfilter p xs = [ x | x &lt;- xs, p x]
gr</pre>
filter :: (a -> Bool) -> [a] -> [a]

-- | The <a>partition</a> function takes a predicate a list and returns the
grpair of lists of elements which do and do not satisfy the predicate,
grrespectively; i.e.,
gr
gr<pre>
grpartition p xs == (filter p xs, filter (not . p) xs)
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; partition (`elem` "aeiou") "Hello World!"
gr("eoo","Hll Wrld!")
gr</pre>
partition :: (a -> Bool) -> [a] -> ([a], [a])

-- | List index (subscript) operator, starting from 0. It is an instance of
grthe more general <a>genericIndex</a>, which takes an index of any
grintegral type.
(!!) :: [a] -> Int -> a
infixl 9 !!

-- | The <a>elemIndex</a> function returns the index of the first element
grin the given list which is equal (by <a>==</a>) to the query element,
gror <a>Nothing</a> if there is no such element.
gr
gr<pre>
gr&gt;&gt;&gt; elemIndex 4 [0..]
grJust 4
gr</pre>
elemIndex :: Eq a => a -> [a] -> Maybe Int

-- | The <a>elemIndices</a> function extends <a>elemIndex</a>, by returning
grthe indices of all elements equal to the query element, in ascending
grorder.
gr
gr<pre>
gr&gt;&gt;&gt; elemIndices 'o' "Hello World"
gr[4,7]
gr</pre>
elemIndices :: Eq a => a -> [a] -> [Int]

-- | The <a>findIndex</a> function takes a predicate and a list and returns
grthe index of the first element in the list satisfying the predicate,
gror <a>Nothing</a> if there is no such element.
gr
gr<pre>
gr&gt;&gt;&gt; findIndex isSpace "Hello World!"
grJust 5
gr</pre>
findIndex :: (a -> Bool) -> [a] -> Maybe Int

-- | The <a>findIndices</a> function extends <a>findIndex</a>, by returning
grthe indices of all elements satisfying the predicate, in ascending
grorder.
gr
gr<pre>
gr&gt;&gt;&gt; findIndices (`elem` "aeiou") "Hello World!"
gr[1,4,7]
gr</pre>
findIndices :: (a -> Bool) -> [a] -> [Int]

-- | <a>zip</a> takes two lists and returns a list of corresponding pairs.
grIf one input list is short, excess elements of the longer list are
grdiscarded.
gr
gr<a>zip</a> is right-lazy:
gr
gr<pre>
grzip [] _|_ = []
gr</pre>
zip :: [a] -> [b] -> [(a, b)]

-- | <a>zip3</a> takes three lists and returns a list of triples, analogous
grto <a>zip</a>.
zip3 :: [a] -> [b] -> [c] -> [(a, b, c)]

-- | The <a>zip4</a> function takes four lists and returns a list of
grquadruples, analogous to <a>zip</a>.
zip4 :: [a] -> [b] -> [c] -> [d] -> [(a, b, c, d)]

-- | The <a>zip5</a> function takes five lists and returns a list of
grfive-tuples, analogous to <a>zip</a>.
zip5 :: [a] -> [b] -> [c] -> [d] -> [e] -> [(a, b, c, d, e)]

-- | The <a>zip6</a> function takes six lists and returns a list of
grsix-tuples, analogous to <a>zip</a>.
zip6 :: [a] -> [b] -> [c] -> [d] -> [e] -> [f] -> [(a, b, c, d, e, f)]

-- | The <a>zip7</a> function takes seven lists and returns a list of
grseven-tuples, analogous to <a>zip</a>.
zip7 :: [a] -> [b] -> [c] -> [d] -> [e] -> [f] -> [g] -> [(a, b, c, d, e, f, g)]

-- | <a>zipWith</a> generalises <a>zip</a> by zipping with the function
grgiven as the first argument, instead of a tupling function. For
grexample, <tt><a>zipWith</a> (+)</tt> is applied to two lists to
grproduce the list of corresponding sums.
gr
gr<a>zipWith</a> is right-lazy:
gr
gr<pre>
grzipWith f [] _|_ = []
gr</pre>
zipWith :: (a -> b -> c) -> [a] -> [b] -> [c]

-- | The <a>zipWith3</a> function takes a function which combines three
grelements, as well as three lists and returns a list of their
grpoint-wise combination, analogous to <a>zipWith</a>.
zipWith3 :: (a -> b -> c -> d) -> [a] -> [b] -> [c] -> [d]

-- | The <a>zipWith4</a> function takes a function which combines four
grelements, as well as four lists and returns a list of their point-wise
grcombination, analogous to <a>zipWith</a>.
zipWith4 :: (a -> b -> c -> d -> e) -> [a] -> [b] -> [c] -> [d] -> [e]

-- | The <a>zipWith5</a> function takes a function which combines five
grelements, as well as five lists and returns a list of their point-wise
grcombination, analogous to <a>zipWith</a>.
zipWith5 :: (a -> b -> c -> d -> e -> f) -> [a] -> [b] -> [c] -> [d] -> [e] -> [f]

-- | The <a>zipWith6</a> function takes a function which combines six
grelements, as well as six lists and returns a list of their point-wise
grcombination, analogous to <a>zipWith</a>.
zipWith6 :: (a -> b -> c -> d -> e -> f -> g) -> [a] -> [b] -> [c] -> [d] -> [e] -> [f] -> [g]

-- | The <a>zipWith7</a> function takes a function which combines seven
grelements, as well as seven lists and returns a list of their
grpoint-wise combination, analogous to <a>zipWith</a>.
zipWith7 :: (a -> b -> c -> d -> e -> f -> g -> h) -> [a] -> [b] -> [c] -> [d] -> [e] -> [f] -> [g] -> [h]

-- | <a>unzip</a> transforms a list of pairs into a list of first
grcomponents and a list of second components.
unzip :: [(a, b)] -> ([a], [b])

-- | The <a>unzip3</a> function takes a list of triples and returns three
grlists, analogous to <a>unzip</a>.
unzip3 :: [(a, b, c)] -> ([a], [b], [c])

-- | The <a>unzip4</a> function takes a list of quadruples and returns four
grlists, analogous to <a>unzip</a>.
unzip4 :: [(a, b, c, d)] -> ([a], [b], [c], [d])

-- | The <a>unzip5</a> function takes a list of five-tuples and returns
grfive lists, analogous to <a>unzip</a>.
unzip5 :: [(a, b, c, d, e)] -> ([a], [b], [c], [d], [e])

-- | The <a>unzip6</a> function takes a list of six-tuples and returns six
grlists, analogous to <a>unzip</a>.
unzip6 :: [(a, b, c, d, e, f)] -> ([a], [b], [c], [d], [e], [f])

-- | The <a>unzip7</a> function takes a list of seven-tuples and returns
grseven lists, analogous to <a>unzip</a>.
unzip7 :: [(a, b, c, d, e, f, g)] -> ([a], [b], [c], [d], [e], [f], [g])

-- | <a>lines</a> breaks a string up into a list of strings at newline
grcharacters. The resulting strings do not contain newlines.
gr
grNote that after splitting the string at newline characters, the last
grpart of the string is considered a line even if it doesn't end with a
grnewline. For example,
gr
gr<pre>
gr&gt;&gt;&gt; lines ""
gr[]
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; lines "\n"
gr[""]
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; lines "one"
gr["one"]
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; lines "one\n"
gr["one"]
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; lines "one\n\n"
gr["one",""]
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; lines "one\ntwo"
gr["one","two"]
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; lines "one\ntwo\n"
gr["one","two"]
gr</pre>
gr
grThus <tt><a>lines</a> s</tt> contains at least as many elements as
grnewlines in <tt>s</tt>.
lines :: String -> [String]

-- | <a>words</a> breaks a string up into a list of words, which were
grdelimited by white space.
gr
gr<pre>
gr&gt;&gt;&gt; words "Lorem ipsum\ndolor"
gr["Lorem","ipsum","dolor"]
gr</pre>
words :: String -> [String]

-- | <a>unlines</a> is an inverse operation to <a>lines</a>. It joins
grlines, after appending a terminating newline to each.
gr
gr<pre>
gr&gt;&gt;&gt; unlines ["Hello", "World", "!"]
gr"Hello\nWorld\n!\n"
gr</pre>
unlines :: [String] -> String

-- | <a>unwords</a> is an inverse operation to <a>words</a>. It joins words
grwith separating spaces.
gr
gr<pre>
gr&gt;&gt;&gt; unwords ["Lorem", "ipsum", "dolor"]
gr"Lorem ipsum dolor"
gr</pre>
unwords :: [String] -> String

-- | <i>O(n^2)</i>. The <a>nub</a> function removes duplicate elements from
gra list. In particular, it keeps only the first occurrence of each
grelement. (The name <a>nub</a> means `essence'.) It is a special case
grof <a>nubBy</a>, which allows the programmer to supply their own
grequality test.
gr
gr<pre>
gr&gt;&gt;&gt; nub [1,2,3,4,3,2,1,2,4,3,5]
gr[1,2,3,4,5]
gr</pre>
nub :: (Eq a) => [a] -> [a]

-- | <a>delete</a> <tt>x</tt> removes the first occurrence of <tt>x</tt>
grfrom its list argument. For example,
gr
gr<pre>
gr&gt;&gt;&gt; delete 'a' "banana"
gr"bnana"
gr</pre>
gr
grIt is a special case of <a>deleteBy</a>, which allows the programmer
grto supply their own equality test.
delete :: (Eq a) => a -> [a] -> [a]

-- | The <a>\\</a> function is list difference (non-associative). In the
grresult of <tt>xs</tt> <a>\\</a> <tt>ys</tt>, the first occurrence of
greach element of <tt>ys</tt> in turn (if any) has been removed from
gr<tt>xs</tt>. Thus
gr
gr<pre>
gr(xs ++ ys) \\ xs == ys.
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; "Hello World!" \\ "ell W"
gr"Hoorld!"
gr</pre>
gr
grIt is a special case of <a>deleteFirstsBy</a>, which allows the
grprogrammer to supply their own equality test.
(\\) :: (Eq a) => [a] -> [a] -> [a]
infix 5 \\

-- | The <a>union</a> function returns the list union of the two lists. For
grexample,
gr
gr<pre>
gr&gt;&gt;&gt; "dog" `union` "cow"
gr"dogcw"
gr</pre>
gr
grDuplicates, and elements of the first list, are removed from the the
grsecond list, but if the first list contains duplicates, so will the
grresult. It is a special case of <a>unionBy</a>, which allows the
grprogrammer to supply their own equality test.
union :: (Eq a) => [a] -> [a] -> [a]

-- | The <a>intersect</a> function takes the list intersection of two
grlists. For example,
gr
gr<pre>
gr&gt;&gt;&gt; [1,2,3,4] `intersect` [2,4,6,8]
gr[2,4]
gr</pre>
gr
grIf the first list contains duplicates, so will the result.
gr
gr<pre>
gr&gt;&gt;&gt; [1,2,2,3,4] `intersect` [6,4,4,2]
gr[2,2,4]
gr</pre>
gr
grIt is a special case of <a>intersectBy</a>, which allows the
grprogrammer to supply their own equality test. If the element is found
grin both the first and the second list, the element from the first list
grwill be used.
intersect :: (Eq a) => [a] -> [a] -> [a]

-- | The <a>sort</a> function implements a stable sorting algorithm. It is
gra special case of <a>sortBy</a>, which allows the programmer to supply
grtheir own comparison function.
gr
grElements are arranged from from lowest to highest, keeping duplicates
grin the order they appeared in the input.
gr
gr<pre>
gr&gt;&gt;&gt; sort [1,6,4,3,2,5]
gr[1,2,3,4,5,6]
gr</pre>
sort :: (Ord a) => [a] -> [a]

-- | Sort a list by comparing the results of a key function applied to each
grelement. <tt>sortOn f</tt> is equivalent to <tt>sortBy (comparing
grf)</tt>, but has the performance advantage of only evaluating
gr<tt>f</tt> once for each element in the input list. This is called the
grdecorate-sort-undecorate paradigm, or Schwartzian transform.
gr
grElements are arranged from from lowest to highest, keeping duplicates
grin the order they appeared in the input.
gr
gr<pre>
gr&gt;&gt;&gt; sortOn fst [(2, "world"), (4, "!"), (1, "Hello")]
gr[(1,"Hello"),(2,"world"),(4,"!")]
gr</pre>
sortOn :: Ord b => (a -> b) -> [a] -> [a]

-- | The <a>insert</a> function takes an element and a list and inserts the
grelement into the list at the first position where it is less than or
grequal to the next element. In particular, if the list is sorted before
grthe call, the result will also be sorted. It is a special case of
gr<a>insertBy</a>, which allows the programmer to supply their own
grcomparison function.
gr
gr<pre>
gr&gt;&gt;&gt; insert 4 [1,2,3,5,6,7]
gr[1,2,3,4,5,6,7]
gr</pre>
insert :: Ord a => a -> [a] -> [a]

-- | The <a>nubBy</a> function behaves just like <a>nub</a>, except it uses
gra user-supplied equality predicate instead of the overloaded <a>==</a>
grfunction.
gr
gr<pre>
gr&gt;&gt;&gt; nubBy (\x y -&gt; mod x 3 == mod y 3) [1,2,4,5,6]
gr[1,2,6]
gr</pre>
nubBy :: (a -> a -> Bool) -> [a] -> [a]

-- | The <a>deleteBy</a> function behaves like <a>delete</a>, but takes a
gruser-supplied equality predicate.
gr
gr<pre>
gr&gt;&gt;&gt; deleteBy (&lt;=) 4 [1..10]
gr[1,2,3,5,6,7,8,9,10]
gr</pre>
deleteBy :: (a -> a -> Bool) -> a -> [a] -> [a]

-- | The <a>deleteFirstsBy</a> function takes a predicate and two lists and
grreturns the first list with the first occurrence of each element of
grthe second list removed.
deleteFirstsBy :: (a -> a -> Bool) -> [a] -> [a] -> [a]

-- | The <a>unionBy</a> function is the non-overloaded version of
gr<a>union</a>.
unionBy :: (a -> a -> Bool) -> [a] -> [a] -> [a]

-- | The <a>intersectBy</a> function is the non-overloaded version of
gr<a>intersect</a>.
intersectBy :: (a -> a -> Bool) -> [a] -> [a] -> [a]

-- | The <a>groupBy</a> function is the non-overloaded version of
gr<a>group</a>.
groupBy :: (a -> a -> Bool) -> [a] -> [[a]]

-- | The <a>sortBy</a> function is the non-overloaded version of
gr<a>sort</a>.
gr
gr<pre>
gr&gt;&gt;&gt; sortBy (\(a,_) (b,_) -&gt; compare a b) [(2, "world"), (4, "!"), (1, "Hello")]
gr[(1,"Hello"),(2,"world"),(4,"!")]
gr</pre>
sortBy :: (a -> a -> Ordering) -> [a] -> [a]

-- | The non-overloaded version of <a>insert</a>.
insertBy :: (a -> a -> Ordering) -> a -> [a] -> [a]

-- | The largest element of a non-empty structure with respect to the given
grcomparison function.
maximumBy :: Foldable t => (a -> a -> Ordering) -> t a -> a

-- | The least element of a non-empty structure with respect to the given
grcomparison function.
minimumBy :: Foldable t => (a -> a -> Ordering) -> t a -> a

-- | The <a>genericLength</a> function is an overloaded version of
gr<a>length</a>. In particular, instead of returning an <a>Int</a>, it
grreturns any type which is an instance of <a>Num</a>. It is, however,
grless efficient than <a>length</a>.
genericLength :: (Num i) => [a] -> i

-- | The <a>genericTake</a> function is an overloaded version of
gr<a>take</a>, which accepts any <a>Integral</a> value as the number of
grelements to take.
genericTake :: (Integral i) => i -> [a] -> [a]

-- | The <a>genericDrop</a> function is an overloaded version of
gr<a>drop</a>, which accepts any <a>Integral</a> value as the number of
grelements to drop.
genericDrop :: (Integral i) => i -> [a] -> [a]

-- | The <a>genericSplitAt</a> function is an overloaded version of
gr<a>splitAt</a>, which accepts any <a>Integral</a> value as the
grposition at which to split.
genericSplitAt :: (Integral i) => i -> [a] -> ([a], [a])

-- | The <a>genericIndex</a> function is an overloaded version of
gr<a>!!</a>, which accepts any <a>Integral</a> value as the index.
genericIndex :: (Integral i) => [a] -> i -> a

-- | The <a>genericReplicate</a> function is an overloaded version of
gr<a>replicate</a>, which accepts any <a>Integral</a> value as the
grnumber of repetitions to make.
genericReplicate :: (Integral i) => i -> a -> [a]


-- | Functions for tracing and monitoring execution.
gr
grThese can be useful for investigating bugs or performance problems.
grThey should <i>not</i> be used in production code.
module Debug.Trace

-- | The <a>trace</a> function outputs the trace message given as its first
grargument, before returning the second argument as its result.
gr
grFor example, this returns the value of <tt>f x</tt> but first outputs
grthe message.
gr
gr<pre>
gr&gt;&gt;&gt; let x = 123; f = show
gr
gr&gt;&gt;&gt; trace ("calling f with x = " ++ show x) (f x)
gr"calling f with x = 123
gr123"
gr</pre>
gr
grThe <a>trace</a> function should <i>only</i> be used for debugging, or
grfor monitoring execution. The function is not referentially
grtransparent: its type indicates that it is a pure function but it has
grthe side effect of outputting the trace message.
trace :: String -> a -> a

-- | Like <a>trace</a> but returns the message instead of a third value.
gr
gr<pre>
gr&gt;&gt;&gt; traceId "hello"
gr"hello
grhello"
gr</pre>
traceId :: String -> String

-- | Like <a>trace</a>, but uses <a>show</a> on the argument to convert it
grto a <a>String</a>.
gr
grThis makes it convenient for printing the values of interesting
grvariables or expressions inside a function. For example here we print
grthe value of the variables <tt>x</tt> and <tt>y</tt>:
gr
gr<pre>
gr&gt;&gt;&gt; let f x y = traceShow (x,y) (x + y) in f (1+2) 5
gr(3,5)
gr8
gr</pre>
traceShow :: Show a => a -> b -> b

-- | Like <a>traceShow</a> but returns the shown value instead of a third
grvalue.
gr
gr<pre>
gr&gt;&gt;&gt; traceShowId (1+2+3, "hello" ++ "world")
gr(6,"helloworld")
gr(6,"helloworld")
gr</pre>
traceShowId :: Show a => a -> a

-- | like <a>trace</a>, but additionally prints a call stack if one is
gravailable.
gr
grIn the current GHC implementation, the call stack is only available if
grthe program was compiled with <tt>-prof</tt>; otherwise
gr<a>traceStack</a> behaves exactly like <a>trace</a>. Entries in the
grcall stack correspond to <tt>SCC</tt> annotations, so it is a good
gridea to use <tt>-fprof-auto</tt> or <tt>-fprof-auto-calls</tt> to add
grSCC annotations automatically.
traceStack :: String -> a -> a

-- | The <a>traceIO</a> function outputs the trace message from the IO
grmonad. This sequences the output with respect to other IO actions.
traceIO :: String -> IO ()

-- | Like <a>trace</a> but returning unit in an arbitrary
gr<a>Applicative</a> context. Allows for convenient use in do-notation.
gr
grNote that the application of <a>traceM</a> is not an action in the
gr<a>Applicative</a> context, as <a>traceIO</a> is in the <a>IO</a>
grtype. While the fresh bindings in the following example will force the
gr<a>traceM</a> expressions to be reduced every time the
gr<tt>do</tt>-block is executed, <tt>traceM "not crashed"</tt> would
gronly be reduced once, and the message would only be printed once. If
gryour monad is in <tt>MonadIO</tt>, <tt>liftIO . traceIO</tt> may be a
grbetter option.
gr
gr<pre>
gr&gt;&gt;&gt; :{
grdo
gr    x &lt;- Just 3
gr    traceM ("x: " ++ show x)
gr    y &lt;- pure 12
gr    traceM ("y: " ++ show y)
gr    pure (x*2 + y)
gr:}
grx: 3
gry: 12
grJust 18
gr</pre>
traceM :: Applicative f => String -> f ()

-- | Like <a>traceM</a>, but uses <a>show</a> on the argument to convert it
grto a <a>String</a>.
gr
gr<pre>
gr&gt;&gt;&gt; :{
grdo
gr    x &lt;- Just 3
gr    traceShowM x
gr    y &lt;- pure 12
gr    traceShowM y
gr    pure (x*2 + y)
gr:}
gr3
gr12
grJust 18
gr</pre>
traceShowM :: (Show a, Applicative f) => a -> f ()

-- | <i>Deprecated: Use <a>traceIO</a></i>
putTraceMsg :: String -> IO ()

-- | The <a>traceEvent</a> function behaves like <a>trace</a> with the
grdifference that the message is emitted to the eventlog, if eventlog
grprofiling is available and enabled at runtime.
gr
grIt is suitable for use in pure code. In an IO context use
gr<a>traceEventIO</a> instead.
gr
grNote that when using GHC's SMP runtime, it is possible (but rare) to
grget duplicate events emitted if two CPUs simultaneously evaluate the
grsame thunk that uses <a>traceEvent</a>.
traceEvent :: String -> a -> a

-- | The <a>traceEventIO</a> function emits a message to the eventlog, if
greventlog profiling is available and enabled at runtime.
gr
grCompared to <a>traceEvent</a>, <a>traceEventIO</a> sequences the event
grwith respect to other IO actions.
traceEventIO :: String -> IO ()

-- | The <a>traceMarker</a> function emits a marker to the eventlog, if
greventlog profiling is available and enabled at runtime. The
gr<tt>String</tt> is the name of the marker. The name is just used in
grthe profiling tools to help you keep clear which marker is which.
gr
grThis function is suitable for use in pure code. In an IO context use
gr<a>traceMarkerIO</a> instead.
gr
grNote that when using GHC's SMP runtime, it is possible (but rare) to
grget duplicate events emitted if two CPUs simultaneously evaluate the
grsame thunk that uses <a>traceMarker</a>.
traceMarker :: String -> a -> a

-- | The <a>traceMarkerIO</a> function emits a marker to the eventlog, if
greventlog profiling is available and enabled at runtime.
gr
grCompared to <a>traceMarker</a>, <a>traceMarkerIO</a> sequences the
grevent with respect to other IO actions.
traceMarkerIO :: String -> IO ()


-- | The <tt>String</tt> type and associated operations.
module Data.String

-- | A <a>String</a> is a list of characters. String constants in Haskell
grare values of type <a>String</a>.
type String = [Char]

-- | Class for string-like datastructures; used by the overloaded string
grextension (-XOverloadedStrings in GHC).
class IsString a
fromString :: IsString a => String -> a

-- | <a>lines</a> breaks a string up into a list of strings at newline
grcharacters. The resulting strings do not contain newlines.
gr
grNote that after splitting the string at newline characters, the last
grpart of the string is considered a line even if it doesn't end with a
grnewline. For example,
gr
gr<pre>
gr&gt;&gt;&gt; lines ""
gr[]
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; lines "\n"
gr[""]
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; lines "one"
gr["one"]
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; lines "one\n"
gr["one"]
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; lines "one\n\n"
gr["one",""]
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; lines "one\ntwo"
gr["one","two"]
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; lines "one\ntwo\n"
gr["one","two"]
gr</pre>
gr
grThus <tt><a>lines</a> s</tt> contains at least as many elements as
grnewlines in <tt>s</tt>.
lines :: String -> [String]

-- | <a>words</a> breaks a string up into a list of words, which were
grdelimited by white space.
gr
gr<pre>
gr&gt;&gt;&gt; words "Lorem ipsum\ndolor"
gr["Lorem","ipsum","dolor"]
gr</pre>
words :: String -> [String]

-- | <a>unlines</a> is an inverse operation to <a>lines</a>. It joins
grlines, after appending a terminating newline to each.
gr
gr<pre>
gr&gt;&gt;&gt; unlines ["Hello", "World", "!"]
gr"Hello\nWorld\n!\n"
gr</pre>
unlines :: [String] -> String

-- | <a>unwords</a> is an inverse operation to <a>words</a>. It joins words
grwith separating spaces.
gr
gr<pre>
gr&gt;&gt;&gt; unwords ["Lorem", "ipsum", "dolor"]
gr"Lorem ipsum dolor"
gr</pre>
unwords :: [String] -> String
instance Data.String.IsString a => Data.String.IsString (Data.Functor.Const.Const a b)
instance Data.String.IsString a => Data.String.IsString (Data.Functor.Identity.Identity a)
instance (a ~ GHC.Types.Char) => Data.String.IsString [a]


-- | A general library for representation and manipulation of versions.
gr
grVersioning schemes are many and varied, so the version representation
grprovided by this library is intended to be a compromise between
grcomplete generality, where almost no common functionality could
grreasonably be provided, and fixing a particular versioning scheme,
grwhich would probably be too restrictive.
gr
grSo the approach taken here is to provide a representation which
grsubsumes many of the versioning schemes commonly in use, and we
grprovide implementations of <a>Eq</a>, <a>Ord</a> and conversion
grto/from <a>String</a> which will be appropriate for some applications,
grbut not all.
module Data.Version

-- | A <a>Version</a> represents the version of a software entity.
gr
grAn instance of <a>Eq</a> is provided, which implements exact equality
grmodulo reordering of the tags in the <a>versionTags</a> field.
gr
grAn instance of <a>Ord</a> is also provided, which gives lexicographic
grordering on the <a>versionBranch</a> fields (i.e. 2.1 &gt; 2.0, 1.2.3
gr&gt; 1.2.2, etc.). This is expected to be sufficient for many uses,
grbut note that you may need to use a more specific ordering for your
grversioning scheme. For example, some versioning schemes may include
grpre-releases which have tags <tt>"pre1"</tt>, <tt>"pre2"</tt>, and so
gron, and these would need to be taken into account when determining
grordering. In some cases, date ordering may be more appropriate, so the
grapplication would have to look for <tt>date</tt> tags in the
gr<a>versionTags</a> field and compare those. The bottom line is, don't
gralways assume that <a>compare</a> and other <a>Ord</a> operations are
grthe right thing for every <a>Version</a>.
gr
grSimilarly, concrete representations of versions may differ. One
grpossible concrete representation is provided (see <a>showVersion</a>
grand <a>parseVersion</a>), but depending on the application a different
grconcrete representation may be more appropriate.
data Version
Version :: [Int] -> [String] -> Version

-- | The numeric branch for this version. This reflects the fact that most
grsoftware versions are tree-structured; there is a main trunk which is
grtagged with versions at various points (1,2,3...), and the first
grbranch off the trunk after version 3 is 3.1, the second branch off the
grtrunk after version 3 is 3.2, and so on. The tree can be branched
grarbitrarily, just by adding more digits.
gr
grWe represent the branch as a list of <a>Int</a>, so version 3.2.1
grbecomes [3,2,1]. Lexicographic ordering (i.e. the default instance of
gr<a>Ord</a> for <tt>[Int]</tt>) gives the natural ordering of branches.
[versionBranch] :: Version -> [Int]

-- | A version can be tagged with an arbitrary list of strings. The
grinterpretation of the list of tags is entirely dependent on the entity
grthat this version applies to.

-- | <i>Deprecated: See GHC ticket #2496</i>
[versionTags] :: Version -> [String]

-- | Provides one possible concrete representation for <a>Version</a>. For
gra version with <a>versionBranch</a> <tt>= [1,2,3]</tt> and
gr<a>versionTags</a> <tt>= ["tag1","tag2"]</tt>, the output will be
gr<tt>1.2.3-tag1-tag2</tt>.
showVersion :: Version -> String

-- | A parser for versions in the format produced by <a>showVersion</a>.
parseVersion :: ReadP Version

-- | Construct tag-less <a>Version</a>
makeVersion :: [Int] -> Version
instance GHC.Generics.Generic Data.Version.Version
instance GHC.Show.Show Data.Version.Version
instance GHC.Read.Read Data.Version.Version
instance GHC.Classes.Eq Data.Version.Version
instance GHC.Classes.Ord Data.Version.Version


-- | The <a>Functor</a>, <a>Monad</a> and <a>MonadPlus</a> classes, with
grsome useful operations on monads.
module Control.Monad

-- | The <a>Functor</a> class is used for types that can be mapped over.
grInstances of <a>Functor</a> should satisfy the following laws:
gr
gr<pre>
grfmap id  ==  id
grfmap (f . g)  ==  fmap f . fmap g
gr</pre>
gr
grThe instances of <a>Functor</a> for lists, <a>Maybe</a> and <a>IO</a>
grsatisfy these laws.
class Functor f
fmap :: Functor f => (a -> b) -> f a -> f b

-- | The <a>Monad</a> class defines the basic operations over a
gr<i>monad</i>, a concept from a branch of mathematics known as
gr<i>category theory</i>. From the perspective of a Haskell programmer,
grhowever, it is best to think of a monad as an <i>abstract datatype</i>
grof actions. Haskell's <tt>do</tt> expressions provide a convenient
grsyntax for writing monadic expressions.
gr
grInstances of <a>Monad</a> should satisfy the following laws:
gr
gr<ul>
gr<li><pre><a>return</a> a <a>&gt;&gt;=</a> k = k a</pre></li>
gr<li><pre>m <a>&gt;&gt;=</a> <a>return</a> = m</pre></li>
gr<li><pre>m <a>&gt;&gt;=</a> (\x -&gt; k x <a>&gt;&gt;=</a> h) = (m
gr<a>&gt;&gt;=</a> k) <a>&gt;&gt;=</a> h</pre></li>
gr</ul>
gr
grFurthermore, the <a>Monad</a> and <a>Applicative</a> operations should
grrelate as follows:
gr
gr<ul>
gr<li><pre><a>pure</a> = <a>return</a></pre></li>
gr<li><pre>(<a>&lt;*&gt;</a>) = <a>ap</a></pre></li>
gr</ul>
gr
grThe above laws imply:
gr
gr<ul>
gr<li><pre><a>fmap</a> f xs = xs <a>&gt;&gt;=</a> <a>return</a> .
grf</pre></li>
gr<li><pre>(<a>&gt;&gt;</a>) = (<a>*&gt;</a>)</pre></li>
gr</ul>
gr
grand that <a>pure</a> and (<a>&lt;*&gt;</a>) satisfy the applicative
grfunctor laws.
gr
grThe instances of <a>Monad</a> for lists, <a>Maybe</a> and <a>IO</a>
grdefined in the <a>Prelude</a> satisfy these laws.
class Applicative m => Monad m

-- | Sequentially compose two actions, passing any value produced by the
grfirst as an argument to the second.
(>>=) :: forall a b. Monad m => m a -> (a -> m b) -> m b

-- | Sequentially compose two actions, discarding any value produced by the
grfirst, like sequencing operators (such as the semicolon) in imperative
grlanguages.
(>>) :: forall a b. Monad m => m a -> m b -> m b

-- | Inject a value into the monadic type.
return :: Monad m => a -> m a

-- | Fail with a message. This operation is not part of the mathematical
grdefinition of a monad, but is invoked on pattern-match failure in a
gr<tt>do</tt> expression.
gr
grAs part of the MonadFail proposal (MFP), this function is moved to its
grown class <tt>MonadFail</tt> (see <a>Control.Monad.Fail</a> for more
grdetails). The definition here will be removed in a future release.
fail :: Monad m => String -> m a

-- | Monads that also support choice and failure.
class (Alternative m, Monad m) => MonadPlus m

-- | The identity of <a>mplus</a>. It should also satisfy the equations
gr
gr<pre>
grmzero &gt;&gt;= f  =  mzero
grv &gt;&gt; mzero   =  mzero
gr</pre>
gr
grThe default definition is
gr
gr<pre>
grmzero = <a>empty</a>
gr</pre>
mzero :: MonadPlus m => m a

-- | An associative operation. The default definition is
gr
gr<pre>
grmplus = (<a>&lt;|&gt;</a>)
gr</pre>
mplus :: MonadPlus m => m a -> m a -> m a

-- | Map each element of a structure to a monadic action, evaluate these
gractions from left to right, and collect the results. For a version
grthat ignores the results see <a>mapM_</a>.
mapM :: (Traversable t, Monad m) => (a -> m b) -> t a -> m (t b)

-- | Map each element of a structure to a monadic action, evaluate these
gractions from left to right, and ignore the results. For a version that
grdoesn't ignore the results see <a>mapM</a>.
gr
grAs of base 4.8.0.0, <a>mapM_</a> is just <a>traverse_</a>, specialized
grto <a>Monad</a>.
mapM_ :: (Foldable t, Monad m) => (a -> m b) -> t a -> m ()

-- | <a>forM</a> is <a>mapM</a> with its arguments flipped. For a version
grthat ignores the results see <a>forM_</a>.
forM :: (Traversable t, Monad m) => t a -> (a -> m b) -> m (t b)

-- | <a>forM_</a> is <a>mapM_</a> with its arguments flipped. For a version
grthat doesn't ignore the results see <a>forM</a>.
gr
grAs of base 4.8.0.0, <a>forM_</a> is just <a>for_</a>, specialized to
gr<a>Monad</a>.
forM_ :: (Foldable t, Monad m) => t a -> (a -> m b) -> m ()

-- | Evaluate each monadic action in the structure from left to right, and
grcollect the results. For a version that ignores the results see
gr<a>sequence_</a>.
sequence :: (Traversable t, Monad m) => t (m a) -> m (t a)

-- | Evaluate each monadic action in the structure from left to right, and
grignore the results. For a version that doesn't ignore the results see
gr<a>sequence</a>.
gr
grAs of base 4.8.0.0, <a>sequence_</a> is just <a>sequenceA_</a>,
grspecialized to <a>Monad</a>.
sequence_ :: (Foldable t, Monad m) => t (m a) -> m ()

-- | Same as <a>&gt;&gt;=</a>, but with the arguments interchanged.
(=<<) :: Monad m => (a -> m b) -> m a -> m b
infixr 1 =<<

-- | Left-to-right Kleisli composition of monads.
(>=>) :: Monad m => (a -> m b) -> (b -> m c) -> (a -> m c)
infixr 1 >=>

-- | Right-to-left Kleisli composition of monads.
gr<tt>(<a>&gt;=&gt;</a>)</tt>, with the arguments flipped.
gr
grNote how this operator resembles function composition
gr<tt>(<a>.</a>)</tt>:
gr
gr<pre>
gr(.)   ::            (b -&gt;   c) -&gt; (a -&gt;   b) -&gt; a -&gt;   c
gr(&lt;=&lt;) :: Monad m =&gt; (b -&gt; m c) -&gt; (a -&gt; m b) -&gt; a -&gt; m c
gr</pre>
(<=<) :: Monad m => (b -> m c) -> (a -> m b) -> (a -> m c)
infixr 1 <=<

-- | <tt><a>forever</a> act</tt> repeats the action infinitely.
forever :: (Applicative f) => f a -> f b

-- | <tt><a>void</a> value</tt> discards or ignores the result of
grevaluation, such as the return value of an <a>IO</a> action.
gr
gr<h4><b>Examples</b></h4>
gr
grReplace the contents of a <tt><tt>Maybe</tt> <tt>Int</tt></tt> with
grunit:
gr
gr<pre>
gr&gt;&gt;&gt; void Nothing
grNothing
gr
gr&gt;&gt;&gt; void (Just 3)
grJust ()
gr</pre>
gr
grReplace the contents of an <tt><tt>Either</tt> <tt>Int</tt>
gr<tt>Int</tt></tt> with unit, resulting in an <tt><tt>Either</tt>
gr<tt>Int</tt> '()'</tt>:
gr
gr<pre>
gr&gt;&gt;&gt; void (Left 8675309)
grLeft 8675309
gr
gr&gt;&gt;&gt; void (Right 8675309)
grRight ()
gr</pre>
gr
grReplace every element of a list with unit:
gr
gr<pre>
gr&gt;&gt;&gt; void [1,2,3]
gr[(),(),()]
gr</pre>
gr
grReplace the second element of a pair with unit:
gr
gr<pre>
gr&gt;&gt;&gt; void (1,2)
gr(1,())
gr</pre>
gr
grDiscard the result of an <a>IO</a> action:
gr
gr<pre>
gr&gt;&gt;&gt; mapM print [1,2]
gr1
gr2
gr[(),()]
gr
gr&gt;&gt;&gt; void $ mapM print [1,2]
gr1
gr2
gr</pre>
void :: Functor f => f a -> f ()

-- | The <a>join</a> function is the conventional monad join operator. It
gris used to remove one level of monadic structure, projecting its bound
grargument into the outer level.
join :: (Monad m) => m (m a) -> m a

-- | The sum of a collection of actions, generalizing <a>concat</a>. As of
grbase 4.8.0.0, <a>msum</a> is just <a>asum</a>, specialized to
gr<a>MonadPlus</a>.
msum :: (Foldable t, MonadPlus m) => t (m a) -> m a

-- | Direct <a>MonadPlus</a> equivalent of <tt>filter</tt>
gr<tt><tt>filter</tt></tt> = <tt>(mfilter:: (a -&gt; Bool) -&gt; [a]
gr-&gt; [a]</tt> applicable to any <a>MonadPlus</a>, for example
gr<tt>mfilter odd (Just 1) == Just 1</tt> <tt>mfilter odd (Just 2) ==
grNothing</tt>
mfilter :: (MonadPlus m) => (a -> Bool) -> m a -> m a

-- | This generalizes the list-based <tt>filter</tt> function.
filterM :: (Applicative m) => (a -> m Bool) -> [a] -> m [a]

-- | The <a>mapAndUnzipM</a> function maps its first argument over a list,
grreturning the result as a pair of lists. This function is mainly used
grwith complicated data structures or a state-transforming monad.
mapAndUnzipM :: (Applicative m) => (a -> m (b, c)) -> [a] -> m ([b], [c])

-- | The <a>zipWithM</a> function generalizes <a>zipWith</a> to arbitrary
grapplicative functors.
zipWithM :: (Applicative m) => (a -> b -> m c) -> [a] -> [b] -> m [c]

-- | <a>zipWithM_</a> is the extension of <a>zipWithM</a> which ignores the
grfinal result.
zipWithM_ :: (Applicative m) => (a -> b -> m c) -> [a] -> [b] -> m ()

-- | The <a>foldM</a> function is analogous to <tt>foldl</tt>, except that
grits result is encapsulated in a monad. Note that <a>foldM</a> works
grfrom left-to-right over the list arguments. This could be an issue
grwhere <tt>(<a>&gt;&gt;</a>)</tt> and the `folded function' are not
grcommutative.
gr
gr<pre>
grfoldM f a1 [x1, x2, ..., xm]
gr
gr==
gr
grdo
gr  a2 &lt;- f a1 x1
gr  a3 &lt;- f a2 x2
gr  ...
gr  f am xm
gr</pre>
gr
grIf right-to-left evaluation is required, the input list should be
grreversed.
gr
grNote: <a>foldM</a> is the same as <a>foldlM</a>
foldM :: (Foldable t, Monad m) => (b -> a -> m b) -> b -> t a -> m b

-- | Like <a>foldM</a>, but discards the result.
foldM_ :: (Foldable t, Monad m) => (b -> a -> m b) -> b -> t a -> m ()

-- | <tt><a>replicateM</a> n act</tt> performs the action <tt>n</tt> times,
grgathering the results.
replicateM :: (Applicative m) => Int -> m a -> m [a]

-- | Like <a>replicateM</a>, but discards the result.
replicateM_ :: (Applicative m) => Int -> m a -> m ()

-- | Conditional failure of <a>Alternative</a> computations. Defined by
gr
gr<pre>
grguard True  = <a>pure</a> ()
grguard False = <a>empty</a>
gr</pre>
gr
gr<h4><b>Examples</b></h4>
gr
grCommon uses of <a>guard</a> include conditionally signaling an error
grin an error monad and conditionally rejecting the current choice in an
gr<a>Alternative</a>-based parser.
gr
grAs an example of signaling an error in the error monad <a>Maybe</a>,
grconsider a safe division function <tt>safeDiv x y</tt> that returns
gr<a>Nothing</a> when the denominator <tt>y</tt> is zero and
gr<tt><a>Just</a> (x `div` y)</tt> otherwise. For example:
gr
gr<pre>
gr&gt;&gt;&gt; safeDiv 4 0
grNothing
gr&gt;&gt;&gt; safeDiv 4 2
grJust 2
gr</pre>
gr
grA definition of <tt>safeDiv</tt> using guards, but not <a>guard</a>:
gr
gr<pre>
grsafeDiv :: Int -&gt; Int -&gt; Maybe Int
grsafeDiv x y | y /= 0    = Just (x `div` y)
gr            | otherwise = Nothing
gr</pre>
gr
grA definition of <tt>safeDiv</tt> using <a>guard</a> and <a>Monad</a>
gr<tt>do</tt>-notation:
gr
gr<pre>
grsafeDiv :: Int -&gt; Int -&gt; Maybe Int
grsafeDiv x y = do
gr  guard (y /= 0)
gr  return (x `div` y)
gr</pre>
guard :: (Alternative f) => Bool -> f ()

-- | Conditional execution of <a>Applicative</a> expressions. For example,
gr
gr<pre>
grwhen debug (putStrLn "Debugging")
gr</pre>
gr
grwill output the string <tt>Debugging</tt> if the Boolean value
gr<tt>debug</tt> is <a>True</a>, and otherwise do nothing.
when :: (Applicative f) => Bool -> f () -> f ()

-- | The reverse of <a>when</a>.
unless :: (Applicative f) => Bool -> f () -> f ()

-- | Promote a function to a monad.
liftM :: (Monad m) => (a1 -> r) -> m a1 -> m r

-- | Promote a function to a monad, scanning the monadic arguments from
grleft to right. For example,
gr
gr<pre>
grliftM2 (+) [0,1] [0,2] = [0,2,1,3]
grliftM2 (+) (Just 1) Nothing = Nothing
gr</pre>
liftM2 :: (Monad m) => (a1 -> a2 -> r) -> m a1 -> m a2 -> m r

-- | Promote a function to a monad, scanning the monadic arguments from
grleft to right (cf. <a>liftM2</a>).
liftM3 :: (Monad m) => (a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r

-- | Promote a function to a monad, scanning the monadic arguments from
grleft to right (cf. <a>liftM2</a>).
liftM4 :: (Monad m) => (a1 -> a2 -> a3 -> a4 -> r) -> m a1 -> m a2 -> m a3 -> m a4 -> m r

-- | Promote a function to a monad, scanning the monadic arguments from
grleft to right (cf. <a>liftM2</a>).
liftM5 :: (Monad m) => (a1 -> a2 -> a3 -> a4 -> a5 -> r) -> m a1 -> m a2 -> m a3 -> m a4 -> m a5 -> m r

-- | In many situations, the <a>liftM</a> operations can be replaced by
gruses of <a>ap</a>, which promotes function application.
gr
gr<pre>
grreturn f `ap` x1 `ap` ... `ap` xn
gr</pre>
gr
gris equivalent to
gr
gr<pre>
grliftMn f x1 x2 ... xn
gr</pre>
ap :: (Monad m) => m (a -> b) -> m a -> m b

-- | Strict version of <a>&lt;$&gt;</a>.
(<$!>) :: Monad m => (a -> b) -> m a -> m b
infixl 4 <$!>


-- | The Prelude: a standard module. The Prelude is imported by default
grinto all Haskell modules unless either there is an explicit import
grstatement for it, or the NoImplicitPrelude extension is enabled.
module Prelude
data Bool
False :: Bool
True :: Bool

-- | Boolean "and"
(&&) :: Bool -> Bool -> Bool
infixr 3 &&

-- | Boolean "or"
(||) :: Bool -> Bool -> Bool
infixr 2 ||

-- | Boolean "not"
not :: Bool -> Bool

-- | <a>otherwise</a> is defined as the value <a>True</a>. It helps to make
grguards more readable. eg.
gr
gr<pre>
grf x | x &lt; 0     = ...
gr    | otherwise = ...
gr</pre>
otherwise :: Bool

-- | The <a>Maybe</a> type encapsulates an optional value. A value of type
gr<tt><a>Maybe</a> a</tt> either contains a value of type <tt>a</tt>
gr(represented as <tt><a>Just</a> a</tt>), or it is empty (represented
gras <a>Nothing</a>). Using <a>Maybe</a> is a good way to deal with
grerrors or exceptional cases without resorting to drastic measures such
gras <a>error</a>.
gr
grThe <a>Maybe</a> type is also a monad. It is a simple kind of error
grmonad, where all errors are represented by <a>Nothing</a>. A richer
grerror monad can be built using the <a>Either</a> type.
data Maybe a
Nothing :: Maybe a
Just :: a -> Maybe a

-- | The <a>maybe</a> function takes a default value, a function, and a
gr<a>Maybe</a> value. If the <a>Maybe</a> value is <a>Nothing</a>, the
grfunction returns the default value. Otherwise, it applies the function
grto the value inside the <a>Just</a> and returns the result.
gr
gr<h4><b>Examples</b></h4>
gr
grBasic usage:
gr
gr<pre>
gr&gt;&gt;&gt; maybe False odd (Just 3)
grTrue
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; maybe False odd Nothing
grFalse
gr</pre>
gr
grRead an integer from a string using <tt>readMaybe</tt>. If we succeed,
grreturn twice the integer; that is, apply <tt>(*2)</tt> to it. If
grinstead we fail to parse an integer, return <tt>0</tt> by default:
gr
gr<pre>
gr&gt;&gt;&gt; import Text.Read ( readMaybe )
gr
gr&gt;&gt;&gt; maybe 0 (*2) (readMaybe "5")
gr10
gr
gr&gt;&gt;&gt; maybe 0 (*2) (readMaybe "")
gr0
gr</pre>
gr
grApply <tt>show</tt> to a <tt>Maybe Int</tt>. If we have <tt>Just
grn</tt>, we want to show the underlying <a>Int</a> <tt>n</tt>. But if
grwe have <a>Nothing</a>, we return the empty string instead of (for
grexample) "Nothing":
gr
gr<pre>
gr&gt;&gt;&gt; maybe "" show (Just 5)
gr"5"
gr
gr&gt;&gt;&gt; maybe "" show Nothing
gr""
gr</pre>
maybe :: b -> (a -> b) -> Maybe a -> b

-- | The <a>Either</a> type represents values with two possibilities: a
grvalue of type <tt><a>Either</a> a b</tt> is either <tt><a>Left</a>
gra</tt> or <tt><a>Right</a> b</tt>.
gr
grThe <a>Either</a> type is sometimes used to represent a value which is
greither correct or an error; by convention, the <a>Left</a> constructor
gris used to hold an error value and the <a>Right</a> constructor is
grused to hold a correct value (mnemonic: "right" also means "correct").
gr
gr<h4><b>Examples</b></h4>
gr
grThe type <tt><a>Either</a> <a>String</a> <a>Int</a></tt> is the type
grof values which can be either a <a>String</a> or an <a>Int</a>. The
gr<a>Left</a> constructor can be used only on <a>String</a>s, and the
gr<a>Right</a> constructor can be used only on <a>Int</a>s:
gr
gr<pre>
gr&gt;&gt;&gt; let s = Left "foo" :: Either String Int
gr
gr&gt;&gt;&gt; s
grLeft "foo"
gr
gr&gt;&gt;&gt; let n = Right 3 :: Either String Int
gr
gr&gt;&gt;&gt; n
grRight 3
gr
gr&gt;&gt;&gt; :type s
grs :: Either String Int
gr
gr&gt;&gt;&gt; :type n
grn :: Either String Int
gr</pre>
gr
grThe <a>fmap</a> from our <a>Functor</a> instance will ignore
gr<a>Left</a> values, but will apply the supplied function to values
grcontained in a <a>Right</a>:
gr
gr<pre>
gr&gt;&gt;&gt; let s = Left "foo" :: Either String Int
gr
gr&gt;&gt;&gt; let n = Right 3 :: Either String Int
gr
gr&gt;&gt;&gt; fmap (*2) s
grLeft "foo"
gr
gr&gt;&gt;&gt; fmap (*2) n
grRight 6
gr</pre>
gr
grThe <a>Monad</a> instance for <a>Either</a> allows us to chain
grtogether multiple actions which may fail, and fail overall if any of
grthe individual steps failed. First we'll write a function that can
greither parse an <a>Int</a> from a <a>Char</a>, or fail.
gr
gr<pre>
gr&gt;&gt;&gt; import Data.Char ( digitToInt, isDigit )
gr
gr&gt;&gt;&gt; :{
gr    let parseEither :: Char -&gt; Either String Int
gr        parseEither c
gr          | isDigit c = Right (digitToInt c)
gr          | otherwise = Left "parse error"
gr
gr&gt;&gt;&gt; :}
gr</pre>
gr
grThe following should work, since both <tt>'1'</tt> and <tt>'2'</tt>
grcan be parsed as <a>Int</a>s.
gr
gr<pre>
gr&gt;&gt;&gt; :{
gr    let parseMultiple :: Either String Int
gr        parseMultiple = do
gr          x &lt;- parseEither '1'
gr          y &lt;- parseEither '2'
gr          return (x + y)
gr
gr&gt;&gt;&gt; :}
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; parseMultiple
grRight 3
gr</pre>
gr
grBut the following should fail overall, since the first operation where
grwe attempt to parse <tt>'m'</tt> as an <a>Int</a> will fail:
gr
gr<pre>
gr&gt;&gt;&gt; :{
gr    let parseMultiple :: Either String Int
gr        parseMultiple = do
gr          x &lt;- parseEither 'm'
gr          y &lt;- parseEither '2'
gr          return (x + y)
gr
gr&gt;&gt;&gt; :}
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; parseMultiple
grLeft "parse error"
gr</pre>
data Either a b
Left :: a -> Either a b
Right :: b -> Either a b

-- | Case analysis for the <a>Either</a> type. If the value is
gr<tt><a>Left</a> a</tt>, apply the first function to <tt>a</tt>; if it
gris <tt><a>Right</a> b</tt>, apply the second function to <tt>b</tt>.
gr
gr<h4><b>Examples</b></h4>
gr
grWe create two values of type <tt><a>Either</a> <a>String</a>
gr<a>Int</a></tt>, one using the <a>Left</a> constructor and another
grusing the <a>Right</a> constructor. Then we apply "either" the
gr<tt>length</tt> function (if we have a <a>String</a>) or the
gr"times-two" function (if we have an <a>Int</a>):
gr
gr<pre>
gr&gt;&gt;&gt; let s = Left "foo" :: Either String Int
gr
gr&gt;&gt;&gt; let n = Right 3 :: Either String Int
gr
gr&gt;&gt;&gt; either length (*2) s
gr3
gr
gr&gt;&gt;&gt; either length (*2) n
gr6
gr</pre>
either :: (a -> c) -> (b -> c) -> Either a b -> c
data Ordering
LT :: Ordering
EQ :: Ordering
GT :: Ordering

-- | The character type <a>Char</a> is an enumeration whose values
grrepresent Unicode (or equivalently ISO/IEC 10646) code points (i.e.
grcharacters, see <a>http://www.unicode.org/</a> for details). This set
grextends the ISO 8859-1 (Latin-1) character set (the first 256
grcharacters), which is itself an extension of the ASCII character set
gr(the first 128 characters). A character literal in Haskell has type
gr<a>Char</a>.
gr
grTo convert a <a>Char</a> to or from the corresponding <a>Int</a> value
grdefined by Unicode, use <a>toEnum</a> and <a>fromEnum</a> from the
gr<a>Enum</a> class respectively (or equivalently <tt>ord</tt> and
gr<tt>chr</tt>).
data Char

-- | A <a>String</a> is a list of characters. String constants in Haskell
grare values of type <a>String</a>.
type String = [Char]

-- | Extract the first component of a pair.
fst :: (a, b) -> a

-- | Extract the second component of a pair.
snd :: (a, b) -> b

-- | <a>curry</a> converts an uncurried function to a curried function.
gr
gr<h4><b>Examples</b></h4>
gr
gr<pre>
gr&gt;&gt;&gt; curry fst 1 2
gr1
gr</pre>
curry :: ((a, b) -> c) -> a -> b -> c

-- | <a>uncurry</a> converts a curried function to a function on pairs.
gr
gr<h4><b>Examples</b></h4>
gr
gr<pre>
gr&gt;&gt;&gt; uncurry (+) (1,2)
gr3
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; uncurry ($) (show, 1)
gr"1"
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; map (uncurry max) [(1,2), (3,4), (6,8)]
gr[2,4,8]
gr</pre>
uncurry :: (a -> b -> c) -> ((a, b) -> c)

-- | The <a>Eq</a> class defines equality (<a>==</a>) and inequality
gr(<a>/=</a>). All the basic datatypes exported by the <a>Prelude</a>
grare instances of <a>Eq</a>, and <a>Eq</a> may be derived for any
grdatatype whose constituents are also instances of <a>Eq</a>.
gr
grMinimal complete definition: either <a>==</a> or <a>/=</a>.
class Eq a
(==) :: Eq a => a -> a -> Bool
(/=) :: Eq a => a -> a -> Bool

-- | The <a>Ord</a> class is used for totally ordered datatypes.
gr
grInstances of <a>Ord</a> can be derived for any user-defined datatype
grwhose constituent types are in <a>Ord</a>. The declared order of the
grconstructors in the data declaration determines the ordering in
grderived <a>Ord</a> instances. The <a>Ordering</a> datatype allows a
grsingle comparison to determine the precise ordering of two objects.
gr
grMinimal complete definition: either <a>compare</a> or <a>&lt;=</a>.
grUsing <a>compare</a> can be more efficient for complex types.
class Eq a => Ord a
compare :: Ord a => a -> a -> Ordering
(<) :: Ord a => a -> a -> Bool
(<=) :: Ord a => a -> a -> Bool
(>) :: Ord a => a -> a -> Bool
(>=) :: Ord a => a -> a -> Bool
max :: Ord a => a -> a -> a
min :: Ord a => a -> a -> a

-- | Class <a>Enum</a> defines operations on sequentially ordered types.
gr
grThe <tt>enumFrom</tt>... methods are used in Haskell's translation of
grarithmetic sequences.
gr
grInstances of <a>Enum</a> may be derived for any enumeration type
gr(types whose constructors have no fields). The nullary constructors
grare assumed to be numbered left-to-right by <a>fromEnum</a> from
gr<tt>0</tt> through <tt>n-1</tt>. See Chapter 10 of the <i>Haskell
grReport</i> for more details.
gr
grFor any type that is an instance of class <a>Bounded</a> as well as
gr<a>Enum</a>, the following should hold:
gr
gr<ul>
gr<li>The calls <tt><a>succ</a> <a>maxBound</a></tt> and <tt><a>pred</a>
gr<a>minBound</a></tt> should result in a runtime error.</li>
gr<li><a>fromEnum</a> and <a>toEnum</a> should give a runtime error if
grthe result value is not representable in the result type. For example,
gr<tt><a>toEnum</a> 7 :: <a>Bool</a></tt> is an error.</li>
gr<li><a>enumFrom</a> and <a>enumFromThen</a> should be defined with an
grimplicit bound, thus:</li>
gr</ul>
gr
gr<pre>
grenumFrom     x   = enumFromTo     x maxBound
grenumFromThen x y = enumFromThenTo x y bound
gr  where
gr    bound | fromEnum y &gt;= fromEnum x = maxBound
gr          | otherwise                = minBound
gr</pre>
class Enum a

-- | the successor of a value. For numeric types, <a>succ</a> adds 1.
succ :: Enum a => a -> a

-- | the predecessor of a value. For numeric types, <a>pred</a> subtracts
gr1.
pred :: Enum a => a -> a

-- | Convert from an <a>Int</a>.
toEnum :: Enum a => Int -> a

-- | Convert to an <a>Int</a>. It is implementation-dependent what
gr<a>fromEnum</a> returns when applied to a value that is too large to
grfit in an <a>Int</a>.
fromEnum :: Enum a => a -> Int

-- | Used in Haskell's translation of <tt>[n..]</tt>.
enumFrom :: Enum a => a -> [a]

-- | Used in Haskell's translation of <tt>[n,n'..]</tt>.
enumFromThen :: Enum a => a -> a -> [a]

-- | Used in Haskell's translation of <tt>[n..m]</tt>.
enumFromTo :: Enum a => a -> a -> [a]

-- | Used in Haskell's translation of <tt>[n,n'..m]</tt>.
enumFromThenTo :: Enum a => a -> a -> a -> [a]

-- | The <a>Bounded</a> class is used to name the upper and lower limits of
gra type. <a>Ord</a> is not a superclass of <a>Bounded</a> since types
grthat are not totally ordered may also have upper and lower bounds.
gr
grThe <a>Bounded</a> class may be derived for any enumeration type;
gr<a>minBound</a> is the first constructor listed in the <tt>data</tt>
grdeclaration and <a>maxBound</a> is the last. <a>Bounded</a> may also
grbe derived for single-constructor datatypes whose constituent types
grare in <a>Bounded</a>.
class Bounded a
minBound :: Bounded a => a
maxBound :: Bounded a => a

-- | A fixed-precision integer type with at least the range <tt>[-2^29 ..
gr2^29-1]</tt>. The exact range for a given implementation can be
grdetermined by using <a>minBound</a> and <a>maxBound</a> from the
gr<a>Bounded</a> class.
data Int

-- | Invariant: <a>Jn#</a> and <a>Jp#</a> are used iff value doesn't fit in
gr<a>S#</a>
gr
grUseful properties resulting from the invariants:
gr
gr<ul>
gr<li><pre>abs (<a>S#</a> _) &lt;= abs (<a>Jp#</a> _)</pre></li>
gr<li><pre>abs (<a>S#</a> _) &lt; abs (<a>Jn#</a> _)</pre></li>
gr</ul>
data Integer

-- | Single-precision floating point numbers. It is desirable that this
grtype be at least equal in range and precision to the IEEE
grsingle-precision type.
data Float

-- | Double-precision floating point numbers. It is desirable that this
grtype be at least equal in range and precision to the IEEE
grdouble-precision type.
data Double

-- | Arbitrary-precision rational numbers, represented as a ratio of two
gr<a>Integer</a> values. A rational number may be constructed using the
gr<a>%</a> operator.
type Rational = Ratio Integer

-- | A <a>Word</a> is an unsigned integral type, with the same size as
gr<a>Int</a>.
data Word

-- | Basic numeric class.
class Num a
(+) :: Num a => a -> a -> a
(-) :: Num a => a -> a -> a
(*) :: Num a => a -> a -> a

-- | Unary negation.
negate :: Num a => a -> a

-- | Absolute value.
abs :: Num a => a -> a

-- | Sign of a number. The functions <a>abs</a> and <a>signum</a> should
grsatisfy the law:
gr
gr<pre>
grabs x * signum x == x
gr</pre>
gr
grFor real numbers, the <a>signum</a> is either <tt>-1</tt> (negative),
gr<tt>0</tt> (zero) or <tt>1</tt> (positive).
signum :: Num a => a -> a

-- | Conversion from an <a>Integer</a>. An integer literal represents the
grapplication of the function <a>fromInteger</a> to the appropriate
grvalue of type <a>Integer</a>, so such literals have type
gr<tt>(<a>Num</a> a) =&gt; a</tt>.
fromInteger :: Num a => Integer -> a
class (Num a, Ord a) => Real a

-- | the rational equivalent of its real argument with full precision
toRational :: Real a => a -> Rational

-- | Integral numbers, supporting integer division.
class (Real a, Enum a) => Integral a

-- | integer division truncated toward zero
quot :: Integral a => a -> a -> a

-- | integer remainder, satisfying
gr
gr<pre>
gr(x `quot` y)*y + (x `rem` y) == x
gr</pre>
rem :: Integral a => a -> a -> a

-- | integer division truncated toward negative infinity
div :: Integral a => a -> a -> a

-- | integer modulus, satisfying
gr
gr<pre>
gr(x `div` y)*y + (x `mod` y) == x
gr</pre>
mod :: Integral a => a -> a -> a

-- | simultaneous <a>quot</a> and <a>rem</a>
quotRem :: Integral a => a -> a -> (a, a)

-- | simultaneous <a>div</a> and <a>mod</a>
divMod :: Integral a => a -> a -> (a, a)

-- | conversion to <a>Integer</a>
toInteger :: Integral a => a -> Integer

-- | Fractional numbers, supporting real division.
class (Num a) => Fractional a

-- | fractional division
(/) :: Fractional a => a -> a -> a

-- | reciprocal fraction
recip :: Fractional a => a -> a

-- | Conversion from a <a>Rational</a> (that is <tt><a>Ratio</a>
gr<a>Integer</a></tt>). A floating literal stands for an application of
gr<a>fromRational</a> to a value of type <a>Rational</a>, so such
grliterals have type <tt>(<a>Fractional</a> a) =&gt; a</tt>.
fromRational :: Fractional a => Rational -> a

-- | Trigonometric and hyperbolic functions and related functions.
class (Fractional a) => Floating a
pi :: Floating a => a
exp :: Floating a => a -> a
log :: Floating a => a -> a
sqrt :: Floating a => a -> a
(**) :: Floating a => a -> a -> a
logBase :: Floating a => a -> a -> a
sin :: Floating a => a -> a
cos :: Floating a => a -> a
tan :: Floating a => a -> a
asin :: Floating a => a -> a
acos :: Floating a => a -> a
atan :: Floating a => a -> a
sinh :: Floating a => a -> a
cosh :: Floating a => a -> a
tanh :: Floating a => a -> a
asinh :: Floating a => a -> a
acosh :: Floating a => a -> a
atanh :: Floating a => a -> a

-- | Extracting components of fractions.
class (Real a, Fractional a) => RealFrac a

-- | The function <a>properFraction</a> takes a real fractional number
gr<tt>x</tt> and returns a pair <tt>(n,f)</tt> such that <tt>x =
grn+f</tt>, and:
gr
gr<ul>
gr<li><tt>n</tt> is an integral number with the same sign as <tt>x</tt>;
grand</li>
gr<li><tt>f</tt> is a fraction with the same type and sign as
gr<tt>x</tt>, and with absolute value less than <tt>1</tt>.</li>
gr</ul>
gr
grThe default definitions of the <a>ceiling</a>, <a>floor</a>,
gr<a>truncate</a> and <a>round</a> functions are in terms of
gr<a>properFraction</a>.
properFraction :: (RealFrac a, (Integral b)) => a -> (b, a)

-- | <tt><a>truncate</a> x</tt> returns the integer nearest <tt>x</tt>
grbetween zero and <tt>x</tt>
truncate :: (RealFrac a, (Integral b)) => a -> b

-- | <tt><a>round</a> x</tt> returns the nearest integer to <tt>x</tt>; the
greven integer if <tt>x</tt> is equidistant between two integers
round :: (RealFrac a, (Integral b)) => a -> b

-- | <tt><a>ceiling</a> x</tt> returns the least integer not less than
gr<tt>x</tt>
ceiling :: (RealFrac a, (Integral b)) => a -> b

-- | <tt><a>floor</a> x</tt> returns the greatest integer not greater than
gr<tt>x</tt>
floor :: (RealFrac a, (Integral b)) => a -> b

-- | Efficient, machine-independent access to the components of a
grfloating-point number.
class (RealFrac a, Floating a) => RealFloat a

-- | a constant function, returning the radix of the representation (often
gr<tt>2</tt>)
floatRadix :: RealFloat a => a -> Integer

-- | a constant function, returning the number of digits of
gr<a>floatRadix</a> in the significand
floatDigits :: RealFloat a => a -> Int

-- | a constant function, returning the lowest and highest values the
grexponent may assume
floatRange :: RealFloat a => a -> (Int, Int)

-- | The function <a>decodeFloat</a> applied to a real floating-point
grnumber returns the significand expressed as an <a>Integer</a> and an
grappropriately scaled exponent (an <a>Int</a>). If
gr<tt><a>decodeFloat</a> x</tt> yields <tt>(m,n)</tt>, then <tt>x</tt>
gris equal in value to <tt>m*b^^n</tt>, where <tt>b</tt> is the
grfloating-point radix, and furthermore, either <tt>m</tt> and
gr<tt>n</tt> are both zero or else <tt>b^(d-1) &lt;= <a>abs</a> m &lt;
grb^d</tt>, where <tt>d</tt> is the value of <tt><a>floatDigits</a>
grx</tt>. In particular, <tt><a>decodeFloat</a> 0 = (0,0)</tt>. If the
grtype contains a negative zero, also <tt><a>decodeFloat</a> (-0.0) =
gr(0,0)</tt>. <i>The result of</i> <tt><a>decodeFloat</a> x</tt> <i>is
grunspecified if either of</i> <tt><a>isNaN</a> x</tt> <i>or</i>
gr<tt><a>isInfinite</a> x</tt> <i>is</i> <a>True</a>.
decodeFloat :: RealFloat a => a -> (Integer, Int)

-- | <a>encodeFloat</a> performs the inverse of <a>decodeFloat</a> in the
grsense that for finite <tt>x</tt> with the exception of <tt>-0.0</tt>,
gr<tt><tt>uncurry</tt> <a>encodeFloat</a> (<a>decodeFloat</a> x) =
grx</tt>. <tt><a>encodeFloat</a> m n</tt> is one of the two closest
grrepresentable floating-point numbers to <tt>m*b^^n</tt> (or
gr<tt>±Infinity</tt> if overflow occurs); usually the closer, but if
gr<tt>m</tt> contains too many bits, the result may be rounded in the
grwrong direction.
encodeFloat :: RealFloat a => Integer -> Int -> a

-- | <a>exponent</a> corresponds to the second component of
gr<a>decodeFloat</a>. <tt><a>exponent</a> 0 = 0</tt> and for finite
grnonzero <tt>x</tt>, <tt><a>exponent</a> x = snd (<a>decodeFloat</a> x)
gr+ <a>floatDigits</a> x</tt>. If <tt>x</tt> is a finite floating-point
grnumber, it is equal in value to <tt><a>significand</a> x * b ^^
gr<a>exponent</a> x</tt>, where <tt>b</tt> is the floating-point radix.
grThe behaviour is unspecified on infinite or <tt>NaN</tt> values.
exponent :: RealFloat a => a -> Int

-- | The first component of <a>decodeFloat</a>, scaled to lie in the open
grinterval (<tt>-1</tt>,<tt>1</tt>), either <tt>0.0</tt> or of absolute
grvalue <tt>&gt;= 1/b</tt>, where <tt>b</tt> is the floating-point
grradix. The behaviour is unspecified on infinite or <tt>NaN</tt>
grvalues.
significand :: RealFloat a => a -> a

-- | multiplies a floating-point number by an integer power of the radix
scaleFloat :: RealFloat a => Int -> a -> a

-- | <a>True</a> if the argument is an IEEE "not-a-number" (NaN) value
isNaN :: RealFloat a => a -> Bool

-- | <a>True</a> if the argument is an IEEE infinity or negative infinity
isInfinite :: RealFloat a => a -> Bool

-- | <a>True</a> if the argument is too small to be represented in
grnormalized format
isDenormalized :: RealFloat a => a -> Bool

-- | <a>True</a> if the argument is an IEEE negative zero
isNegativeZero :: RealFloat a => a -> Bool

-- | <a>True</a> if the argument is an IEEE floating point number
isIEEE :: RealFloat a => a -> Bool

-- | a version of arctangent taking two real floating-point arguments. For
grreal floating <tt>x</tt> and <tt>y</tt>, <tt><a>atan2</a> y x</tt>
grcomputes the angle (from the positive x-axis) of the vector from the
grorigin to the point <tt>(x,y)</tt>. <tt><a>atan2</a> y x</tt> returns
gra value in the range [<tt>-pi</tt>, <tt>pi</tt>]. It follows the
grCommon Lisp semantics for the origin when signed zeroes are supported.
gr<tt><a>atan2</a> y 1</tt>, with <tt>y</tt> in a type that is
gr<a>RealFloat</a>, should return the same value as <tt><a>atan</a>
gry</tt>. A default definition of <a>atan2</a> is provided, but
grimplementors can provide a more accurate implementation.
atan2 :: RealFloat a => a -> a -> a

-- | the same as <tt><a>flip</a> (<a>-</a>)</tt>.
gr
grBecause <tt>-</tt> is treated specially in the Haskell grammar,
gr<tt>(-</tt> <i>e</i><tt>)</tt> is not a section, but an application of
grprefix negation. However, <tt>(<a>subtract</a></tt>
gr<i>exp</i><tt>)</tt> is equivalent to the disallowed section.
subtract :: (Num a) => a -> a -> a
even :: (Integral a) => a -> Bool
odd :: (Integral a) => a -> Bool

-- | <tt><a>gcd</a> x y</tt> is the non-negative factor of both <tt>x</tt>
grand <tt>y</tt> of which every common factor of <tt>x</tt> and
gr<tt>y</tt> is also a factor; for example <tt><a>gcd</a> 4 2 = 2</tt>,
gr<tt><a>gcd</a> (-4) 6 = 2</tt>, <tt><a>gcd</a> 0 4</tt> = <tt>4</tt>.
gr<tt><a>gcd</a> 0 0</tt> = <tt>0</tt>. (That is, the common divisor
grthat is "greatest" in the divisibility preordering.)
gr
grNote: Since for signed fixed-width integer types, <tt><a>abs</a>
gr<a>minBound</a> &lt; 0</tt>, the result may be negative if one of the
grarguments is <tt><a>minBound</a></tt> (and necessarily is if the other
gris <tt>0</tt> or <tt><a>minBound</a></tt>) for such types.
gcd :: (Integral a) => a -> a -> a

-- | <tt><a>lcm</a> x y</tt> is the smallest positive integer that both
gr<tt>x</tt> and <tt>y</tt> divide.
lcm :: (Integral a) => a -> a -> a

-- | raise a number to a non-negative integral power
(^) :: (Num a, Integral b) => a -> b -> a
infixr 8 ^

-- | raise a number to an integral power
(^^) :: (Fractional a, Integral b) => a -> b -> a
infixr 8 ^^

-- | general coercion from integral types
fromIntegral :: (Integral a, Num b) => a -> b

-- | general coercion to fractional types
realToFrac :: (Real a, Fractional b) => a -> b

-- | The class of semigroups (types with an associative binary operation).
gr
grInstances should satisfy the associativity law:
gr
gr<ul>
gr<li><pre>x <a>&lt;&gt;</a> (y <a>&lt;&gt;</a> z) = (x <a>&lt;&gt;</a>
gry) <a>&lt;&gt;</a> z</pre></li>
gr</ul>
class Semigroup a

-- | An associative operation.
(<>) :: Semigroup a => a -> a -> a

-- | The class of monoids (types with an associative binary operation that
grhas an identity). Instances should satisfy the following laws:
gr
gr<ul>
gr<li><pre>x <a>&lt;&gt;</a> <a>mempty</a> = x</pre></li>
gr<li><pre><a>mempty</a> <a>&lt;&gt;</a> x = x</pre></li>
gr<li><tt>x <a>&lt;&gt;</a> (y <a>&lt;&gt;</a> z) = (x <a>&lt;&gt;</a>
gry) <a>&lt;&gt;</a> z</tt> (<a>Semigroup</a> law)</li>
gr<li><pre><a>mconcat</a> = <a>foldr</a> '(&lt;&gt;)'
gr<a>mempty</a></pre></li>
gr</ul>
gr
grThe method names refer to the monoid of lists under concatenation, but
grthere are many other instances.
gr
grSome types can be viewed as a monoid in more than one way, e.g. both
graddition and multiplication on numbers. In such cases we often define
gr<tt>newtype</tt>s and make those instances of <a>Monoid</a>, e.g.
gr<tt>Sum</tt> and <tt>Product</tt>.
gr
gr<b>NOTE</b>: <a>Semigroup</a> is a superclass of <a>Monoid</a> since
gr<i>base-4.11.0.0</i>.
class Semigroup a => Monoid a

-- | Identity of <a>mappend</a>
mempty :: Monoid a => a

-- | An associative operation
gr
gr<b>NOTE</b>: This method is redundant and has the default
grimplementation <tt><a>mappend</a> = '(&lt;&gt;)'</tt> since
gr<i>base-4.11.0.0</i>.
mappend :: Monoid a => a -> a -> a

-- | Fold a list using the monoid.
gr
grFor most types, the default definition for <a>mconcat</a> will be
grused, but the function is included in the class definition so that an
groptimized version can be provided for specific types.
mconcat :: Monoid a => [a] -> a

-- | The <a>Functor</a> class is used for types that can be mapped over.
grInstances of <a>Functor</a> should satisfy the following laws:
gr
gr<pre>
grfmap id  ==  id
grfmap (f . g)  ==  fmap f . fmap g
gr</pre>
gr
grThe instances of <a>Functor</a> for lists, <a>Maybe</a> and <a>IO</a>
grsatisfy these laws.
class Functor f
fmap :: Functor f => (a -> b) -> f a -> f b

-- | Replace all locations in the input with the same value. The default
grdefinition is <tt><a>fmap</a> . <a>const</a></tt>, but this may be
groverridden with a more efficient version.
(<$) :: Functor f => a -> f b -> f a

-- | An infix synonym for <a>fmap</a>.
gr
grThe name of this operator is an allusion to <tt>$</tt>. Note the
grsimilarities between their types:
gr
gr<pre>
gr ($)  ::              (a -&gt; b) -&gt;   a -&gt;   b
gr(&lt;$&gt;) :: Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
gr</pre>
gr
grWhereas <tt>$</tt> is function application, <a>&lt;$&gt;</a> is
grfunction application lifted over a <a>Functor</a>.
gr
gr<h4><b>Examples</b></h4>
gr
grConvert from a <tt><tt>Maybe</tt> <tt>Int</tt></tt> to a
gr<tt><tt>Maybe</tt> <tt>String</tt></tt> using <tt>show</tt>:
gr
gr<pre>
gr&gt;&gt;&gt; show &lt;$&gt; Nothing
grNothing
gr
gr&gt;&gt;&gt; show &lt;$&gt; Just 3
grJust "3"
gr</pre>
gr
grConvert from an <tt><tt>Either</tt> <tt>Int</tt> <tt>Int</tt></tt> to
gran <tt><tt>Either</tt> <tt>Int</tt></tt> <tt>String</tt> using
gr<tt>show</tt>:
gr
gr<pre>
gr&gt;&gt;&gt; show &lt;$&gt; Left 17
grLeft 17
gr
gr&gt;&gt;&gt; show &lt;$&gt; Right 17
grRight "17"
gr</pre>
gr
grDouble each element of a list:
gr
gr<pre>
gr&gt;&gt;&gt; (*2) &lt;$&gt; [1,2,3]
gr[2,4,6]
gr</pre>
gr
grApply <tt>even</tt> to the second element of a pair:
gr
gr<pre>
gr&gt;&gt;&gt; even &lt;$&gt; (2,2)
gr(2,True)
gr</pre>
(<$>) :: Functor f => (a -> b) -> f a -> f b
infixl 4 <$>

-- | A functor with application, providing operations to
gr
gr<ul>
gr<li>embed pure expressions (<a>pure</a>), and</li>
gr<li>sequence computations and combine their results (<a>&lt;*&gt;</a>
grand <a>liftA2</a>).</li>
gr</ul>
gr
grA minimal complete definition must include implementations of
gr<a>pure</a> and of either <a>&lt;*&gt;</a> or <a>liftA2</a>. If it
grdefines both, then they must behave the same as their default
grdefinitions:
gr
gr<pre>
gr(<a>&lt;*&gt;</a>) = <a>liftA2</a> <a>id</a>
gr</pre>
gr
gr<pre>
gr<a>liftA2</a> f x y = f <tt>&lt;$&gt;</tt> x <a>&lt;*&gt;</a> y
gr</pre>
gr
grFurther, any definition must satisfy the following:
gr
gr<ul>
gr<li><i><i>identity</i></i> <pre><a>pure</a> <a>id</a> <a>&lt;*&gt;</a>
grv = v</pre></li>
gr<li><i><i>composition</i></i> <pre><a>pure</a> (.) <a>&lt;*&gt;</a> u
gr<a>&lt;*&gt;</a> v <a>&lt;*&gt;</a> w = u <a>&lt;*&gt;</a> (v
gr<a>&lt;*&gt;</a> w)</pre></li>
gr<li><i><i>homomorphism</i></i> <pre><a>pure</a> f <a>&lt;*&gt;</a>
gr<a>pure</a> x = <a>pure</a> (f x)</pre></li>
gr<li><i><i>interchange</i></i> <pre>u <a>&lt;*&gt;</a> <a>pure</a> y =
gr<a>pure</a> (<a>$</a> y) <a>&lt;*&gt;</a> u</pre></li>
gr</ul>
gr
grThe other methods have the following default definitions, which may be
groverridden with equivalent specialized implementations:
gr
gr<ul>
gr<li><pre>u <a>*&gt;</a> v = (<a>id</a> <a>&lt;$</a> u)
gr<a>&lt;*&gt;</a> v</pre></li>
gr<li><pre>u <a>&lt;*</a> v = <a>liftA2</a> <a>const</a> u v</pre></li>
gr</ul>
gr
grAs a consequence of these laws, the <a>Functor</a> instance for
gr<tt>f</tt> will satisfy
gr
gr<ul>
gr<li><pre><a>fmap</a> f x = <a>pure</a> f <a>&lt;*&gt;</a> x</pre></li>
gr</ul>
gr
grIt may be useful to note that supposing
gr
gr<pre>
grforall x y. p (q x y) = f x . g y
gr</pre>
gr
grit follows from the above that
gr
gr<pre>
gr<a>liftA2</a> p (<a>liftA2</a> q u v) = <a>liftA2</a> f u . <a>liftA2</a> g v
gr</pre>
gr
grIf <tt>f</tt> is also a <a>Monad</a>, it should satisfy
gr
gr<ul>
gr<li><pre><a>pure</a> = <a>return</a></pre></li>
gr<li><pre>(<a>&lt;*&gt;</a>) = <a>ap</a></pre></li>
gr<li><pre>(<a>*&gt;</a>) = (<a>&gt;&gt;</a>)</pre></li>
gr</ul>
gr
gr(which implies that <a>pure</a> and <a>&lt;*&gt;</a> satisfy the
grapplicative functor laws).
class Functor f => Applicative f

-- | Lift a value.
pure :: Applicative f => a -> f a

-- | Sequential application.
gr
grA few functors support an implementation of <a>&lt;*&gt;</a> that is
grmore efficient than the default one.
(<*>) :: Applicative f => f (a -> b) -> f a -> f b

-- | Sequence actions, discarding the value of the first argument.
(*>) :: Applicative f => f a -> f b -> f b

-- | Sequence actions, discarding the value of the second argument.
(<*) :: Applicative f => f a -> f b -> f a

-- | The <a>Monad</a> class defines the basic operations over a
gr<i>monad</i>, a concept from a branch of mathematics known as
gr<i>category theory</i>. From the perspective of a Haskell programmer,
grhowever, it is best to think of a monad as an <i>abstract datatype</i>
grof actions. Haskell's <tt>do</tt> expressions provide a convenient
grsyntax for writing monadic expressions.
gr
grInstances of <a>Monad</a> should satisfy the following laws:
gr
gr<ul>
gr<li><pre><a>return</a> a <a>&gt;&gt;=</a> k = k a</pre></li>
gr<li><pre>m <a>&gt;&gt;=</a> <a>return</a> = m</pre></li>
gr<li><pre>m <a>&gt;&gt;=</a> (\x -&gt; k x <a>&gt;&gt;=</a> h) = (m
gr<a>&gt;&gt;=</a> k) <a>&gt;&gt;=</a> h</pre></li>
gr</ul>
gr
grFurthermore, the <a>Monad</a> and <a>Applicative</a> operations should
grrelate as follows:
gr
gr<ul>
gr<li><pre><a>pure</a> = <a>return</a></pre></li>
gr<li><pre>(<a>&lt;*&gt;</a>) = <a>ap</a></pre></li>
gr</ul>
gr
grThe above laws imply:
gr
gr<ul>
gr<li><pre><a>fmap</a> f xs = xs <a>&gt;&gt;=</a> <a>return</a> .
grf</pre></li>
gr<li><pre>(<a>&gt;&gt;</a>) = (<a>*&gt;</a>)</pre></li>
gr</ul>
gr
grand that <a>pure</a> and (<a>&lt;*&gt;</a>) satisfy the applicative
grfunctor laws.
gr
grThe instances of <a>Monad</a> for lists, <a>Maybe</a> and <a>IO</a>
grdefined in the <a>Prelude</a> satisfy these laws.
class Applicative m => Monad m

-- | Sequentially compose two actions, passing any value produced by the
grfirst as an argument to the second.
(>>=) :: forall a b. Monad m => m a -> (a -> m b) -> m b

-- | Sequentially compose two actions, discarding any value produced by the
grfirst, like sequencing operators (such as the semicolon) in imperative
grlanguages.
(>>) :: forall a b. Monad m => m a -> m b -> m b

-- | Inject a value into the monadic type.
return :: Monad m => a -> m a

-- | Fail with a message. This operation is not part of the mathematical
grdefinition of a monad, but is invoked on pattern-match failure in a
gr<tt>do</tt> expression.
gr
grAs part of the MonadFail proposal (MFP), this function is moved to its
grown class <tt>MonadFail</tt> (see <a>Control.Monad.Fail</a> for more
grdetails). The definition here will be removed in a future release.
fail :: Monad m => String -> m a

-- | Map each element of a structure to a monadic action, evaluate these
gractions from left to right, and ignore the results. For a version that
grdoesn't ignore the results see <a>mapM</a>.
gr
grAs of base 4.8.0.0, <a>mapM_</a> is just <a>traverse_</a>, specialized
grto <a>Monad</a>.
mapM_ :: (Foldable t, Monad m) => (a -> m b) -> t a -> m ()

-- | Evaluate each monadic action in the structure from left to right, and
grignore the results. For a version that doesn't ignore the results see
gr<a>sequence</a>.
gr
grAs of base 4.8.0.0, <a>sequence_</a> is just <a>sequenceA_</a>,
grspecialized to <a>Monad</a>.
sequence_ :: (Foldable t, Monad m) => t (m a) -> m ()

-- | Same as <a>&gt;&gt;=</a>, but with the arguments interchanged.
(=<<) :: Monad m => (a -> m b) -> m a -> m b
infixr 1 =<<

-- | Data structures that can be folded.
gr
grFor example, given a data type
gr
gr<pre>
grdata Tree a = Empty | Leaf a | Node (Tree a) a (Tree a)
gr</pre>
gr
gra suitable instance would be
gr
gr<pre>
grinstance Foldable Tree where
gr   foldMap f Empty = mempty
gr   foldMap f (Leaf x) = f x
gr   foldMap f (Node l k r) = foldMap f l `mappend` f k `mappend` foldMap f r
gr</pre>
gr
grThis is suitable even for abstract types, as the monoid is assumed to
grsatisfy the monoid laws. Alternatively, one could define
gr<tt>foldr</tt>:
gr
gr<pre>
grinstance Foldable Tree where
gr   foldr f z Empty = z
gr   foldr f z (Leaf x) = f x z
gr   foldr f z (Node l k r) = foldr f (f k (foldr f z r)) l
gr</pre>
gr
gr<tt>Foldable</tt> instances are expected to satisfy the following
grlaws:
gr
gr<pre>
grfoldr f z t = appEndo (foldMap (Endo . f) t ) z
gr</pre>
gr
gr<pre>
grfoldl f z t = appEndo (getDual (foldMap (Dual . Endo . flip f) t)) z
gr</pre>
gr
gr<pre>
grfold = foldMap id
gr</pre>
gr
gr<pre>
grlength = getSum . foldMap (Sum . const  1)
gr</pre>
gr
gr<tt>sum</tt>, <tt>product</tt>, <tt>maximum</tt>, and <tt>minimum</tt>
grshould all be essentially equivalent to <tt>foldMap</tt> forms, such
gras
gr
gr<pre>
grsum = getSum . foldMap Sum
gr</pre>
gr
grbut may be less defined.
gr
grIf the type is also a <a>Functor</a> instance, it should satisfy
gr
gr<pre>
grfoldMap f = fold . fmap f
gr</pre>
gr
grwhich implies that
gr
gr<pre>
grfoldMap f . fmap g = foldMap (f . g)
gr</pre>
class Foldable t

-- | Map each element of the structure to a monoid, and combine the
grresults.
foldMap :: (Foldable t, Monoid m) => (a -> m) -> t a -> m

-- | Right-associative fold of a structure.
gr
grIn the case of lists, <a>foldr</a>, when applied to a binary operator,
gra starting value (typically the right-identity of the operator), and a
grlist, reduces the list using the binary operator, from right to left:
gr
gr<pre>
grfoldr f z [x1, x2, ..., xn] == x1 `f` (x2 `f` ... (xn `f` z)...)
gr</pre>
gr
grNote that, since the head of the resulting expression is produced by
gran application of the operator to the first element of the list,
gr<a>foldr</a> can produce a terminating expression from an infinite
grlist.
gr
grFor a general <a>Foldable</a> structure this should be semantically
gridentical to,
gr
gr<pre>
grfoldr f z = <a>foldr</a> f z . <a>toList</a>
gr</pre>
foldr :: Foldable t => (a -> b -> b) -> b -> t a -> b

-- | Left-associative fold of a structure.
gr
grIn the case of lists, <a>foldl</a>, when applied to a binary operator,
gra starting value (typically the left-identity of the operator), and a
grlist, reduces the list using the binary operator, from left to right:
gr
gr<pre>
grfoldl f z [x1, x2, ..., xn] == (...((z `f` x1) `f` x2) `f`...) `f` xn
gr</pre>
gr
grNote that to produce the outermost application of the operator the
grentire input list must be traversed. This means that <a>foldl'</a>
grwill diverge if given an infinite list.
gr
grAlso note that if you want an efficient left-fold, you probably want
grto use <a>foldl'</a> instead of <a>foldl</a>. The reason for this is
grthat latter does not force the "inner" results (e.g. <tt>z <tt>f</tt>
grx1</tt> in the above example) before applying them to the operator
gr(e.g. to <tt>(<tt>f</tt> x2)</tt>). This results in a thunk chain
gr<tt>O(n)</tt> elements long, which then must be evaluated from the
groutside-in.
gr
grFor a general <a>Foldable</a> structure this should be semantically
gridentical to,
gr
gr<pre>
grfoldl f z = <a>foldl</a> f z . <a>toList</a>
gr</pre>
foldl :: Foldable t => (b -> a -> b) -> b -> t a -> b

-- | A variant of <a>foldr</a> that has no base case, and thus may only be
grapplied to non-empty structures.
gr
gr<pre>
gr<a>foldr1</a> f = <a>foldr1</a> f . <a>toList</a>
gr</pre>
foldr1 :: Foldable t => (a -> a -> a) -> t a -> a

-- | A variant of <a>foldl</a> that has no base case, and thus may only be
grapplied to non-empty structures.
gr
gr<pre>
gr<a>foldl1</a> f = <a>foldl1</a> f . <a>toList</a>
gr</pre>
foldl1 :: Foldable t => (a -> a -> a) -> t a -> a

-- | Does the element occur in the structure?
elem :: (Foldable t, Eq a) => a -> t a -> Bool

-- | The largest element of a non-empty structure.
maximum :: forall a. (Foldable t, Ord a) => t a -> a

-- | The least element of a non-empty structure.
minimum :: forall a. (Foldable t, Ord a) => t a -> a

-- | The <a>sum</a> function computes the sum of the numbers of a
grstructure.
sum :: (Foldable t, Num a) => t a -> a

-- | The <a>product</a> function computes the product of the numbers of a
grstructure.
product :: (Foldable t, Num a) => t a -> a

-- | Functors representing data structures that can be traversed from left
grto right.
gr
grA definition of <a>traverse</a> must satisfy the following laws:
gr
gr<ul>
gr<li><i><i>naturality</i></i> <tt>t . <a>traverse</a> f =
gr<a>traverse</a> (t . f)</tt> for every applicative transformation
gr<tt>t</tt></li>
gr<li><i><i>identity</i></i> <tt><a>traverse</a> Identity =
grIdentity</tt></li>
gr<li><i><i>composition</i></i> <tt><a>traverse</a> (Compose .
gr<a>fmap</a> g . f) = Compose . <a>fmap</a> (<a>traverse</a> g) .
gr<a>traverse</a> f</tt></li>
gr</ul>
gr
grA definition of <a>sequenceA</a> must satisfy the following laws:
gr
gr<ul>
gr<li><i><i>naturality</i></i> <tt>t . <a>sequenceA</a> =
gr<a>sequenceA</a> . <a>fmap</a> t</tt> for every applicative
grtransformation <tt>t</tt></li>
gr<li><i><i>identity</i></i> <tt><a>sequenceA</a> . <a>fmap</a> Identity
gr= Identity</tt></li>
gr<li><i><i>composition</i></i> <tt><a>sequenceA</a> . <a>fmap</a>
grCompose = Compose . <a>fmap</a> <a>sequenceA</a> .
gr<a>sequenceA</a></tt></li>
gr</ul>
gr
grwhere an <i>applicative transformation</i> is a function
gr
gr<pre>
grt :: (Applicative f, Applicative g) =&gt; f a -&gt; g a
gr</pre>
gr
grpreserving the <a>Applicative</a> operations, i.e.
gr
gr<ul>
gr<li><pre>t (<a>pure</a> x) = <a>pure</a> x</pre></li>
gr<li><pre>t (x <a>&lt;*&gt;</a> y) = t x <a>&lt;*&gt;</a> t
gry</pre></li>
gr</ul>
gr
grand the identity functor <tt>Identity</tt> and composition of functors
gr<tt>Compose</tt> are defined as
gr
gr<pre>
grnewtype Identity a = Identity a
gr
grinstance Functor Identity where
gr  fmap f (Identity x) = Identity (f x)
gr
grinstance Applicative Identity where
gr  pure x = Identity x
gr  Identity f &lt;*&gt; Identity x = Identity (f x)
gr
grnewtype Compose f g a = Compose (f (g a))
gr
grinstance (Functor f, Functor g) =&gt; Functor (Compose f g) where
gr  fmap f (Compose x) = Compose (fmap (fmap f) x)
gr
grinstance (Applicative f, Applicative g) =&gt; Applicative (Compose f g) where
gr  pure x = Compose (pure (pure x))
gr  Compose f &lt;*&gt; Compose x = Compose ((&lt;*&gt;) &lt;$&gt; f &lt;*&gt; x)
gr</pre>
gr
gr(The naturality law is implied by parametricity.)
gr
grInstances are similar to <a>Functor</a>, e.g. given a data type
gr
gr<pre>
grdata Tree a = Empty | Leaf a | Node (Tree a) a (Tree a)
gr</pre>
gr
gra suitable instance would be
gr
gr<pre>
grinstance Traversable Tree where
gr   traverse f Empty = pure Empty
gr   traverse f (Leaf x) = Leaf &lt;$&gt; f x
gr   traverse f (Node l k r) = Node &lt;$&gt; traverse f l &lt;*&gt; f k &lt;*&gt; traverse f r
gr</pre>
gr
grThis is suitable even for abstract types, as the laws for
gr<a>&lt;*&gt;</a> imply a form of associativity.
gr
grThe superclass instances should satisfy the following:
gr
gr<ul>
gr<li>In the <a>Functor</a> instance, <a>fmap</a> should be equivalent
grto traversal with the identity applicative functor
gr(<a>fmapDefault</a>).</li>
gr<li>In the <a>Foldable</a> instance, <a>foldMap</a> should be
grequivalent to traversal with a constant applicative functor
gr(<a>foldMapDefault</a>).</li>
gr</ul>
class (Functor t, Foldable t) => Traversable t

-- | Map each element of a structure to an action, evaluate these actions
grfrom left to right, and collect the results. For a version that
grignores the results see <a>traverse_</a>.
traverse :: (Traversable t, Applicative f) => (a -> f b) -> t a -> f (t b)

-- | Evaluate each action in the structure from left to right, and and
grcollect the results. For a version that ignores the results see
gr<a>sequenceA_</a>.
sequenceA :: (Traversable t, Applicative f) => t (f a) -> f (t a)

-- | Map each element of a structure to a monadic action, evaluate these
gractions from left to right, and collect the results. For a version
grthat ignores the results see <a>mapM_</a>.
mapM :: (Traversable t, Monad m) => (a -> m b) -> t a -> m (t b)

-- | Evaluate each monadic action in the structure from left to right, and
grcollect the results. For a version that ignores the results see
gr<a>sequence_</a>.
sequence :: (Traversable t, Monad m) => t (m a) -> m (t a)

-- | Identity function.
gr
gr<pre>
grid x = x
gr</pre>
id :: a -> a

-- | <tt>const x</tt> is a unary function which evaluates to <tt>x</tt> for
grall inputs.
gr
gr<pre>
gr&gt;&gt;&gt; const 42 "hello"
gr42
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; map (const 42) [0..3]
gr[42,42,42,42]
gr</pre>
const :: a -> b -> a

-- | Function composition.
(.) :: (b -> c) -> (a -> b) -> a -> c
infixr 9 .

-- | <tt><a>flip</a> f</tt> takes its (first) two arguments in the reverse
grorder of <tt>f</tt>.
gr
gr<pre>
gr&gt;&gt;&gt; flip (++) "hello" "world"
gr"worldhello"
gr</pre>
flip :: (a -> b -> c) -> b -> a -> c

-- | Application operator. This operator is redundant, since ordinary
grapplication <tt>(f x)</tt> means the same as <tt>(f <a>$</a> x)</tt>.
grHowever, <a>$</a> has low, right-associative binding precedence, so it
grsometimes allows parentheses to be omitted; for example:
gr
gr<pre>
grf $ g $ h x  =  f (g (h x))
gr</pre>
gr
grIt is also useful in higher-order situations, such as <tt><a>map</a>
gr(<a>$</a> 0) xs</tt>, or <tt><a>zipWith</a> (<a>$</a>) fs xs</tt>.
($) :: (a -> b) -> a -> b
infixr 0 $

-- | <tt><a>until</a> p f</tt> yields the result of applying <tt>f</tt>
gruntil <tt>p</tt> holds.
until :: (a -> Bool) -> (a -> a) -> a -> a

-- | <a>asTypeOf</a> is a type-restricted version of <a>const</a>. It is
grusually used as an infix operator, and its typing forces its first
grargument (which is usually overloaded) to have the same type as the
grsecond.
asTypeOf :: a -> a -> a

-- | <a>error</a> stops execution and displays an error message.
error :: forall (r :: RuntimeRep). forall (a :: TYPE r). HasCallStack => [Char] -> a

-- | A variant of <a>error</a> that does not produce a stack trace.
errorWithoutStackTrace :: forall (r :: RuntimeRep). forall (a :: TYPE r). [Char] -> a

-- | A special case of <a>error</a>. It is expected that compilers will
grrecognize this and insert error messages which are more appropriate to
grthe context in which <a>undefined</a> appears.
undefined :: forall (r :: RuntimeRep). forall (a :: TYPE r). HasCallStack => a

-- | The value of <tt>seq a b</tt> is bottom if <tt>a</tt> is bottom, and
grotherwise equal to <tt>b</tt>. In other words, it evaluates the first
grargument <tt>a</tt> to weak head normal form (WHNF). <tt>seq</tt> is
grusually introduced to improve performance by avoiding unneeded
grlaziness.
gr
grA note on evaluation order: the expression <tt>seq a b</tt> does
gr<i>not</i> guarantee that <tt>a</tt> will be evaluated before
gr<tt>b</tt>. The only guarantee given by <tt>seq</tt> is that the both
gr<tt>a</tt> and <tt>b</tt> will be evaluated before <tt>seq</tt>
grreturns a value. In particular, this means that <tt>b</tt> may be
grevaluated before <tt>a</tt>. If you need to guarantee a specific order
grof evaluation, you must use the function <tt>pseq</tt> from the
gr"parallel" package.
seq :: () => a -> b -> b

-- | Strict (call-by-value) application operator. It takes a function and
gran argument, evaluates the argument to weak head normal form (WHNF),
grthen calls the function with that value.
($!) :: (a -> b) -> a -> b
infixr 0 $!

-- | <a>map</a> <tt>f xs</tt> is the list obtained by applying <tt>f</tt>
grto each element of <tt>xs</tt>, i.e.,
gr
gr<pre>
grmap f [x1, x2, ..., xn] == [f x1, f x2, ..., f xn]
grmap f [x1, x2, ...] == [f x1, f x2, ...]
gr</pre>
map :: (a -> b) -> [a] -> [b]

-- | Append two lists, i.e.,
gr
gr<pre>
gr[x1, ..., xm] ++ [y1, ..., yn] == [x1, ..., xm, y1, ..., yn]
gr[x1, ..., xm] ++ [y1, ...] == [x1, ..., xm, y1, ...]
gr</pre>
gr
grIf the first list is not finite, the result is the first list.
(++) :: [a] -> [a] -> [a]
infixr 5 ++

-- | <a>filter</a>, applied to a predicate and a list, returns the list of
grthose elements that satisfy the predicate; i.e.,
gr
gr<pre>
grfilter p xs = [ x | x &lt;- xs, p x]
gr</pre>
filter :: (a -> Bool) -> [a] -> [a]

-- | Extract the first element of a list, which must be non-empty.
head :: [a] -> a

-- | Extract the last element of a list, which must be finite and
grnon-empty.
last :: [a] -> a

-- | Extract the elements after the head of a list, which must be
grnon-empty.
tail :: [a] -> [a]

-- | Return all the elements of a list except the last one. The list must
grbe non-empty.
init :: [a] -> [a]

-- | Test whether the structure is empty. The default implementation is
groptimized for structures that are similar to cons-lists, because there
gris no general way to do better.
null :: Foldable t => t a -> Bool

-- | Returns the size/length of a finite structure as an <a>Int</a>. The
grdefault implementation is optimized for structures that are similar to
grcons-lists, because there is no general way to do better.
length :: Foldable t => t a -> Int

-- | List index (subscript) operator, starting from 0. It is an instance of
grthe more general <a>genericIndex</a>, which takes an index of any
grintegral type.
(!!) :: [a] -> Int -> a
infixl 9 !!

-- | <a>reverse</a> <tt>xs</tt> returns the elements of <tt>xs</tt> in
grreverse order. <tt>xs</tt> must be finite.
reverse :: [a] -> [a]

-- | <a>and</a> returns the conjunction of a container of Bools. For the
grresult to be <a>True</a>, the container must be finite; <a>False</a>,
grhowever, results from a <a>False</a> value finitely far from the left
grend.
and :: Foldable t => t Bool -> Bool

-- | <a>or</a> returns the disjunction of a container of Bools. For the
grresult to be <a>False</a>, the container must be finite; <a>True</a>,
grhowever, results from a <a>True</a> value finitely far from the left
grend.
or :: Foldable t => t Bool -> Bool

-- | Determines whether any element of the structure satisfies the
grpredicate.
any :: Foldable t => (a -> Bool) -> t a -> Bool

-- | Determines whether all elements of the structure satisfy the
grpredicate.
all :: Foldable t => (a -> Bool) -> t a -> Bool

-- | The concatenation of all the elements of a container of lists.
concat :: Foldable t => t [a] -> [a]

-- | Map a function over all the elements of a container and concatenate
grthe resulting lists.
concatMap :: Foldable t => (a -> [b]) -> t a -> [b]

-- | <a>scanl</a> is similar to <a>foldl</a>, but returns a list of
grsuccessive reduced values from the left:
gr
gr<pre>
grscanl f z [x1, x2, ...] == [z, z `f` x1, (z `f` x1) `f` x2, ...]
gr</pre>
gr
grNote that
gr
gr<pre>
grlast (scanl f z xs) == foldl f z xs.
gr</pre>
scanl :: (b -> a -> b) -> b -> [a] -> [b]

-- | <a>scanl1</a> is a variant of <a>scanl</a> that has no starting value
grargument:
gr
gr<pre>
grscanl1 f [x1, x2, ...] == [x1, x1 `f` x2, ...]
gr</pre>
scanl1 :: (a -> a -> a) -> [a] -> [a]

-- | <a>scanr</a> is the right-to-left dual of <a>scanl</a>. Note that
gr
gr<pre>
grhead (scanr f z xs) == foldr f z xs.
gr</pre>
scanr :: (a -> b -> b) -> b -> [a] -> [b]

-- | <a>scanr1</a> is a variant of <a>scanr</a> that has no starting value
grargument.
scanr1 :: (a -> a -> a) -> [a] -> [a]

-- | <a>iterate</a> <tt>f x</tt> returns an infinite list of repeated
grapplications of <tt>f</tt> to <tt>x</tt>:
gr
gr<pre>
griterate f x == [x, f x, f (f x), ...]
gr</pre>
gr
grNote that <a>iterate</a> is lazy, potentially leading to thunk
grbuild-up if the consumer doesn't force each iterate. See 'iterate\''
grfor a strict variant of this function.
iterate :: (a -> a) -> a -> [a]

-- | <a>repeat</a> <tt>x</tt> is an infinite list, with <tt>x</tt> the
grvalue of every element.
repeat :: a -> [a]

-- | <a>replicate</a> <tt>n x</tt> is a list of length <tt>n</tt> with
gr<tt>x</tt> the value of every element. It is an instance of the more
grgeneral <a>genericReplicate</a>, in which <tt>n</tt> may be of any
grintegral type.
replicate :: Int -> a -> [a]

-- | <a>cycle</a> ties a finite list into a circular one, or equivalently,
grthe infinite repetition of the original list. It is the identity on
grinfinite lists.
cycle :: [a] -> [a]

-- | <a>take</a> <tt>n</tt>, applied to a list <tt>xs</tt>, returns the
grprefix of <tt>xs</tt> of length <tt>n</tt>, or <tt>xs</tt> itself if
gr<tt>n &gt; <a>length</a> xs</tt>:
gr
gr<pre>
grtake 5 "Hello World!" == "Hello"
grtake 3 [1,2,3,4,5] == [1,2,3]
grtake 3 [1,2] == [1,2]
grtake 3 [] == []
grtake (-1) [1,2] == []
grtake 0 [1,2] == []
gr</pre>
gr
grIt is an instance of the more general <a>genericTake</a>, in which
gr<tt>n</tt> may be of any integral type.
take :: Int -> [a] -> [a]

-- | <a>drop</a> <tt>n xs</tt> returns the suffix of <tt>xs</tt> after the
grfirst <tt>n</tt> elements, or <tt>[]</tt> if <tt>n &gt; <a>length</a>
grxs</tt>:
gr
gr<pre>
grdrop 6 "Hello World!" == "World!"
grdrop 3 [1,2,3,4,5] == [4,5]
grdrop 3 [1,2] == []
grdrop 3 [] == []
grdrop (-1) [1,2] == [1,2]
grdrop 0 [1,2] == [1,2]
gr</pre>
gr
grIt is an instance of the more general <a>genericDrop</a>, in which
gr<tt>n</tt> may be of any integral type.
drop :: Int -> [a] -> [a]

-- | <a>splitAt</a> <tt>n xs</tt> returns a tuple where first element is
gr<tt>xs</tt> prefix of length <tt>n</tt> and second element is the
grremainder of the list:
gr
gr<pre>
grsplitAt 6 "Hello World!" == ("Hello ","World!")
grsplitAt 3 [1,2,3,4,5] == ([1,2,3],[4,5])
grsplitAt 1 [1,2,3] == ([1],[2,3])
grsplitAt 3 [1,2,3] == ([1,2,3],[])
grsplitAt 4 [1,2,3] == ([1,2,3],[])
grsplitAt 0 [1,2,3] == ([],[1,2,3])
grsplitAt (-1) [1,2,3] == ([],[1,2,3])
gr</pre>
gr
grIt is equivalent to <tt>(<a>take</a> n xs, <a>drop</a> n xs)</tt> when
gr<tt>n</tt> is not <tt>_|_</tt> (<tt>splitAt _|_ xs = _|_</tt>).
gr<a>splitAt</a> is an instance of the more general
gr<a>genericSplitAt</a>, in which <tt>n</tt> may be of any integral
grtype.
splitAt :: Int -> [a] -> ([a], [a])

-- | <a>takeWhile</a>, applied to a predicate <tt>p</tt> and a list
gr<tt>xs</tt>, returns the longest prefix (possibly empty) of
gr<tt>xs</tt> of elements that satisfy <tt>p</tt>:
gr
gr<pre>
grtakeWhile (&lt; 3) [1,2,3,4,1,2,3,4] == [1,2]
grtakeWhile (&lt; 9) [1,2,3] == [1,2,3]
grtakeWhile (&lt; 0) [1,2,3] == []
gr</pre>
takeWhile :: (a -> Bool) -> [a] -> [a]

-- | <a>dropWhile</a> <tt>p xs</tt> returns the suffix remaining after
gr<a>takeWhile</a> <tt>p xs</tt>:
gr
gr<pre>
grdropWhile (&lt; 3) [1,2,3,4,5,1,2,3] == [3,4,5,1,2,3]
grdropWhile (&lt; 9) [1,2,3] == []
grdropWhile (&lt; 0) [1,2,3] == [1,2,3]
gr</pre>
dropWhile :: (a -> Bool) -> [a] -> [a]

-- | <a>span</a>, applied to a predicate <tt>p</tt> and a list <tt>xs</tt>,
grreturns a tuple where first element is longest prefix (possibly empty)
grof <tt>xs</tt> of elements that satisfy <tt>p</tt> and second element
gris the remainder of the list:
gr
gr<pre>
grspan (&lt; 3) [1,2,3,4,1,2,3,4] == ([1,2],[3,4,1,2,3,4])
grspan (&lt; 9) [1,2,3] == ([1,2,3],[])
grspan (&lt; 0) [1,2,3] == ([],[1,2,3])
gr</pre>
gr
gr<a>span</a> <tt>p xs</tt> is equivalent to <tt>(<a>takeWhile</a> p xs,
gr<a>dropWhile</a> p xs)</tt>
span :: (a -> Bool) -> [a] -> ([a], [a])

-- | <a>break</a>, applied to a predicate <tt>p</tt> and a list
gr<tt>xs</tt>, returns a tuple where first element is longest prefix
gr(possibly empty) of <tt>xs</tt> of elements that <i>do not satisfy</i>
gr<tt>p</tt> and second element is the remainder of the list:
gr
gr<pre>
grbreak (&gt; 3) [1,2,3,4,1,2,3,4] == ([1,2,3],[4,1,2,3,4])
grbreak (&lt; 9) [1,2,3] == ([],[1,2,3])
grbreak (&gt; 9) [1,2,3] == ([1,2,3],[])
gr</pre>
gr
gr<a>break</a> <tt>p</tt> is equivalent to <tt><a>span</a> (<a>not</a> .
grp)</tt>.
break :: (a -> Bool) -> [a] -> ([a], [a])

-- | <a>notElem</a> is the negation of <a>elem</a>.
notElem :: (Foldable t, Eq a) => a -> t a -> Bool
infix 4 `notElem`

-- | <a>lookup</a> <tt>key assocs</tt> looks up a key in an association
grlist.
lookup :: (Eq a) => a -> [(a, b)] -> Maybe b

-- | <a>zip</a> takes two lists and returns a list of corresponding pairs.
grIf one input list is short, excess elements of the longer list are
grdiscarded.
gr
gr<a>zip</a> is right-lazy:
gr
gr<pre>
grzip [] _|_ = []
gr</pre>
zip :: [a] -> [b] -> [(a, b)]

-- | <a>zip3</a> takes three lists and returns a list of triples, analogous
grto <a>zip</a>.
zip3 :: [a] -> [b] -> [c] -> [(a, b, c)]

-- | <a>zipWith</a> generalises <a>zip</a> by zipping with the function
grgiven as the first argument, instead of a tupling function. For
grexample, <tt><a>zipWith</a> (+)</tt> is applied to two lists to
grproduce the list of corresponding sums.
gr
gr<a>zipWith</a> is right-lazy:
gr
gr<pre>
grzipWith f [] _|_ = []
gr</pre>
zipWith :: (a -> b -> c) -> [a] -> [b] -> [c]

-- | The <a>zipWith3</a> function takes a function which combines three
grelements, as well as three lists and returns a list of their
grpoint-wise combination, analogous to <a>zipWith</a>.
zipWith3 :: (a -> b -> c -> d) -> [a] -> [b] -> [c] -> [d]

-- | <a>unzip</a> transforms a list of pairs into a list of first
grcomponents and a list of second components.
unzip :: [(a, b)] -> ([a], [b])

-- | The <a>unzip3</a> function takes a list of triples and returns three
grlists, analogous to <a>unzip</a>.
unzip3 :: [(a, b, c)] -> ([a], [b], [c])

-- | <a>lines</a> breaks a string up into a list of strings at newline
grcharacters. The resulting strings do not contain newlines.
gr
grNote that after splitting the string at newline characters, the last
grpart of the string is considered a line even if it doesn't end with a
grnewline. For example,
gr
gr<pre>
gr&gt;&gt;&gt; lines ""
gr[]
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; lines "\n"
gr[""]
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; lines "one"
gr["one"]
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; lines "one\n"
gr["one"]
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; lines "one\n\n"
gr["one",""]
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; lines "one\ntwo"
gr["one","two"]
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; lines "one\ntwo\n"
gr["one","two"]
gr</pre>
gr
grThus <tt><a>lines</a> s</tt> contains at least as many elements as
grnewlines in <tt>s</tt>.
lines :: String -> [String]

-- | <a>words</a> breaks a string up into a list of words, which were
grdelimited by white space.
gr
gr<pre>
gr&gt;&gt;&gt; words "Lorem ipsum\ndolor"
gr["Lorem","ipsum","dolor"]
gr</pre>
words :: String -> [String]

-- | <a>unlines</a> is an inverse operation to <a>lines</a>. It joins
grlines, after appending a terminating newline to each.
gr
gr<pre>
gr&gt;&gt;&gt; unlines ["Hello", "World", "!"]
gr"Hello\nWorld\n!\n"
gr</pre>
unlines :: [String] -> String

-- | <a>unwords</a> is an inverse operation to <a>words</a>. It joins words
grwith separating spaces.
gr
gr<pre>
gr&gt;&gt;&gt; unwords ["Lorem", "ipsum", "dolor"]
gr"Lorem ipsum dolor"
gr</pre>
unwords :: [String] -> String

-- | The <tt>shows</tt> functions return a function that prepends the
groutput <a>String</a> to an existing <a>String</a>. This allows
grconstant-time concatenation of results using function composition.
type ShowS = String -> String

-- | Conversion of values to readable <a>String</a>s.
gr
grDerived instances of <a>Show</a> have the following properties, which
grare compatible with derived instances of <a>Read</a>:
gr
gr<ul>
gr<li>The result of <a>show</a> is a syntactically correct Haskell
grexpression containing only constants, given the fixity declarations in
grforce at the point where the type is declared. It contains only the
grconstructor names defined in the data type, parentheses, and spaces.
grWhen labelled constructor fields are used, braces, commas, field
grnames, and equal signs are also used.</li>
gr<li>If the constructor is defined to be an infix operator, then
gr<a>showsPrec</a> will produce infix applications of the
grconstructor.</li>
gr<li>the representation will be enclosed in parentheses if the
grprecedence of the top-level constructor in <tt>x</tt> is less than
gr<tt>d</tt> (associativity is ignored). Thus, if <tt>d</tt> is
gr<tt>0</tt> then the result is never surrounded in parentheses; if
gr<tt>d</tt> is <tt>11</tt> it is always surrounded in parentheses,
grunless it is an atomic expression.</li>
gr<li>If the constructor is defined using record syntax, then
gr<a>show</a> will produce the record-syntax form, with the fields given
grin the same order as the original declaration.</li>
gr</ul>
gr
grFor example, given the declarations
gr
gr<pre>
grinfixr 5 :^:
grdata Tree a =  Leaf a  |  Tree a :^: Tree a
gr</pre>
gr
grthe derived instance of <a>Show</a> is equivalent to
gr
gr<pre>
grinstance (Show a) =&gt; Show (Tree a) where
gr
gr       showsPrec d (Leaf m) = showParen (d &gt; app_prec) $
gr            showString "Leaf " . showsPrec (app_prec+1) m
gr         where app_prec = 10
gr
gr       showsPrec d (u :^: v) = showParen (d &gt; up_prec) $
gr            showsPrec (up_prec+1) u .
gr            showString " :^: "      .
gr            showsPrec (up_prec+1) v
gr         where up_prec = 5
gr</pre>
gr
grNote that right-associativity of <tt>:^:</tt> is ignored. For example,
gr
gr<ul>
gr<li><tt><a>show</a> (Leaf 1 :^: Leaf 2 :^: Leaf 3)</tt> produces the
grstring <tt>"Leaf 1 :^: (Leaf 2 :^: Leaf 3)"</tt>.</li>
gr</ul>
class Show a

-- | Convert a value to a readable <a>String</a>.
gr
gr<a>showsPrec</a> should satisfy the law
gr
gr<pre>
grshowsPrec d x r ++ s  ==  showsPrec d x (r ++ s)
gr</pre>
gr
grDerived instances of <a>Read</a> and <a>Show</a> satisfy the
grfollowing:
gr
gr<ul>
gr<li><tt>(x,"")</tt> is an element of <tt>(<a>readsPrec</a> d
gr(<a>showsPrec</a> d x ""))</tt>.</li>
gr</ul>
gr
grThat is, <a>readsPrec</a> parses the string produced by
gr<a>showsPrec</a>, and delivers the value that <a>showsPrec</a> started
grwith.
showsPrec :: Show a => Int -> a -> ShowS

-- | A specialised variant of <a>showsPrec</a>, using precedence context
grzero, and returning an ordinary <a>String</a>.
show :: Show a => a -> String

-- | The method <a>showList</a> is provided to allow the programmer to give
gra specialised way of showing lists of values. For example, this is
grused by the predefined <a>Show</a> instance of the <a>Char</a> type,
grwhere values of type <a>String</a> should be shown in double quotes,
grrather than between square brackets.
showList :: Show a => [a] -> ShowS

-- | equivalent to <a>showsPrec</a> with a precedence of 0.
shows :: (Show a) => a -> ShowS

-- | utility function converting a <a>Char</a> to a show function that
grsimply prepends the character unchanged.
showChar :: Char -> ShowS

-- | utility function converting a <a>String</a> to a show function that
grsimply prepends the string unchanged.
showString :: String -> ShowS

-- | utility function that surrounds the inner show function with
grparentheses when the <a>Bool</a> parameter is <a>True</a>.
showParen :: Bool -> ShowS -> ShowS

-- | A parser for a type <tt>a</tt>, represented as a function that takes a
gr<a>String</a> and returns a list of possible parses as
gr<tt>(a,<a>String</a>)</tt> pairs.
gr
grNote that this kind of backtracking parser is very inefficient;
grreading a large structure may be quite slow (cf <a>ReadP</a>).
type ReadS a = String -> [(a, String)]

-- | Parsing of <a>String</a>s, producing values.
gr
grDerived instances of <a>Read</a> make the following assumptions, which
grderived instances of <a>Show</a> obey:
gr
gr<ul>
gr<li>If the constructor is defined to be an infix operator, then the
grderived <a>Read</a> instance will parse only infix applications of the
grconstructor (not the prefix form).</li>
gr<li>Associativity is not used to reduce the occurrence of parentheses,
gralthough precedence may be.</li>
gr<li>If the constructor is defined using record syntax, the derived
gr<a>Read</a> will parse only the record-syntax form, and furthermore,
grthe fields must be given in the same order as the original
grdeclaration.</li>
gr<li>The derived <a>Read</a> instance allows arbitrary Haskell
grwhitespace between tokens of the input string. Extra parentheses are
gralso allowed.</li>
gr</ul>
gr
grFor example, given the declarations
gr
gr<pre>
grinfixr 5 :^:
grdata Tree a =  Leaf a  |  Tree a :^: Tree a
gr</pre>
gr
grthe derived instance of <a>Read</a> in Haskell 2010 is equivalent to
gr
gr<pre>
grinstance (Read a) =&gt; Read (Tree a) where
gr
gr        readsPrec d r =  readParen (d &gt; app_prec)
gr                         (\r -&gt; [(Leaf m,t) |
gr                                 ("Leaf",s) &lt;- lex r,
gr                                 (m,t) &lt;- readsPrec (app_prec+1) s]) r
gr
gr                      ++ readParen (d &gt; up_prec)
gr                         (\r -&gt; [(u:^:v,w) |
gr                                 (u,s) &lt;- readsPrec (up_prec+1) r,
gr                                 (":^:",t) &lt;- lex s,
gr                                 (v,w) &lt;- readsPrec (up_prec+1) t]) r
gr
gr          where app_prec = 10
gr                up_prec = 5
gr</pre>
gr
grNote that right-associativity of <tt>:^:</tt> is unused.
gr
grThe derived instance in GHC is equivalent to
gr
gr<pre>
grinstance (Read a) =&gt; Read (Tree a) where
gr
gr        readPrec = parens $ (prec app_prec $ do
gr                                 Ident "Leaf" &lt;- lexP
gr                                 m &lt;- step readPrec
gr                                 return (Leaf m))
gr
gr                     +++ (prec up_prec $ do
gr                                 u &lt;- step readPrec
gr                                 Symbol ":^:" &lt;- lexP
gr                                 v &lt;- step readPrec
gr                                 return (u :^: v))
gr
gr          where app_prec = 10
gr                up_prec = 5
gr
gr        readListPrec = readListPrecDefault
gr</pre>
gr
grWhy do both <a>readsPrec</a> and <a>readPrec</a> exist, and why does
grGHC opt to implement <a>readPrec</a> in derived <a>Read</a> instances
grinstead of <a>readsPrec</a>? The reason is that <a>readsPrec</a> is
grbased on the <a>ReadS</a> type, and although <a>ReadS</a> is mentioned
grin the Haskell 2010 Report, it is not a very efficient parser data
grstructure.
gr
gr<a>readPrec</a>, on the other hand, is based on a much more efficient
gr<a>ReadPrec</a> datatype (a.k.a "new-style parsers"), but its
grdefinition relies on the use of the <tt>RankNTypes</tt> language
grextension. Therefore, <a>readPrec</a> (and its cousin,
gr<a>readListPrec</a>) are marked as GHC-only. Nevertheless, it is
grrecommended to use <a>readPrec</a> instead of <a>readsPrec</a>
grwhenever possible for the efficiency improvements it brings.
gr
grAs mentioned above, derived <a>Read</a> instances in GHC will
grimplement <a>readPrec</a> instead of <a>readsPrec</a>. The default
grimplementations of <a>readsPrec</a> (and its cousin, <a>readList</a>)
grwill simply use <a>readPrec</a> under the hood. If you are writing a
gr<a>Read</a> instance by hand, it is recommended to write it like so:
gr
gr<pre>
grinstance <a>Read</a> T where
gr  <a>readPrec</a>     = ...
gr  <a>readListPrec</a> = <a>readListPrecDefault</a>
gr</pre>
class Read a

-- | attempts to parse a value from the front of the string, returning a
grlist of (parsed value, remaining string) pairs. If there is no
grsuccessful parse, the returned list is empty.
gr
grDerived instances of <a>Read</a> and <a>Show</a> satisfy the
grfollowing:
gr
gr<ul>
gr<li><tt>(x,"")</tt> is an element of <tt>(<a>readsPrec</a> d
gr(<a>showsPrec</a> d x ""))</tt>.</li>
gr</ul>
gr
grThat is, <a>readsPrec</a> parses the string produced by
gr<a>showsPrec</a>, and delivers the value that <a>showsPrec</a> started
grwith.
readsPrec :: Read a => Int -> ReadS a

-- | The method <a>readList</a> is provided to allow the programmer to give
gra specialised way of parsing lists of values. For example, this is
grused by the predefined <a>Read</a> instance of the <a>Char</a> type,
grwhere values of type <a>String</a> should be are expected to use
grdouble quotes, rather than square brackets.
readList :: Read a => ReadS [a]

-- | equivalent to <a>readsPrec</a> with a precedence of 0.
reads :: Read a => ReadS a

-- | <tt><a>readParen</a> <a>True</a> p</tt> parses what <tt>p</tt> parses,
grbut surrounded with parentheses.
gr
gr<tt><a>readParen</a> <a>False</a> p</tt> parses what <tt>p</tt>
grparses, but optionally surrounded with parentheses.
readParen :: Bool -> ReadS a -> ReadS a

-- | The <a>read</a> function reads input from a string, which must be
grcompletely consumed by the input process. <a>read</a> fails with an
gr<a>error</a> if the parse is unsuccessful, and it is therefore
grdiscouraged from being used in real applications. Use <a>readMaybe</a>
gror <a>readEither</a> for safe alternatives.
gr
gr<pre>
gr&gt;&gt;&gt; read "123" :: Int
gr123
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; read "hello" :: Int
gr*** Exception: Prelude.read: no parse
gr</pre>
read :: Read a => String -> a

-- | The <a>lex</a> function reads a single lexeme from the input,
grdiscarding initial white space, and returning the characters that
grconstitute the lexeme. If the input string contains only white space,
gr<a>lex</a> returns a single successful `lexeme' consisting of the
grempty string. (Thus <tt><a>lex</a> "" = [("","")]</tt>.) If there is
grno legal lexeme at the beginning of the input string, <a>lex</a> fails
gr(i.e. returns <tt>[]</tt>).
gr
grThis lexer is not completely faithful to the Haskell lexical syntax in
grthe following respects:
gr
gr<ul>
gr<li>Qualified names are not handled properly</li>
gr<li>Octal and hexadecimal numerics are not recognized as a single
grtoken</li>
gr<li>Comments are not treated properly</li>
gr</ul>
lex :: ReadS String

-- | A value of type <tt><a>IO</a> a</tt> is a computation which, when
grperformed, does some I/O before returning a value of type <tt>a</tt>.
gr
grThere is really only one way to "perform" an I/O action: bind it to
gr<tt>Main.main</tt> in your program. When your program is run, the I/O
grwill be performed. It isn't possible to perform I/O from an arbitrary
grfunction, unless that function is itself in the <a>IO</a> monad and
grcalled at some point, directly or indirectly, from <tt>Main.main</tt>.
gr
gr<a>IO</a> is a monad, so <a>IO</a> actions can be combined using
greither the do-notation or the <tt>&gt;&gt;</tt> and <tt>&gt;&gt;=</tt>
groperations from the <tt>Monad</tt> class.
data IO a

-- | Write a character to the standard output device (same as
gr<a>hPutChar</a> <a>stdout</a>).
putChar :: Char -> IO ()

-- | Write a string to the standard output device (same as <a>hPutStr</a>
gr<a>stdout</a>).
putStr :: String -> IO ()

-- | The same as <a>putStr</a>, but adds a newline character.
putStrLn :: String -> IO ()

-- | The <a>print</a> function outputs a value of any printable type to the
grstandard output device. Printable types are those that are instances
grof class <a>Show</a>; <a>print</a> converts values to strings for
groutput using the <a>show</a> operation and adds a newline.
gr
grFor example, a program to print the first 20 integers and their powers
grof 2 could be written as:
gr
gr<pre>
grmain = print ([(n, 2^n) | n &lt;- [0..19]])
gr</pre>
print :: Show a => a -> IO ()

-- | Read a character from the standard input device (same as
gr<a>hGetChar</a> <a>stdin</a>).
getChar :: IO Char

-- | Read a line from the standard input device (same as <a>hGetLine</a>
gr<a>stdin</a>).
getLine :: IO String

-- | The <a>getContents</a> operation returns all user input as a single
grstring, which is read lazily as it is needed (same as
gr<a>hGetContents</a> <a>stdin</a>).
getContents :: IO String

-- | The <a>interact</a> function takes a function of type
gr<tt>String-&gt;String</tt> as its argument. The entire input from the
grstandard input device is passed to this function as its argument, and
grthe resulting string is output on the standard output device.
interact :: (String -> String) -> IO ()

-- | File and directory names are values of type <a>String</a>, whose
grprecise meaning is operating system dependent. Files can be opened,
gryielding a handle which can then be used to operate on the contents of
grthat file.
type FilePath = String

-- | The <a>readFile</a> function reads a file and returns the contents of
grthe file as a string. The file is read lazily, on demand, as with
gr<a>getContents</a>.
readFile :: FilePath -> IO String

-- | The computation <a>writeFile</a> <tt>file str</tt> function writes the
grstring <tt>str</tt>, to the file <tt>file</tt>.
writeFile :: FilePath -> String -> IO ()

-- | The computation <a>appendFile</a> <tt>file str</tt> function appends
grthe string <tt>str</tt>, to the file <tt>file</tt>.
gr
grNote that <a>writeFile</a> and <a>appendFile</a> write a literal
grstring to a file. To write a value of any printable type, as with
gr<a>print</a>, use the <a>show</a> function to convert the value to a
grstring first.
gr
gr<pre>
grmain = appendFile "squares" (show [(x,x*x) | x &lt;- [0,0.1..2]])
gr</pre>
appendFile :: FilePath -> String -> IO ()

-- | The <a>readIO</a> function is similar to <a>read</a> except that it
grsignals parse failure to the <a>IO</a> monad instead of terminating
grthe program.
readIO :: Read a => String -> IO a

-- | The <a>readLn</a> function combines <a>getLine</a> and <a>readIO</a>.
readLn :: Read a => IO a

-- | The Haskell 2010 type for exceptions in the <a>IO</a> monad. Any I/O
groperation may raise an <a>IOError</a> instead of returning a result.
grFor a more general type of exception, including also those that arise
grin pure code, see <a>Exception</a>.
gr
grIn Haskell 2010, this is an opaque type.
type IOError = IOException

-- | Raise an <a>IOError</a> in the <a>IO</a> monad.
ioError :: IOError -> IO a

-- | Construct an <a>IOError</a> value with a string describing the error.
grThe <a>fail</a> method of the <a>IO</a> instance of the <a>Monad</a>
grclass raises a <a>userError</a>, thus:
gr
gr<pre>
grinstance Monad IO where
gr  ...
gr  fail s = ioError (userError s)
gr</pre>
userError :: String -> IOError


-- | The representations of the types <a>TyCon</a> and <a>TypeRep</a>, and
grthe function <a>mkTyCon</a> which is used by derived instances of
gr<a>Typeable</a> to construct <a>TyCon</a>s.
gr
grBe warned, these functions can be used to construct ill-kinded type
grrepresentations.
module Type.Reflection.Unsafe

-- | A concrete representation of a (monomorphic) type. <a>TypeRep</a>
grsupports reasonably efficient equality.
data TypeRep (a :: k)

-- | Construct a representation for a type application.
mkTrApp :: forall k1 k2 (a :: k1 -> k2) (b :: k1). TypeRep (a :: k1 -> k2) -> TypeRep (b :: k1) -> TypeRep (a b)

-- | Exquisitely unsafe.
mkTyCon :: String -> String -> String -> Int -> KindRep -> TyCon

-- | Observe the <a>Fingerprint</a> of a type representation
typeRepFingerprint :: TypeRep a -> Fingerprint
someTypeRepFingerprint :: SomeTypeRep -> Fingerprint

-- | The representation produced by GHC for conjuring up the kind of a
gr<tt>TypeRep</tt>. See Note [Representing TyCon kinds: KindRep] in
grTcTypeable.
data KindRep
KindRepTyConApp :: TyCon -> [KindRep] -> KindRep
KindRepVar :: !KindBndr -> KindRep
KindRepApp :: KindRep -> KindRep -> KindRep
KindRepFun :: KindRep -> KindRep -> KindRep
KindRepTYPE :: !RuntimeRep -> KindRep
KindRepTypeLitS :: TypeLitSort -> Addr# -> KindRep
KindRepTypeLitD :: TypeLitSort -> [Char] -> KindRep
data TypeLitSort
TypeLitSymbol :: TypeLitSort
TypeLitNat :: TypeLitSort
data TyCon

-- | Construct a representation for a type constructor applied at a
grmonomorphic kind.
gr
grNote that this is unsafe as it allows you to construct ill-kinded
grtypes.
mkTrCon :: forall k (a :: k). TyCon -> [SomeTypeRep] -> TypeRep a
tyConKindRep :: TyCon -> KindRep
tyConKindArgs :: TyCon -> Int
tyConFingerprint :: TyCon -> Fingerprint


-- | Optional instance of <a>Show</a> for functions:
gr
gr<pre>
grinstance Show (a -&gt; b) where
gr   showsPrec _ _ = showString \"\&lt;function\&gt;\"
gr</pre>
module Text.Show.Functions
instance GHC.Show.Show (a -> b)


-- | A C <tt>printf(3)</tt>-like formatter. This version has been extended
grby Bart Massey as per the recommendations of John Meacham and Simon
grMarlow
gr&lt;<a>http://comments.gmane.org/gmane.comp.lang.haskell.libraries/4726</a>&gt;
grto support extensible formatting for new datatypes. It has also been
grextended to support almost all C <tt>printf(3)</tt> syntax.
module Text.Printf

-- | Format a variable number of arguments with the C-style formatting
grstring.
gr
gr<pre>
gr&gt;&gt;&gt; printf "%s, %d, %.4f" "hello" 123 pi
grhello, 123, 3.1416
gr</pre>
gr
grThe return value is either <a>String</a> or <tt>(<a>IO</a> a)</tt>
gr(which should be <tt>(<a>IO</a> '()')</tt>, but Haskell's type system
grmakes this hard).
gr
grThe format string consists of ordinary characters and <i>conversion
grspecifications</i>, which specify how to format one of the arguments
grto <a>printf</a> in the output string. A format specification is
grintroduced by the <tt>%</tt> character; this character can be
grself-escaped into the format string using <tt>%%</tt>. A format
grspecification ends with a /format character/ that provides the primary
grinformation about how to format the value. The rest of the conversion
grspecification is optional. In order, one may have flag characters, a
grwidth specifier, a precision specifier, and type-specific modifier
grcharacters.
gr
grUnlike C <tt>printf(3)</tt>, the formatting of this <a>printf</a> is
grdriven by the argument type; formatting is type specific. The types
grformatted by <a>printf</a> "out of the box" are:
gr
gr<ul>
gr<li><a>Integral</a> types, including <a>Char</a></li>
gr<li><a>String</a></li>
gr<li><a>RealFloat</a> types</li>
gr</ul>
gr
gr<a>printf</a> is also extensible to support other types: see below.
gr
grA conversion specification begins with the character <tt>%</tt>,
grfollowed by zero or more of the following flags:
gr
gr<pre>
gr-      left adjust (default is right adjust)
gr+      always use a sign (+ or -) for signed conversions
grspace  leading space for positive numbers in signed conversions
gr0      pad with zeros rather than spaces
gr#      use an \"alternate form\": see below
gr</pre>
gr
grWhen both flags are given, <tt>-</tt> overrides <tt>0</tt> and
gr<tt>+</tt> overrides space. A negative width specifier in a <tt>*</tt>
grconversion is treated as positive but implies the left adjust flag.
gr
grThe "alternate form" for unsigned radix conversions is as in C
gr<tt>printf(3)</tt>:
gr
gr<pre>
gr%o           prefix with a leading 0 if needed
gr%x           prefix with a leading 0x if nonzero
gr%X           prefix with a leading 0X if nonzero
gr%b           prefix with a leading 0b if nonzero
gr%[eEfFgG]    ensure that the number contains a decimal point
gr</pre>
gr
grAny flags are followed optionally by a field width:
gr
gr<pre>
grnum    field width
gr*      as num, but taken from argument list
gr</pre>
gr
grThe field width is a minimum, not a maximum: it will be expanded as
grneeded to avoid mutilating a value.
gr
grAny field width is followed optionally by a precision:
gr
gr<pre>
gr.num   precision
gr.      same as .0
gr.*     as num, but taken from argument list
gr</pre>
gr
grNegative precision is taken as 0. The meaning of the precision depends
gron the conversion type.
gr
gr<pre>
grIntegral    minimum number of digits to show
grRealFloat   number of digits after the decimal point
grString      maximum number of characters
gr</pre>
gr
grThe precision for Integral types is accomplished by zero-padding. If
grboth precision and zero-pad are given for an Integral field, the
grzero-pad is ignored.
gr
grAny precision is followed optionally for Integral types by a width
grmodifier; the only use of this modifier being to set the implicit size
grof the operand for conversion of a negative operand to unsigned:
gr
gr<pre>
grhh     Int8
grh      Int16
grl      Int32
grll     Int64
grL      Int64
gr</pre>
gr
grThe specification ends with a format character:
gr
gr<pre>
grc      character               Integral
grd      decimal                 Integral
gro      octal                   Integral
grx      hexadecimal             Integral
grX      hexadecimal             Integral
grb      binary                  Integral
gru      unsigned decimal        Integral
grf      floating point          RealFloat
grF      floating point          RealFloat
grg      general format float    RealFloat
grG      general format float    RealFloat
gre      exponent format float   RealFloat
grE      exponent format float   RealFloat
grs      string                  String
grv      default format          any type
gr</pre>
gr
grThe "%v" specifier is provided for all built-in types, and should be
grprovided for user-defined type formatters as well. It picks a "best"
grrepresentation for the given type. For the built-in types the "%v"
grspecifier is converted as follows:
gr
gr<pre>
grc      Char
gru      other unsigned Integral
grd      other signed Integral
grg      RealFloat
grs      String
gr</pre>
gr
grMismatch between the argument types and the format string, as well as
grany other syntactic or semantic errors in the format string, will
grcause an exception to be thrown at runtime.
gr
grNote that the formatting for <a>RealFloat</a> types is currently a bit
grdifferent from that of C <tt>printf(3)</tt>, conforming instead to
gr<a>showEFloat</a>, <a>showFFloat</a> and <a>showGFloat</a> (and their
gralternate versions <a>showFFloatAlt</a> and <a>showGFloatAlt</a>).
grThis is hard to fix: the fixed versions would format in a
grbackward-incompatible way. In any case the Haskell behavior is
grgenerally more sensible than the C behavior. A brief summary of some
grkey differences:
gr
gr<ul>
gr<li>Haskell <a>printf</a> never uses the default "6-digit" precision
grused by C printf.</li>
gr<li>Haskell <a>printf</a> treats the "precision" specifier as
grindicating the number of digits after the decimal point.</li>
gr<li>Haskell <a>printf</a> prints the exponent of e-format numbers
grwithout a gratuitous plus sign, and with the minimum possible number
grof digits.</li>
gr<li>Haskell <a>printf</a> will place a zero after a decimal point when
grpossible.</li>
gr</ul>
printf :: (PrintfType r) => String -> r

-- | Similar to <a>printf</a>, except that output is via the specified
gr<a>Handle</a>. The return type is restricted to <tt>(<a>IO</a>
gra)</tt>.
hPrintf :: (HPrintfType r) => Handle -> String -> r

-- | Typeclass of <a>printf</a>-formattable values. The <a>formatArg</a>
grmethod takes a value and a field format descriptor and either fails
grdue to a bad descriptor or produces a <a>ShowS</a> as the result. The
grdefault <a>parseFormat</a> expects no modifiers: this is the normal
grcase. Minimal instance: <a>formatArg</a>.
class PrintfArg a

formatArg :: PrintfArg a => a -> FieldFormatter

parseFormat :: PrintfArg a => a -> ModifierParser

-- | This is the type of a field formatter reified over its argument.
type FieldFormatter = FieldFormat -> ShowS

-- | Description of field formatting for <a>formatArg</a>. See UNIX
gr<a>printf</a>(3) for a description of how field formatting works.
data FieldFormat
FieldFormat :: Maybe Int -> Maybe Int -> Maybe FormatAdjustment -> Maybe FormatSign -> Bool -> String -> Char -> FieldFormat

-- | Total width of the field.
[fmtWidth] :: FieldFormat -> Maybe Int

-- | Secondary field width specifier.
[fmtPrecision] :: FieldFormat -> Maybe Int

-- | Kind of filling or padding to be done.
[fmtAdjust] :: FieldFormat -> Maybe FormatAdjustment

-- | Whether to insist on a plus sign for positive numbers.
[fmtSign] :: FieldFormat -> Maybe FormatSign

-- | Indicates an "alternate format". See printf(3) for the details, which
grvary by argument spec.
[fmtAlternate] :: FieldFormat -> Bool

-- | Characters that appeared immediately to the left of <a>fmtChar</a> in
grthe format and were accepted by the type's <a>parseFormat</a>.
grNormally the empty string.
[fmtModifiers] :: FieldFormat -> String

-- | The format character <a>printf</a> was invoked with. <a>formatArg</a>
grshould fail unless this character matches the type. It is normal to
grhandle many different format characters for a single type.
[fmtChar] :: FieldFormat -> Char

-- | Whether to left-adjust or zero-pad a field. These are mutually
grexclusive, with <a>LeftAdjust</a> taking precedence.
data FormatAdjustment
LeftAdjust :: FormatAdjustment
ZeroPad :: FormatAdjustment

-- | How to handle the sign of a numeric field. These are mutually
grexclusive, with <a>SignPlus</a> taking precedence.
data FormatSign
SignPlus :: FormatSign
SignSpace :: FormatSign

-- | Substitute a 'v' format character with the given default format
grcharacter in the <a>FieldFormat</a>. A convenience for
gruser-implemented types, which should support "%v".
vFmt :: Char -> FieldFormat -> FieldFormat

-- | Type of a function that will parse modifier characters from the format
grstring.
type ModifierParser = String -> FormatParse

-- | The "format parser" walks over argument-type-specific modifier
grcharacters to find the primary format character. This is the type of
grits result.
data FormatParse
FormatParse :: String -> Char -> String -> FormatParse

-- | Any modifiers found.
[fpModifiers] :: FormatParse -> String

-- | Primary format character.
[fpChar] :: FormatParse -> Char

-- | Rest of the format string.
[fpRest] :: FormatParse -> String

-- | Formatter for <a>String</a> values.
formatString :: IsChar a => [a] -> FieldFormatter

-- | Formatter for <a>Char</a> values.
formatChar :: Char -> FieldFormatter

-- | Formatter for <a>Int</a> values.
formatInt :: (Integral a, Bounded a) => a -> FieldFormatter

-- | Formatter for <a>Integer</a> values.
formatInteger :: Integer -> FieldFormatter

-- | Formatter for <a>RealFloat</a> values.
formatRealFloat :: RealFloat a => a -> FieldFormatter

-- | Calls <a>perror</a> to indicate an unknown format letter for a given
grtype.
errorBadFormat :: Char -> a

-- | Calls <a>perror</a> to indicate that the format string ended early.
errorShortFormat :: a

-- | Calls <a>perror</a> to indicate that there is a missing argument in
grthe argument list.
errorMissingArgument :: a

-- | Calls <a>perror</a> to indicate that there is a type error or similar
grin the given argument.
errorBadArgument :: a

-- | Raises an <a>error</a> with a printf-specific prefix on the message
grstring.
perror :: String -> a

-- | The <a>PrintfType</a> class provides the variable argument magic for
gr<a>printf</a>. Its implementation is intentionally not visible from
grthis module. If you attempt to pass an argument of a type which is not
gran instance of this class to <a>printf</a> or <a>hPrintf</a>, then the
grcompiler will report it as a missing instance of <a>PrintfArg</a>.
class PrintfType t

-- | The <a>HPrintfType</a> class provides the variable argument magic for
gr<a>hPrintf</a>. Its implementation is intentionally not visible from
grthis module.
class HPrintfType t

-- | This class, with only the one instance, is used as a workaround for
grthe fact that <a>String</a>, as a concrete type, is not allowable as a
grtypeclass instance. <a>IsChar</a> is exported for
grbackward-compatibility.
class IsChar c

toChar :: IsChar c => c -> Char

fromChar :: IsChar c => Char -> c
instance Text.Printf.IsChar c => Text.Printf.PrintfType [c]
instance (a ~ ()) => Text.Printf.PrintfType (GHC.Types.IO a)
instance (Text.Printf.PrintfArg a, Text.Printf.PrintfType r) => Text.Printf.PrintfType (a -> r)
instance (a ~ ()) => Text.Printf.HPrintfType (GHC.Types.IO a)
instance (Text.Printf.PrintfArg a, Text.Printf.HPrintfType r) => Text.Printf.HPrintfType (a -> r)
instance Text.Printf.PrintfArg GHC.Types.Char
instance Text.Printf.IsChar c => Text.Printf.PrintfArg [c]
instance Text.Printf.PrintfArg GHC.Types.Int
instance Text.Printf.PrintfArg GHC.Int.Int8
instance Text.Printf.PrintfArg GHC.Int.Int16
instance Text.Printf.PrintfArg GHC.Int.Int32
instance Text.Printf.PrintfArg GHC.Int.Int64
instance Text.Printf.PrintfArg GHC.Types.Word
instance Text.Printf.PrintfArg GHC.Word.Word8
instance Text.Printf.PrintfArg GHC.Word.Word16
instance Text.Printf.PrintfArg GHC.Word.Word32
instance Text.Printf.PrintfArg GHC.Word.Word64
instance Text.Printf.PrintfArg GHC.Integer.Type.Integer
instance Text.Printf.PrintfArg GHC.Natural.Natural
instance Text.Printf.PrintfArg GHC.Types.Float
instance Text.Printf.PrintfArg GHC.Types.Double
instance Text.Printf.IsChar GHC.Types.Char


-- | In general terms, a weak pointer is a reference to an object that is
grnot followed by the garbage collector - that is, the existence of a
grweak pointer to an object has no effect on the lifetime of that
grobject. A weak pointer can be de-referenced to find out whether the
grobject it refers to is still alive or not, and if so to return the
grobject itself.
gr
grWeak pointers are particularly useful for caches and memo tables. To
grbuild a memo table, you build a data structure mapping from the
grfunction argument (the key) to its result (the value). When you apply
grthe function to a new argument you first check whether the key/value
grpair is already in the memo table. The key point is that the memo
grtable itself should not keep the key and value alive. So the table
grshould contain a weak pointer to the key, not an ordinary pointer. The
grpointer to the value must not be weak, because the only reference to
grthe value might indeed be from the memo table.
gr
grSo it looks as if the memo table will keep all its values alive for
grever. One way to solve this is to purge the table occasionally, by
grdeleting entries whose keys have died.
gr
grThe weak pointers in this library support another approach, called
gr<i>finalization</i>. When the key referred to by a weak pointer dies,
grthe storage manager arranges to run a programmer-specified finalizer.
grIn the case of memo tables, for example, the finalizer could remove
grthe key/value pair from the memo table.
gr
grAnother difficulty with the memo table is that the value of a
grkey/value pair might itself contain a pointer to the key. So the memo
grtable keeps the value alive, which keeps the key alive, even though
grthere may be no other references to the key so both should die. The
grweak pointers in this library provide a slight generalisation of the
grbasic weak-pointer idea, in which each weak pointer actually contains
grboth a key and a value.
module System.Mem.Weak

-- | A weak pointer object with a key and a value. The value has type
gr<tt>v</tt>.
gr
grA weak pointer expresses a relationship between two objects, the
gr<i>key</i> and the <i>value</i>: if the key is considered to be alive
grby the garbage collector, then the value is also alive. A reference
grfrom the value to the key does <i>not</i> keep the key alive.
gr
grA weak pointer may also have a finalizer of type <tt>IO ()</tt>; if it
grdoes, then the finalizer will be run at most once, at a time after the
grkey has become unreachable by the program ("dead"). The storage
grmanager attempts to run the finalizer(s) for an object soon after the
grobject dies, but promptness is not guaranteed.
gr
grIt is not guaranteed that a finalizer will eventually run, and no
grattempt is made to run outstanding finalizers when the program exits.
grTherefore finalizers should not be relied on to clean up resources -
grother methods (eg. exception handlers) should be employed, possibly in
graddition to finalizers.
gr
grReferences from the finalizer to the key are treated in the same way
gras references from the value to the key: they do not keep the key
gralive. A finalizer may therefore ressurrect the key, perhaps by
grstoring it in the same data structure.
gr
grThe finalizer, and the relationship between the key and the value,
grexist regardless of whether the program keeps a reference to the
gr<a>Weak</a> object or not.
gr
grThere may be multiple weak pointers with the same key. In this case,
grthe finalizers for each of these weak pointers will all be run in some
grarbitrary order, or perhaps concurrently, when the key dies. If the
grprogrammer specifies a finalizer that assumes it has the only
grreference to an object (for example, a file that it wishes to close),
grthen the programmer must ensure that there is only one such finalizer.
gr
grIf there are no other threads to run, the runtime system will check
grfor runnable finalizers before declaring the system to be deadlocked.
gr
grWARNING: weak pointers to ordinary non-primitive Haskell types are
grparticularly fragile, because the compiler is free to optimise away or
grduplicate the underlying data structure. Therefore attempting to place
gra finalizer on an ordinary Haskell type may well result in the
grfinalizer running earlier than you expected. This is not a problem for
grcaches and memo tables where early finalization is benign.
gr
grFinalizers <i>can</i> be used reliably for types that are created
grexplicitly and have identity, such as <tt>IORef</tt> and
gr<tt>MVar</tt>. However, to place a finalizer on one of these types,
gryou should use the specific operation provided for that type, e.g.
gr<tt>mkWeakIORef</tt> and <tt>addMVarFinalizer</tt> respectively (the
grnon-uniformity is accidental). These operations attach the finalizer
grto the primitive object inside the box (e.g. <tt>MutVar#</tt> in the
grcase of <tt>IORef</tt>), because attaching the finalizer to the box
gritself fails when the outer box is optimised away by the compiler.
data Weak v

-- | Establishes a weak pointer to <tt>k</tt>, with value <tt>v</tt> and a
grfinalizer.
gr
grThis is the most general interface for building a weak pointer.
mkWeak :: k -> v -> Maybe (IO ()) -> IO (Weak v)

-- | Dereferences a weak pointer. If the key is still alive, then
gr<tt><a>Just</a> v</tt> is returned (where <tt>v</tt> is the
gr<i>value</i> in the weak pointer), otherwise <a>Nothing</a> is
grreturned.
gr
grThe return value of <a>deRefWeak</a> depends on when the garbage
grcollector runs, hence it is in the <a>IO</a> monad.
deRefWeak :: Weak v -> IO (Maybe v)

-- | Causes a the finalizer associated with a weak pointer to be run
grimmediately.
finalize :: Weak v -> IO ()

-- | A specialised version of <a>mkWeak</a>, where the key and the value
grare the same object:
gr
gr<pre>
grmkWeakPtr key finalizer = mkWeak key key finalizer
gr</pre>
mkWeakPtr :: k -> Maybe (IO ()) -> IO (Weak k)

-- | A specialised version of <a>mkWeakPtr</a>, where the <a>Weak</a>
grobject returned is simply thrown away (however the finalizer will be
grremembered by the garbage collector, and will still be run when the
grkey becomes unreachable).
gr
grNote: adding a finalizer to a <a>ForeignPtr</a> using
gr<a>addFinalizer</a> won't work; use the specialised version
gr<a>addForeignPtrFinalizer</a> instead. For discussion see the
gr<a>Weak</a> type. .
addFinalizer :: key -> IO () -> IO ()

-- | A specialised version of <a>mkWeak</a> where the value is actually a
grpair of the key and value passed to <a>mkWeakPair</a>:
gr
gr<pre>
grmkWeakPair key val finalizer = mkWeak key (key,val) finalizer
gr</pre>
gr
grThe advantage of this is that the key can be retrieved by
gr<a>deRefWeak</a> in addition to the value.
mkWeakPair :: k -> v -> Maybe (IO ()) -> IO (Weak (k, v))


-- | Stable names are a way of performing fast (O(1)), not-quite-exact
grcomparison between objects.
gr
grStable names solve the following problem: suppose you want to build a
grhash table with Haskell objects as keys, but you want to use pointer
grequality for comparison; maybe because the keys are large and hashing
grwould be slow, or perhaps because the keys are infinite in size. We
grcan't build a hash table using the address of the object as the key,
grbecause objects get moved around by the garbage collector, meaning a
grre-hash would be necessary after every garbage collection.
module System.Mem.StableName

-- | An abstract name for an object, that supports equality and hashing.
gr
grStable names have the following property:
gr
gr<ul>
gr<li>If <tt>sn1 :: StableName</tt> and <tt>sn2 :: StableName</tt> and
gr<tt>sn1 == sn2</tt> then <tt>sn1</tt> and <tt>sn2</tt> were created by
grcalls to <tt>makeStableName</tt> on the same object.</li>
gr</ul>
gr
grThe reverse is not necessarily true: if two stable names are not
grequal, then the objects they name may still be equal. Note in
grparticular that <a>makeStableName</a> may return a different
gr<a>StableName</a> after an object is evaluated.
gr
grStable Names are similar to Stable Pointers
gr(<a>Foreign.StablePtr</a>), but differ in the following ways:
gr
gr<ul>
gr<li>There is no <tt>freeStableName</tt> operation, unlike
gr<a>Foreign.StablePtr</a>s. Stable names are reclaimed by the runtime
grsystem when they are no longer needed.</li>
gr<li>There is no <tt>deRefStableName</tt> operation. You can't get back
grfrom a stable name to the original Haskell object. The reason for this
gris that the existence of a stable name for an object does not
grguarantee the existence of the object itself; it can still be garbage
grcollected.</li>
gr</ul>
data StableName a

-- | Makes a <a>StableName</a> for an arbitrary object. The object passed
gras the first argument is not evaluated by <a>makeStableName</a>.
makeStableName :: a -> IO (StableName a)

-- | Convert a <a>StableName</a> to an <a>Int</a>. The <a>Int</a> returned
gris not necessarily unique; several <a>StableName</a>s may map to the
grsame <a>Int</a> (in practice however, the chances of this are small,
grso the result of <a>hashStableName</a> makes a good hash key).
hashStableName :: StableName a -> Int

-- | Equality on <a>StableName</a> that does not require that the types of
grthe arguments match.
eqStableName :: StableName a -> StableName b -> Bool
instance GHC.Classes.Eq (System.Mem.StableName.StableName a)


-- | Memory-related system things.
module System.Mem

-- | Triggers an immediate major garbage collection.
performGC :: IO ()

-- | Triggers an immediate major garbage collection.
performMajorGC :: IO ()

-- | Triggers an immediate minor garbage collection.
performMinorGC :: IO ()

-- | Every thread has an allocation counter that tracks how much memory has
grbeen allocated by the thread. The counter is initialized to zero, and
gr<a>setAllocationCounter</a> sets the current value. The allocation
grcounter counts *down*, so in the absence of a call to
gr<a>setAllocationCounter</a> its value is the negation of the number of
grbytes of memory allocated by the thread.
gr
grThere are two things that you can do with this counter:
gr
gr<ul>
gr<li>Use it as a simple profiling mechanism, with
gr<a>getAllocationCounter</a>.</li>
gr<li>Use it as a resource limit. See <a>enableAllocationLimit</a>.</li>
gr</ul>
gr
grAllocation accounting is accurate only to about 4Kbytes.
setAllocationCounter :: Int64 -> IO ()

-- | Return the current value of the allocation counter for the current
grthread.
getAllocationCounter :: IO Int64

-- | Enables the allocation counter to be treated as a limit for the
grcurrent thread. When the allocation limit is enabled, if the
grallocation counter counts down below zero, the thread will be sent the
gr<a>AllocationLimitExceeded</a> asynchronous exception. When this
grhappens, the counter is reinitialised (by default to 100K, but tunable
grwith the <tt>+RTS -xq</tt> option) so that it can handle the exception
grand perform any necessary clean up. If it exhausts this additional
grallowance, another <a>AllocationLimitExceeded</a> exception is sent,
grand so forth. Like other asynchronous exceptions, the
gr<a>AllocationLimitExceeded</a> exception is deferred while the thread
gris inside <a>mask</a> or an exception handler in <a>catch</a>.
gr
grNote that memory allocation is unrelated to <i>live memory</i>, also
grknown as <i>heap residency</i>. A thread can allocate a large amount
grof memory and retain anything between none and all of it. It is better
grto think of the allocation limit as a limit on <i>CPU time</i>, rather
grthan a limit on memory.
gr
grCompared to using timeouts, allocation limits don't count time spent
grblocked or in foreign calls.
enableAllocationLimit :: IO ()

-- | Disable allocation limit processing for the current thread.
disableAllocationLimit :: IO ()


-- | Information about the characteristics of the host system lucky enough
grto run your program.
module System.Info

-- | The operating system on which the program is running.
os :: String

-- | The machine architecture on which the program is running.
arch :: String

-- | The Haskell implementation with which the program was compiled or is
grbeing interpreted.
compilerName :: String

-- | The version of <a>compilerName</a> with which the program was compiled
gror is being interpreted.
compilerVersion :: Version


-- | Exiting the program.
module System.Exit

-- | Defines the exit codes that a program can return.
data ExitCode

-- | indicates successful termination;
ExitSuccess :: ExitCode

-- | indicates program failure with an exit code. The exact interpretation
grof the code is operating-system dependent. In particular, some values
grmay be prohibited (e.g. 0 on a POSIX-compliant system).
ExitFailure :: Int -> ExitCode

-- | Computation <a>exitWith</a> <tt>code</tt> throws <a>ExitCode</a>
gr<tt>code</tt>. Normally this terminates the program, returning
gr<tt>code</tt> to the program's caller.
gr
grOn program termination, the standard <a>Handle</a>s <a>stdout</a> and
gr<a>stderr</a> are flushed automatically; any other buffered
gr<a>Handle</a>s need to be flushed manually, otherwise the buffered
grdata will be discarded.
gr
grA program that fails in any other way is treated as if it had called
gr<a>exitFailure</a>. A program that terminates successfully without
grcalling <a>exitWith</a> explicitly is treated as if it had called
gr<a>exitWith</a> <a>ExitSuccess</a>.
gr
grAs an <a>ExitCode</a> is not an <a>IOError</a>, <a>exitWith</a>
grbypasses the error handling in the <a>IO</a> monad and cannot be
grintercepted by <a>catch</a> from the <a>Prelude</a>. However it is a
gr<tt>SomeException</tt>, and can be caught using the functions of
gr<a>Control.Exception</a>. This means that cleanup computations added
grwith <a>bracket</a> (from <a>Control.Exception</a>) are also executed
grproperly on <a>exitWith</a>.
gr
grNote: in GHC, <a>exitWith</a> should be called from the main program
grthread in order to exit the process. When called from another thread,
gr<a>exitWith</a> will throw an <tt>ExitException</tt> as normal, but
grthe exception will not cause the process itself to exit.
exitWith :: ExitCode -> IO a

-- | The computation <a>exitFailure</a> is equivalent to <a>exitWith</a>
gr<tt>(</tt><a>ExitFailure</a> <i>exitfail</i><tt>)</tt>, where
gr<i>exitfail</i> is implementation-dependent.
exitFailure :: IO a

-- | The computation <a>exitSuccess</a> is equivalent to <a>exitWith</a>
gr<a>ExitSuccess</a>, It terminates the program successfully.
exitSuccess :: IO a

-- | Write given error message to <a>stderr</a> and terminate with
gr<a>exitFailure</a>.
die :: String -> IO a


-- | Miscellaneous information about the system environment.
module System.Environment

-- | Computation <a>getArgs</a> returns a list of the program's command
grline arguments (not including the program name).
getArgs :: IO [String]

-- | Computation <a>getProgName</a> returns the name of the program as it
grwas invoked.
gr
grHowever, this is hard-to-impossible to implement on some non-Unix
grOSes, so instead, for maximum portability, we just return the leafname
grof the program as invoked. Even then there are some differences
grbetween platforms: on Windows, for example, a program invoked as foo
gris probably really <tt>FOO.EXE</tt>, and that is what
gr<a>getProgName</a> will return.
getProgName :: IO String

-- | Returns the absolute pathname of the current executable.
gr
grNote that for scripts and interactive sessions, this is the path to
grthe interpreter (e.g. ghci.)
gr
grSince base 4.11.0.0, <a>getExecutablePath</a> resolves symlinks on
grWindows. If an executable is launched through a symlink,
gr<a>getExecutablePath</a> returns the absolute path of the original
grexecutable.
getExecutablePath :: IO FilePath

-- | Computation <a>getEnv</a> <tt>var</tt> returns the value of the
grenvironment variable <tt>var</tt>. For the inverse, the <a>setEnv</a>
grfunction can be used.
gr
grThis computation may fail with:
gr
gr<ul>
gr<li><a>isDoesNotExistError</a> if the environment variable does not
grexist.</li>
gr</ul>
getEnv :: String -> IO String

-- | Return the value of the environment variable <tt>var</tt>, or
gr<tt>Nothing</tt> if there is no such value.
gr
grFor POSIX users, this is equivalent to <a>getEnv</a>.
lookupEnv :: String -> IO (Maybe String)

-- | <tt>setEnv name value</tt> sets the specified environment variable to
gr<tt>value</tt>.
gr
grEarly versions of this function operated under the mistaken belief
grthat setting an environment variable to the <i>empty string</i> on
grWindows removes that environment variable from the environment. For
grthe sake of compatibility, it adopted that behavior on POSIX. In
grparticular
gr
gr<pre>
grsetEnv name ""
gr</pre>
gr
grhas the same effect as
gr
gr<pre>
gr<a>unsetEnv</a> name
gr</pre>
gr
grIf you'd like to be able to set environment variables to blank
grstrings, use <a>setEnv</a>.
gr
grThrows <a>IOException</a> if <tt>name</tt> is the empty string or
grcontains an equals sign.
setEnv :: String -> String -> IO ()

-- | <tt>unsetEnv name</tt> removes the specified environment variable from
grthe environment of the current process.
gr
grThrows <a>IOException</a> if <tt>name</tt> is the empty string or
grcontains an equals sign.
unsetEnv :: String -> IO ()

-- | <a>withArgs</a> <tt>args act</tt> - while executing action
gr<tt>act</tt>, have <a>getArgs</a> return <tt>args</tt>.
withArgs :: [String] -> IO a -> IO a

-- | <a>withProgName</a> <tt>name act</tt> - while executing action
gr<tt>act</tt>, have <a>getProgName</a> return <tt>name</tt>.
withProgName :: String -> IO a -> IO a

-- | <a>getEnvironment</a> retrieves the entire environment as a list of
gr<tt>(key,value)</tt> pairs.
gr
grIf an environment entry does not contain an <tt>'='</tt> character,
grthe <tt>key</tt> is the whole entry and the <tt>value</tt> is the
grempty string.
getEnvironment :: IO [(String, String)]


-- | A setEnv implementation that allows blank environment variables.
grMimics the <a>Env</a> module from the <tt>unix</tt> package, but with
grsupport for Windows too.
gr
grThe matrix of platforms that:
gr
gr<ul>
gr<li>support putenv(<a>FOO</a>) to unset environment variables,</li>
gr<li>support putenv("FOO=") to unset environment variables or set them
grto blank values,</li>
gr<li>support unsetenv to unset environment variables,</li>
gr<li>support setenv to set environment variables,</li>
gr<li>etc.</li>
gr</ul>
gr
gris very complicated. I think AIX is screwed, but we don't support it.
grThe whole situation with setenv(3), unsetenv(3), and putenv(3) is not
grgood. Even mingw32 adds its own crap to the pile, but luckily, we can
grjust use Windows' native environment functions to sidestep the issue.
gr
gr#12494
module System.Environment.Blank

-- | Returns the absolute pathname of the current executable.
gr
grNote that for scripts and interactive sessions, this is the path to
grthe interpreter (e.g. ghci.)
gr
grSince base 4.11.0.0, <a>getExecutablePath</a> resolves symlinks on
grWindows. If an executable is launched through a symlink,
gr<a>getExecutablePath</a> returns the absolute path of the original
grexecutable.
getExecutablePath :: IO FilePath

-- | Computation <a>getArgs</a> returns a list of the program's command
grline arguments (not including the program name).
getArgs :: IO [String]

-- | Computation <a>getProgName</a> returns the name of the program as it
grwas invoked.
gr
grHowever, this is hard-to-impossible to implement on some non-Unix
grOSes, so instead, for maximum portability, we just return the leafname
grof the program as invoked. Even then there are some differences
grbetween platforms: on Windows, for example, a program invoked as foo
gris probably really <tt>FOO.EXE</tt>, and that is what
gr<a>getProgName</a> will return.
getProgName :: IO String

-- | <a>withArgs</a> <tt>args act</tt> - while executing action
gr<tt>act</tt>, have <a>getArgs</a> return <tt>args</tt>.
withArgs :: [String] -> IO a -> IO a

-- | <a>withProgName</a> <tt>name act</tt> - while executing action
gr<tt>act</tt>, have <a>getProgName</a> return <tt>name</tt>.
withProgName :: String -> IO a -> IO a

-- | <a>getEnvironment</a> retrieves the entire environment as a list of
gr<tt>(key,value)</tt> pairs.
gr
grIf an environment entry does not contain an <tt>'='</tt> character,
grthe <tt>key</tt> is the whole entry and the <tt>value</tt> is the
grempty string.
getEnvironment :: IO [(String, String)]

-- | <a>lookupEnv</a>.
getEnv :: String -> IO (Maybe String)

-- | Get an environment value or a default value.
getEnvDefault :: String -> String -> IO String

-- | Like <a>setEnv</a>, but allows blank environment values and mimics the
grfunction signature of <a>setEnv</a> from the <tt>unix</tt> package.
setEnv :: String -> String -> Bool -> IO ()

-- | Like <a>unsetEnv</a>, but allows for the removal of blank environment
grvariables.
unsetEnv :: String -> IO ()


-- | This library provides facilities for parsing the command-line options
grin a standalone program. It is essentially a Haskell port of the GNU
gr<tt>getopt</tt> library.
module System.Console.GetOpt

-- | Process the command-line, and return the list of values that matched
gr(and those that didn't). The arguments are:
gr
gr<ul>
gr<li>The order requirements (see <a>ArgOrder</a>)</li>
gr<li>The option descriptions (see <a>OptDescr</a>)</li>
gr<li>The actual command line arguments (presumably got from
gr<a>getArgs</a>).</li>
gr</ul>
gr
gr<a>getOpt</a> returns a triple consisting of the option arguments, a
grlist of non-options, and a list of error messages.
getOpt :: ArgOrder a -> [OptDescr a] -> [String] -> ([a], [String], [String])

-- | This is almost the same as <a>getOpt</a>, but returns a quadruple
grconsisting of the option arguments, a list of non-options, a list of
grunrecognized options, and a list of error messages.
getOpt' :: ArgOrder a -> [OptDescr a] -> [String] -> ([a], [String], [String], [String])

-- | Return a string describing the usage of a command, derived from the
grheader (first argument) and the options described by the second
grargument.
usageInfo :: String -> [OptDescr a] -> String

-- | What to do with options following non-options
data ArgOrder a

-- | no option processing after first non-option
RequireOrder :: ArgOrder a

-- | freely intersperse options and non-options
Permute :: ArgOrder a

-- | wrap non-options into options
ReturnInOrder :: (String -> a) -> ArgOrder a

-- | Each <a>OptDescr</a> describes a single option.
gr
grThe arguments to <a>Option</a> are:
gr
gr<ul>
gr<li>list of short option characters</li>
gr<li>list of long option strings (without "--")</li>
gr<li>argument descriptor</li>
gr<li>explanation of option for user</li>
gr</ul>
data OptDescr a
Option :: [Char] -> [String] -> (ArgDescr a) -> String -> OptDescr a

-- | Describes whether an option takes an argument or not, and if so how
grthe argument is injected into a value of type <tt>a</tt>.
data ArgDescr a

-- | no argument expected
NoArg :: a -> ArgDescr a

-- | option requires argument
ReqArg :: (String -> a) -> String -> ArgDescr a

-- | optional argument
OptArg :: (Maybe String -> a) -> String -> ArgDescr a
instance GHC.Base.Functor System.Console.GetOpt.OptDescr
instance GHC.Base.Functor System.Console.GetOpt.ArgDescr
instance GHC.Base.Functor System.Console.GetOpt.ArgOrder


-- | The standard CPUTime library.
module System.CPUTime

-- | Computation <a>getCPUTime</a> returns the number of picoseconds CPU
grtime used by the current program. The precision of this result is
grimplementation-dependent.
getCPUTime :: IO Integer

-- | The <a>cpuTimePrecision</a> constant is the smallest measurable
grdifference in CPU time that the implementation can record, and is
grgiven as an integral number of picoseconds.
cpuTimePrecision :: Integer


-- | This module defines the <a>HasField</a> class used by the
gr<tt>OverloadedRecordFields</tt> extension. See the
gr&lt;<a>https://ghc.haskell.org/trac/ghc/wiki/Records/OverloadedRecordFields</a>
grwiki page&gt; for more details.
module GHC.Records

-- | Constraint representing the fact that the field <tt>x</tt> belongs to
grthe record type <tt>r</tt> and has field type <tt>a</tt>. This will be
grsolved automatically, but manual instances may be provided as well.
class HasField (x :: k) r a | x r -> a

-- | Selector function to extract the field from the record.
getField :: HasField x r a => r -> a


-- | This module defines the <a>IsLabel</a> class is used by the
gr<tt>OverloadedLabels</tt> extension. See the <a>wiki page</a> for more
grdetails.
gr
grWhen <tt>OverloadedLabels</tt> is enabled, if GHC sees an occurrence
grof the overloaded label syntax <tt>#foo</tt>, it is replaced with
gr
gr<pre>
grfromLabel @"foo" :: alpha
gr</pre>
gr
grplus a wanted constraint <tt>IsLabel "foo" alpha</tt>.
gr
grNote that if <tt>RebindableSyntax</tt> is enabled, the desugaring of
groverloaded label syntax will make use of whatever <tt>fromLabel</tt>
gris in scope.
module GHC.OverloadedLabels
class IsLabel (x :: Symbol) a
fromLabel :: IsLabel x a => a


-- | Target byte ordering.
module GHC.ByteOrder

-- | Byte ordering.
data ByteOrder

-- | most-significant-byte occurs in lowest address.
BigEndian :: ByteOrder

-- | least-significant-byte occurs in lowest address.
LittleEndian :: ByteOrder

-- | The byte ordering of the target machine.
targetByteOrder :: ByteOrder
instance GHC.Show.Show GHC.ByteOrder.ByteOrder
instance GHC.Read.Read GHC.ByteOrder.ByteOrder
instance GHC.Enum.Enum GHC.ByteOrder.ByteOrder
instance GHC.Enum.Bounded GHC.ByteOrder.ByteOrder
instance GHC.Classes.Ord GHC.ByteOrder.ByteOrder
instance GHC.Classes.Eq GHC.ByteOrder.ByteOrder


-- | An abstract interface to a unique symbol generator.
module Data.Unique

-- | An abstract unique object. Objects of type <a>Unique</a> may be
grcompared for equality and ordering and hashed into <a>Int</a>.
gr
gr<pre>
gr&gt;&gt;&gt; :{
grdo x &lt;- newUnique
gr   print (x == x)
gr   y &lt;- newUnique
gr   print (x == y)
gr:}
grTrue
grFalse
gr</pre>
data Unique

-- | Creates a new object of type <a>Unique</a>. The value returned will
grnot compare equal to any other value of type <a>Unique</a> returned by
grprevious calls to <a>newUnique</a>. There is no limit on the number of
grtimes <a>newUnique</a> may be called.
newUnique :: IO Unique

-- | Hashes a <a>Unique</a> into an <a>Int</a>. Two <a>Unique</a>s may hash
grto the same value, although in practice this is unlikely. The
gr<a>Int</a> returned makes a good hash key.
hashUnique :: Unique -> Int
instance GHC.Classes.Ord Data.Unique.Unique
instance GHC.Classes.Eq Data.Unique.Unique


-- | Mutable references in the (strict) ST monad.
module Data.STRef

-- | a value of type <tt>STRef s a</tt> is a mutable variable in state
grthread <tt>s</tt>, containing a value of type <tt>a</tt>
gr
gr<pre>
gr&gt;&gt;&gt; :{
grrunST (do
gr    ref &lt;- newSTRef "hello"
gr    x &lt;- readSTRef ref
gr    writeSTRef ref (x ++ "world")
gr    readSTRef ref )
gr:}
gr"helloworld"
gr</pre>
data STRef s a

-- | Build a new <a>STRef</a> in the current state thread
newSTRef :: a -> ST s (STRef s a)

-- | Read the value of an <a>STRef</a>
readSTRef :: STRef s a -> ST s a

-- | Write a new value into an <a>STRef</a>
writeSTRef :: STRef s a -> a -> ST s ()

-- | Mutate the contents of an <a>STRef</a>.
gr
gr<pre>
gr&gt;&gt;&gt; :{
grrunST (do
gr    ref &lt;- newSTRef ""
gr    modifySTRef ref (const "world")
gr    modifySTRef ref (++ "!")
gr    modifySTRef ref ("Hello, " ++)
gr    readSTRef ref )
gr:}
gr"Hello, world!"
gr</pre>
gr
grBe warned that <a>modifySTRef</a> does not apply the function
grstrictly. This means if the program calls <a>modifySTRef</a> many
grtimes, but seldomly uses the value, thunks will pile up in memory
grresulting in a space leak. This is a common mistake made when using an
grSTRef as a counter. For example, the following will leak memory and
grmay produce a stack overflow:
gr
gr<pre>
gr&gt;&gt;&gt; import Control.Monad (replicateM_)
gr
gr&gt;&gt;&gt; :{
grprint (runST (do
gr    ref &lt;- newSTRef 0
gr    replicateM_ 1000 $ modifySTRef ref (+1)
gr    readSTRef ref ))
gr:}
gr1000
gr</pre>
gr
grTo avoid this problem, use <a>modifySTRef'</a> instead.
modifySTRef :: STRef s a -> (a -> a) -> ST s ()

-- | Strict version of <a>modifySTRef</a>
modifySTRef' :: STRef s a -> (a -> a) -> ST s ()


-- | Mutable references in the (strict) ST monad (re-export of
gr<a>Data.STRef</a>)
module Data.STRef.Strict


-- | Standard functions on rational numbers
module Data.Ratio

-- | Rational numbers, with numerator and denominator of some
gr<a>Integral</a> type.
data Ratio a

-- | Arbitrary-precision rational numbers, represented as a ratio of two
gr<a>Integer</a> values. A rational number may be constructed using the
gr<a>%</a> operator.
type Rational = Ratio Integer

-- | Forms the ratio of two integral numbers.
(%) :: (Integral a) => a -> a -> Ratio a
infixl 7 %

-- | Extract the numerator of the ratio in reduced form: the numerator and
grdenominator have no common factor and the denominator is positive.
numerator :: Ratio a -> a

-- | Extract the denominator of the ratio in reduced form: the numerator
grand denominator have no common factor and the denominator is positive.
denominator :: Ratio a -> a

-- | <a>approxRational</a>, applied to two real fractional numbers
gr<tt>x</tt> and <tt>epsilon</tt>, returns the simplest rational number
grwithin <tt>epsilon</tt> of <tt>x</tt>. A rational number <tt>y</tt> is
grsaid to be <i>simpler</i> than another <tt>y'</tt> if
gr
gr<ul>
gr<li><tt><a>abs</a> (<a>numerator</a> y) &lt;= <a>abs</a>
gr(<a>numerator</a> y')</tt>, and</li>
gr<li><tt><a>denominator</a> y &lt;= <a>denominator</a> y'</tt>.</li>
gr</ul>
gr
grAny real interval contains a unique simplest rational; in particular,
grnote that <tt>0/1</tt> is the simplest rational of all.
approxRational :: (RealFrac a) => a -> a -> Rational


-- | Basic kinds
module Data.Kind

-- | The kind of types with values. For example <tt>Int :: Type</tt>.
type Type = *

-- | The kind of constraints, like <tt>Show a</tt>
data Constraint

-- | A backward-compatible (pre-GHC 8.0) synonym for <a>Type</a>
type * = *

-- | A unicode backward-compatible (pre-GHC 8.0) synonym for <a>Type</a>
type ★ = *


-- | The <a>Ix</a> class is used to map a contiguous subrange of values in
grtype onto integers. It is used primarily for array indexing (see the
grarray package). <a>Ix</a> uses row-major order.
module Data.Ix

-- | The <a>Ix</a> class is used to map a contiguous subrange of values in
gra type onto integers. It is used primarily for array indexing (see the
grarray package).
gr
grThe first argument <tt>(l,u)</tt> of each of these operations is a
grpair specifying the lower and upper bounds of a contiguous subrange of
grvalues.
gr
grAn implementation is entitled to assume the following laws about these
groperations:
gr
gr<ul>
gr<li><tt><a>inRange</a> (l,u) i == <a>elem</a> i (<a>range</a>
gr(l,u))</tt> <tt> </tt></li>
gr<li><tt><a>range</a> (l,u) <a>!!</a> <a>index</a> (l,u) i == i</tt>,
grwhen <tt><a>inRange</a> (l,u) i</tt></li>
gr<li><tt><a>map</a> (<a>index</a> (l,u)) (<a>range</a> (l,u))) ==
gr[0..<a>rangeSize</a> (l,u)-1]</tt> <tt> </tt></li>
gr<li><tt><a>rangeSize</a> (l,u) == <a>length</a> (<a>range</a>
gr(l,u))</tt> <tt> </tt></li>
gr</ul>
class (Ord a) => Ix a

-- | The list of values in the subrange defined by a bounding pair.
range :: Ix a => (a, a) -> [a]

-- | The position of a subscript in the subrange.
index :: Ix a => (a, a) -> a -> Int

-- | Returns <a>True</a> the given subscript lies in the range defined the
grbounding pair.
inRange :: Ix a => (a, a) -> a -> Bool

-- | The size of the subrange defined by a bounding pair.
rangeSize :: Ix a => (a, a) -> Int


-- | This library provides support for <i>strict</i> state threads, as
grdescribed in the PLDI '94 paper by John Launchbury and Simon Peyton
grJones <i>Lazy Functional State Threads</i>.
gr
grUnsafe API.
module Control.Monad.ST.Unsafe

-- | <a>unsafeInterleaveST</a> allows an <a>ST</a> computation to be
grdeferred lazily. When passed a value of type <tt>ST a</tt>, the
gr<a>ST</a> computation will only be performed when the value of the
gr<tt>a</tt> is demanded.
unsafeInterleaveST :: ST s a -> ST s a

-- | <a>unsafeDupableInterleaveST</a> allows an <a>ST</a> computation to be
grdeferred lazily. When passed a value of type <tt>ST a</tt>, the
gr<a>ST</a> computation will only be performed when the value of the
gr<tt>a</tt> is demanded.
gr
grThe computation may be performed multiple times by different threads,
grpossibly at the same time. To prevent this, use
gr<a>unsafeInterleaveST</a> instead.
unsafeDupableInterleaveST :: ST s a -> ST s a

-- | Convert an <a>IO</a> action to an <a>ST</a> action. This relies on
gr<a>IO</a> and <a>ST</a> having the same representation modulo the
grconstraint on the type of the state.
unsafeIOToST :: IO a -> ST s a

-- | Convert an <a>ST</a> action to an <a>IO</a> action. This relies on
gr<a>IO</a> and <a>ST</a> having the same representation modulo the
grconstraint on the type of the state.
gr
grFor an example demonstrating why this is unsafe, see
gr<a>https://mail.haskell.org/pipermail/haskell-cafe/2009-April/060719.html</a>
unsafeSTToIO :: ST s a -> IO a


-- | This library provides support for <i>strict</i> state threads, as
grdescribed in the PLDI '94 paper by John Launchbury and Simon Peyton
grJones <i>Lazy Functional State Threads</i>.
gr
grSafe API Only.

-- | <i>Deprecated: Safe is now the default, please use Control.Monad.ST
grinstead</i>
module Control.Monad.ST.Safe

-- | The strict state-transformer monad. A computation of type
gr<tt><a>ST</a> s a</tt> transforms an internal state indexed by
gr<tt>s</tt>, and returns a value of type <tt>a</tt>. The <tt>s</tt>
grparameter is either
gr
gr<ul>
gr<li>an uninstantiated type variable (inside invocations of
gr<a>runST</a>), or</li>
gr<li><a>RealWorld</a> (inside invocations of <a>stToIO</a>).</li>
gr</ul>
gr
grIt serves to keep the internal states of different invocations of
gr<a>runST</a> separate from each other and from invocations of
gr<a>stToIO</a>.
gr
grThe <a>&gt;&gt;=</a> and <a>&gt;&gt;</a> operations are strict in the
grstate (though not in values stored in the state). For example,
gr
gr<pre>
gr<a>runST</a> (writeSTRef _|_ v &gt;&gt;= f) = _|_
gr</pre>
data ST s a

-- | Return the value computed by a state transformer computation. The
gr<tt>forall</tt> ensures that the internal state used by the <a>ST</a>
grcomputation is inaccessible to the rest of the program.
runST :: (forall s. ST s a) -> a

-- | Allow the result of a state transformer computation to be used
gr(lazily) inside the computation. Note that if <tt>f</tt> is strict,
gr<tt><a>fixST</a> f = _|_</tt>.
fixST :: (a -> ST s a) -> ST s a

-- | <tt>RealWorld</tt> is deeply magical. It is <i>primitive</i>, but it
gris not <i>unlifted</i> (hence <tt>ptrArg</tt>). We never manipulate
grvalues of type <tt>RealWorld</tt>; it's only used in the type system,
grto parameterise <tt>State#</tt>.
data RealWorld

-- | Embed a strict state transformer in an <a>IO</a> action. The
gr<a>RealWorld</a> parameter indicates that the internal state used by
grthe <a>ST</a> computation is a special one supplied by the <a>IO</a>
grmonad, and thus distinct from those used by invocations of
gr<a>runST</a>.
stToIO :: ST RealWorld a -> IO a


-- | This library provides support for <i>strict</i> state threads, as
grdescribed in the PLDI '94 paper by John Launchbury and Simon Peyton
grJones <i>Lazy Functional State Threads</i>.
gr
grReferences (variables) that can be used within the <tt>ST</tt> monad
grare provided by <a>Data.STRef</a>, and arrays are provided by
gr<a>Data.Array.ST</a>.
module Control.Monad.ST

-- | The strict state-transformer monad. A computation of type
gr<tt><a>ST</a> s a</tt> transforms an internal state indexed by
gr<tt>s</tt>, and returns a value of type <tt>a</tt>. The <tt>s</tt>
grparameter is either
gr
gr<ul>
gr<li>an uninstantiated type variable (inside invocations of
gr<a>runST</a>), or</li>
gr<li><a>RealWorld</a> (inside invocations of <a>stToIO</a>).</li>
gr</ul>
gr
grIt serves to keep the internal states of different invocations of
gr<a>runST</a> separate from each other and from invocations of
gr<a>stToIO</a>.
gr
grThe <a>&gt;&gt;=</a> and <a>&gt;&gt;</a> operations are strict in the
grstate (though not in values stored in the state). For example,
gr
gr<pre>
gr<a>runST</a> (writeSTRef _|_ v &gt;&gt;= f) = _|_
gr</pre>
data ST s a

-- | Return the value computed by a state transformer computation. The
gr<tt>forall</tt> ensures that the internal state used by the <a>ST</a>
grcomputation is inaccessible to the rest of the program.
runST :: (forall s. ST s a) -> a

-- | Allow the result of a state transformer computation to be used
gr(lazily) inside the computation. Note that if <tt>f</tt> is strict,
gr<tt><a>fixST</a> f = _|_</tt>.
fixST :: (a -> ST s a) -> ST s a

-- | <tt>RealWorld</tt> is deeply magical. It is <i>primitive</i>, but it
gris not <i>unlifted</i> (hence <tt>ptrArg</tt>). We never manipulate
grvalues of type <tt>RealWorld</tt>; it's only used in the type system,
grto parameterise <tt>State#</tt>.
data RealWorld

-- | Embed a strict state transformer in an <a>IO</a> action. The
gr<a>RealWorld</a> parameter indicates that the internal state used by
grthe <a>ST</a> computation is a special one supplied by the <a>IO</a>
grmonad, and thus distinct from those used by invocations of
gr<a>runST</a>.
stToIO :: ST RealWorld a -> IO a


-- | The strict ST monad (re-export of <a>Control.Monad.ST</a>)
module Control.Monad.ST.Strict


-- | This module presents an identical interface to
gr<a>Control.Monad.ST</a>, except that the monad delays evaluation of
grstate operations until a value depending on them is required.
gr
grUnsafe API.
module Control.Monad.ST.Lazy.Unsafe
unsafeInterleaveST :: ST s a -> ST s a
unsafeIOToST :: IO a -> ST s a


-- | This module presents an identical interface to
gr<a>Control.Monad.ST</a>, except that the monad delays evaluation of
grstate operations until a value depending on them is required.
gr
grSafe API only.

-- | <i>Deprecated: Safe is now the default, please use
grControl.Monad.ST.Lazy instead</i>
module Control.Monad.ST.Lazy.Safe

-- | The lazy state-transformer monad. A computation of type <tt><a>ST</a>
grs a</tt> transforms an internal state indexed by <tt>s</tt>, and
grreturns a value of type <tt>a</tt>. The <tt>s</tt> parameter is either
gr
gr<ul>
gr<li>an uninstantiated type variable (inside invocations of
gr<a>runST</a>), or</li>
gr<li><a>RealWorld</a> (inside invocations of <a>stToIO</a>).</li>
gr</ul>
gr
grIt serves to keep the internal states of different invocations of
gr<a>runST</a> separate from each other and from invocations of
gr<a>stToIO</a>.
gr
grThe <a>&gt;&gt;=</a> and <a>&gt;&gt;</a> operations are not strict in
grthe state. For example,
gr
gr<pre>
gr<a>runST</a> (writeSTRef _|_ v &gt;&gt;= readSTRef _|_ &gt;&gt; return 2) = 2
gr</pre>
data ST s a

-- | Return the value computed by a state transformer computation. The
gr<tt>forall</tt> ensures that the internal state used by the <a>ST</a>
grcomputation is inaccessible to the rest of the program.
runST :: (forall s. ST s a) -> a

-- | Allow the result of a state transformer computation to be used
gr(lazily) inside the computation. Note that if <tt>f</tt> is strict,
gr<tt><a>fixST</a> f = _|_</tt>.
fixST :: (a -> ST s a) -> ST s a

-- | Convert a strict <a>ST</a> computation into a lazy one. The strict
grstate thread passed to <a>strictToLazyST</a> is not performed until
grthe result of the lazy state thread it returns is demanded.
strictToLazyST :: ST s a -> ST s a

-- | Convert a lazy <a>ST</a> computation into a strict one.
lazyToStrictST :: ST s a -> ST s a

-- | <tt>RealWorld</tt> is deeply magical. It is <i>primitive</i>, but it
gris not <i>unlifted</i> (hence <tt>ptrArg</tt>). We never manipulate
grvalues of type <tt>RealWorld</tt>; it's only used in the type system,
grto parameterise <tt>State#</tt>.
data RealWorld

-- | A monad transformer embedding lazy state transformers in the <a>IO</a>
grmonad. The <a>RealWorld</a> parameter indicates that the internal
grstate used by the <a>ST</a> computation is a special one supplied by
grthe <a>IO</a> monad, and thus distinct from those used by invocations
grof <a>runST</a>.
stToIO :: ST RealWorld a -> IO a


-- | This module presents an identical interface to
gr<a>Control.Monad.ST</a>, except that the monad delays evaluation of
grstate operations until a value depending on them is required.
module Control.Monad.ST.Lazy

-- | The lazy state-transformer monad. A computation of type <tt><a>ST</a>
grs a</tt> transforms an internal state indexed by <tt>s</tt>, and
grreturns a value of type <tt>a</tt>. The <tt>s</tt> parameter is either
gr
gr<ul>
gr<li>an uninstantiated type variable (inside invocations of
gr<a>runST</a>), or</li>
gr<li><a>RealWorld</a> (inside invocations of <a>stToIO</a>).</li>
gr</ul>
gr
grIt serves to keep the internal states of different invocations of
gr<a>runST</a> separate from each other and from invocations of
gr<a>stToIO</a>.
gr
grThe <a>&gt;&gt;=</a> and <a>&gt;&gt;</a> operations are not strict in
grthe state. For example,
gr
gr<pre>
gr<a>runST</a> (writeSTRef _|_ v &gt;&gt;= readSTRef _|_ &gt;&gt; return 2) = 2
gr</pre>
data ST s a

-- | Return the value computed by a state transformer computation. The
gr<tt>forall</tt> ensures that the internal state used by the <a>ST</a>
grcomputation is inaccessible to the rest of the program.
runST :: (forall s. ST s a) -> a

-- | Allow the result of a state transformer computation to be used
gr(lazily) inside the computation. Note that if <tt>f</tt> is strict,
gr<tt><a>fixST</a> f = _|_</tt>.
fixST :: (a -> ST s a) -> ST s a

-- | Convert a strict <a>ST</a> computation into a lazy one. The strict
grstate thread passed to <a>strictToLazyST</a> is not performed until
grthe result of the lazy state thread it returns is demanded.
strictToLazyST :: ST s a -> ST s a

-- | Convert a lazy <a>ST</a> computation into a strict one.
lazyToStrictST :: ST s a -> ST s a

-- | <tt>RealWorld</tt> is deeply magical. It is <i>primitive</i>, but it
gris not <i>unlifted</i> (hence <tt>ptrArg</tt>). We never manipulate
grvalues of type <tt>RealWorld</tt>; it's only used in the type system,
grto parameterise <tt>State#</tt>.
data RealWorld

-- | A monad transformer embedding lazy state transformers in the <a>IO</a>
grmonad. The <a>RealWorld</a> parameter indicates that the internal
grstate used by the <a>ST</a> computation is a special one supplied by
grthe <a>IO</a> monad, and thus distinct from those used by invocations
grof <a>runST</a>.
stToIO :: ST RealWorld a -> IO a


-- | Mutable references in the lazy ST monad.
module Data.STRef.Lazy

-- | a value of type <tt>STRef s a</tt> is a mutable variable in state
grthread <tt>s</tt>, containing a value of type <tt>a</tt>
gr
gr<pre>
gr&gt;&gt;&gt; :{
grrunST (do
gr    ref &lt;- newSTRef "hello"
gr    x &lt;- readSTRef ref
gr    writeSTRef ref (x ++ "world")
gr    readSTRef ref )
gr:}
gr"helloworld"
gr</pre>
data STRef s a
newSTRef :: a -> ST s (STRef s a)
readSTRef :: STRef s a -> ST s a
writeSTRef :: STRef s a -> a -> ST s ()
modifySTRef :: STRef s a -> (a -> a) -> ST s ()


-- | <i>This module is DEPRECATED and will be removed in the future!</i>
gr
gr<a>Functor</a> and <a>Monad</a> instances for <tt>(-&gt;) r</tt> and
gr<a>Functor</a> instances for <tt>(,) a</tt> and <tt><a>Either</a>
gra</tt>.

-- | <i>Deprecated: This module now contains no instances and will be
grremoved in the future</i>
module Control.Monad.Instances

-- | The <a>Functor</a> class is used for types that can be mapped over.
grInstances of <a>Functor</a> should satisfy the following laws:
gr
gr<pre>
grfmap id  ==  id
grfmap (f . g)  ==  fmap f . fmap g
gr</pre>
gr
grThe instances of <a>Functor</a> for lists, <a>Maybe</a> and <a>IO</a>
grsatisfy these laws.
class Functor f
fmap :: Functor f => (a -> b) -> f a -> f b

-- | Replace all locations in the input with the same value. The default
grdefinition is <tt><a>fmap</a> . <a>const</a></tt>, but this may be
groverridden with a more efficient version.
(<$) :: Functor f => a -> f b -> f a

-- | The <a>Monad</a> class defines the basic operations over a
gr<i>monad</i>, a concept from a branch of mathematics known as
gr<i>category theory</i>. From the perspective of a Haskell programmer,
grhowever, it is best to think of a monad as an <i>abstract datatype</i>
grof actions. Haskell's <tt>do</tt> expressions provide a convenient
grsyntax for writing monadic expressions.
gr
grInstances of <a>Monad</a> should satisfy the following laws:
gr
gr<ul>
gr<li><pre><a>return</a> a <a>&gt;&gt;=</a> k = k a</pre></li>
gr<li><pre>m <a>&gt;&gt;=</a> <a>return</a> = m</pre></li>
gr<li><pre>m <a>&gt;&gt;=</a> (\x -&gt; k x <a>&gt;&gt;=</a> h) = (m
gr<a>&gt;&gt;=</a> k) <a>&gt;&gt;=</a> h</pre></li>
gr</ul>
gr
grFurthermore, the <a>Monad</a> and <a>Applicative</a> operations should
grrelate as follows:
gr
gr<ul>
gr<li><pre><a>pure</a> = <a>return</a></pre></li>
gr<li><pre>(<a>&lt;*&gt;</a>) = <a>ap</a></pre></li>
gr</ul>
gr
grThe above laws imply:
gr
gr<ul>
gr<li><pre><a>fmap</a> f xs = xs <a>&gt;&gt;=</a> <a>return</a> .
grf</pre></li>
gr<li><pre>(<a>&gt;&gt;</a>) = (<a>*&gt;</a>)</pre></li>
gr</ul>
gr
grand that <a>pure</a> and (<a>&lt;*&gt;</a>) satisfy the applicative
grfunctor laws.
gr
grThe instances of <a>Monad</a> for lists, <a>Maybe</a> and <a>IO</a>
grdefined in the <a>Prelude</a> satisfy these laws.
class Applicative m => Monad m

-- | Sequentially compose two actions, passing any value produced by the
grfirst as an argument to the second.
(>>=) :: forall a b. Monad m => m a -> (a -> m b) -> m b

-- | Sequentially compose two actions, discarding any value produced by the
grfirst, like sequencing operators (such as the semicolon) in imperative
grlanguages.
(>>) :: forall a b. Monad m => m a -> m b -> m b

-- | Inject a value into the monadic type.
return :: Monad m => a -> m a

-- | Fail with a message. This operation is not part of the mathematical
grdefinition of a monad, but is invoked on pattern-match failure in a
gr<tt>do</tt> expression.
gr
grAs part of the MonadFail proposal (MFP), this function is moved to its
grown class <tt>MonadFail</tt> (see <a>Control.Monad.Fail</a> for more
grdetails). The definition here will be removed in a future release.
fail :: Monad m => String -> m a


-- | Class of monads based on <tt>IO</tt>.
module Control.Monad.IO.Class

-- | Monads in which <a>IO</a> computations may be embedded. Any monad
grbuilt by applying a sequence of monad transformers to the <a>IO</a>
grmonad will be an instance of this class.
gr
grInstances should satisfy the following laws, which state that
gr<a>liftIO</a> is a transformer of monads:
gr
gr<ul>
gr<li><pre><a>liftIO</a> . <a>return</a> = <a>return</a></pre></li>
gr<li><pre><a>liftIO</a> (m &gt;&gt;= f) = <a>liftIO</a> m &gt;&gt;=
gr(<a>liftIO</a> . f)</pre></li>
gr</ul>
class (Monad m) => MonadIO m

-- | Lift a computation from the <a>IO</a> monad.
liftIO :: MonadIO m => IO a -> m a
instance Control.Monad.IO.Class.MonadIO GHC.Types.IO


-- | This module provides access to internal garbage collection and memory
grusage statistics. These statistics are not available unless a program
gris run with the <tt>-T</tt> RTS flag.
gr
grThis module is GHC-only and should not be considered portable.
module GHC.Stats

-- | Statistics about runtime activity since the start of the program. This
gris a mirror of the C <tt>struct RTSStats</tt> in <tt>RtsAPI.h</tt>
data RTSStats
RTSStats :: Word32 -> Word32 -> Word64 -> Word64 -> Word64 -> Word64 -> Word64 -> Word64 -> Word64 -> Word64 -> Word64 -> Word64 -> Word64 -> RtsTime -> RtsTime -> RtsTime -> RtsTime -> RtsTime -> RtsTime -> GCDetails -> RTSStats

-- | Total number of GCs
[gcs] :: RTSStats -> Word32

-- | Total number of major (oldest generation) GCs
[major_gcs] :: RTSStats -> Word32

-- | Total bytes allocated
[allocated_bytes] :: RTSStats -> Word64

-- | Maximum live data (including large objects + compact regions)
[max_live_bytes] :: RTSStats -> Word64

-- | Maximum live data in large objects
[max_large_objects_bytes] :: RTSStats -> Word64

-- | Maximum live data in compact regions
[max_compact_bytes] :: RTSStats -> Word64

-- | Maximum slop
[max_slop_bytes] :: RTSStats -> Word64

-- | Maximum memory in use by the RTS
[max_mem_in_use_bytes] :: RTSStats -> Word64

-- | Sum of live bytes across all major GCs. Divided by major_gcs gives the
graverage live data over the lifetime of the program.
[cumulative_live_bytes] :: RTSStats -> Word64

-- | Sum of copied_bytes across all GCs
[copied_bytes] :: RTSStats -> Word64

-- | Sum of copied_bytes across all parallel GCs
[par_copied_bytes] :: RTSStats -> Word64

-- | Sum of par_max_copied_bytes across all parallel GCs. Deprecated.
[cumulative_par_max_copied_bytes] :: RTSStats -> Word64

-- | Sum of par_balanced_copied bytes across all parallel GCs
[cumulative_par_balanced_copied_bytes] :: RTSStats -> Word64

-- | Total CPU time used by the mutator
[mutator_cpu_ns] :: RTSStats -> RtsTime

-- | Total elapsed time used by the mutator
[mutator_elapsed_ns] :: RTSStats -> RtsTime

-- | Total CPU time used by the GC
[gc_cpu_ns] :: RTSStats -> RtsTime

-- | Total elapsed time used by the GC
[gc_elapsed_ns] :: RTSStats -> RtsTime

-- | Total CPU time (at the previous GC)
[cpu_ns] :: RTSStats -> RtsTime

-- | Total elapsed time (at the previous GC)
[elapsed_ns] :: RTSStats -> RtsTime

-- | Details about the most recent GC
[gc] :: RTSStats -> GCDetails

-- | Statistics about a single GC. This is a mirror of the C <tt>struct
grGCDetails</tt> in <tt>RtsAPI.h</tt>, with the field prefixed with
gr<tt>gc_</tt> to avoid collisions with <a>RTSStats</a>.
data GCDetails
GCDetails :: Word32 -> Word32 -> Word64 -> Word64 -> Word64 -> Word64 -> Word64 -> Word64 -> Word64 -> Word64 -> Word64 -> RtsTime -> RtsTime -> RtsTime -> GCDetails

-- | The generation number of this GC
[gcdetails_gen] :: GCDetails -> Word32

-- | Number of threads used in this GC
[gcdetails_threads] :: GCDetails -> Word32

-- | Number of bytes allocated since the previous GC
[gcdetails_allocated_bytes] :: GCDetails -> Word64

-- | Total amount of live data in the heap (incliudes large + compact data)
[gcdetails_live_bytes] :: GCDetails -> Word64

-- | Total amount of live data in large objects
[gcdetails_large_objects_bytes] :: GCDetails -> Word64

-- | Total amount of live data in compact regions
[gcdetails_compact_bytes] :: GCDetails -> Word64

-- | Total amount of slop (wasted memory)
[gcdetails_slop_bytes] :: GCDetails -> Word64

-- | Total amount of memory in use by the RTS
[gcdetails_mem_in_use_bytes] :: GCDetails -> Word64

-- | Total amount of data copied during this GC
[gcdetails_copied_bytes] :: GCDetails -> Word64

-- | In parallel GC, the max amount of data copied by any one thread.
grDeprecated.
[gcdetails_par_max_copied_bytes] :: GCDetails -> Word64

-- | In parallel GC, the amount of balanced data copied by all threads
[gcdetails_par_balanced_copied_bytes] :: GCDetails -> Word64

-- | The time elapsed during synchronisation before GC
[gcdetails_sync_elapsed_ns] :: GCDetails -> RtsTime

-- | The CPU time used during GC itself
[gcdetails_cpu_ns] :: GCDetails -> RtsTime

-- | The time elapsed during GC itself
[gcdetails_elapsed_ns] :: GCDetails -> RtsTime

-- | Time values from the RTS, using a fixed resolution of nanoseconds.
type RtsTime = Int64

-- | Get current runtime system statistics.
getRTSStats :: IO RTSStats

-- | Returns whether GC stats have been enabled (with <tt>+RTS -T</tt>, for
grexample).
getRTSStatsEnabled :: IO Bool
instance GHC.Show.Show GHC.Stats.RTSStats
instance GHC.Read.Read GHC.Stats.RTSStats
instance GHC.Show.Show GHC.Stats.GCDetails
instance GHC.Read.Read GHC.Stats.GCDetails


-- | Accessors to GHC RTS flags. Descriptions of flags can be seen in
gr<a>GHC User's Guide</a>, or by running RTS help message using <tt>+RTS
gr--help</tt>.
module GHC.RTS.Flags

-- | <tt><tt>Time</tt></tt> is defined as a <tt><tt>StgWord64</tt></tt> in
gr<tt>stg/Types.h</tt>
type RtsTime = Word64

-- | Parameters of the runtime system
data RTSFlags
RTSFlags :: GCFlags -> ConcFlags -> MiscFlags -> DebugFlags -> CCFlags -> ProfFlags -> TraceFlags -> TickyFlags -> ParFlags -> RTSFlags
[gcFlags] :: RTSFlags -> GCFlags
[concurrentFlags] :: RTSFlags -> ConcFlags
[miscFlags] :: RTSFlags -> MiscFlags
[debugFlags] :: RTSFlags -> DebugFlags
[costCentreFlags] :: RTSFlags -> CCFlags
[profilingFlags] :: RTSFlags -> ProfFlags
[traceFlags] :: RTSFlags -> TraceFlags
[tickyFlags] :: RTSFlags -> TickyFlags
[parFlags] :: RTSFlags -> ParFlags

-- | Should we produce a summary of the garbage collector statistics after
grthe program has exited?
data GiveGCStats
NoGCStats :: GiveGCStats
CollectGCStats :: GiveGCStats
OneLineGCStats :: GiveGCStats
SummaryGCStats :: GiveGCStats
VerboseGCStats :: GiveGCStats

-- | Parameters of the garbage collector.
data GCFlags
GCFlags :: Maybe FilePath -> GiveGCStats -> Word32 -> Word32 -> Word32 -> Word32 -> Word32 -> Word32 -> Word32 -> Word32 -> Word32 -> Word32 -> Bool -> Double -> Double -> Word32 -> Bool -> Bool -> Double -> Bool -> Bool -> RtsTime -> Bool -> Word -> Word -> Bool -> Word -> GCFlags
[statsFile] :: GCFlags -> Maybe FilePath
[giveStats] :: GCFlags -> GiveGCStats
[maxStkSize] :: GCFlags -> Word32
[initialStkSize] :: GCFlags -> Word32
[stkChunkSize] :: GCFlags -> Word32
[stkChunkBufferSize] :: GCFlags -> Word32
[maxHeapSize] :: GCFlags -> Word32
[minAllocAreaSize] :: GCFlags -> Word32
[largeAllocLim] :: GCFlags -> Word32
[nurseryChunkSize] :: GCFlags -> Word32
[minOldGenSize] :: GCFlags -> Word32
[heapSizeSuggestion] :: GCFlags -> Word32
[heapSizeSuggestionAuto] :: GCFlags -> Bool
[oldGenFactor] :: GCFlags -> Double
[pcFreeHeap] :: GCFlags -> Double
[generations] :: GCFlags -> Word32
[squeezeUpdFrames] :: GCFlags -> Bool

-- | True <a>=</a> "compact all the time"
[compact] :: GCFlags -> Bool
[compactThreshold] :: GCFlags -> Double

-- | use "mostly mark-sweep" instead of copying for the oldest generation
[sweep] :: GCFlags -> Bool
[ringBell] :: GCFlags -> Bool
[idleGCDelayTime] :: GCFlags -> RtsTime
[doIdleGC] :: GCFlags -> Bool

-- | address to ask the OS for memory
[heapBase] :: GCFlags -> Word
[allocLimitGrace] :: GCFlags -> Word
[numa] :: GCFlags -> Bool
[numaMask] :: GCFlags -> Word

-- | Parameters concerning context switching
data ConcFlags
ConcFlags :: RtsTime -> Int -> ConcFlags
[ctxtSwitchTime] :: ConcFlags -> RtsTime
[ctxtSwitchTicks] :: ConcFlags -> Int

-- | Miscellaneous parameters
data MiscFlags
MiscFlags :: RtsTime -> Bool -> Bool -> Bool -> Bool -> Bool -> Word -> MiscFlags
[tickInterval] :: MiscFlags -> RtsTime
[installSignalHandlers] :: MiscFlags -> Bool
[installSEHHandlers] :: MiscFlags -> Bool
[generateCrashDumpFile] :: MiscFlags -> Bool
[generateStackTrace] :: MiscFlags -> Bool
[machineReadable] :: MiscFlags -> Bool

-- | address to ask the OS for memory for the linker, 0 ==&gt; off
[linkerMemBase] :: MiscFlags -> Word

-- | Flags to control debugging output &amp; extra checking in various
grsubsystems.
data DebugFlags
DebugFlags :: Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> DebugFlags

-- | <tt>s</tt>
[scheduler] :: DebugFlags -> Bool

-- | <tt>i</tt>
[interpreter] :: DebugFlags -> Bool

-- | <tt>w</tt>
[weak] :: DebugFlags -> Bool

-- | <tt>G</tt>
[gccafs] :: DebugFlags -> Bool

-- | <tt>g</tt>
[gc] :: DebugFlags -> Bool

-- | <tt>b</tt>
[block_alloc] :: DebugFlags -> Bool

-- | <tt>S</tt>
[sanity] :: DebugFlags -> Bool

-- | <tt>t</tt>
[stable] :: DebugFlags -> Bool

-- | <tt>p</tt>
[prof] :: DebugFlags -> Bool

-- | <tt>l</tt> the object linker
[linker] :: DebugFlags -> Bool

-- | <tt>a</tt>
[apply] :: DebugFlags -> Bool

-- | <tt>m</tt>
[stm] :: DebugFlags -> Bool

-- | <tt>z</tt> stack squeezing &amp; lazy blackholing
[squeeze] :: DebugFlags -> Bool

-- | <tt>c</tt> coverage
[hpc] :: DebugFlags -> Bool

-- | <tt>r</tt>
[sparks] :: DebugFlags -> Bool

-- | Should the RTS produce a cost-center summary?
data DoCostCentres
CostCentresNone :: DoCostCentres
CostCentresSummary :: DoCostCentres
CostCentresVerbose :: DoCostCentres
CostCentresAll :: DoCostCentres
CostCentresJSON :: DoCostCentres

-- | Parameters pertaining to the cost-center profiler.
data CCFlags
CCFlags :: DoCostCentres -> Int -> Int -> CCFlags
[doCostCentres] :: CCFlags -> DoCostCentres
[profilerTicks] :: CCFlags -> Int
[msecsPerTick] :: CCFlags -> Int

-- | What sort of heap profile are we collecting?
data DoHeapProfile
NoHeapProfiling :: DoHeapProfile
HeapByCCS :: DoHeapProfile
HeapByMod :: DoHeapProfile
HeapByDescr :: DoHeapProfile
HeapByType :: DoHeapProfile
HeapByRetainer :: DoHeapProfile
HeapByLDV :: DoHeapProfile
HeapByClosureType :: DoHeapProfile

-- | Parameters of the cost-center profiler
data ProfFlags
ProfFlags :: DoHeapProfile -> RtsTime -> Word -> Bool -> Bool -> Word -> Word -> Maybe String -> Maybe String -> Maybe String -> Maybe String -> Maybe String -> Maybe String -> Maybe String -> ProfFlags
[doHeapProfile] :: ProfFlags -> DoHeapProfile

-- | time between samples
[heapProfileInterval] :: ProfFlags -> RtsTime

-- | ticks between samples (derived)
[heapProfileIntervalTicks] :: ProfFlags -> Word
[includeTSOs] :: ProfFlags -> Bool
[showCCSOnException] :: ProfFlags -> Bool
[maxRetainerSetSize] :: ProfFlags -> Word
[ccsLength] :: ProfFlags -> Word
[modSelector] :: ProfFlags -> Maybe String
[descrSelector] :: ProfFlags -> Maybe String
[typeSelector] :: ProfFlags -> Maybe String
[ccSelector] :: ProfFlags -> Maybe String
[ccsSelector] :: ProfFlags -> Maybe String
[retainerSelector] :: ProfFlags -> Maybe String
[bioSelector] :: ProfFlags -> Maybe String

-- | Is event tracing enabled?
data DoTrace

-- | no tracing
TraceNone :: DoTrace

-- | send tracing events to the event log
TraceEventLog :: DoTrace

-- | send tracing events to <tt>stderr</tt>
TraceStderr :: DoTrace

-- | Parameters pertaining to event tracing
data TraceFlags
TraceFlags :: DoTrace -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> TraceFlags
[tracing] :: TraceFlags -> DoTrace

-- | show timestamp in stderr output
[timestamp] :: TraceFlags -> Bool

-- | trace scheduler events
[traceScheduler] :: TraceFlags -> Bool

-- | trace GC events
[traceGc] :: TraceFlags -> Bool

-- | trace spark events by a sampled method
[sparksSampled] :: TraceFlags -> Bool

-- | trace spark events 100% accurately
[sparksFull] :: TraceFlags -> Bool

-- | trace user events (emitted from Haskell code)
[user] :: TraceFlags -> Bool

-- | Parameters pertaining to ticky-ticky profiler
data TickyFlags
TickyFlags :: Bool -> Maybe FilePath -> TickyFlags
[showTickyStats] :: TickyFlags -> Bool
[tickyFile] :: TickyFlags -> Maybe FilePath

-- | Parameters pertaining to parallelism
data ParFlags
ParFlags :: Word32 -> Bool -> Word32 -> Bool -> Word32 -> Bool -> Word32 -> Word32 -> Word32 -> Bool -> ParFlags
[nCapabilities] :: ParFlags -> Word32
[migrate] :: ParFlags -> Bool
[maxLocalSparks] :: ParFlags -> Word32
[parGcEnabled] :: ParFlags -> Bool
[parGcGen] :: ParFlags -> Word32
[parGcLoadBalancingEnabled] :: ParFlags -> Bool
[parGcLoadBalancingGen] :: ParFlags -> Word32
[parGcNoSyncWithIdle] :: ParFlags -> Word32
[parGcThreads] :: ParFlags -> Word32
[setAffinity] :: ParFlags -> Bool
getRTSFlags :: IO RTSFlags
getGCFlags :: IO GCFlags
getConcFlags :: IO ConcFlags
getMiscFlags :: IO MiscFlags
getDebugFlags :: IO DebugFlags
getCCFlags :: IO CCFlags
getProfFlags :: IO ProfFlags
getTraceFlags :: IO TraceFlags
getTickyFlags :: IO TickyFlags
getParFlags :: IO ParFlags
instance GHC.Show.Show GHC.RTS.Flags.RTSFlags
instance GHC.Show.Show GHC.RTS.Flags.ParFlags
instance GHC.Show.Show GHC.RTS.Flags.TickyFlags
instance GHC.Show.Show GHC.RTS.Flags.TraceFlags
instance GHC.Show.Show GHC.RTS.Flags.DoTrace
instance GHC.Show.Show GHC.RTS.Flags.ProfFlags
instance GHC.Show.Show GHC.RTS.Flags.DoHeapProfile
instance GHC.Show.Show GHC.RTS.Flags.CCFlags
instance GHC.Show.Show GHC.RTS.Flags.DoCostCentres
instance GHC.Show.Show GHC.RTS.Flags.DebugFlags
instance GHC.Show.Show GHC.RTS.Flags.MiscFlags
instance GHC.Show.Show GHC.RTS.Flags.ConcFlags
instance GHC.Show.Show GHC.RTS.Flags.GCFlags
instance GHC.Show.Show GHC.RTS.Flags.GiveGCStats
instance GHC.Enum.Enum GHC.RTS.Flags.DoTrace
instance GHC.Enum.Enum GHC.RTS.Flags.DoHeapProfile
instance GHC.Enum.Enum GHC.RTS.Flags.DoCostCentres
instance GHC.Enum.Enum GHC.RTS.Flags.GiveGCStats


-- | Internals of the <a>ExecutionStack</a> module
module GHC.ExecutionStack.Internal

-- | Location information about an address from a backtrace.
data Location
Location :: String -> String -> Maybe SrcLoc -> Location
[objectName] :: Location -> String
[functionName] :: Location -> String
[srcLoc] :: Location -> Maybe SrcLoc

-- | A location in the original program source.
data SrcLoc
SrcLoc :: String -> Int -> Int -> SrcLoc
[sourceFile] :: SrcLoc -> String
[sourceLine] :: SrcLoc -> Int
[sourceColumn] :: SrcLoc -> Int

-- | The state of the execution stack
data StackTrace

-- | List the frames of a stack trace.
stackFrames :: StackTrace -> Maybe [Location]

-- | How many stack frames in the given <a>StackTrace</a>
stackDepth :: StackTrace -> Int

-- | Get an execution stack.
collectStackTrace :: IO (Maybe StackTrace)

-- | Render a stacktrace as a string
showStackFrames :: [Location] -> ShowS

-- | Free the cached debug data.
invalidateDebugCache :: IO ()


-- | This is a module for efficient stack traces. This stack trace
grimplementation is considered low overhead. Basic usage looks like
grthis:
gr
gr<pre>
grimport GHC.ExecutionStack
gr
grmyFunction :: IO ()
grmyFunction = do
gr     putStrLn =&lt;&lt; showStackTrace
gr</pre>
gr
grYour GHC must have been built with <tt>libdw</tt> support for this to
grwork.
gr
gr<pre>
gruser@host:~$ ghc --info | grep libdw
gr ,("RTS expects libdw",<a>YES</a>)
gr</pre>
module GHC.ExecutionStack

-- | Location information about an address from a backtrace.
data Location
Location :: String -> String -> Maybe SrcLoc -> Location
[objectName] :: Location -> String
[functionName] :: Location -> String
[srcLoc] :: Location -> Maybe SrcLoc

-- | A location in the original program source.
data SrcLoc
SrcLoc :: String -> Int -> Int -> SrcLoc
[sourceFile] :: SrcLoc -> String
[sourceLine] :: SrcLoc -> Int
[sourceColumn] :: SrcLoc -> Int

-- | Get a trace of the current execution stack state.
gr
grReturns <tt>Nothing</tt> if stack trace support isn't available on
grhost machine.
getStackTrace :: IO (Maybe [Location])

-- | Get a string representation of the current execution stack state.
showStackTrace :: IO (Maybe String)


-- | A <a>NonEmpty</a> list is one which always has at least one element,
grbut is otherwise identical to the traditional list type in complexity
grand in terms of API. You will almost certainly want to import this
grmodule <tt>qualified</tt>.
module Data.List.NonEmpty

-- | Non-empty (and non-strict) list type.
data NonEmpty a
(:|) :: a -> [a] -> NonEmpty a

-- | Map a function over a <a>NonEmpty</a> stream.
map :: (a -> b) -> NonEmpty a -> NonEmpty b

-- | 'intersperse x xs' alternates elements of the list with copies of
gr<tt>x</tt>.
gr
gr<pre>
grintersperse 0 (1 :| [2,3]) == 1 :| [0,2,0,3]
gr</pre>
intersperse :: a -> NonEmpty a -> NonEmpty a

-- | <a>scanl</a> is similar to <a>foldl</a>, but returns a stream of
grsuccessive reduced values from the left:
gr
gr<pre>
grscanl f z [x1, x2, ...] == z :| [z `f` x1, (z `f` x1) `f` x2, ...]
gr</pre>
gr
grNote that
gr
gr<pre>
grlast (scanl f z xs) == foldl f z xs.
gr</pre>
scanl :: Foldable f => (b -> a -> b) -> b -> f a -> NonEmpty b

-- | <a>scanr</a> is the right-to-left dual of <a>scanl</a>. Note that
gr
gr<pre>
grhead (scanr f z xs) == foldr f z xs.
gr</pre>
scanr :: Foldable f => (a -> b -> b) -> b -> f a -> NonEmpty b

-- | <a>scanl1</a> is a variant of <a>scanl</a> that has no starting value
grargument:
gr
gr<pre>
grscanl1 f [x1, x2, ...] == x1 :| [x1 `f` x2, x1 `f` (x2 `f` x3), ...]
gr</pre>
scanl1 :: (a -> a -> a) -> NonEmpty a -> NonEmpty a

-- | <a>scanr1</a> is a variant of <a>scanr</a> that has no starting value
grargument.
scanr1 :: (a -> a -> a) -> NonEmpty a -> NonEmpty a

-- | <a>transpose</a> for <a>NonEmpty</a>, behaves the same as
gr<a>transpose</a> The rows/columns need not be the same length, in
grwhich case &gt; transpose . transpose /= id
transpose :: NonEmpty (NonEmpty a) -> NonEmpty (NonEmpty a)

-- | <a>sortBy</a> for <a>NonEmpty</a>, behaves the same as <a>sortBy</a>
sortBy :: (a -> a -> Ordering) -> NonEmpty a -> NonEmpty a

-- | <a>sortWith</a> for <a>NonEmpty</a>, behaves the same as:
gr
gr<pre>
grsortBy . comparing
gr</pre>
sortWith :: Ord o => (a -> o) -> NonEmpty a -> NonEmpty a

-- | Number of elements in <a>NonEmpty</a> list.
length :: NonEmpty a -> Int

-- | Extract the first element of the stream.
head :: NonEmpty a -> a

-- | Extract the possibly-empty tail of the stream.
tail :: NonEmpty a -> [a]

-- | Extract the last element of the stream.
last :: NonEmpty a -> a

-- | Extract everything except the last element of the stream.
init :: NonEmpty a -> [a]

-- | Prepend an element to the stream.
(<|) :: a -> NonEmpty a -> NonEmpty a
infixr 5 <|

-- | Synonym for <a>&lt;|</a>.
cons :: a -> NonEmpty a -> NonEmpty a

-- | <a>uncons</a> produces the first element of the stream, and a stream
grof the remaining elements, if any.
uncons :: NonEmpty a -> (a, Maybe (NonEmpty a))

-- | The <a>unfoldr</a> function is analogous to <a>Data.List</a>'s
gr<a>unfoldr</a> operation.
unfoldr :: (a -> (b, Maybe a)) -> a -> NonEmpty b

-- | Sort a stream.
sort :: Ord a => NonEmpty a -> NonEmpty a

-- | <a>reverse</a> a finite NonEmpty stream.
reverse :: NonEmpty a -> NonEmpty a

-- | The <a>inits</a> function takes a stream <tt>xs</tt> and returns all
grthe finite prefixes of <tt>xs</tt>.
inits :: Foldable f => f a -> NonEmpty [a]

-- | The <a>tails</a> function takes a stream <tt>xs</tt> and returns all
grthe suffixes of <tt>xs</tt>.
tails :: Foldable f => f a -> NonEmpty [a]

-- | <tt><a>iterate</a> f x</tt> produces the infinite sequence of repeated
grapplications of <tt>f</tt> to <tt>x</tt>.
gr
gr<pre>
griterate f x = x :| [f x, f (f x), ..]
gr</pre>
iterate :: (a -> a) -> a -> NonEmpty a

-- | <tt><a>repeat</a> x</tt> returns a constant stream, where all elements
grare equal to <tt>x</tt>.
repeat :: a -> NonEmpty a

-- | <tt><a>cycle</a> xs</tt> returns the infinite repetition of
gr<tt>xs</tt>:
gr
gr<pre>
grcycle (1 :| [2,3]) = 1 :| [2,3,1,2,3,...]
gr</pre>
cycle :: NonEmpty a -> NonEmpty a

-- | <a>unfold</a> produces a new stream by repeatedly applying the
grunfolding function to the seed value to produce an element of type
gr<tt>b</tt> and a new seed value. When the unfolding function returns
gr<a>Nothing</a> instead of a new seed value, the stream ends.

-- | <i>Deprecated: Use unfoldr</i>
unfold :: (a -> (b, Maybe a)) -> a -> NonEmpty b

-- | <tt><a>insert</a> x xs</tt> inserts <tt>x</tt> into the last position
grin <tt>xs</tt> where it is still less than or equal to the next
grelement. In particular, if the list is sorted beforehand, the result
grwill also be sorted.
insert :: (Foldable f, Ord a) => a -> f a -> NonEmpty a

-- | <tt><a>some1</a> x</tt> sequences <tt>x</tt> one or more times.
some1 :: Alternative f => f a -> f (NonEmpty a)

-- | <tt><a>take</a> n xs</tt> returns the first <tt>n</tt> elements of
gr<tt>xs</tt>.
take :: Int -> NonEmpty a -> [a]

-- | <tt><a>drop</a> n xs</tt> drops the first <tt>n</tt> elements off the
grfront of the sequence <tt>xs</tt>.
drop :: Int -> NonEmpty a -> [a]

-- | <tt><a>splitAt</a> n xs</tt> returns a pair consisting of the prefix
grof <tt>xs</tt> of length <tt>n</tt> and the remaining stream
grimmediately following this prefix.
gr
gr<pre>
gr'splitAt' n xs == ('take' n xs, 'drop' n xs)
grxs == ys ++ zs where (ys, zs) = 'splitAt' n xs
gr</pre>
splitAt :: Int -> NonEmpty a -> ([a], [a])

-- | <tt><a>takeWhile</a> p xs</tt> returns the longest prefix of the
grstream <tt>xs</tt> for which the predicate <tt>p</tt> holds.
takeWhile :: (a -> Bool) -> NonEmpty a -> [a]

-- | <tt><a>dropWhile</a> p xs</tt> returns the suffix remaining after
gr<tt><a>takeWhile</a> p xs</tt>.
dropWhile :: (a -> Bool) -> NonEmpty a -> [a]

-- | <tt><a>span</a> p xs</tt> returns the longest prefix of <tt>xs</tt>
grthat satisfies <tt>p</tt>, together with the remainder of the stream.
gr
gr<pre>
gr'span' p xs == ('takeWhile' p xs, 'dropWhile' p xs)
grxs == ys ++ zs where (ys, zs) = 'span' p xs
gr</pre>
span :: (a -> Bool) -> NonEmpty a -> ([a], [a])

-- | The <tt><a>break</a> p</tt> function is equivalent to <tt><a>span</a>
gr(not . p)</tt>.
break :: (a -> Bool) -> NonEmpty a -> ([a], [a])

-- | <tt><a>filter</a> p xs</tt> removes any elements from <tt>xs</tt> that
grdo not satisfy <tt>p</tt>.
filter :: (a -> Bool) -> NonEmpty a -> [a]

-- | The <a>partition</a> function takes a predicate <tt>p</tt> and a
grstream <tt>xs</tt>, and returns a pair of lists. The first list
grcorresponds to the elements of <tt>xs</tt> for which <tt>p</tt> holds;
grthe second corresponds to the elements of <tt>xs</tt> for which
gr<tt>p</tt> does not hold.
gr
gr<pre>
gr'partition' p xs = ('filter' p xs, 'filter' (not . p) xs)
gr</pre>
partition :: (a -> Bool) -> NonEmpty a -> ([a], [a])

-- | The <a>group</a> function takes a stream and returns a list of streams
grsuch that flattening the resulting list is equal to the argument.
grMoreover, each stream in the resulting list contains only equal
grelements. For example, in list notation:
gr
gr<pre>
gr'group' $ 'cycle' "Mississippi"
gr  = "M" : "i" : "ss" : "i" : "ss" : "i" : "pp" : "i" : "M" : "i" : ...
gr</pre>
group :: (Foldable f, Eq a) => f a -> [NonEmpty a]

-- | <a>groupBy</a> operates like <a>group</a>, but uses the provided
grequality predicate instead of <a>==</a>.
groupBy :: Foldable f => (a -> a -> Bool) -> f a -> [NonEmpty a]

-- | <a>groupWith</a> operates like <a>group</a>, but uses the provided
grprojection when comparing for equality
groupWith :: (Foldable f, Eq b) => (a -> b) -> f a -> [NonEmpty a]

-- | <a>groupAllWith</a> operates like <a>groupWith</a>, but sorts the list
grfirst so that each equivalence class has, at most, one list in the
groutput
groupAllWith :: (Ord b) => (a -> b) -> [a] -> [NonEmpty a]

-- | <a>group1</a> operates like <a>group</a>, but uses the knowledge that
grits input is non-empty to produce guaranteed non-empty output.
group1 :: Eq a => NonEmpty a -> NonEmpty (NonEmpty a)

-- | <a>groupBy1</a> is to <a>group1</a> as <a>groupBy</a> is to
gr<a>group</a>.
groupBy1 :: (a -> a -> Bool) -> NonEmpty a -> NonEmpty (NonEmpty a)

-- | <a>groupWith1</a> is to <a>group1</a> as <a>groupWith</a> is to
gr<a>group</a>
groupWith1 :: (Eq b) => (a -> b) -> NonEmpty a -> NonEmpty (NonEmpty a)

-- | <a>groupAllWith1</a> is to <a>groupWith1</a> as <a>groupAllWith</a> is
grto <a>groupWith</a>
groupAllWith1 :: (Ord b) => (a -> b) -> NonEmpty a -> NonEmpty (NonEmpty a)

-- | The <tt>isPrefix</tt> function returns <tt>True</tt> if the first
grargument is a prefix of the second.
isPrefixOf :: Eq a => [a] -> NonEmpty a -> Bool

-- | The <a>nub</a> function removes duplicate elements from a list. In
grparticular, it keeps only the first occurrence of each element. (The
grname <a>nub</a> means 'essence'.) It is a special case of
gr<a>nubBy</a>, which allows the programmer to supply their own
grinequality test.
nub :: Eq a => NonEmpty a -> NonEmpty a

-- | The <a>nubBy</a> function behaves just like <a>nub</a>, except it uses
gra user-supplied equality predicate instead of the overloaded <a>==</a>
grfunction.
nubBy :: (a -> a -> Bool) -> NonEmpty a -> NonEmpty a

-- | <tt>xs !! n</tt> returns the element of the stream <tt>xs</tt> at
grindex <tt>n</tt>. Note that the head of the stream has index 0.
gr
gr<i>Beware</i>: a negative or out-of-bounds index will cause an error.
(!!) :: NonEmpty a -> Int -> a
infixl 9 !!

-- | The <a>zip</a> function takes two streams and returns a stream of
grcorresponding pairs.
zip :: NonEmpty a -> NonEmpty b -> NonEmpty (a, b)

-- | The <a>zipWith</a> function generalizes <a>zip</a>. Rather than
grtupling the elements, the elements are combined using the function
grpassed as the first argument.
zipWith :: (a -> b -> c) -> NonEmpty a -> NonEmpty b -> NonEmpty c

-- | The <a>unzip</a> function is the inverse of the <a>zip</a> function.
unzip :: Functor f => f (a, b) -> (f a, f b)

-- | Converts a normal list to a <a>NonEmpty</a> stream.
gr
grRaises an error if given an empty list.
fromList :: [a] -> NonEmpty a

-- | Convert a stream to a normal list efficiently.
toList :: NonEmpty a -> [a]

-- | <a>nonEmpty</a> efficiently turns a normal list into a <a>NonEmpty</a>
grstream, producing <a>Nothing</a> if the input is empty.
nonEmpty :: [a] -> Maybe (NonEmpty a)

-- | Compute n-ary logic exclusive OR operation on <a>NonEmpty</a> list.
xor :: NonEmpty Bool -> Bool


-- | Monadic zipping (used for monad comprehensions)
module Control.Monad.Zip

-- | <a>MonadZip</a> type class. Minimal definition: <a>mzip</a> or
gr<a>mzipWith</a>
gr
grInstances should satisfy the laws:
gr
gr<ul>
gr<li>Naturality :</li>
gr</ul>
gr
gr<pre>
grliftM (f *** g) (mzip ma mb) = mzip (liftM f ma) (liftM g mb)
gr</pre>
gr
gr<ul>
gr<li>Information Preservation:</li>
gr</ul>
gr
gr<pre>
grliftM (const ()) ma = liftM (const ()) mb
gr==&gt;
grmunzip (mzip ma mb) = (ma, mb)
gr</pre>
class Monad m => MonadZip m
mzip :: MonadZip m => m a -> m b -> m (a, b)
mzipWith :: MonadZip m => (a -> b -> c) -> m a -> m b -> m c
munzip :: MonadZip m => m (a, b) -> (m a, m b)
instance Control.Monad.Zip.MonadZip []
instance Control.Monad.Zip.MonadZip GHC.Base.NonEmpty
instance Control.Monad.Zip.MonadZip Data.Functor.Identity.Identity
instance Control.Monad.Zip.MonadZip Data.Semigroup.Internal.Dual
instance Control.Monad.Zip.MonadZip Data.Semigroup.Internal.Sum
instance Control.Monad.Zip.MonadZip Data.Semigroup.Internal.Product
instance Control.Monad.Zip.MonadZip GHC.Base.Maybe
instance Control.Monad.Zip.MonadZip Data.Monoid.First
instance Control.Monad.Zip.MonadZip Data.Monoid.Last
instance Control.Monad.Zip.MonadZip f => Control.Monad.Zip.MonadZip (Data.Semigroup.Internal.Alt f)
instance Control.Monad.Zip.MonadZip Data.Proxy.Proxy
instance Control.Monad.Zip.MonadZip GHC.Generics.U1
instance Control.Monad.Zip.MonadZip GHC.Generics.Par1
instance Control.Monad.Zip.MonadZip f => Control.Monad.Zip.MonadZip (GHC.Generics.Rec1 f)
instance Control.Monad.Zip.MonadZip f => Control.Monad.Zip.MonadZip (GHC.Generics.M1 i c f)
instance (Control.Monad.Zip.MonadZip f, Control.Monad.Zip.MonadZip g) => Control.Monad.Zip.MonadZip (f GHC.Generics.:*: g)


-- | Liftings of the Prelude classes <a>Eq</a>, <a>Ord</a>, <a>Read</a> and
gr<a>Show</a> to unary and binary type constructors.
gr
grThese classes are needed to express the constraints on arguments of
grtransformers in portable Haskell. Thus for a new transformer
gr<tt>T</tt>, one might write instances like
gr
gr<pre>
grinstance (Eq1 f) =&gt; Eq1 (T f) where ...
grinstance (Ord1 f) =&gt; Ord1 (T f) where ...
grinstance (Read1 f) =&gt; Read1 (T f) where ...
grinstance (Show1 f) =&gt; Show1 (T f) where ...
gr</pre>
gr
grIf these instances can be defined, defining instances of the base
grclasses is mechanical:
gr
gr<pre>
grinstance (Eq1 f, Eq a) =&gt; Eq (T f a) where (==) = eq1
grinstance (Ord1 f, Ord a) =&gt; Ord (T f a) where compare = compare1
grinstance (Read1 f, Read a) =&gt; Read (T f a) where
gr  readPrec     = readPrec1
gr  readListPrec = readListPrecDefault
grinstance (Show1 f, Show a) =&gt; Show (T f a) where showsPrec = showsPrec1
gr</pre>
module Data.Functor.Classes

-- | Lifting of the <a>Eq</a> class to unary type constructors.
class Eq1 f

-- | Lift an equality test through the type constructor.
gr
grThe function will usually be applied to an equality function, but the
grmore general type ensures that the implementation uses it to compare
grelements of the first container with elements of the second.
liftEq :: Eq1 f => (a -> b -> Bool) -> f a -> f b -> Bool

-- | Lift the standard <tt>(<a>==</a>)</tt> function through the type
grconstructor.
eq1 :: (Eq1 f, Eq a) => f a -> f a -> Bool

-- | Lifting of the <a>Ord</a> class to unary type constructors.
class (Eq1 f) => Ord1 f

-- | Lift a <a>compare</a> function through the type constructor.
gr
grThe function will usually be applied to a comparison function, but the
grmore general type ensures that the implementation uses it to compare
grelements of the first container with elements of the second.
liftCompare :: Ord1 f => (a -> b -> Ordering) -> f a -> f b -> Ordering

-- | Lift the standard <a>compare</a> function through the type
grconstructor.
compare1 :: (Ord1 f, Ord a) => f a -> f a -> Ordering

-- | Lifting of the <a>Read</a> class to unary type constructors.
gr
grBoth <a>liftReadsPrec</a> and <a>liftReadPrec</a> exist to match the
grinterface provided in the <a>Read</a> type class, but it is
grrecommended to implement <a>Read1</a> instances using
gr<a>liftReadPrec</a> as opposed to <a>liftReadsPrec</a>, since the
grformer is more efficient than the latter. For example:
gr
gr<pre>
grinstance <a>Read1</a> T where
gr  <a>liftReadPrec</a>     = ...
gr  <a>liftReadListPrec</a> = <a>liftReadListPrecDefault</a>
gr</pre>
gr
grFor more information, refer to the documentation for the <a>Read</a>
grclass.
class Read1 f

-- | <a>readsPrec</a> function for an application of the type constructor
grbased on <a>readsPrec</a> and <a>readList</a> functions for the
grargument type.
liftReadsPrec :: Read1 f => (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (f a)

-- | <a>readList</a> function for an application of the type constructor
grbased on <a>readsPrec</a> and <a>readList</a> functions for the
grargument type. The default implementation using standard list syntax
gris correct for most types.
liftReadList :: Read1 f => (Int -> ReadS a) -> ReadS [a] -> ReadS [f a]

-- | <a>readPrec</a> function for an application of the type constructor
grbased on <a>readPrec</a> and <a>readListPrec</a> functions for the
grargument type.
liftReadPrec :: Read1 f => ReadPrec a -> ReadPrec [a] -> ReadPrec (f a)

-- | <a>readListPrec</a> function for an application of the type
grconstructor based on <a>readPrec</a> and <a>readListPrec</a> functions
grfor the argument type.
gr
grThe default definition uses <a>liftReadList</a>. Instances that define
gr<a>liftReadPrec</a> should also define <a>liftReadListPrec</a> as
gr<a>liftReadListPrecDefault</a>.
liftReadListPrec :: Read1 f => ReadPrec a -> ReadPrec [a] -> ReadPrec [f a]

-- | Lift the standard <a>readsPrec</a> and <a>readList</a> functions
grthrough the type constructor.
readsPrec1 :: (Read1 f, Read a) => Int -> ReadS (f a)

-- | Lift the standard <a>readPrec</a> and <a>readListPrec</a> functions
grthrough the type constructor.
readPrec1 :: (Read1 f, Read a) => ReadPrec (f a)

-- | A possible replacement definition for the <a>liftReadList</a> method.
grThis is only needed for <a>Read1</a> instances where
gr<a>liftReadListPrec</a> isn't defined as
gr<a>liftReadListPrecDefault</a>.
liftReadListDefault :: Read1 f => (Int -> ReadS a) -> ReadS [a] -> ReadS [f a]

-- | A possible replacement definition for the <a>liftReadListPrec</a>
grmethod, defined using <a>liftReadPrec</a>.
liftReadListPrecDefault :: Read1 f => ReadPrec a -> ReadPrec [a] -> ReadPrec [f a]

-- | Lifting of the <a>Show</a> class to unary type constructors.
class Show1 f

-- | <a>showsPrec</a> function for an application of the type constructor
grbased on <a>showsPrec</a> and <a>showList</a> functions for the
grargument type.
liftShowsPrec :: Show1 f => (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> f a -> ShowS

-- | <a>showList</a> function for an application of the type constructor
grbased on <a>showsPrec</a> and <a>showList</a> functions for the
grargument type. The default implementation using standard list syntax
gris correct for most types.
liftShowList :: Show1 f => (Int -> a -> ShowS) -> ([a] -> ShowS) -> [f a] -> ShowS

-- | Lift the standard <a>showsPrec</a> and <a>showList</a> functions
grthrough the type constructor.
showsPrec1 :: (Show1 f, Show a) => Int -> f a -> ShowS

-- | Lifting of the <a>Eq</a> class to binary type constructors.
class Eq2 f

-- | Lift equality tests through the type constructor.
gr
grThe function will usually be applied to equality functions, but the
grmore general type ensures that the implementation uses them to compare
grelements of the first container with elements of the second.
liftEq2 :: Eq2 f => (a -> b -> Bool) -> (c -> d -> Bool) -> f a c -> f b d -> Bool

-- | Lift the standard <tt>(<a>==</a>)</tt> function through the type
grconstructor.
eq2 :: (Eq2 f, Eq a, Eq b) => f a b -> f a b -> Bool

-- | Lifting of the <a>Ord</a> class to binary type constructors.
class (Eq2 f) => Ord2 f

-- | Lift <a>compare</a> functions through the type constructor.
gr
grThe function will usually be applied to comparison functions, but the
grmore general type ensures that the implementation uses them to compare
grelements of the first container with elements of the second.
liftCompare2 :: Ord2 f => (a -> b -> Ordering) -> (c -> d -> Ordering) -> f a c -> f b d -> Ordering

-- | Lift the standard <a>compare</a> function through the type
grconstructor.
compare2 :: (Ord2 f, Ord a, Ord b) => f a b -> f a b -> Ordering

-- | Lifting of the <a>Read</a> class to binary type constructors.
gr
grBoth <a>liftReadsPrec2</a> and <a>liftReadPrec2</a> exist to match the
grinterface provided in the <a>Read</a> type class, but it is
grrecommended to implement <a>Read2</a> instances using
gr<a>liftReadPrec2</a> as opposed to <a>liftReadsPrec2</a>, since the
grformer is more efficient than the latter. For example:
gr
gr<pre>
grinstance <a>Read2</a> T where
gr  <a>liftReadPrec2</a>     = ...
gr  <a>liftReadListPrec2</a> = <a>liftReadListPrec2Default</a>
gr</pre>
gr
grFor more information, refer to the documentation for the <a>Read</a>
grclass. @since 4.9.0.0
class Read2 f

-- | <a>readsPrec</a> function for an application of the type constructor
grbased on <a>readsPrec</a> and <a>readList</a> functions for the
grargument types.
liftReadsPrec2 :: Read2 f => (Int -> ReadS a) -> ReadS [a] -> (Int -> ReadS b) -> ReadS [b] -> Int -> ReadS (f a b)

-- | <a>readList</a> function for an application of the type constructor
grbased on <a>readsPrec</a> and <a>readList</a> functions for the
grargument types. The default implementation using standard list syntax
gris correct for most types.
liftReadList2 :: Read2 f => (Int -> ReadS a) -> ReadS [a] -> (Int -> ReadS b) -> ReadS [b] -> ReadS [f a b]

-- | <a>readPrec</a> function for an application of the type constructor
grbased on <a>readPrec</a> and <a>readListPrec</a> functions for the
grargument types.
liftReadPrec2 :: Read2 f => ReadPrec a -> ReadPrec [a] -> ReadPrec b -> ReadPrec [b] -> ReadPrec (f a b)

-- | <a>readListPrec</a> function for an application of the type
grconstructor based on <a>readPrec</a> and <a>readListPrec</a> functions
grfor the argument types.
gr
grThe default definition uses <a>liftReadList2</a>. Instances that
grdefine <a>liftReadPrec2</a> should also define
gr<a>liftReadListPrec2</a> as <a>liftReadListPrec2Default</a>.
liftReadListPrec2 :: Read2 f => ReadPrec a -> ReadPrec [a] -> ReadPrec b -> ReadPrec [b] -> ReadPrec [f a b]

-- | Lift the standard <a>readsPrec</a> function through the type
grconstructor.
readsPrec2 :: (Read2 f, Read a, Read b) => Int -> ReadS (f a b)

-- | Lift the standard <a>readPrec</a> function through the type
grconstructor.
readPrec2 :: (Read2 f, Read a, Read b) => ReadPrec (f a b)

-- | A possible replacement definition for the <a>liftReadList2</a> method.
grThis is only needed for <a>Read2</a> instances where
gr<a>liftReadListPrec2</a> isn't defined as
gr<a>liftReadListPrec2Default</a>.
liftReadList2Default :: Read2 f => (Int -> ReadS a) -> ReadS [a] -> (Int -> ReadS b) -> ReadS [b] -> ReadS [f a b]

-- | A possible replacement definition for the <a>liftReadListPrec2</a>
grmethod, defined using <a>liftReadPrec2</a>.
liftReadListPrec2Default :: Read2 f => ReadPrec a -> ReadPrec [a] -> ReadPrec b -> ReadPrec [b] -> ReadPrec [f a b]

-- | Lifting of the <a>Show</a> class to binary type constructors.
class Show2 f

-- | <a>showsPrec</a> function for an application of the type constructor
grbased on <a>showsPrec</a> and <a>showList</a> functions for the
grargument types.
liftShowsPrec2 :: Show2 f => (Int -> a -> ShowS) -> ([a] -> ShowS) -> (Int -> b -> ShowS) -> ([b] -> ShowS) -> Int -> f a b -> ShowS

-- | <a>showList</a> function for an application of the type constructor
grbased on <a>showsPrec</a> and <a>showList</a> functions for the
grargument types. The default implementation using standard list syntax
gris correct for most types.
liftShowList2 :: Show2 f => (Int -> a -> ShowS) -> ([a] -> ShowS) -> (Int -> b -> ShowS) -> ([b] -> ShowS) -> [f a b] -> ShowS

-- | Lift the standard <a>showsPrec</a> function through the type
grconstructor.
showsPrec2 :: (Show2 f, Show a, Show b) => Int -> f a b -> ShowS

-- | <tt><a>readsData</a> p d</tt> is a parser for datatypes where each
gralternative begins with a data constructor. It parses the constructor
grand passes it to <tt>p</tt>. Parsers for various constructors can be
grconstructed with <a>readsUnary</a>, <a>readsUnary1</a> and
gr<a>readsBinary1</a>, and combined with <tt>mappend</tt> from the
gr<tt>Monoid</tt> class.
readsData :: (String -> ReadS a) -> Int -> ReadS a

-- | <tt><a>readData</a> p</tt> is a parser for datatypes where each
gralternative begins with a data constructor. It parses the constructor
grand passes it to <tt>p</tt>. Parsers for various constructors can be
grconstructed with <a>readUnaryWith</a> and <a>readBinaryWith</a>, and
grcombined with '(<a>|</a>)' from the <a>Alternative</a> class.
readData :: ReadPrec a -> ReadPrec a

-- | <tt><a>readsUnaryWith</a> rp n c n'</tt> matches the name of a unary
grdata constructor and then parses its argument using <tt>rp</tt>.
readsUnaryWith :: (Int -> ReadS a) -> String -> (a -> t) -> String -> ReadS t

-- | <tt><a>readUnaryWith</a> rp n c'</tt> matches the name of a unary data
grconstructor and then parses its argument using <tt>rp</tt>.
readUnaryWith :: ReadPrec a -> String -> (a -> t) -> ReadPrec t

-- | <tt><a>readsBinaryWith</a> rp1 rp2 n c n'</tt> matches the name of a
grbinary data constructor and then parses its arguments using
gr<tt>rp1</tt> and <tt>rp2</tt> respectively.
readsBinaryWith :: (Int -> ReadS a) -> (Int -> ReadS b) -> String -> (a -> b -> t) -> String -> ReadS t

-- | <tt><a>readBinaryWith</a> rp1 rp2 n c'</tt> matches the name of a
grbinary data constructor and then parses its arguments using
gr<tt>rp1</tt> and <tt>rp2</tt> respectively.
readBinaryWith :: ReadPrec a -> ReadPrec b -> String -> (a -> b -> t) -> ReadPrec t

-- | <tt><a>showsUnaryWith</a> sp n d x</tt> produces the string
grrepresentation of a unary data constructor with name <tt>n</tt> and
grargument <tt>x</tt>, in precedence context <tt>d</tt>.
showsUnaryWith :: (Int -> a -> ShowS) -> String -> Int -> a -> ShowS

-- | <tt><a>showsBinaryWith</a> sp1 sp2 n d x y</tt> produces the string
grrepresentation of a binary data constructor with name <tt>n</tt> and
grarguments <tt>x</tt> and <tt>y</tt>, in precedence context <tt>d</tt>.
showsBinaryWith :: (Int -> a -> ShowS) -> (Int -> b -> ShowS) -> String -> Int -> a -> b -> ShowS

-- | <tt><a>readsUnary</a> n c n'</tt> matches the name of a unary data
grconstructor and then parses its argument using <a>readsPrec</a>.

-- | <i>Deprecated: Use readsUnaryWith to define liftReadsPrec</i>
readsUnary :: (Read a) => String -> (a -> t) -> String -> ReadS t

-- | <tt><a>readsUnary1</a> n c n'</tt> matches the name of a unary data
grconstructor and then parses its argument using <a>readsPrec1</a>.

-- | <i>Deprecated: Use readsUnaryWith to define liftReadsPrec</i>
readsUnary1 :: (Read1 f, Read a) => String -> (f a -> t) -> String -> ReadS t

-- | <tt><a>readsBinary1</a> n c n'</tt> matches the name of a binary data
grconstructor and then parses its arguments using <a>readsPrec1</a>.

-- | <i>Deprecated: Use readsBinaryWith to define liftReadsPrec</i>
readsBinary1 :: (Read1 f, Read1 g, Read a) => String -> (f a -> g a -> t) -> String -> ReadS t

-- | <tt><a>showsUnary</a> n d x</tt> produces the string representation of
gra unary data constructor with name <tt>n</tt> and argument <tt>x</tt>,
grin precedence context <tt>d</tt>.

-- | <i>Deprecated: Use showsUnaryWith to define liftShowsPrec</i>
showsUnary :: (Show a) => String -> Int -> a -> ShowS

-- | <tt><a>showsUnary1</a> n d x</tt> produces the string representation
grof a unary data constructor with name <tt>n</tt> and argument
gr<tt>x</tt>, in precedence context <tt>d</tt>.

-- | <i>Deprecated: Use showsUnaryWith to define liftShowsPrec</i>
showsUnary1 :: (Show1 f, Show a) => String -> Int -> f a -> ShowS

-- | <tt><a>showsBinary1</a> n d x y</tt> produces the string
grrepresentation of a binary data constructor with name <tt>n</tt> and
grarguments <tt>x</tt> and <tt>y</tt>, in precedence context <tt>d</tt>.

-- | <i>Deprecated: Use showsBinaryWith to define liftShowsPrec</i>
showsBinary1 :: (Show1 f, Show1 g, Show a) => String -> Int -> f a -> g a -> ShowS
instance Data.Functor.Classes.Show2 (,)
instance GHC.Show.Show a => Data.Functor.Classes.Show1 ((,) a)
instance Data.Functor.Classes.Show2 Data.Either.Either
instance GHC.Show.Show a => Data.Functor.Classes.Show1 (Data.Either.Either a)
instance Data.Functor.Classes.Show2 Data.Functor.Const.Const
instance GHC.Show.Show a => Data.Functor.Classes.Show1 (Data.Functor.Const.Const a)
instance Data.Functor.Classes.Read2 (,)
instance GHC.Read.Read a => Data.Functor.Classes.Read1 ((,) a)
instance Data.Functor.Classes.Read2 Data.Either.Either
instance GHC.Read.Read a => Data.Functor.Classes.Read1 (Data.Either.Either a)
instance Data.Functor.Classes.Read2 Data.Functor.Const.Const
instance GHC.Read.Read a => Data.Functor.Classes.Read1 (Data.Functor.Const.Const a)
instance Data.Functor.Classes.Ord2 (,)
instance GHC.Classes.Ord a => Data.Functor.Classes.Ord1 ((,) a)
instance Data.Functor.Classes.Ord2 Data.Either.Either
instance GHC.Classes.Ord a => Data.Functor.Classes.Ord1 (Data.Either.Either a)
instance Data.Functor.Classes.Ord2 Data.Functor.Const.Const
instance GHC.Classes.Ord a => Data.Functor.Classes.Ord1 (Data.Functor.Const.Const a)
instance Data.Functor.Classes.Eq2 (,)
instance GHC.Classes.Eq a => Data.Functor.Classes.Eq1 ((,) a)
instance Data.Functor.Classes.Eq2 Data.Either.Either
instance GHC.Classes.Eq a => Data.Functor.Classes.Eq1 (Data.Either.Either a)
instance Data.Functor.Classes.Eq2 Data.Functor.Const.Const
instance GHC.Classes.Eq a => Data.Functor.Classes.Eq1 (Data.Functor.Const.Const a)
instance Data.Functor.Classes.Show1 GHC.Base.Maybe
instance Data.Functor.Classes.Show1 []
instance Data.Functor.Classes.Show1 GHC.Base.NonEmpty
instance Data.Functor.Classes.Show1 Data.Functor.Identity.Identity
instance Data.Functor.Classes.Show1 Data.Proxy.Proxy
instance Data.Functor.Classes.Read1 GHC.Base.Maybe
instance Data.Functor.Classes.Read1 []
instance Data.Functor.Classes.Read1 GHC.Base.NonEmpty
instance Data.Functor.Classes.Read1 Data.Functor.Identity.Identity
instance Data.Functor.Classes.Read1 Data.Proxy.Proxy
instance Data.Functor.Classes.Ord1 GHC.Base.Maybe
instance Data.Functor.Classes.Ord1 []
instance Data.Functor.Classes.Ord1 GHC.Base.NonEmpty
instance Data.Functor.Classes.Ord1 Data.Functor.Identity.Identity
instance Data.Functor.Classes.Ord1 Data.Proxy.Proxy
instance Data.Functor.Classes.Eq1 GHC.Base.Maybe
instance Data.Functor.Classes.Eq1 []
instance Data.Functor.Classes.Eq1 GHC.Base.NonEmpty
instance Data.Functor.Classes.Eq1 Data.Functor.Identity.Identity
instance Data.Functor.Classes.Eq1 Data.Proxy.Proxy


module Data.Bifunctor

-- | A bifunctor is a type constructor that takes two type arguments and is
gra functor in <i>both</i> arguments. That is, unlike with
gr<a>Functor</a>, a type constructor such as <a>Either</a> does not need
grto be partially applied for a <a>Bifunctor</a> instance, and the
grmethods in this class permit mapping functions over the <a>Left</a>
grvalue or the <a>Right</a> value, or both at the same time.
gr
grFormally, the class <a>Bifunctor</a> represents a bifunctor from
gr<tt>Hask</tt> -&gt; <tt>Hask</tt>.
gr
grIntuitively it is a bifunctor where both the first and second
grarguments are covariant.
gr
grYou can define a <a>Bifunctor</a> by either defining <a>bimap</a> or
grby defining both <a>first</a> and <a>second</a>.
gr
grIf you supply <a>bimap</a>, you should ensure that:
gr
gr<pre>
gr<a>bimap</a> <a>id</a> <a>id</a> ≡ <a>id</a>
gr</pre>
gr
grIf you supply <a>first</a> and <a>second</a>, ensure:
gr
gr<pre>
gr<a>first</a> <a>id</a> ≡ <a>id</a>
gr<a>second</a> <a>id</a> ≡ <a>id</a>
gr</pre>
gr
grIf you supply both, you should also ensure:
gr
gr<pre>
gr<a>bimap</a> f g ≡ <a>first</a> f <a>.</a> <a>second</a> g
gr</pre>
gr
grThese ensure by parametricity:
gr
gr<pre>
gr<a>bimap</a>  (f <a>.</a> g) (h <a>.</a> i) ≡ <a>bimap</a> f h <a>.</a> <a>bimap</a> g i
gr<a>first</a>  (f <a>.</a> g) ≡ <a>first</a>  f <a>.</a> <a>first</a>  g
gr<a>second</a> (f <a>.</a> g) ≡ <a>second</a> f <a>.</a> <a>second</a> g
gr</pre>
class Bifunctor p

-- | Map over both arguments at the same time.
gr
gr<pre>
gr<a>bimap</a> f g ≡ <a>first</a> f <a>.</a> <a>second</a> g
gr</pre>
gr
gr<h4><b>Examples</b></h4>
gr
gr<pre>
gr&gt;&gt;&gt; bimap toUpper (+1) ('j', 3)
gr('J',4)
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; bimap toUpper (+1) (Left 'j')
grLeft 'J'
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; bimap toUpper (+1) (Right 3)
grRight 4
gr</pre>
bimap :: Bifunctor p => (a -> b) -> (c -> d) -> p a c -> p b d

-- | Map covariantly over the first argument.
gr
gr<pre>
gr<a>first</a> f ≡ <a>bimap</a> f <a>id</a>
gr</pre>
gr
gr<h4><b>Examples</b></h4>
gr
gr<pre>
gr&gt;&gt;&gt; first toUpper ('j', 3)
gr('J',3)
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; first toUpper (Left 'j')
grLeft 'J'
gr</pre>
first :: Bifunctor p => (a -> b) -> p a c -> p b c

-- | Map covariantly over the second argument.
gr
gr<pre>
gr<a>second</a> ≡ <a>bimap</a> <a>id</a>
gr</pre>
gr
gr<h4><b>Examples</b></h4>
gr
gr<pre>
gr&gt;&gt;&gt; second (+1) ('j', 3)
gr('j',4)
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; second (+1) (Right 3)
grRight 4
gr</pre>
second :: Bifunctor p => (b -> c) -> p a b -> p a c
instance Data.Bifunctor.Bifunctor (,)
instance Data.Bifunctor.Bifunctor ((,,) x1)
instance Data.Bifunctor.Bifunctor ((,,,) x1 x2)
instance Data.Bifunctor.Bifunctor ((,,,,) x1 x2 x3)
instance Data.Bifunctor.Bifunctor ((,,,,,) x1 x2 x3 x4)
instance Data.Bifunctor.Bifunctor ((,,,,,,) x1 x2 x3 x4 x5)
instance Data.Bifunctor.Bifunctor Data.Either.Either
instance Data.Bifunctor.Bifunctor Data.Functor.Const.Const
instance Data.Bifunctor.Bifunctor (GHC.Generics.K1 i)


module Data.Bifoldable

-- | <a>Bifoldable</a> identifies foldable structures with two different
grvarieties of elements (as opposed to <a>Foldable</a>, which has one
grvariety of element). Common examples are <a>Either</a> and '(,)':
gr
gr<pre>
grinstance Bifoldable Either where
gr  bifoldMap f _ (Left  a) = f a
gr  bifoldMap _ g (Right b) = g b
gr
grinstance Bifoldable (,) where
gr  bifoldr f g z (a, b) = f a (g b z)
gr</pre>
gr
grA minimal <a>Bifoldable</a> definition consists of either
gr<a>bifoldMap</a> or <a>bifoldr</a>. When defining more than this
grminimal set, one should ensure that the following identities hold:
gr
gr<pre>
gr<a>bifold</a> ≡ <a>bifoldMap</a> <a>id</a> <a>id</a>
gr<a>bifoldMap</a> f g ≡ <a>bifoldr</a> (<a>mappend</a> . f) (<a>mappend</a> . g) <a>mempty</a>
gr<a>bifoldr</a> f g z t ≡ <a>appEndo</a> (<a>bifoldMap</a> (Endo . f) (Endo . g) t) z
gr</pre>
gr
grIf the type is also a <tt>Bifunctor</tt> instance, it should satisfy:
gr
gr<pre>
gr'bifoldMap' f g ≡ 'bifold' . 'bimap' f g
gr</pre>
gr
grwhich implies that
gr
gr<pre>
gr'bifoldMap' f g . 'bimap' h i ≡ 'bifoldMap' (f . h) (g . i)
gr</pre>
class Bifoldable p

-- | Combines the elements of a structure using a monoid.
gr
gr<pre>
gr<a>bifold</a> ≡ <a>bifoldMap</a> <a>id</a> <a>id</a>
gr</pre>
bifold :: (Bifoldable p, Monoid m) => p m m -> m

-- | Combines the elements of a structure, given ways of mapping them to a
grcommon monoid.
gr
gr<pre>
gr<a>bifoldMap</a> f g
gr     ≡ <a>bifoldr</a> (<a>mappend</a> . f) (<a>mappend</a> . g) <a>mempty</a>
gr</pre>
bifoldMap :: (Bifoldable p, Monoid m) => (a -> m) -> (b -> m) -> p a b -> m

-- | Combines the elements of a structure in a right associative manner.
grGiven a hypothetical function <tt>toEitherList :: p a b -&gt; [Either
gra b]</tt> yielding a list of all elements of a structure in order, the
grfollowing would hold:
gr
gr<pre>
gr<a>bifoldr</a> f g z ≡ <a>foldr</a> (<a>either</a> f g) z . toEitherList
gr</pre>
bifoldr :: Bifoldable p => (a -> c -> c) -> (b -> c -> c) -> c -> p a b -> c

-- | Combines the elements of a structure in a left associative manner.
grGiven a hypothetical function <tt>toEitherList :: p a b -&gt; [Either
gra b]</tt> yielding a list of all elements of a structure in order, the
grfollowing would hold:
gr
gr<pre>
gr<a>bifoldl</a> f g z
gr     ≡ <a>foldl</a> (acc -&gt; <a>either</a> (f acc) (g acc)) z . toEitherList
gr</pre>
gr
grNote that if you want an efficient left-fold, you probably want to use
gr<a>bifoldl'</a> instead of <a>bifoldl</a>. The reason is that the
grlatter does not force the "inner" results, resulting in a thunk chain
grwhich then must be evaluated from the outside-in.
bifoldl :: Bifoldable p => (c -> a -> c) -> (c -> b -> c) -> c -> p a b -> c

-- | As <a>bifoldr</a>, but strict in the result of the reduction functions
grat each step.
bifoldr' :: Bifoldable t => (a -> c -> c) -> (b -> c -> c) -> c -> t a b -> c

-- | A variant of <a>bifoldr</a> that has no base case, and thus may only
grbe applied to non-empty structures.
bifoldr1 :: Bifoldable t => (a -> a -> a) -> t a a -> a

-- | Right associative monadic bifold over a structure.
bifoldrM :: (Bifoldable t, Monad m) => (a -> c -> m c) -> (b -> c -> m c) -> c -> t a b -> m c

-- | As <a>bifoldl</a>, but strict in the result of the reduction functions
grat each step.
gr
grThis ensures that each step of the bifold is forced to weak head
grnormal form before being applied, avoiding the collection of thunks
grthat would otherwise occur. This is often what you want to strictly
grreduce a finite structure to a single, monolithic result (e.g.,
gr<a>bilength</a>).
bifoldl' :: Bifoldable t => (a -> b -> a) -> (a -> c -> a) -> a -> t b c -> a

-- | A variant of <a>bifoldl</a> that has no base case, and thus may only
grbe applied to non-empty structures.
bifoldl1 :: Bifoldable t => (a -> a -> a) -> t a a -> a

-- | Left associative monadic bifold over a structure.
bifoldlM :: (Bifoldable t, Monad m) => (a -> b -> m a) -> (a -> c -> m a) -> a -> t b c -> m a

-- | Map each element of a structure using one of two actions, evaluate
grthese actions from left to right, and ignore the results. For a
grversion that doesn't ignore the results, see <a>bitraverse</a>.
bitraverse_ :: (Bifoldable t, Applicative f) => (a -> f c) -> (b -> f d) -> t a b -> f ()

-- | As <a>bitraverse_</a>, but with the structure as the primary argument.
grFor a version that doesn't ignore the results, see <a>bifor</a>.
gr
gr<pre>
gr&gt;&gt;&gt; &gt; bifor_ ('a', "bc") print (print . reverse)
gr'a'
gr"cb"
gr</pre>
bifor_ :: (Bifoldable t, Applicative f) => t a b -> (a -> f c) -> (b -> f d) -> f ()

-- | Alias for <a>bitraverse_</a>.
bimapM_ :: (Bifoldable t, Applicative f) => (a -> f c) -> (b -> f d) -> t a b -> f ()

-- | Alias for <a>bifor_</a>.
biforM_ :: (Bifoldable t, Applicative f) => t a b -> (a -> f c) -> (b -> f d) -> f ()

-- | Alias for <a>biasum</a>.
bimsum :: (Bifoldable t, Alternative f) => t (f a) (f a) -> f a

-- | Alias for <a>bisequence_</a>.
bisequenceA_ :: (Bifoldable t, Applicative f) => t (f a) (f b) -> f ()

-- | Evaluate each action in the structure from left to right, and ignore
grthe results. For a version that doesn't ignore the results, see
gr<a>bisequence</a>.
bisequence_ :: (Bifoldable t, Applicative f) => t (f a) (f b) -> f ()

-- | The sum of a collection of actions, generalizing <a>biconcat</a>.
biasum :: (Bifoldable t, Alternative f) => t (f a) (f a) -> f a

-- | Collects the list of elements of a structure, from left to right.
biList :: Bifoldable t => t a a -> [a]

-- | Test whether the structure is empty.
binull :: Bifoldable t => t a b -> Bool

-- | Returns the size/length of a finite structure as an <a>Int</a>.
bilength :: Bifoldable t => t a b -> Int

-- | Does the element occur in the structure?
bielem :: (Bifoldable t, Eq a) => a -> t a a -> Bool

-- | The largest element of a non-empty structure.
bimaximum :: forall t a. (Bifoldable t, Ord a) => t a a -> a

-- | The least element of a non-empty structure.
biminimum :: forall t a. (Bifoldable t, Ord a) => t a a -> a

-- | The <a>bisum</a> function computes the sum of the numbers of a
grstructure.
bisum :: (Bifoldable t, Num a) => t a a -> a

-- | The <a>biproduct</a> function computes the product of the numbers of a
grstructure.
biproduct :: (Bifoldable t, Num a) => t a a -> a

-- | Reduces a structure of lists to the concatenation of those lists.
biconcat :: Bifoldable t => t [a] [a] -> [a]

-- | Given a means of mapping the elements of a structure to lists,
grcomputes the concatenation of all such lists in order.
biconcatMap :: Bifoldable t => (a -> [c]) -> (b -> [c]) -> t a b -> [c]

-- | <a>biand</a> returns the conjunction of a container of Bools. For the
grresult to be <a>True</a>, the container must be finite; <a>False</a>,
grhowever, results from a <a>False</a> value finitely far from the left
grend.
biand :: Bifoldable t => t Bool Bool -> Bool

-- | <a>bior</a> returns the disjunction of a container of Bools. For the
grresult to be <a>False</a>, the container must be finite; <a>True</a>,
grhowever, results from a <a>True</a> value finitely far from the left
grend.
bior :: Bifoldable t => t Bool Bool -> Bool

-- | Determines whether any element of the structure satisfies its
grappropriate predicate argument.
biany :: Bifoldable t => (a -> Bool) -> (b -> Bool) -> t a b -> Bool

-- | Determines whether all elements of the structure satisfy their
grappropriate predicate argument.
biall :: Bifoldable t => (a -> Bool) -> (b -> Bool) -> t a b -> Bool

-- | The largest element of a non-empty structure with respect to the given
grcomparison function.
bimaximumBy :: Bifoldable t => (a -> a -> Ordering) -> t a a -> a

-- | The least element of a non-empty structure with respect to the given
grcomparison function.
biminimumBy :: Bifoldable t => (a -> a -> Ordering) -> t a a -> a

-- | <a>binotElem</a> is the negation of <a>bielem</a>.
binotElem :: (Bifoldable t, Eq a) => a -> t a a -> Bool

-- | The <a>bifind</a> function takes a predicate and a structure and
grreturns the leftmost element of the structure matching the predicate,
gror <a>Nothing</a> if there is no such element.
bifind :: Bifoldable t => (a -> Bool) -> t a a -> Maybe a
instance Data.Bifoldable.Bifoldable (,)
instance Data.Bifoldable.Bifoldable Data.Functor.Const.Const
instance Data.Bifoldable.Bifoldable (GHC.Generics.K1 i)
instance Data.Bifoldable.Bifoldable ((,,) x)
instance Data.Bifoldable.Bifoldable ((,,,) x y)
instance Data.Bifoldable.Bifoldable ((,,,,) x y z)
instance Data.Bifoldable.Bifoldable ((,,,,,) x y z w)
instance Data.Bifoldable.Bifoldable ((,,,,,,) x y z w v)
instance Data.Bifoldable.Bifoldable Data.Either.Either


module Data.Bitraversable

-- | <a>Bitraversable</a> identifies bifunctorial data structures whose
grelements can be traversed in order, performing <a>Applicative</a> or
gr<a>Monad</a> actions at each element, and collecting a result
grstructure with the same shape.
gr
grAs opposed to <a>Traversable</a> data structures, which have one
grvariety of element on which an action can be performed,
gr<a>Bitraversable</a> data structures have two such varieties of
grelements.
gr
grA definition of <a>bitraverse</a> must satisfy the following laws:
gr
gr<ul>
gr<li><i><i>naturality</i></i> <tt><a>bitraverse</a> (t . f) (t . g) ≡ t
gr. <a>bitraverse</a> f g</tt> for every applicative transformation
gr<tt>t</tt></li>
gr<li><i><i>identity</i></i> <tt><a>bitraverse</a> <a>Identity</a>
gr<a>Identity</a> ≡ <a>Identity</a></tt></li>
gr<li><i><i>composition</i></i> <tt><tt>Compose</tt> . <a>fmap</a>
gr(<a>bitraverse</a> g1 g2) . <a>bitraverse</a> f1 f2 ≡ <a>traverse</a>
gr(<tt>Compose</tt> . <a>fmap</a> g1 . f1) (<tt>Compose</tt> .
gr<a>fmap</a> g2 . f2)</tt></li>
gr</ul>
gr
grwhere an <i>applicative transformation</i> is a function
gr
gr<pre>
grt :: (<a>Applicative</a> f, <a>Applicative</a> g) =&gt; f a -&gt; g a
gr</pre>
gr
grpreserving the <a>Applicative</a> operations:
gr
gr<pre>
grt (<a>pure</a> x) = <a>pure</a> x
grt (f <a>&lt;*&gt;</a> x) = t f <a>&lt;*&gt;</a> t x
gr</pre>
gr
grand the identity functor <a>Identity</a> and composition functors
gr<tt>Compose</tt> are defined as
gr
gr<pre>
grnewtype Identity a = Identity { runIdentity :: a }
gr
grinstance Functor Identity where
gr  fmap f (Identity x) = Identity (f x)
gr
grinstance Applicative Identity where
gr  pure = Identity
gr  Identity f &lt;*&gt; Identity x = Identity (f x)
gr
grnewtype Compose f g a = Compose (f (g a))
gr
grinstance (Functor f, Functor g) =&gt; Functor (Compose f g) where
gr  fmap f (Compose x) = Compose (fmap (fmap f) x)
gr
grinstance (Applicative f, Applicative g) =&gt; Applicative (Compose f g) where
gr  pure = Compose . pure . pure
gr  Compose f &lt;*&gt; Compose x = Compose ((&lt;*&gt;) &lt;$&gt; f &lt;*&gt; x)
gr</pre>
gr
grSome simple examples are <a>Either</a> and '(,)':
gr
gr<pre>
grinstance Bitraversable Either where
gr  bitraverse f _ (Left x) = Left &lt;$&gt; f x
gr  bitraverse _ g (Right y) = Right &lt;$&gt; g y
gr
grinstance Bitraversable (,) where
gr  bitraverse f g (x, y) = (,) &lt;$&gt; f x &lt;*&gt; g y
gr</pre>
gr
gr<a>Bitraversable</a> relates to its superclasses in the following
grways:
gr
gr<pre>
gr<a>bimap</a> f g ≡ <a>runIdentity</a> . <a>bitraverse</a> (<a>Identity</a> . f) (<a>Identity</a> . g)
gr<a>bifoldMap</a> f g = <a>getConst</a> . <a>bitraverse</a> (<a>Const</a> . f) (<a>Const</a> . g)
gr</pre>
gr
grThese are available as <a>bimapDefault</a> and <a>bifoldMapDefault</a>
grrespectively.
class (Bifunctor t, Bifoldable t) => Bitraversable t

-- | Evaluates the relevant functions at each element in the structure,
grrunning the action, and builds a new structure with the same shape,
grusing the results produced from sequencing the actions.
gr
gr<pre>
gr<a>bitraverse</a> f g ≡ <a>bisequenceA</a> . <a>bimap</a> f g
gr</pre>
gr
grFor a version that ignores the results, see <a>bitraverse_</a>.
bitraverse :: (Bitraversable t, Applicative f) => (a -> f c) -> (b -> f d) -> t a b -> f (t c d)

-- | Alias for <a>bisequence</a>.
bisequenceA :: (Bitraversable t, Applicative f) => t (f a) (f b) -> f (t a b)

-- | Sequences all the actions in a structure, building a new structure
grwith the same shape using the results of the actions. For a version
grthat ignores the results, see <a>bisequence_</a>.
gr
gr<pre>
gr<a>bisequence</a> ≡ <a>bitraverse</a> <a>id</a> <a>id</a>
gr</pre>
bisequence :: (Bitraversable t, Applicative f) => t (f a) (f b) -> f (t a b)

-- | Alias for <a>bitraverse</a>.
bimapM :: (Bitraversable t, Applicative f) => (a -> f c) -> (b -> f d) -> t a b -> f (t c d)

-- | <a>bifor</a> is <a>bitraverse</a> with the structure as the first
grargument. For a version that ignores the results, see <a>bifor_</a>.
bifor :: (Bitraversable t, Applicative f) => t a b -> (a -> f c) -> (b -> f d) -> f (t c d)

-- | Alias for <a>bifor</a>.
biforM :: (Bitraversable t, Applicative f) => t a b -> (a -> f c) -> (b -> f d) -> f (t c d)

-- | The <a>bimapAccumL</a> function behaves like a combination of
gr<a>bimap</a> and <a>bifoldl</a>; it traverses a structure from left to
grright, threading a state of type <tt>a</tt> and using the given
gractions to compute new elements for the structure.
bimapAccumL :: Bitraversable t => (a -> b -> (a, c)) -> (a -> d -> (a, e)) -> a -> t b d -> (a, t c e)

-- | The <a>bimapAccumR</a> function behaves like a combination of
gr<a>bimap</a> and <a>bifoldl</a>; it traverses a structure from right
grto left, threading a state of type <tt>a</tt> and using the given
gractions to compute new elements for the structure.
bimapAccumR :: Bitraversable t => (a -> b -> (a, c)) -> (a -> d -> (a, e)) -> a -> t b d -> (a, t c e)

-- | A default definition of <a>bimap</a> in terms of the
gr<a>Bitraversable</a> operations.
gr
gr<pre>
gr<a>bimapDefault</a> f g ≡
gr     <a>runIdentity</a> . <a>bitraverse</a> (<a>Identity</a> . f) (<a>Identity</a> . g)
gr</pre>
bimapDefault :: forall t a b c d. Bitraversable t => (a -> b) -> (c -> d) -> t a c -> t b d

-- | A default definition of <a>bifoldMap</a> in terms of the
gr<a>Bitraversable</a> operations.
gr
gr<pre>
gr<a>bifoldMapDefault</a> f g ≡
gr    <a>getConst</a> . <a>bitraverse</a> (<a>Const</a> . f) (<a>Const</a> . g)
gr</pre>
bifoldMapDefault :: forall t m a b. (Bitraversable t, Monoid m) => (a -> m) -> (b -> m) -> t a b -> m
instance Data.Bitraversable.Bitraversable (,)
instance Data.Bitraversable.Bitraversable ((,,) x)
instance Data.Bitraversable.Bitraversable ((,,,) x y)
instance Data.Bitraversable.Bitraversable ((,,,,) x y z)
instance Data.Bitraversable.Bitraversable ((,,,,,) x y z w)
instance Data.Bitraversable.Bitraversable ((,,,,,,) x y z w v)
instance Data.Bitraversable.Bitraversable Data.Either.Either
instance Data.Bitraversable.Bitraversable Data.Functor.Const.Const
instance Data.Bitraversable.Bitraversable (GHC.Generics.K1 i)


-- | This module provides scalable event notification for file descriptors
grand timeouts.
gr
grThis module should be considered GHC internal.
gr
gr<ul>
gr
gr<li>---------------------------------------------------------------------------</li>
gr</ul>
module GHC.Event

-- | The event manager state.
data EventManager

-- | The event manager state.
data TimerManager

-- | Retrieve the system event manager for the capability on which the
grcalling thread is running.
gr
grThis function always returns <a>Just</a> the current thread's event
grmanager when using the threaded RTS and <a>Nothing</a> otherwise.
getSystemEventManager :: IO (Maybe EventManager)

-- | Create a new event manager.
new :: IO EventManager
getSystemTimerManager :: IO TimerManager

-- | An I/O event.
data Event

-- | Data is available to be read.
evtRead :: Event

-- | The file descriptor is ready to accept a write.
evtWrite :: Event

-- | Callback invoked on I/O events.
type IOCallback = FdKey -> Event -> IO ()

-- | A file descriptor registration cookie.
data FdKey

-- | The lifetime of an event registration.
data Lifetime

-- | the registration will be active for only one event
OneShot :: Lifetime

-- | the registration will trigger multiple times
MultiShot :: Lifetime

-- | <tt>registerFd mgr cb fd evs lt</tt> registers interest in the events
gr<tt>evs</tt> on the file descriptor <tt>fd</tt> for lifetime
gr<tt>lt</tt>. <tt>cb</tt> is called for each event that occurs. Returns
gra cookie that can be handed to <a>unregisterFd</a>.
registerFd :: EventManager -> IOCallback -> Fd -> Event -> Lifetime -> IO FdKey

-- | Drop a previous file descriptor registration.
unregisterFd :: EventManager -> FdKey -> IO ()

-- | Drop a previous file descriptor registration, without waking the event
grmanager thread. The return value indicates whether the event manager
grought to be woken.
unregisterFd_ :: EventManager -> FdKey -> IO Bool

-- | Close a file descriptor in a race-safe way.
closeFd :: EventManager -> (Fd -> IO ()) -> Fd -> IO ()

-- | Callback invoked on timeout events.
type TimeoutCallback = IO ()

-- | A timeout registration cookie.
data TimeoutKey

-- | Register a timeout in the given number of microseconds. The returned
gr<a>TimeoutKey</a> can be used to later unregister or update the
grtimeout. The timeout is automatically unregistered after the given
grtime has passed.
registerTimeout :: TimerManager -> Int -> TimeoutCallback -> IO TimeoutKey

-- | Update an active timeout to fire in the given number of microseconds.
updateTimeout :: TimerManager -> TimeoutKey -> Int -> IO ()

-- | Unregister an active timeout.
unregisterTimeout :: TimerManager -> TimeoutKey -> IO ()


-- | Basic concurrency stuff.
module GHC.Conc

-- | A <a>ThreadId</a> is an abstract type representing a handle to a
grthread. <a>ThreadId</a> is an instance of <a>Eq</a>, <a>Ord</a> and
gr<a>Show</a>, where the <a>Ord</a> instance implements an arbitrary
grtotal ordering over <a>ThreadId</a>s. The <a>Show</a> instance lets
gryou convert an arbitrary-valued <a>ThreadId</a> to string form;
grshowing a <a>ThreadId</a> value is occasionally useful when debugging
gror diagnosing the behaviour of a concurrent program.
gr
gr<i>Note</i>: in GHC, if you have a <a>ThreadId</a>, you essentially
grhave a pointer to the thread itself. This means the thread itself
grcan't be garbage collected until you drop the <a>ThreadId</a>. This
grmisfeature will hopefully be corrected at a later date.
data ThreadId
ThreadId :: ThreadId# -> ThreadId

-- | Creates a new thread to run the <a>IO</a> computation passed as the
grfirst argument, and returns the <a>ThreadId</a> of the newly created
grthread.
gr
grThe new thread will be a lightweight, <i>unbound</i> thread. Foreign
grcalls made by this thread are not guaranteed to be made by any
grparticular OS thread; if you need foreign calls to be made by a
grparticular OS thread, then use <a>forkOS</a> instead.
gr
grThe new thread inherits the <i>masked</i> state of the parent (see
gr<a>mask</a>).
gr
grThe newly created thread has an exception handler that discards the
grexceptions <a>BlockedIndefinitelyOnMVar</a>,
gr<a>BlockedIndefinitelyOnSTM</a>, and <a>ThreadKilled</a>, and passes
grall other exceptions to the uncaught exception handler.
forkIO :: IO () -> IO ThreadId

-- | Like <a>forkIO</a>, but the child thread is passed a function that can
grbe used to unmask asynchronous exceptions. This function is typically
grused in the following way
gr
gr<pre>
gr... mask_ $ forkIOWithUnmask $ \unmask -&gt;
gr               catch (unmask ...) handler
gr</pre>
gr
grso that the exception handler in the child thread is established with
grasynchronous exceptions masked, meanwhile the main body of the child
grthread is executed in the unmasked state.
gr
grNote that the unmask function passed to the child thread should only
grbe used in that thread; the behaviour is undefined if it is invoked in
gra different thread.
forkIOWithUnmask :: ((forall a. IO a -> IO a) -> IO ()) -> IO ThreadId

-- | Like <a>forkIO</a>, but lets you specify on which capability the
grthread should run. Unlike a <a>forkIO</a> thread, a thread created by
gr<a>forkOn</a> will stay on the same capability for its entire lifetime
gr(<a>forkIO</a> threads can migrate between capabilities according to
grthe scheduling policy). <a>forkOn</a> is useful for overriding the
grscheduling policy when you know in advance how best to distribute the
grthreads.
gr
grThe <a>Int</a> argument specifies a <i>capability number</i> (see
gr<a>getNumCapabilities</a>). Typically capabilities correspond to
grphysical processors, but the exact behaviour is
grimplementation-dependent. The value passed to <a>forkOn</a> is
grinterpreted modulo the total number of capabilities as returned by
gr<a>getNumCapabilities</a>.
gr
grGHC note: the number of capabilities is specified by the <tt>+RTS
gr-N</tt> option when the program is started. Capabilities can be fixed
grto actual processor cores with <tt>+RTS -qa</tt> if the underlying
groperating system supports that, although in practice this is usually
grunnecessary (and may actually degrade performance in some cases -
grexperimentation is recommended).
forkOn :: Int -> IO () -> IO ThreadId

-- | Like <a>forkIOWithUnmask</a>, but the child thread is pinned to the
grgiven CPU, as with <a>forkOn</a>.
forkOnWithUnmask :: Int -> ((forall a. IO a -> IO a) -> IO ()) -> IO ThreadId

-- | the value passed to the <tt>+RTS -N</tt> flag. This is the number of
grHaskell threads that can run truly simultaneously at any given time,
grand is typically set to the number of physical processor cores on the
grmachine.
gr
grStrictly speaking it is better to use <a>getNumCapabilities</a>,
grbecause the number of capabilities might vary at runtime.
numCapabilities :: Int

-- | Returns the number of Haskell threads that can run truly
grsimultaneously (on separate physical processors) at any given time. To
grchange this value, use <a>setNumCapabilities</a>.
getNumCapabilities :: IO Int

-- | Set the number of Haskell threads that can run truly simultaneously
gr(on separate physical processors) at any given time. The number passed
grto <a>forkOn</a> is interpreted modulo this value. The initial value
gris given by the <tt>+RTS -N</tt> runtime flag.
gr
grThis is also the number of threads that will participate in parallel
grgarbage collection. It is strongly recommended that the number of
grcapabilities is not set larger than the number of physical processor
grcores, and it may often be beneficial to leave one or more cores free
grto avoid contention with other processes in the machine.
setNumCapabilities :: Int -> IO ()

-- | Returns the number of CPUs that the machine has
getNumProcessors :: IO Int

-- | Returns the number of sparks currently in the local spark pool
numSparks :: IO Int
childHandler :: SomeException -> IO ()

-- | Returns the <a>ThreadId</a> of the calling thread (GHC only).
myThreadId :: IO ThreadId

-- | <a>killThread</a> raises the <a>ThreadKilled</a> exception in the
grgiven thread (GHC only).
gr
gr<pre>
grkillThread tid = throwTo tid ThreadKilled
gr</pre>
killThread :: ThreadId -> IO ()

-- | <a>throwTo</a> raises an arbitrary exception in the target thread (GHC
gronly).
gr
grException delivery synchronizes between the source and target thread:
gr<a>throwTo</a> does not return until the exception has been raised in
grthe target thread. The calling thread can thus be certain that the
grtarget thread has received the exception. Exception delivery is also
gratomic with respect to other exceptions. Atomicity is a useful
grproperty to have when dealing with race conditions: e.g. if there are
grtwo threads that can kill each other, it is guaranteed that only one
grof the threads will get to kill the other.
gr
grWhatever work the target thread was doing when the exception was
grraised is not lost: the computation is suspended until required by
granother thread.
gr
grIf the target thread is currently making a foreign call, then the
grexception will not be raised (and hence <a>throwTo</a> will not
grreturn) until the call has completed. This is the case regardless of
grwhether the call is inside a <a>mask</a> or not. However, in GHC a
grforeign call can be annotated as <tt>interruptible</tt>, in which case
gra <a>throwTo</a> will cause the RTS to attempt to cause the call to
grreturn; see the GHC documentation for more details.
gr
grImportant note: the behaviour of <a>throwTo</a> differs from that
grdescribed in the paper "Asynchronous exceptions in Haskell"
gr(<a>http://research.microsoft.com/~simonpj/Papers/asynch-exns.htm</a>).
grIn the paper, <a>throwTo</a> is non-blocking; but the library
grimplementation adopts a more synchronous design in which
gr<a>throwTo</a> does not return until the exception is received by the
grtarget thread. The trade-off is discussed in Section 9 of the paper.
grLike any blocking operation, <a>throwTo</a> is therefore interruptible
gr(see Section 5.3 of the paper). Unlike other interruptible operations,
grhowever, <a>throwTo</a> is <i>always</i> interruptible, even if it
grdoes not actually block.
gr
grThere is no guarantee that the exception will be delivered promptly,
gralthough the runtime will endeavour to ensure that arbitrary delays
grdon't occur. In GHC, an exception can only be raised when a thread
grreaches a <i>safe point</i>, where a safe point is where memory
grallocation occurs. Some loops do not perform any memory allocation
grinside the loop and therefore cannot be interrupted by a
gr<a>throwTo</a>.
gr
grIf the target of <a>throwTo</a> is the calling thread, then the
grbehaviour is the same as <a>throwIO</a>, except that the exception is
grthrown as an asynchronous exception. This means that if there is an
grenclosing pure computation, which would be the case if the current IO
groperation is inside <a>unsafePerformIO</a> or
gr<a>unsafeInterleaveIO</a>, that computation is not permanently
grreplaced by the exception, but is suspended as if it had received an
grasynchronous exception.
gr
grNote that if <a>throwTo</a> is called with the current thread as the
grtarget, the exception will be thrown even if the thread is currently
grinside <a>mask</a> or <a>uninterruptibleMask</a>.
throwTo :: Exception e => ThreadId -> e -> IO ()
par :: a -> b -> b
infixr 0 `par`
pseq :: a -> b -> b
infixr 0 `pseq`

-- | Internal function used by the RTS to run sparks.
runSparks :: IO ()

-- | The <a>yield</a> action allows (forces, in a co-operative multitasking
grimplementation) a context-switch to any other currently runnable
grthreads (if any), and is occasionally useful when implementing
grconcurrency abstractions.
yield :: IO ()

-- | <a>labelThread</a> stores a string as identifier for this thread if
gryou built a RTS with debugging support. This identifier will be used
grin the debugging output to make distinction of different threads
greasier (otherwise you only have the thread state object's address in
grthe heap).
gr
grOther applications like the graphical Concurrent Haskell Debugger
gr(<a>http://www.informatik.uni-kiel.de/~fhu/chd/</a>) may choose to
groverload <a>labelThread</a> for their purposes as well.
labelThread :: ThreadId -> String -> IO ()

-- | Make a weak pointer to a <a>ThreadId</a>. It can be important to do
grthis if you want to hold a reference to a <a>ThreadId</a> while still
grallowing the thread to receive the <tt>BlockedIndefinitely</tt> family
grof exceptions (e.g. <a>BlockedIndefinitelyOnMVar</a>). Holding a
grnormal <a>ThreadId</a> reference will prevent the delivery of
gr<tt>BlockedIndefinitely</tt> exceptions because the reference could be
grused as the target of <a>throwTo</a> at any time, which would unblock
grthe thread.
gr
grHolding a <tt>Weak ThreadId</tt>, on the other hand, will not prevent
grthe thread from receiving <tt>BlockedIndefinitely</tt> exceptions. It
gris still possible to throw an exception to a <tt>Weak ThreadId</tt>,
grbut the caller must use <tt>deRefWeak</tt> first to determine whether
grthe thread still exists.
mkWeakThreadId :: ThreadId -> IO (Weak ThreadId)

-- | The current status of a thread
data ThreadStatus

-- | the thread is currently runnable or running
ThreadRunning :: ThreadStatus

-- | the thread has finished
ThreadFinished :: ThreadStatus

-- | the thread is blocked on some resource
ThreadBlocked :: BlockReason -> ThreadStatus

-- | the thread received an uncaught exception
ThreadDied :: ThreadStatus
data BlockReason

-- | blocked on <a>MVar</a>
BlockedOnMVar :: BlockReason

-- | blocked on a computation in progress by another thread
BlockedOnBlackHole :: BlockReason

-- | blocked in <a>throwTo</a>
BlockedOnException :: BlockReason

-- | blocked in <a>retry</a> in an STM transaction
BlockedOnSTM :: BlockReason

-- | currently in a foreign call
BlockedOnForeignCall :: BlockReason

-- | blocked on some other resource. Without <tt>-threaded</tt>, I/O and
gr<tt>threadDelay</tt> show up as <a>BlockedOnOther</a>, with
gr<tt>-threaded</tt> they show up as <a>BlockedOnMVar</a>.
BlockedOnOther :: BlockReason
threadStatus :: ThreadId -> IO ThreadStatus

-- | Returns the number of the capability on which the thread is currently
grrunning, and a boolean indicating whether the thread is locked to that
grcapability or not. A thread is locked to a capability if it was
grcreated with <tt>forkOn</tt>.
threadCapability :: ThreadId -> IO (Int, Bool)

-- | Make a StablePtr that can be passed to the C function
gr<tt>hs_try_putmvar()</tt>. The RTS wants a <a>StablePtr</a> to the
grunderlying <a>MVar#</a>, but a <a>StablePtr#</a> can only refer to
grlifted types, so we have to cheat by coercing.
newStablePtrPrimMVar :: MVar () -> IO (StablePtr PrimMVar)
data PrimMVar

-- | Suspends the current thread for a given number of microseconds (GHC
gronly).
gr
grThere is no guarantee that the thread will be rescheduled promptly
grwhen the delay has expired, but the thread will never continue to run
gr<i>earlier</i> than specified.
threadDelay :: Int -> IO ()

-- | Set the value of returned TVar to True after a given number of
grmicroseconds. The caveats associated with threadDelay also apply.
registerDelay :: Int -> IO (TVar Bool)

-- | Block the current thread until data is available to read on the given
grfile descriptor (GHC only).
gr
grThis will throw an <tt>IOError</tt> if the file descriptor was closed
grwhile this thread was blocked. To safely close a file descriptor that
grhas been used with <a>threadWaitRead</a>, use <a>closeFdWith</a>.
threadWaitRead :: Fd -> IO ()

-- | Block the current thread until data can be written to the given file
grdescriptor (GHC only).
gr
grThis will throw an <tt>IOError</tt> if the file descriptor was closed
grwhile this thread was blocked. To safely close a file descriptor that
grhas been used with <a>threadWaitWrite</a>, use <a>closeFdWith</a>.
threadWaitWrite :: Fd -> IO ()

-- | Returns an STM action that can be used to wait for data to read from a
grfile descriptor. The second returned value is an IO action that can be
grused to deregister interest in the file descriptor.
threadWaitReadSTM :: Fd -> IO (STM (), IO ())

-- | Returns an STM action that can be used to wait until data can be
grwritten to a file descriptor. The second returned value is an IO
graction that can be used to deregister interest in the file descriptor.
threadWaitWriteSTM :: Fd -> IO (STM (), IO ())

-- | Close a file descriptor in a concurrency-safe way (GHC only). If you
grare using <a>threadWaitRead</a> or <a>threadWaitWrite</a> to perform
grblocking I/O, you <i>must</i> use this function to close file
grdescriptors, or blocked threads may not be woken.
gr
grAny threads that are blocked on the file descriptor via
gr<a>threadWaitRead</a> or <a>threadWaitWrite</a> will be unblocked by
grhaving IO exceptions thrown.
closeFdWith :: (Fd -> IO ()) -> Fd -> IO ()

-- | Every thread has an allocation counter that tracks how much memory has
grbeen allocated by the thread. The counter is initialized to zero, and
gr<a>setAllocationCounter</a> sets the current value. The allocation
grcounter counts *down*, so in the absence of a call to
gr<a>setAllocationCounter</a> its value is the negation of the number of
grbytes of memory allocated by the thread.
gr
grThere are two things that you can do with this counter:
gr
gr<ul>
gr<li>Use it as a simple profiling mechanism, with
gr<a>getAllocationCounter</a>.</li>
gr<li>Use it as a resource limit. See <a>enableAllocationLimit</a>.</li>
gr</ul>
gr
grAllocation accounting is accurate only to about 4Kbytes.
setAllocationCounter :: Int64 -> IO ()

-- | Return the current value of the allocation counter for the current
grthread.
getAllocationCounter :: IO Int64

-- | Enables the allocation counter to be treated as a limit for the
grcurrent thread. When the allocation limit is enabled, if the
grallocation counter counts down below zero, the thread will be sent the
gr<a>AllocationLimitExceeded</a> asynchronous exception. When this
grhappens, the counter is reinitialised (by default to 100K, but tunable
grwith the <tt>+RTS -xq</tt> option) so that it can handle the exception
grand perform any necessary clean up. If it exhausts this additional
grallowance, another <a>AllocationLimitExceeded</a> exception is sent,
grand so forth. Like other asynchronous exceptions, the
gr<a>AllocationLimitExceeded</a> exception is deferred while the thread
gris inside <a>mask</a> or an exception handler in <a>catch</a>.
gr
grNote that memory allocation is unrelated to <i>live memory</i>, also
grknown as <i>heap residency</i>. A thread can allocate a large amount
grof memory and retain anything between none and all of it. It is better
grto think of the allocation limit as a limit on <i>CPU time</i>, rather
grthan a limit on memory.
gr
grCompared to using timeouts, allocation limits don't count time spent
grblocked or in foreign calls.
enableAllocationLimit :: IO ()

-- | Disable allocation limit processing for the current thread.
disableAllocationLimit :: IO ()

-- | A monad supporting atomic memory transactions.
newtype STM a
STM :: (State# RealWorld -> (# State# RealWorld, a #)) -> STM a

-- | Perform a series of STM actions atomically.
gr
grUsing <a>atomically</a> inside an <a>unsafePerformIO</a> or
gr<a>unsafeInterleaveIO</a> subverts some of guarantees that STM
grprovides. It makes it possible to run a transaction inside of another
grtransaction, depending on when the thunk is evaluated. If a nested
grtransaction is attempted, an exception is thrown by the runtime. It is
grpossible to safely use <a>atomically</a> inside <a>unsafePerformIO</a>
gror <a>unsafeInterleaveIO</a>, but the typechecker does not rule out
grprograms that may attempt nested transactions, meaning that the
grprogrammer must take special care to prevent these.
gr
grHowever, there are functions for creating transactional variables that
grcan always be safely called in <a>unsafePerformIO</a>. See:
gr<a>newTVarIO</a>, <tt>newTChanIO</tt>, <tt>newBroadcastTChanIO</tt>,
gr<tt>newTQueueIO</tt>, <tt>newTBQueueIO</tt>, and <tt>newTMVarIO</tt>.
gr
grUsing <a>unsafePerformIO</a> inside of <a>atomically</a> is also
grdangerous but for different reasons. See <a>unsafeIOToSTM</a> for more
gron this.
atomically :: STM a -> IO a

-- | Retry execution of the current memory transaction because it has seen
grvalues in <a>TVar</a>s which mean that it should not continue (e.g.
grthe <a>TVar</a>s represent a shared buffer that is now empty). The
grimplementation may block the thread until one of the <a>TVar</a>s that
grit has read from has been updated. (GHC only)
retry :: STM a

-- | Compose two alternative STM actions (GHC only).
gr
grIf the first action completes without retrying then it forms the
grresult of the <a>orElse</a>. Otherwise, if the first action retries,
grthen the second action is tried in its place. If both actions retry
grthen the <a>orElse</a> as a whole retries.
orElse :: STM a -> STM a -> STM a

-- | A variant of <a>throw</a> that can only be used within the <a>STM</a>
grmonad.
gr
grThrowing an exception in <tt>STM</tt> aborts the transaction and
grpropagates the exception.
gr
grAlthough <a>throwSTM</a> has a type that is an instance of the type of
gr<a>throw</a>, the two functions are subtly different:
gr
gr<pre>
grthrow e    `seq` x  ===&gt; throw e
grthrowSTM e `seq` x  ===&gt; x
gr</pre>
gr
grThe first example will cause the exception <tt>e</tt> to be raised,
grwhereas the second one won't. In fact, <a>throwSTM</a> will only cause
gran exception to be raised when it is used within the <a>STM</a> monad.
grThe <a>throwSTM</a> variant should be used in preference to
gr<a>throw</a> to raise an exception within the <a>STM</a> monad because
grit guarantees ordering with respect to other <a>STM</a> operations,
grwhereas <a>throw</a> does not.
throwSTM :: Exception e => e -> STM a

-- | Exception handling within STM actions.
catchSTM :: Exception e => STM a -> (e -> STM a) -> STM a

-- | <a>alwaysSucceeds</a> adds a new invariant that must be true when
grpassed to <a>alwaysSucceeds</a>, at the end of the current
grtransaction, and at the end of every subsequent transaction. If it
grfails at any of those points then the transaction violating it is
graborted and the exception raised by the invariant is propagated.
alwaysSucceeds :: STM a -> STM ()

-- | <a>always</a> is a variant of <a>alwaysSucceeds</a> in which the
grinvariant is expressed as an <tt>STM Bool</tt> action that must return
gr<tt>True</tt>. Returning <tt>False</tt> or raising an exception are
grboth treated as invariant failures.
always :: STM Bool -> STM ()

-- | Shared memory locations that support atomic memory transactions.
data TVar a
TVar :: (TVar# RealWorld a) -> TVar a

-- | Create a new <a>TVar</a> holding a value supplied
newTVar :: a -> STM (TVar a)

-- | <tt>IO</tt> version of <a>newTVar</a>. This is useful for creating
grtop-level <a>TVar</a>s using <a>unsafePerformIO</a>, because using
gr<a>atomically</a> inside <a>unsafePerformIO</a> isn't possible.
newTVarIO :: a -> IO (TVar a)

-- | Return the current value stored in a <a>TVar</a>.
readTVar :: TVar a -> STM a

-- | Return the current value stored in a <a>TVar</a>. This is equivalent
grto
gr
gr<pre>
grreadTVarIO = atomically . readTVar
gr</pre>
gr
grbut works much faster, because it doesn't perform a complete
grtransaction, it just reads the current value of the <a>TVar</a>.
readTVarIO :: TVar a -> IO a

-- | Write the supplied value into a <a>TVar</a>.
writeTVar :: TVar a -> a -> STM ()

-- | Unsafely performs IO in the STM monad. Beware: this is a highly
grdangerous thing to do.
gr
gr<ul>
gr<li>The STM implementation will often run transactions multiple times,
grso you need to be prepared for this if your IO has any side
greffects.</li>
gr<li>The STM implementation will abort transactions that are known to
grbe invalid and need to be restarted. This may happen in the middle of
gr<a>unsafeIOToSTM</a>, so make sure you don't acquire any resources
grthat need releasing (exception handlers are ignored when aborting the
grtransaction). That includes doing any IO using Handles, for example.
grGetting this wrong will probably lead to random deadlocks.</li>
gr<li>The transaction may have seen an inconsistent view of memory when
grthe IO runs. Invariants that you expect to be true throughout your
grprogram may not be true inside a transaction, due to the way
grtransactions are implemented. Normally this wouldn't be visible to the
grprogrammer, but using <a>unsafeIOToSTM</a> can expose it.</li>
gr</ul>
unsafeIOToSTM :: IO a -> STM a

-- | Provide an <a>IO</a> action with the current value of an <a>MVar</a>.
grThe <a>MVar</a> will be empty for the duration that the action is
grrunning.
withMVar :: MVar a -> (a -> IO b) -> IO b
type Signal = CInt
type HandlerFun = ForeignPtr Word8 -> IO ()
setHandler :: Signal -> Maybe (HandlerFun, Dynamic) -> IO (Maybe (HandlerFun, Dynamic))
runHandlers :: ForeignPtr Word8 -> Signal -> IO ()
ensureIOManagerIsRunning :: IO ()
ioManagerCapabilitiesChanged :: IO ()
setUncaughtExceptionHandler :: (SomeException -> IO ()) -> IO ()
getUncaughtExceptionHandler :: IO (SomeException -> IO ())
reportError :: SomeException -> IO ()
reportStackOverflow :: IO ()
reportHeapOverflow :: IO ()


-- | Quantity semaphores in which each thread may wait for an arbitrary
gr"amount".
module Control.Concurrent.QSemN

-- | <a>QSemN</a> is a quantity semaphore in which the resource is aqcuired
grand released in units of one. It provides guaranteed FIFO ordering for
grsatisfying blocked <a>waitQSemN</a> calls.
gr
grThe pattern
gr
gr<pre>
grbracket_ (waitQSemN n) (signalQSemN n) (...)
gr</pre>
gr
gris safe; it never loses any of the resource.
data QSemN

-- | Build a new <a>QSemN</a> with a supplied initial quantity. The initial
grquantity must be at least 0.
newQSemN :: Int -> IO QSemN

-- | Wait for the specified quantity to become available
waitQSemN :: QSemN -> Int -> IO ()

-- | Signal that a given quantity is now available from the <a>QSemN</a>.
signalQSemN :: QSemN -> Int -> IO ()


-- | Simple quantity semaphores.
module Control.Concurrent.QSem

-- | <a>QSem</a> is a quantity semaphore in which the resource is aqcuired
grand released in units of one. It provides guaranteed FIFO ordering for
grsatisfying blocked <a>waitQSem</a> calls.
gr
grThe pattern
gr
gr<pre>
grbracket_ waitQSem signalQSem (...)
gr</pre>
gr
gris safe; it never loses a unit of the resource.
data QSem

-- | Build a new <a>QSem</a> with a supplied initial quantity. The initial
grquantity must be at least 0.
newQSem :: Int -> IO QSem

-- | Wait for a unit to become available
waitQSem :: QSem -> IO ()

-- | Signal that a unit of the <a>QSem</a> is available
signalQSem :: QSem -> IO ()


-- | Unbounded channels.
gr
grThe channels are implemented with <tt>MVar</tt>s and therefore inherit
grall the caveats that apply to <tt>MVar</tt>s (possibility of races,
grdeadlocks etc). The stm (software transactional memory) library has a
grmore robust implementation of channels called <tt>TChan</tt>s.
module Control.Concurrent.Chan

-- | <a>Chan</a> is an abstract type representing an unbounded FIFO
grchannel.
data Chan a

-- | Build and returns a new instance of <a>Chan</a>.
newChan :: IO (Chan a)

-- | Write a value to a <a>Chan</a>.
writeChan :: Chan a -> a -> IO ()

-- | Read the next value from the <a>Chan</a>. Blocks when the channel is
grempty. Since the read end of a channel is an <a>MVar</a>, this
groperation inherits fairness guarantees of <a>MVar</a>s (e.g. threads
grblocked in this operation are woken up in FIFO order).
gr
grThrows <tt>BlockedIndefinitelyOnMVar</tt> when the channel is empty
grand no other thread holds a reference to the channel.
readChan :: Chan a -> IO a

-- | Duplicate a <a>Chan</a>: the duplicate channel begins empty, but data
grwritten to either channel from then on will be available from both.
grHence this creates a kind of broadcast channel, where data written by
granyone is seen by everyone else.
gr
gr(Note that a duplicated channel is not equal to its original. So:
gr<tt>fmap (c /=) $ dupChan c</tt> returns <tt>True</tt> for all
gr<tt>c</tt>.)
dupChan :: Chan a -> IO (Chan a)

-- | Return a lazy list representing the contents of the supplied
gr<a>Chan</a>, much like <a>hGetContents</a>.
getChanContents :: Chan a -> IO [a]

-- | Write an entire list of items to a <a>Chan</a>.
writeList2Chan :: Chan a -> [a] -> IO ()
instance GHC.Classes.Eq (Control.Concurrent.Chan.Chan a)


-- | A common interface to a collection of useful concurrency abstractions.
module Control.Concurrent

-- | A <a>ThreadId</a> is an abstract type representing a handle to a
grthread. <a>ThreadId</a> is an instance of <a>Eq</a>, <a>Ord</a> and
gr<a>Show</a>, where the <a>Ord</a> instance implements an arbitrary
grtotal ordering over <a>ThreadId</a>s. The <a>Show</a> instance lets
gryou convert an arbitrary-valued <a>ThreadId</a> to string form;
grshowing a <a>ThreadId</a> value is occasionally useful when debugging
gror diagnosing the behaviour of a concurrent program.
gr
gr<i>Note</i>: in GHC, if you have a <a>ThreadId</a>, you essentially
grhave a pointer to the thread itself. This means the thread itself
grcan't be garbage collected until you drop the <a>ThreadId</a>. This
grmisfeature will hopefully be corrected at a later date.
data ThreadId

-- | Returns the <a>ThreadId</a> of the calling thread (GHC only).
myThreadId :: IO ThreadId

-- | Creates a new thread to run the <a>IO</a> computation passed as the
grfirst argument, and returns the <a>ThreadId</a> of the newly created
grthread.
gr
grThe new thread will be a lightweight, <i>unbound</i> thread. Foreign
grcalls made by this thread are not guaranteed to be made by any
grparticular OS thread; if you need foreign calls to be made by a
grparticular OS thread, then use <a>forkOS</a> instead.
gr
grThe new thread inherits the <i>masked</i> state of the parent (see
gr<a>mask</a>).
gr
grThe newly created thread has an exception handler that discards the
grexceptions <a>BlockedIndefinitelyOnMVar</a>,
gr<a>BlockedIndefinitelyOnSTM</a>, and <a>ThreadKilled</a>, and passes
grall other exceptions to the uncaught exception handler.
forkIO :: IO () -> IO ThreadId

-- | Fork a thread and call the supplied function when the thread is about
grto terminate, with an exception or a returned value. The function is
grcalled with asynchronous exceptions masked.
gr
gr<pre>
grforkFinally action and_then =
gr  mask $ \restore -&gt;
gr    forkIO $ try (restore action) &gt;&gt;= and_then
gr</pre>
gr
grThis function is useful for informing the parent when a child
grterminates, for example.
forkFinally :: IO a -> (Either SomeException a -> IO ()) -> IO ThreadId

-- | Like <a>forkIO</a>, but the child thread is passed a function that can
grbe used to unmask asynchronous exceptions. This function is typically
grused in the following way
gr
gr<pre>
gr... mask_ $ forkIOWithUnmask $ \unmask -&gt;
gr               catch (unmask ...) handler
gr</pre>
gr
grso that the exception handler in the child thread is established with
grasynchronous exceptions masked, meanwhile the main body of the child
grthread is executed in the unmasked state.
gr
grNote that the unmask function passed to the child thread should only
grbe used in that thread; the behaviour is undefined if it is invoked in
gra different thread.
forkIOWithUnmask :: ((forall a. IO a -> IO a) -> IO ()) -> IO ThreadId

-- | <a>killThread</a> raises the <a>ThreadKilled</a> exception in the
grgiven thread (GHC only).
gr
gr<pre>
grkillThread tid = throwTo tid ThreadKilled
gr</pre>
killThread :: ThreadId -> IO ()

-- | <a>throwTo</a> raises an arbitrary exception in the target thread (GHC
gronly).
gr
grException delivery synchronizes between the source and target thread:
gr<a>throwTo</a> does not return until the exception has been raised in
grthe target thread. The calling thread can thus be certain that the
grtarget thread has received the exception. Exception delivery is also
gratomic with respect to other exceptions. Atomicity is a useful
grproperty to have when dealing with race conditions: e.g. if there are
grtwo threads that can kill each other, it is guaranteed that only one
grof the threads will get to kill the other.
gr
grWhatever work the target thread was doing when the exception was
grraised is not lost: the computation is suspended until required by
granother thread.
gr
grIf the target thread is currently making a foreign call, then the
grexception will not be raised (and hence <a>throwTo</a> will not
grreturn) until the call has completed. This is the case regardless of
grwhether the call is inside a <a>mask</a> or not. However, in GHC a
grforeign call can be annotated as <tt>interruptible</tt>, in which case
gra <a>throwTo</a> will cause the RTS to attempt to cause the call to
grreturn; see the GHC documentation for more details.
gr
grImportant note: the behaviour of <a>throwTo</a> differs from that
grdescribed in the paper "Asynchronous exceptions in Haskell"
gr(<a>http://research.microsoft.com/~simonpj/Papers/asynch-exns.htm</a>).
grIn the paper, <a>throwTo</a> is non-blocking; but the library
grimplementation adopts a more synchronous design in which
gr<a>throwTo</a> does not return until the exception is received by the
grtarget thread. The trade-off is discussed in Section 9 of the paper.
grLike any blocking operation, <a>throwTo</a> is therefore interruptible
gr(see Section 5.3 of the paper). Unlike other interruptible operations,
grhowever, <a>throwTo</a> is <i>always</i> interruptible, even if it
grdoes not actually block.
gr
grThere is no guarantee that the exception will be delivered promptly,
gralthough the runtime will endeavour to ensure that arbitrary delays
grdon't occur. In GHC, an exception can only be raised when a thread
grreaches a <i>safe point</i>, where a safe point is where memory
grallocation occurs. Some loops do not perform any memory allocation
grinside the loop and therefore cannot be interrupted by a
gr<a>throwTo</a>.
gr
grIf the target of <a>throwTo</a> is the calling thread, then the
grbehaviour is the same as <a>throwIO</a>, except that the exception is
grthrown as an asynchronous exception. This means that if there is an
grenclosing pure computation, which would be the case if the current IO
groperation is inside <a>unsafePerformIO</a> or
gr<a>unsafeInterleaveIO</a>, that computation is not permanently
grreplaced by the exception, but is suspended as if it had received an
grasynchronous exception.
gr
grNote that if <a>throwTo</a> is called with the current thread as the
grtarget, the exception will be thrown even if the thread is currently
grinside <a>mask</a> or <a>uninterruptibleMask</a>.
throwTo :: Exception e => ThreadId -> e -> IO ()

-- | Like <a>forkIO</a>, but lets you specify on which capability the
grthread should run. Unlike a <a>forkIO</a> thread, a thread created by
gr<a>forkOn</a> will stay on the same capability for its entire lifetime
gr(<a>forkIO</a> threads can migrate between capabilities according to
grthe scheduling policy). <a>forkOn</a> is useful for overriding the
grscheduling policy when you know in advance how best to distribute the
grthreads.
gr
grThe <a>Int</a> argument specifies a <i>capability number</i> (see
gr<a>getNumCapabilities</a>). Typically capabilities correspond to
grphysical processors, but the exact behaviour is
grimplementation-dependent. The value passed to <a>forkOn</a> is
grinterpreted modulo the total number of capabilities as returned by
gr<a>getNumCapabilities</a>.
gr
grGHC note: the number of capabilities is specified by the <tt>+RTS
gr-N</tt> option when the program is started. Capabilities can be fixed
grto actual processor cores with <tt>+RTS -qa</tt> if the underlying
groperating system supports that, although in practice this is usually
grunnecessary (and may actually degrade performance in some cases -
grexperimentation is recommended).
forkOn :: Int -> IO () -> IO ThreadId

-- | Like <a>forkIOWithUnmask</a>, but the child thread is pinned to the
grgiven CPU, as with <a>forkOn</a>.
forkOnWithUnmask :: Int -> ((forall a. IO a -> IO a) -> IO ()) -> IO ThreadId

-- | Returns the number of Haskell threads that can run truly
grsimultaneously (on separate physical processors) at any given time. To
grchange this value, use <a>setNumCapabilities</a>.
getNumCapabilities :: IO Int

-- | Set the number of Haskell threads that can run truly simultaneously
gr(on separate physical processors) at any given time. The number passed
grto <a>forkOn</a> is interpreted modulo this value. The initial value
gris given by the <tt>+RTS -N</tt> runtime flag.
gr
grThis is also the number of threads that will participate in parallel
grgarbage collection. It is strongly recommended that the number of
grcapabilities is not set larger than the number of physical processor
grcores, and it may often be beneficial to leave one or more cores free
grto avoid contention with other processes in the machine.
setNumCapabilities :: Int -> IO ()

-- | Returns the number of the capability on which the thread is currently
grrunning, and a boolean indicating whether the thread is locked to that
grcapability or not. A thread is locked to a capability if it was
grcreated with <tt>forkOn</tt>.
threadCapability :: ThreadId -> IO (Int, Bool)

-- | The <a>yield</a> action allows (forces, in a co-operative multitasking
grimplementation) a context-switch to any other currently runnable
grthreads (if any), and is occasionally useful when implementing
grconcurrency abstractions.
yield :: IO ()

-- | Suspends the current thread for a given number of microseconds (GHC
gronly).
gr
grThere is no guarantee that the thread will be rescheduled promptly
grwhen the delay has expired, but the thread will never continue to run
gr<i>earlier</i> than specified.
threadDelay :: Int -> IO ()

-- | Block the current thread until data is available to read on the given
grfile descriptor (GHC only).
gr
grThis will throw an <a>IOError</a> if the file descriptor was closed
grwhile this thread was blocked. To safely close a file descriptor that
grhas been used with <a>threadWaitRead</a>, use <a>closeFdWith</a>.
threadWaitRead :: Fd -> IO ()

-- | Block the current thread until data can be written to the given file
grdescriptor (GHC only).
gr
grThis will throw an <a>IOError</a> if the file descriptor was closed
grwhile this thread was blocked. To safely close a file descriptor that
grhas been used with <a>threadWaitWrite</a>, use <a>closeFdWith</a>.
threadWaitWrite :: Fd -> IO ()

-- | Returns an STM action that can be used to wait for data to read from a
grfile descriptor. The second returned value is an IO action that can be
grused to deregister interest in the file descriptor.
threadWaitReadSTM :: Fd -> IO (STM (), IO ())

-- | Returns an STM action that can be used to wait until data can be
grwritten to a file descriptor. The second returned value is an IO
graction that can be used to deregister interest in the file descriptor.
threadWaitWriteSTM :: Fd -> IO (STM (), IO ())

-- | <a>True</a> if bound threads are supported. If
gr<tt>rtsSupportsBoundThreads</tt> is <a>False</a>,
gr<a>isCurrentThreadBound</a> will always return <a>False</a> and both
gr<a>forkOS</a> and <a>runInBoundThread</a> will fail.
rtsSupportsBoundThreads :: Bool

-- | Like <a>forkIO</a>, this sparks off a new thread to run the <a>IO</a>
grcomputation passed as the first argument, and returns the
gr<a>ThreadId</a> of the newly created thread.
gr
grHowever, <a>forkOS</a> creates a <i>bound</i> thread, which is
grnecessary if you need to call foreign (non-Haskell) libraries that
grmake use of thread-local state, such as OpenGL (see
gr<a>Control.Concurrent#boundthreads</a>).
gr
grUsing <a>forkOS</a> instead of <a>forkIO</a> makes no difference at
grall to the scheduling behaviour of the Haskell runtime system. It is a
grcommon misconception that you need to use <a>forkOS</a> instead of
gr<a>forkIO</a> to avoid blocking all the Haskell threads when making a
grforeign call; this isn't the case. To allow foreign calls to be made
grwithout blocking all the Haskell threads (with GHC), it is only
grnecessary to use the <tt>-threaded</tt> option when linking your
grprogram, and to make sure the foreign import is not marked
gr<tt>unsafe</tt>.
forkOS :: IO () -> IO ThreadId

-- | Like <a>forkIOWithUnmask</a>, but the child thread is a bound thread,
gras with <a>forkOS</a>.
forkOSWithUnmask :: ((forall a. IO a -> IO a) -> IO ()) -> IO ThreadId

-- | Returns <a>True</a> if the calling thread is <i>bound</i>, that is, if
grit is safe to use foreign libraries that rely on thread-local state
grfrom the calling thread.
isCurrentThreadBound :: IO Bool

-- | Run the <a>IO</a> computation passed as the first argument. If the
grcalling thread is not <i>bound</i>, a bound thread is created
grtemporarily. <tt>runInBoundThread</tt> doesn't finish until the
gr<a>IO</a> computation finishes.
gr
grYou can wrap a series of foreign function calls that rely on
grthread-local state with <tt>runInBoundThread</tt> so that you can use
grthem without knowing whether the current thread is <i>bound</i>.
runInBoundThread :: IO a -> IO a

-- | Run the <a>IO</a> computation passed as the first argument. If the
grcalling thread is <i>bound</i>, an unbound thread is created
grtemporarily using <a>forkIO</a>. <tt>runInBoundThread</tt> doesn't
grfinish until the <a>IO</a> computation finishes.
gr
grUse this function <i>only</i> in the rare case that you have actually
grobserved a performance loss due to the use of bound threads. A program
grthat doesn't need its main thread to be bound and makes <i>heavy</i>
gruse of concurrency (e.g. a web server), might want to wrap its
gr<tt>main</tt> action in <tt>runInUnboundThread</tt>.
gr
grNote that exceptions which are thrown to the current thread are thrown
grin turn to the thread that is executing the given computation. This
grensures there's always a way of killing the forked thread.
runInUnboundThread :: IO a -> IO a

-- | Make a weak pointer to a <a>ThreadId</a>. It can be important to do
grthis if you want to hold a reference to a <a>ThreadId</a> while still
grallowing the thread to receive the <tt>BlockedIndefinitely</tt> family
grof exceptions (e.g. <a>BlockedIndefinitelyOnMVar</a>). Holding a
grnormal <a>ThreadId</a> reference will prevent the delivery of
gr<tt>BlockedIndefinitely</tt> exceptions because the reference could be
grused as the target of <a>throwTo</a> at any time, which would unblock
grthe thread.
gr
grHolding a <tt>Weak ThreadId</tt>, on the other hand, will not prevent
grthe thread from receiving <tt>BlockedIndefinitely</tt> exceptions. It
gris still possible to throw an exception to a <tt>Weak ThreadId</tt>,
grbut the caller must use <tt>deRefWeak</tt> first to determine whether
grthe thread still exists.
mkWeakThreadId :: ThreadId -> IO (Weak ThreadId)


-- | Attach a timeout event to arbitrary <a>IO</a> computations.
module System.Timeout

-- | Wrap an <a>IO</a> computation to time out and return <tt>Nothing</tt>
grin case no result is available within <tt>n</tt> microseconds
gr(<tt>1/10^6</tt> seconds). In case a result is available before the
grtimeout expires, <tt>Just a</tt> is returned. A negative timeout
grinterval means "wait indefinitely". When specifying long timeouts, be
grcareful not to exceed <tt>maxBound :: Int</tt>.
gr
gr<pre>
gr&gt;&gt;&gt; timeout 1000000 (threadDelay 1000 *&gt; pure "finished on time")
grJust "finished on time"
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; timeout 10000 (threadDelay 100000 *&gt; pure "finished on time")
grNothing
gr</pre>
gr
grThe design of this combinator was guided by the objective that
gr<tt>timeout n f</tt> should behave exactly the same as <tt>f</tt> as
grlong as <tt>f</tt> doesn't time out. This means that <tt>f</tt> has
grthe same <a>myThreadId</a> it would have without the timeout wrapper.
grAny exceptions <tt>f</tt> might throw cancel the timeout and propagate
grfurther up. It also possible for <tt>f</tt> to receive exceptions
grthrown to it by another thread.
gr
grA tricky implementation detail is the question of how to abort an
gr<tt>IO</tt> computation. This combinator relies on asynchronous
grexceptions internally. The technique works very well for computations
grexecuting inside of the Haskell runtime system, but it doesn't work at
grall for non-Haskell code. Foreign function calls, for example, cannot
grbe timed out with this combinator simply because an arbitrary C
grfunction cannot receive asynchronous exceptions. When <tt>timeout</tt>
gris used to wrap an FFI call that blocks, no timeout event can be
grdelivered until the FFI call returns, which pretty much negates the
grpurpose of the combinator. In practice, however, this limitation is
grless severe than it may sound. Standard I/O functions like
gr<a>hGetBuf</a>, <a>hPutBuf</a>, Network.Socket.accept, or
gr<a>hWaitForInput</a> appear to be blocking, but they really don't
grbecause the runtime system uses scheduling mechanisms like
gr<tt>select(2)</tt> to perform asynchronous I/O, so it is possible to
grinterrupt standard socket I/O or file I/O using this combinator.
timeout :: Int -> IO a -> IO (Maybe a)
instance GHC.Classes.Eq System.Timeout.Timeout
instance GHC.Show.Show System.Timeout.Timeout
instance GHC.Exception.Exception System.Timeout.Timeout


-- | "Scrap your boilerplate" --- Generic programming in Haskell. See
gr<a>http://www.haskell.org/haskellwiki/Research_papers/Generics#Scrap_your_boilerplate.21</a>.
grThis module provides the <a>Data</a> class with its primitives for
grgeneric programming, along with instances for many datatypes. It
grcorresponds to a merge between the previous
gr<a>Data.Generics.Basics</a> and almost all of
gr<a>Data.Generics.Instances</a>. The instances that are not present in
grthis module were moved to the <tt>Data.Generics.Instances</tt> module
grin the <tt>syb</tt> package.
gr
grFor more information, please visit the new SYB wiki:
gr<a>http://www.cs.uu.nl/wiki/bin/view/GenericProgramming/SYB</a>.
module Data.Data

-- | The <a>Data</a> class comprehends a fundamental primitive
gr<a>gfoldl</a> for folding over constructor applications, say terms.
grThis primitive can be instantiated in several ways to map over the
grimmediate subterms of a term; see the <tt>gmap</tt> combinators later
grin this class. Indeed, a generic programmer does not necessarily need
grto use the ingenious gfoldl primitive but rather the intuitive
gr<tt>gmap</tt> combinators. The <a>gfoldl</a> primitive is completed by
grmeans to query top-level constructors, to turn constructor
grrepresentations into proper terms, and to list all possible datatype
grconstructors. This completion allows us to serve generic programming
grscenarios like read, show, equality, term generation.
gr
grThe combinators <a>gmapT</a>, <a>gmapQ</a>, <a>gmapM</a>, etc are all
grprovided with default definitions in terms of <a>gfoldl</a>, leaving
gropen the opportunity to provide datatype-specific definitions. (The
grinclusion of the <tt>gmap</tt> combinators as members of class
gr<a>Data</a> allows the programmer or the compiler to derive
grspecialised, and maybe more efficient code per datatype. <i>Note</i>:
gr<a>gfoldl</a> is more higher-order than the <tt>gmap</tt> combinators.
grThis is subject to ongoing benchmarking experiments. It might turn out
grthat the <tt>gmap</tt> combinators will be moved out of the class
gr<a>Data</a>.)
gr
grConceptually, the definition of the <tt>gmap</tt> combinators in terms
grof the primitive <a>gfoldl</a> requires the identification of the
gr<a>gfoldl</a> function arguments. Technically, we also need to
gridentify the type constructor <tt>c</tt> for the construction of the
grresult type from the folded term type.
gr
grIn the definition of <tt>gmapQ</tt><i>x</i> combinators, we use
grphantom type constructors for the <tt>c</tt> in the type of
gr<a>gfoldl</a> because the result type of a query does not involve the
gr(polymorphic) type of the term argument. In the definition of
gr<a>gmapQl</a> we simply use the plain constant type constructor
grbecause <a>gfoldl</a> is left-associative anyway and so it is readily
grsuited to fold a left-associative binary operation over the immediate
grsubterms. In the definition of gmapQr, extra effort is needed. We use
gra higher-order accumulation trick to mediate between left-associative
grconstructor application vs. right-associative binary operation (e.g.,
gr<tt>(:)</tt>). When the query is meant to compute a value of type
gr<tt>r</tt>, then the result type withing generic folding is <tt>r
gr-&gt; r</tt>. So the result of folding is a function to which we
grfinally pass the right unit.
gr
grWith the <tt>-XDeriveDataTypeable</tt> option, GHC can generate
grinstances of the <a>Data</a> class automatically. For example, given
grthe declaration
gr
gr<pre>
grdata T a b = C1 a b | C2 deriving (Typeable, Data)
gr</pre>
gr
grGHC will generate an instance that is equivalent to
gr
gr<pre>
grinstance (Data a, Data b) =&gt; Data (T a b) where
gr    gfoldl k z (C1 a b) = z C1 `k` a `k` b
gr    gfoldl k z C2       = z C2
gr
gr    gunfold k z c = case constrIndex c of
gr                        1 -&gt; k (k (z C1))
gr                        2 -&gt; z C2
gr
gr    toConstr (C1 _ _) = con_C1
gr    toConstr C2       = con_C2
gr
gr    dataTypeOf _ = ty_T
gr
grcon_C1 = mkConstr ty_T "C1" [] Prefix
grcon_C2 = mkConstr ty_T "C2" [] Prefix
grty_T   = mkDataType "Module.T" [con_C1, con_C2]
gr</pre>
gr
grThis is suitable for datatypes that are exported transparently.
class Typeable a => Data a

-- | Left-associative fold operation for constructor applications.
gr
grThe type of <a>gfoldl</a> is a headache, but operationally it is a
grsimple generalisation of a list fold.
gr
grThe default definition for <a>gfoldl</a> is <tt><a>const</a>
gr<a>id</a></tt>, which is suitable for abstract datatypes with no
grsubstructures.
gfoldl :: Data a => (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> a -> c a

-- | Unfolding constructor applications
gunfold :: Data a => (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c a

-- | Obtaining the constructor from a given datum. For proper terms, this
gris meant to be the top-level constructor. Primitive datatypes are here
grviewed as potentially infinite sets of values (i.e., constructors).
toConstr :: Data a => a -> Constr

-- | The outer type constructor of the type
dataTypeOf :: Data a => a -> DataType

-- | Mediate types and unary type constructors.
gr
grIn <a>Data</a> instances of the form
gr
gr<pre>
grinstance (Data a, ...) =&gt; Data (T a)
gr</pre>
gr
gr<a>dataCast1</a> should be defined as <a>gcast1</a>.
gr
grThe default definition is <tt><a>const</a> <a>Nothing</a></tt>, which
gris appropriate for instances of other forms.
dataCast1 :: (Data a, Typeable t) => (forall d. Data d => c (t d)) -> Maybe (c a)

-- | Mediate types and binary type constructors.
gr
grIn <a>Data</a> instances of the form
gr
gr<pre>
grinstance (Data a, Data b, ...) =&gt; Data (T a b)
gr</pre>
gr
gr<a>dataCast2</a> should be defined as <a>gcast2</a>.
gr
grThe default definition is <tt><a>const</a> <a>Nothing</a></tt>, which
gris appropriate for instances of other forms.
dataCast2 :: (Data a, Typeable t) => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a)

-- | A generic transformation that maps over the immediate subterms
gr
grThe default definition instantiates the type constructor <tt>c</tt> in
grthe type of <a>gfoldl</a> to an identity datatype constructor, using
grthe isomorphism pair as injection and projection.
gmapT :: Data a => (forall b. Data b => b -> b) -> a -> a

-- | A generic query with a left-associative binary operator
gmapQl :: forall r r'. Data a => (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r

-- | A generic query with a right-associative binary operator
gmapQr :: forall r r'. Data a => (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r

-- | A generic query that processes the immediate subterms and returns a
grlist of results. The list is given in the same order as originally
grspecified in the declaration of the data constructors.
gmapQ :: Data a => (forall d. Data d => d -> u) -> a -> [u]

-- | A generic query that processes one child by index (zero-based)
gmapQi :: forall u. Data a => Int -> (forall d. Data d => d -> u) -> a -> u

-- | A generic monadic transformation that maps over the immediate subterms
gr
grThe default definition instantiates the type constructor <tt>c</tt> in
grthe type of <a>gfoldl</a> to the monad datatype constructor, defining
grinjection and projection using <a>return</a> and <a>&gt;&gt;=</a>.
gmapM :: forall m. (Data a, Monad m) => (forall d. Data d => d -> m d) -> a -> m a

-- | Transformation of at least one immediate subterm does not fail
gmapMp :: forall m. (Data a, MonadPlus m) => (forall d. Data d => d -> m d) -> a -> m a

-- | Transformation of one immediate subterm with success
gmapMo :: forall m. (Data a, MonadPlus m) => (forall d. Data d => d -> m d) -> a -> m a

-- | Representation of datatypes. A package of constructor representations
grwith names of type and module.
data DataType

-- | Constructs an algebraic datatype
mkDataType :: String -> [Constr] -> DataType

-- | Constructs the <a>Int</a> type
mkIntType :: String -> DataType

-- | Constructs the <a>Float</a> type
mkFloatType :: String -> DataType

-- | Constructs the <a>Char</a> type
mkCharType :: String -> DataType

-- | Constructs a non-representation for a non-representable type
mkNoRepType :: String -> DataType

-- | Gets the type constructor including the module
dataTypeName :: DataType -> String

-- | Public representation of datatypes
data DataRep
AlgRep :: [Constr] -> DataRep
IntRep :: DataRep
FloatRep :: DataRep
CharRep :: DataRep
NoRep :: DataRep

-- | Gets the public presentation of a datatype
dataTypeRep :: DataType -> DataRep

-- | Look up a constructor by its representation
repConstr :: DataType -> ConstrRep -> Constr

-- | Test for an algebraic type
isAlgType :: DataType -> Bool

-- | Gets the constructors of an algebraic datatype
dataTypeConstrs :: DataType -> [Constr]

-- | Gets the constructor for an index (algebraic datatypes only)
indexConstr :: DataType -> ConIndex -> Constr

-- | Gets the maximum constructor index of an algebraic datatype
maxConstrIndex :: DataType -> ConIndex

-- | Test for a non-representable type
isNorepType :: DataType -> Bool

-- | Representation of constructors. Note that equality on constructors
grwith different types may not work -- i.e. the constructors for
gr<a>False</a> and <a>Nothing</a> may compare equal.
data Constr

-- | Unique index for datatype constructors, counting from 1 in the order
grthey are given in the program text.
type ConIndex = Int

-- | Fixity of constructors
data Fixity
Prefix :: Fixity
Infix :: Fixity

-- | Constructs a constructor
mkConstr :: DataType -> String -> [String] -> Fixity -> Constr
mkIntegralConstr :: (Integral a, Show a) => DataType -> a -> Constr
mkRealConstr :: (Real a, Show a) => DataType -> a -> Constr

-- | Makes a constructor for <a>Char</a>.
mkCharConstr :: DataType -> Char -> Constr

-- | Gets the datatype of a constructor
constrType :: Constr -> DataType

-- | Public representation of constructors
data ConstrRep
AlgConstr :: ConIndex -> ConstrRep
IntConstr :: Integer -> ConstrRep
FloatConstr :: Rational -> ConstrRep
CharConstr :: Char -> ConstrRep

-- | Gets the public presentation of constructors
constrRep :: Constr -> ConstrRep

-- | Gets the field labels of a constructor. The list of labels is returned
grin the same order as they were given in the original constructor
grdeclaration.
constrFields :: Constr -> [String]

-- | Gets the fixity of a constructor
constrFixity :: Constr -> Fixity

-- | Gets the index of a constructor (algebraic datatypes only)
constrIndex :: Constr -> ConIndex

-- | Gets the string for a constructor
showConstr :: Constr -> String

-- | Lookup a constructor via a string
readConstr :: DataType -> String -> Maybe Constr

-- | Gets the unqualified type constructor: drop *.*.*... before name
tyconUQname :: String -> String

-- | Gets the module of a type constructor: take *.*.*... before name
tyconModule :: String -> String

-- | Build a term skeleton
fromConstr :: Data a => Constr -> a

-- | Build a term and use a generic function for subterms
fromConstrB :: Data a => (forall d. Data d => d) -> Constr -> a

-- | Monadic variation on <a>fromConstrB</a>
fromConstrM :: forall m a. (Monad m, Data a) => (forall d. Data d => m d) -> Constr -> m a
instance GHC.Show.Show Data.Data.DataRep
instance GHC.Classes.Eq Data.Data.DataRep
instance GHC.Show.Show Data.Data.DataType
instance GHC.Show.Show Data.Data.Fixity
instance GHC.Classes.Eq Data.Data.Fixity
instance GHC.Show.Show Data.Data.ConstrRep
instance GHC.Classes.Eq Data.Data.ConstrRep
instance Data.Data.Data GHC.Types.Bool
instance Data.Data.Data a => Data.Data.Data (GHC.Base.NonEmpty a)
instance Data.Data.Data a => Data.Data.Data (GHC.Base.Maybe a)
instance Data.Data.Data GHC.Types.Ordering
instance (Data.Data.Data a, Data.Data.Data b) => Data.Data.Data (Data.Either.Either a b)
instance Data.Data.Data ()
instance (Data.Data.Data a, Data.Data.Data b) => Data.Data.Data (a, b)
instance (Data.Data.Data a, Data.Data.Data b, Data.Data.Data c) => Data.Data.Data (a, b, c)
instance (Data.Data.Data a, Data.Data.Data b, Data.Data.Data c, Data.Data.Data d) => Data.Data.Data (a, b, c, d)
instance (Data.Data.Data a, Data.Data.Data b, Data.Data.Data c, Data.Data.Data d, Data.Data.Data e) => Data.Data.Data (a, b, c, d, e)
instance (Data.Data.Data a, Data.Data.Data b, Data.Data.Data c, Data.Data.Data d, Data.Data.Data e, Data.Data.Data f) => Data.Data.Data (a, b, c, d, e, f)
instance (Data.Data.Data a, Data.Data.Data b, Data.Data.Data c, Data.Data.Data d, Data.Data.Data e, Data.Data.Data f, Data.Data.Data g) => Data.Data.Data (a, b, c, d, e, f, g)
instance Data.Data.Data Foreign.Ptr.IntPtr
instance Data.Data.Data Foreign.Ptr.WordPtr
instance Data.Data.Data t => Data.Data.Data (Data.Proxy.Proxy t)
instance (a ~ b, Data.Data.Data a) => Data.Data.Data (a Data.Type.Equality.:~: b)
instance forall i j (a :: i) (b :: j). (Data.Typeable.Internal.Typeable i, Data.Typeable.Internal.Typeable j, Data.Typeable.Internal.Typeable a, Data.Typeable.Internal.Typeable b, (a :: i) ~~ (b :: j)) => Data.Data.Data (a Data.Type.Equality.:~~: b)
instance (GHC.Types.Coercible a b, Data.Data.Data a, Data.Data.Data b) => Data.Data.Data (Data.Type.Coercion.Coercion a b)
instance Data.Data.Data a => Data.Data.Data (Data.Functor.Identity.Identity a)
instance forall k a (b :: k). (Data.Typeable.Internal.Typeable k, Data.Data.Data a, Data.Typeable.Internal.Typeable b) => Data.Data.Data (Data.Functor.Const.Const a b)
instance Data.Data.Data Data.Version.Version
instance Data.Data.Data a => Data.Data.Data (Data.Semigroup.Internal.Dual a)
instance Data.Data.Data Data.Semigroup.Internal.All
instance Data.Data.Data Data.Semigroup.Internal.Any
instance Data.Data.Data a => Data.Data.Data (Data.Semigroup.Internal.Sum a)
instance Data.Data.Data a => Data.Data.Data (Data.Semigroup.Internal.Product a)
instance Data.Data.Data a => Data.Data.Data (Data.Monoid.First a)
instance Data.Data.Data a => Data.Data.Data (Data.Monoid.Last a)
instance (Data.Data.Data (f a), Data.Data.Data a, Data.Typeable.Internal.Typeable f) => Data.Data.Data (Data.Semigroup.Internal.Alt f a)
instance Data.Data.Data p => Data.Data.Data (GHC.Generics.U1 p)
instance Data.Data.Data p => Data.Data.Data (GHC.Generics.Par1 p)
instance (Data.Data.Data (f p), Data.Typeable.Internal.Typeable f, Data.Data.Data p) => Data.Data.Data (GHC.Generics.Rec1 f p)
instance (Data.Typeable.Internal.Typeable i, Data.Data.Data p, Data.Data.Data c) => Data.Data.Data (GHC.Generics.K1 i c p)
instance (Data.Data.Data p, Data.Data.Data (f p), Data.Typeable.Internal.Typeable c, Data.Typeable.Internal.Typeable i, Data.Typeable.Internal.Typeable f) => Data.Data.Data (GHC.Generics.M1 i c f p)
instance (Data.Typeable.Internal.Typeable f, Data.Typeable.Internal.Typeable g, Data.Data.Data p, Data.Data.Data (f p), Data.Data.Data (g p)) => Data.Data.Data ((GHC.Generics.:+:) f g p)
instance (Data.Typeable.Internal.Typeable f, Data.Typeable.Internal.Typeable g, Data.Data.Data p, Data.Data.Data (f (g p))) => Data.Data.Data ((GHC.Generics.:.:) f g p)
instance Data.Data.Data p => Data.Data.Data (GHC.Generics.V1 p)
instance (Data.Typeable.Internal.Typeable f, Data.Typeable.Internal.Typeable g, Data.Data.Data p, Data.Data.Data (f p), Data.Data.Data (g p)) => Data.Data.Data ((GHC.Generics.:*:) f g p)
instance Data.Data.Data GHC.Generics.Fixity
instance Data.Data.Data GHC.Generics.Associativity
instance Data.Data.Data GHC.Generics.SourceUnpackedness
instance Data.Data.Data GHC.Generics.SourceStrictness
instance Data.Data.Data GHC.Generics.DecidedStrictness
instance Data.Data.Data GHC.Types.Char
instance Data.Data.Data GHC.Types.Float
instance Data.Data.Data GHC.Types.Double
instance Data.Data.Data GHC.Types.Int
instance Data.Data.Data GHC.Integer.Type.Integer
instance Data.Data.Data GHC.Natural.Natural
instance Data.Data.Data GHC.Int.Int8
instance Data.Data.Data GHC.Int.Int16
instance Data.Data.Data GHC.Int.Int32
instance Data.Data.Data GHC.Int.Int64
instance Data.Data.Data GHC.Types.Word
instance Data.Data.Data GHC.Word.Word8
instance Data.Data.Data GHC.Word.Word16
instance Data.Data.Data GHC.Word.Word32
instance Data.Data.Data GHC.Word.Word64
instance (Data.Data.Data a, GHC.Real.Integral a) => Data.Data.Data (GHC.Real.Ratio a)
instance Data.Data.Data a => Data.Data.Data [a]
instance Data.Data.Data a => Data.Data.Data (GHC.Ptr.Ptr a)
instance Data.Data.Data a => Data.Data.Data (GHC.ForeignPtr.ForeignPtr a)
instance (Data.Data.Data a, Data.Data.Data b, GHC.Arr.Ix a) => Data.Data.Data (GHC.Arr.Array a b)
instance GHC.Show.Show Data.Data.Constr
instance GHC.Classes.Eq Data.Data.Constr


-- | GHC Extensions: this is the Approved Way to get at GHC-specific
grextensions.
gr
grNote: no other base module should import this module.
module GHC.Exts

-- | A fixed-precision integer type with at least the range <tt>[-2^29 ..
gr2^29-1]</tt>. The exact range for a given implementation can be
grdetermined by using <a>minBound</a> and <a>maxBound</a> from the
gr<a>Bounded</a> class.
data Int
I# :: Int# -> Int

-- | A <a>Word</a> is an unsigned integral type, with the same size as
gr<a>Int</a>.
data Word
W# :: Word# -> Word

-- | Single-precision floating point numbers. It is desirable that this
grtype be at least equal in range and precision to the IEEE
grsingle-precision type.
data Float
F# :: Float# -> Float

-- | Double-precision floating point numbers. It is desirable that this
grtype be at least equal in range and precision to the IEEE
grdouble-precision type.
data Double
D# :: Double# -> Double

-- | The character type <a>Char</a> is an enumeration whose values
grrepresent Unicode (or equivalently ISO/IEC 10646) code points (i.e.
grcharacters, see <a>http://www.unicode.org/</a> for details). This set
grextends the ISO 8859-1 (Latin-1) character set (the first 256
grcharacters), which is itself an extension of the ASCII character set
gr(the first 128 characters). A character literal in Haskell has type
gr<a>Char</a>.
gr
grTo convert a <a>Char</a> to or from the corresponding <a>Int</a> value
grdefined by Unicode, use <a>toEnum</a> and <a>fromEnum</a> from the
gr<a>Enum</a> class respectively (or equivalently <tt>ord</tt> and
gr<tt>chr</tt>).
data Char
C# :: Char# -> Char

-- | A value of type <tt><a>Ptr</a> a</tt> represents a pointer to an
grobject, or an array of objects, which may be marshalled to or from
grHaskell values of type <tt>a</tt>.
gr
grThe type <tt>a</tt> will often be an instance of class <a>Storable</a>
grwhich provides the marshalling operations. However this is not
gressential, and you can provide your own operations to access the
grpointer. For example you might write small foreign functions to get or
grset the fields of a C <tt>struct</tt>.
data Ptr a
Ptr :: Addr# -> Ptr a

-- | A value of type <tt><a>FunPtr</a> a</tt> is a pointer to a function
grcallable from foreign code. The type <tt>a</tt> will normally be a
gr<i>foreign type</i>, a function type with zero or more arguments where
gr
gr<ul>
gr<li>the argument types are <i>marshallable foreign types</i>, i.e.
gr<a>Char</a>, <a>Int</a>, <a>Double</a>, <a>Float</a>, <a>Bool</a>,
gr<a>Int8</a>, <a>Int16</a>, <a>Int32</a>, <a>Int64</a>, <a>Word8</a>,
gr<a>Word16</a>, <a>Word32</a>, <a>Word64</a>, <tt><a>Ptr</a> a</tt>,
gr<tt><a>FunPtr</a> a</tt>, <tt><a>StablePtr</a> a</tt> or a renaming of
grany of these using <tt>newtype</tt>.</li>
gr<li>the return type is either a marshallable foreign type or has the
grform <tt><a>IO</a> t</tt> where <tt>t</tt> is a marshallable foreign
grtype or <tt>()</tt>.</li>
gr</ul>
gr
grA value of type <tt><a>FunPtr</a> a</tt> may be a pointer to a foreign
grfunction, either returned by another foreign function or imported with
gra a static address import like
gr
gr<pre>
grforeign import ccall "stdlib.h &amp;free"
gr  p_free :: FunPtr (Ptr a -&gt; IO ())
gr</pre>
gr
gror a pointer to a Haskell function created using a <i>wrapper</i> stub
grdeclared to produce a <a>FunPtr</a> of the correct type. For example:
gr
gr<pre>
grtype Compare = Int -&gt; Int -&gt; Bool
grforeign import ccall "wrapper"
gr  mkCompare :: Compare -&gt; IO (FunPtr Compare)
gr</pre>
gr
grCalls to wrapper stubs like <tt>mkCompare</tt> allocate storage, which
grshould be released with <a>freeHaskellFunPtr</a> when no longer
grrequired.
gr
grTo convert <a>FunPtr</a> values to corresponding Haskell functions,
grone can define a <i>dynamic</i> stub for the specific foreign type,
gre.g.
gr
gr<pre>
grtype IntFunction = CInt -&gt; IO ()
grforeign import ccall "dynamic"
gr  mkFun :: FunPtr IntFunction -&gt; IntFunction
gr</pre>
data FunPtr a
FunPtr :: Addr# -> FunPtr a
maxTupleSize :: Int

-- | The value of <tt>seq a b</tt> is bottom if <tt>a</tt> is bottom, and
grotherwise equal to <tt>b</tt>. In other words, it evaluates the first
grargument <tt>a</tt> to weak head normal form (WHNF). <tt>seq</tt> is
grusually introduced to improve performance by avoiding unneeded
grlaziness.
gr
grA note on evaluation order: the expression <tt>seq a b</tt> does
gr<i>not</i> guarantee that <tt>a</tt> will be evaluated before
gr<tt>b</tt>. The only guarantee given by <tt>seq</tt> is that the both
gr<tt>a</tt> and <tt>b</tt> will be evaluated before <tt>seq</tt>
grreturns a value. In particular, this means that <tt>b</tt> may be
grevaluated before <tt>a</tt>. If you need to guarantee a specific order
grof evaluation, you must use the function <tt>pseq</tt> from the
gr"parallel" package.
seq :: () => a -> b -> b
realWorld# :: State# RealWorld
void# :: Void#

-- | The function <tt>unsafeCoerce#</tt> allows you to side-step the
grtypechecker entirely. That is, it allows you to coerce any type into
grany other type. If you use this function, you had better get it right,
grotherwise segmentation faults await. It is generally used when you
grwant to write a program that you know is well-typed, but where
grHaskell's type system is not expressive enough to prove that it is
grwell typed.
gr
grThe following uses of <tt>unsafeCoerce#</tt> are supposed to work
gr(i.e. not lead to spurious compile-time or run-time crashes):
gr
gr<ul>
gr<li>Casting any lifted type to <tt>Any</tt></li>
gr<li>Casting <tt>Any</tt> back to the real type</li>
gr<li>Casting an unboxed type to another unboxed type of the same size.
gr(Casting between floating-point and integral types does not work. See
grthe <tt>GHC.Float</tt> module for functions to do work.)</li>
gr<li>Casting between two types that have the same runtime
grrepresentation. One case is when the two types differ only in
gr"phantom" type parameters, for example <tt>Ptr Int</tt> to <tt>Ptr
grFloat</tt>, or <tt>[Int]</tt> to <tt>[Float]</tt> when the list is
grknown to be empty. Also, a <tt>newtype</tt> of a type <tt>T</tt> has
grthe same representation at runtime as <tt>T</tt>.</li>
gr</ul>
gr
grOther uses of <tt>unsafeCoerce#</tt> are undefined. In particular, you
grshould not use <tt>unsafeCoerce#</tt> to cast a T to an algebraic data
grtype D, unless T is also an algebraic data type. For example, do not
grcast <tt>Int-&gt;Int</tt> to <tt>Bool</tt>, even if you later cast
grthat <tt>Bool</tt> back to <tt>Int-&gt;Int</tt> before applying it.
grThe reasons have to do with GHC's internal representation details (for
grthe cognoscenti, data values can be entered but function closures
grcannot). If you want a safe type to cast things to, use <tt>Any</tt>,
grwhich is not an algebraic data type.
unsafeCoerce# :: () => a -> b

-- | The null address.
nullAddr# :: Addr#
magicDict :: () => a

-- | Witness for an unboxed <tt>Proxy#</tt> value, which has no runtime
grrepresentation.
proxy# :: () => Proxy# a

-- | An arbitrary machine address assumed to point outside the
grgarbage-collected heap.
data Addr# :: TYPE AddrRep
data Array# (a :: *) :: TYPE UnliftedRep
data ByteArray# :: TYPE UnliftedRep
data Char# :: TYPE WordRep
data Double# :: TYPE DoubleRep
data Float# :: TYPE FloatRep
data Int# :: TYPE IntRep
data Int32# :: TYPE IntRep
data Int64# :: TYPE Int64Rep
data Weak# (a :: *) :: TYPE UnliftedRep
data MutableArray# (a :: *) (b :: *) :: TYPE UnliftedRep
data MutableByteArray# (a :: *) :: TYPE UnliftedRep

-- | A shared mutable variable (<i>not</i> the same as a
gr<tt>MutVar#</tt>!). (Note: in a non-concurrent implementation,
gr<tt>(MVar# a)</tt> can be represented by <tt>(MutVar# (Maybe
gra))</tt>.)
data MVar# (a :: *) (b :: *) :: TYPE UnliftedRep

-- | <tt>RealWorld</tt> is deeply magical. It is <i>primitive</i>, but it
gris not <i>unlifted</i> (hence <tt>ptrArg</tt>). We never manipulate
grvalues of type <tt>RealWorld</tt>; it's only used in the type system,
grto parameterise <tt>State#</tt>.
data RealWorld
data StablePtr# (a :: *) :: TYPE AddrRep
data ArrayArray# :: TYPE UnliftedRep
data MutableArrayArray# (a :: *) :: TYPE UnliftedRep

-- | <tt>State#</tt> is the primitive, unlifted type of states. It has one
grtype parameter, thus <tt>State# RealWorld</tt>, or <tt>State# s</tt>,
grwhere s is a type variable. The only purpose of the type parameter is
grto keep different state threads separate. It is represented by nothing
grat all.
data State# (a :: *) :: TYPE TupleRep ([] :: [RuntimeRep])
data StableName# (a :: *) :: TYPE UnliftedRep
data (~#) :: forall k0 k1. () => k0 -> k1 -> TYPE TupleRep ([] :: [RuntimeRep])

-- | A <tt>MutVar#</tt> behaves like a single-element mutable array.
data MutVar# (a :: *) (b :: *) :: TYPE UnliftedRep
data Void# :: TYPE TupleRep ([] :: [RuntimeRep])
data Word# :: TYPE WordRep
data Word32# :: TYPE WordRep
data Word64# :: TYPE Word64Rep

-- | (In a non-concurrent implementation, this can be a singleton type,
grwhose (unique) value is returned by <tt>myThreadId#</tt>. The other
groperations can be omitted.)
data ThreadId# :: TYPE UnliftedRep

-- | Primitive bytecode type.
data BCO# :: TYPE UnliftedRep
data TVar# (a :: *) (b :: *) :: TYPE UnliftedRep
data Compact# :: TYPE UnliftedRep

-- | The type constructor <tt>Proxy#</tt> is used to bear witness to some
grtype variable. It's used when you want to pass around proxy values for
grdoing things like modelling type applications. A <tt>Proxy#</tt> is
grnot only unboxed, it also has a polymorphic kind, and has no runtime
grrepresentation, being totally free.
data Proxy# :: forall k0. () => k0 -> TYPE TupleRep ([] :: [RuntimeRep])
data SmallArray# (a :: *) :: TYPE UnliftedRep
data SmallMutableArray# (a :: *) (b :: *) :: TYPE UnliftedRep
data Int8X16# :: TYPE VecRep Vec16 Int8ElemRep
data Int16X8# :: TYPE VecRep Vec8 Int16ElemRep
data Int32X4# :: TYPE VecRep Vec4 Int32ElemRep
data Int64X2# :: TYPE VecRep Vec2 Int64ElemRep
data Int8X32# :: TYPE VecRep Vec32 Int8ElemRep
data Int16X16# :: TYPE VecRep Vec16 Int16ElemRep
data Int32X8# :: TYPE VecRep Vec8 Int32ElemRep
data Int64X4# :: TYPE VecRep Vec4 Int64ElemRep
data Int8X64# :: TYPE VecRep Vec64 Int8ElemRep
data Int16X32# :: TYPE VecRep Vec32 Int16ElemRep
data Int32X16# :: TYPE VecRep Vec16 Int32ElemRep
data Int64X8# :: TYPE VecRep Vec8 Int64ElemRep
data Word8X16# :: TYPE VecRep Vec16 Word8ElemRep
data Word16X8# :: TYPE VecRep Vec8 Word16ElemRep
data Word32X4# :: TYPE VecRep Vec4 Word32ElemRep
data Word64X2# :: TYPE VecRep Vec2 Word64ElemRep
data Word8X32# :: TYPE VecRep Vec32 Word8ElemRep
data Word16X16# :: TYPE VecRep Vec16 Word16ElemRep
data Word32X8# :: TYPE VecRep Vec8 Word32ElemRep
data Word64X4# :: TYPE VecRep Vec4 Word64ElemRep
data Word8X64# :: TYPE VecRep Vec64 Word8ElemRep
data Word16X32# :: TYPE VecRep Vec32 Word16ElemRep
data Word32X16# :: TYPE VecRep Vec16 Word32ElemRep
data Word64X8# :: TYPE VecRep Vec8 Word64ElemRep
data FloatX4# :: TYPE VecRep Vec4 FloatElemRep
data DoubleX2# :: TYPE VecRep Vec2 DoubleElemRep
data FloatX8# :: TYPE VecRep Vec8 FloatElemRep
data DoubleX4# :: TYPE VecRep Vec4 DoubleElemRep
data FloatX16# :: TYPE VecRep Vec16 FloatElemRep
data DoubleX8# :: TYPE VecRep Vec8 DoubleElemRep
gtChar# :: Char# -> Char# -> Int#
geChar# :: Char# -> Char# -> Int#
eqChar# :: Char# -> Char# -> Int#
neChar# :: Char# -> Char# -> Int#
ltChar# :: Char# -> Char# -> Int#
leChar# :: Char# -> Char# -> Int#
ord# :: Char# -> Int#
(+#) :: Int# -> Int# -> Int#
infixl 6 +#
(-#) :: Int# -> Int# -> Int#
infixl 6 -#

-- | Low word of signed integer multiply.
(*#) :: Int# -> Int# -> Int#
infixl 7 *#

-- | Return non-zero if there is any possibility that the upper word of a
grsigned integer multiply might contain useful information. Return zero
gronly if you are completely sure that no overflow can occur. On a
gr32-bit platform, the recommended implementation is to do a 32 x 32
gr-&gt; 64 signed multiply, and subtract result[63:32] from (result[31]
gr&gt;&gt;signed 31). If this is zero, meaning that the upper word is
grmerely a sign extension of the lower one, no overflow can occur.
gr
grOn a 64-bit platform it is not always possible to acquire the top 64
grbits of the result. Therefore, a recommended implementation is to take
grthe absolute value of both operands, and return 0 iff bits[63:31] of
grthem are zero, since that means that their magnitudes fit within 31
grbits, so the magnitude of the product must fit into 62 bits.
gr
grIf in doubt, return non-zero, but do make an effort to create the
grcorrect answer for small args, since otherwise the performance of
gr<tt>(*) :: Integer -&gt; Integer -&gt; Integer</tt> will be poor.
mulIntMayOflo# :: Int# -> Int# -> Int#

-- | Rounds towards zero. The behavior is undefined if the second argument
gris zero.
quotInt# :: Int# -> Int# -> Int#

-- | Satisfies <tt>(quotInt# x y) *# y +# (remInt# x y) == x</tt>. The
grbehavior is undefined if the second argument is zero.
remInt# :: Int# -> Int# -> Int#

-- | Rounds towards zero.
quotRemInt# :: Int# -> Int# -> (# Int#, Int# #)
andI# :: Int# -> Int# -> Int#
orI# :: Int# -> Int# -> Int#
xorI# :: Int# -> Int# -> Int#
notI# :: Int# -> Int#
negateInt# :: Int# -> Int#

-- | Add signed integers reporting overflow. First member of result is the
grsum truncated to an <tt>Int#</tt>; second member is zero if the true
grsum fits in an <tt>Int#</tt>, nonzero if overflow occurred (the sum is
greither too large or too small to fit in an <tt>Int#</tt>).
addIntC# :: Int# -> Int# -> (# Int#, Int# #)

-- | Subtract signed integers reporting overflow. First member of result is
grthe difference truncated to an <tt>Int#</tt>; second member is zero if
grthe true difference fits in an <tt>Int#</tt>, nonzero if overflow
groccurred (the difference is either too large or too small to fit in an
gr<tt>Int#</tt>).
subIntC# :: Int# -> Int# -> (# Int#, Int# #)
(>#) :: Int# -> Int# -> Int#
infix 4 >#
(>=#) :: Int# -> Int# -> Int#
infix 4 >=#
(==#) :: Int# -> Int# -> Int#
infix 4 ==#
(/=#) :: Int# -> Int# -> Int#
infix 4 /=#
(<#) :: Int# -> Int# -> Int#
infix 4 <#
(<=#) :: Int# -> Int# -> Int#
infix 4 <=#
chr# :: Int# -> Char#
int2Word# :: Int# -> Word#
int2Float# :: Int# -> Float#
int2Double# :: Int# -> Double#
word2Float# :: Word# -> Float#
word2Double# :: Word# -> Double#

-- | Shift left. Result undefined if shift amount is not in the range 0 to
grword size - 1 inclusive.
uncheckedIShiftL# :: Int# -> Int# -> Int#

-- | Shift right arithmetic. Result undefined if shift amount is not in the
grrange 0 to word size - 1 inclusive.
uncheckedIShiftRA# :: Int# -> Int# -> Int#

-- | Shift right logical. Result undefined if shift amount is not in the
grrange 0 to word size - 1 inclusive.
uncheckedIShiftRL# :: Int# -> Int# -> Int#
plusWord# :: Word# -> Word# -> Word#

-- | Subtract unsigned integers reporting overflow. The first element of
grthe pair is the result. The second element is the carry flag, which is
grnonzero on overflow.
subWordC# :: Word# -> Word# -> (# Word#, Int# #)
plusWord2# :: Word# -> Word# -> (# Word#, Word# #)
minusWord# :: Word# -> Word# -> Word#
timesWord# :: Word# -> Word# -> Word#
timesWord2# :: Word# -> Word# -> (# Word#, Word# #)
quotWord# :: Word# -> Word# -> Word#
remWord# :: Word# -> Word# -> Word#
quotRemWord# :: Word# -> Word# -> (# Word#, Word# #)
quotRemWord2# :: Word# -> Word# -> Word# -> (# Word#, Word# #)
and# :: Word# -> Word# -> Word#
or# :: Word# -> Word# -> Word#
xor# :: Word# -> Word# -> Word#
not# :: Word# -> Word#

-- | Shift left logical. Result undefined if shift amount is not in the
grrange 0 to word size - 1 inclusive.
uncheckedShiftL# :: Word# -> Int# -> Word#

-- | Shift right logical. Result undefined if shift amount is not in the
grrange 0 to word size - 1 inclusive.
uncheckedShiftRL# :: Word# -> Int# -> Word#
word2Int# :: Word# -> Int#
gtWord# :: Word# -> Word# -> Int#
geWord# :: Word# -> Word# -> Int#
eqWord# :: Word# -> Word# -> Int#
neWord# :: Word# -> Word# -> Int#
ltWord# :: Word# -> Word# -> Int#
leWord# :: Word# -> Word# -> Int#

-- | Count the number of set bits in the lower 8 bits of a word.
popCnt8# :: Word# -> Word#

-- | Count the number of set bits in the lower 16 bits of a word.
popCnt16# :: Word# -> Word#

-- | Count the number of set bits in the lower 32 bits of a word.
popCnt32# :: Word# -> Word#

-- | Count the number of set bits in a 64-bit word.
popCnt64# :: Word# -> Word#

-- | Count the number of set bits in a word.
popCnt# :: Word# -> Word#

-- | Deposit bits to lower 8 bits of a word at locations specified by a
grmask.
pdep8# :: Word# -> Word# -> Word#

-- | Deposit bits to lower 16 bits of a word at locations specified by a
grmask.
pdep16# :: Word# -> Word# -> Word#

-- | Deposit bits to lower 32 bits of a word at locations specified by a
grmask.
pdep32# :: Word# -> Word# -> Word#

-- | Deposit bits to a word at locations specified by a mask.
pdep64# :: Word# -> Word# -> Word#

-- | Deposit bits to a word at locations specified by a mask.
pdep# :: Word# -> Word# -> Word#

-- | Extract bits from lower 8 bits of a word at locations specified by a
grmask.
pext8# :: Word# -> Word# -> Word#

-- | Extract bits from lower 16 bits of a word at locations specified by a
grmask.
pext16# :: Word# -> Word# -> Word#

-- | Extract bits from lower 32 bits of a word at locations specified by a
grmask.
pext32# :: Word# -> Word# -> Word#

-- | Extract bits from a word at locations specified by a mask.
pext64# :: Word# -> Word# -> Word#

-- | Extract bits from a word at locations specified by a mask.
pext# :: Word# -> Word# -> Word#

-- | Count leading zeros in the lower 8 bits of a word.
clz8# :: Word# -> Word#

-- | Count leading zeros in the lower 16 bits of a word.
clz16# :: Word# -> Word#

-- | Count leading zeros in the lower 32 bits of a word.
clz32# :: Word# -> Word#

-- | Count leading zeros in a 64-bit word.
clz64# :: Word# -> Word#

-- | Count leading zeros in a word.
clz# :: Word# -> Word#

-- | Count trailing zeros in the lower 8 bits of a word.
ctz8# :: Word# -> Word#

-- | Count trailing zeros in the lower 16 bits of a word.
ctz16# :: Word# -> Word#

-- | Count trailing zeros in the lower 32 bits of a word.
ctz32# :: Word# -> Word#

-- | Count trailing zeros in a 64-bit word.
ctz64# :: Word# -> Word#

-- | Count trailing zeros in a word.
ctz# :: Word# -> Word#

-- | Swap bytes in the lower 16 bits of a word. The higher bytes are
grundefined.
byteSwap16# :: Word# -> Word#

-- | Swap bytes in the lower 32 bits of a word. The higher bytes are
grundefined.
byteSwap32# :: Word# -> Word#

-- | Swap bytes in a 64 bits of a word.
byteSwap64# :: Word# -> Word#

-- | Swap bytes in a word.
byteSwap# :: Word# -> Word#
narrow8Int# :: Int# -> Int#
narrow16Int# :: Int# -> Int#
narrow32Int# :: Int# -> Int#
narrow8Word# :: Word# -> Word#
narrow16Word# :: Word# -> Word#
narrow32Word# :: Word# -> Word#
(>##) :: Double# -> Double# -> Int#
infix 4 >##
(>=##) :: Double# -> Double# -> Int#
infix 4 >=##
(==##) :: Double# -> Double# -> Int#
infix 4 ==##
(/=##) :: Double# -> Double# -> Int#
infix 4 /=##
(<##) :: Double# -> Double# -> Int#
infix 4 <##
(<=##) :: Double# -> Double# -> Int#
infix 4 <=##
(+##) :: Double# -> Double# -> Double#
infixl 6 +##
(-##) :: Double# -> Double# -> Double#
infixl 6 -##
(*##) :: Double# -> Double# -> Double#
infixl 7 *##
(/##) :: Double# -> Double# -> Double#
infixl 7 /##
negateDouble# :: Double# -> Double#
fabsDouble# :: Double# -> Double#

-- | Truncates a <tt>Double#</tt> value to the nearest <tt>Int#</tt>.
grResults are undefined if the truncation if truncation yields a value
groutside the range of <tt>Int#</tt>.
double2Int# :: Double# -> Int#
double2Float# :: Double# -> Float#
expDouble# :: Double# -> Double#
logDouble# :: Double# -> Double#
sqrtDouble# :: Double# -> Double#
sinDouble# :: Double# -> Double#
cosDouble# :: Double# -> Double#
tanDouble# :: Double# -> Double#
asinDouble# :: Double# -> Double#
acosDouble# :: Double# -> Double#
atanDouble# :: Double# -> Double#
sinhDouble# :: Double# -> Double#
coshDouble# :: Double# -> Double#
tanhDouble# :: Double# -> Double#

-- | Exponentiation.
(**##) :: Double# -> Double# -> Double#

-- | Convert to integer. First component of the result is -1 or 1,
grindicating the sign of the mantissa. The next two are the high and low
gr32 bits of the mantissa respectively, and the last is the exponent.
decodeDouble_2Int# :: Double# -> (# Int#, Word#, Word#, Int# #)

-- | Decode <tt>Double#</tt> into mantissa and base-2 exponent.
decodeDouble_Int64# :: Double# -> (# Int#, Int# #)
gtFloat# :: Float# -> Float# -> Int#
geFloat# :: Float# -> Float# -> Int#
eqFloat# :: Float# -> Float# -> Int#
neFloat# :: Float# -> Float# -> Int#
ltFloat# :: Float# -> Float# -> Int#
leFloat# :: Float# -> Float# -> Int#
plusFloat# :: Float# -> Float# -> Float#
minusFloat# :: Float# -> Float# -> Float#
timesFloat# :: Float# -> Float# -> Float#
divideFloat# :: Float# -> Float# -> Float#
negateFloat# :: Float# -> Float#
fabsFloat# :: Float# -> Float#

-- | Truncates a <tt>Float#</tt> value to the nearest <tt>Int#</tt>.
grResults are undefined if the truncation if truncation yields a value
groutside the range of <tt>Int#</tt>.
float2Int# :: Float# -> Int#
expFloat# :: Float# -> Float#
logFloat# :: Float# -> Float#
sqrtFloat# :: Float# -> Float#
sinFloat# :: Float# -> Float#
cosFloat# :: Float# -> Float#
tanFloat# :: Float# -> Float#
asinFloat# :: Float# -> Float#
acosFloat# :: Float# -> Float#
atanFloat# :: Float# -> Float#
sinhFloat# :: Float# -> Float#
coshFloat# :: Float# -> Float#
tanhFloat# :: Float# -> Float#
powerFloat# :: Float# -> Float# -> Float#
float2Double# :: Float# -> Double#

-- | Convert to integers. First <tt>Int#</tt> in result is the mantissa;
grsecond is the exponent.
decodeFloat_Int# :: Float# -> (# Int#, Int# #)

-- | Create a new mutable array with the specified number of elements, in
grthe specified state thread, with each element containing the specified
grinitial value.
newArray# :: () => Int# -> a -> State# d -> (# State# d, MutableArray# d a #)
sameMutableArray# :: () => MutableArray# d a -> MutableArray# d a -> Int#

-- | Read from specified index of mutable array. Result is not yet
grevaluated.
readArray# :: () => MutableArray# d a -> Int# -> State# d -> (# State# d, a #)

-- | Write to specified index of mutable array.
writeArray# :: () => MutableArray# d a -> Int# -> a -> State# d -> State# d

-- | Return the number of elements in the array.
sizeofArray# :: () => Array# a -> Int#

-- | Return the number of elements in the array.
sizeofMutableArray# :: () => MutableArray# d a -> Int#

-- | Read from specified index of immutable array. Result is packaged into
gran unboxed singleton; the result itself is not yet evaluated.
indexArray# :: () => Array# a -> Int# -> (# a #)

-- | Make a mutable array immutable, without copying.
unsafeFreezeArray# :: () => MutableArray# d a -> State# d -> (# State# d, Array# a #)

-- | Make an immutable array mutable, without copying.
unsafeThawArray# :: () => Array# a -> State# d -> (# State# d, MutableArray# d a #)

-- | Given a source array, an offset into the source array, a destination
grarray, an offset into the destination array, and a number of elements
grto copy, copy the elements from the source array to the destination
grarray. Both arrays must fully contain the specified ranges, but this
gris not checked. The two arrays must not be the same array in different
grstates, but this is not checked either.
copyArray# :: () => Array# a -> Int# -> MutableArray# d a -> Int# -> Int# -> State# d -> State# d

-- | Given a source array, an offset into the source array, a destination
grarray, an offset into the destination array, and a number of elements
grto copy, copy the elements from the source array to the destination
grarray. Both arrays must fully contain the specified ranges, but this
gris not checked. In the case where the source and destination are the
grsame array the source and destination regions may overlap.
copyMutableArray# :: () => MutableArray# d a -> Int# -> MutableArray# d a -> Int# -> Int# -> State# d -> State# d

-- | Given a source array, an offset into the source array, and a number of
grelements to copy, create a new array with the elements from the source
grarray. The provided array must fully contain the specified range, but
grthis is not checked.
cloneArray# :: () => Array# a -> Int# -> Int# -> Array# a

-- | Given a source array, an offset into the source array, and a number of
grelements to copy, create a new array with the elements from the source
grarray. The provided array must fully contain the specified range, but
grthis is not checked.
cloneMutableArray# :: () => MutableArray# d a -> Int# -> Int# -> State# d -> (# State# d, MutableArray# d a #)

-- | Given a source array, an offset into the source array, and a number of
grelements to copy, create a new array with the elements from the source
grarray. The provided array must fully contain the specified range, but
grthis is not checked.
freezeArray# :: () => MutableArray# d a -> Int# -> Int# -> State# d -> (# State# d, Array# a #)

-- | Given a source array, an offset into the source array, and a number of
grelements to copy, create a new array with the elements from the source
grarray. The provided array must fully contain the specified range, but
grthis is not checked.
thawArray# :: () => Array# a -> Int# -> Int# -> State# d -> (# State# d, MutableArray# d a #)

-- | Unsafe, machine-level atomic compare and swap on an element within an
grArray.
casArray# :: () => MutableArray# d a -> Int# -> a -> a -> State# d -> (# State# d, Int#, a #)

-- | Create a new mutable array with the specified number of elements, in
grthe specified state thread, with each element containing the specified
grinitial value.
newSmallArray# :: () => Int# -> a -> State# d -> (# State# d, SmallMutableArray# d a #)
sameSmallMutableArray# :: () => SmallMutableArray# d a -> SmallMutableArray# d a -> Int#

-- | Read from specified index of mutable array. Result is not yet
grevaluated.
readSmallArray# :: () => SmallMutableArray# d a -> Int# -> State# d -> (# State# d, a #)

-- | Write to specified index of mutable array.
writeSmallArray# :: () => SmallMutableArray# d a -> Int# -> a -> State# d -> State# d

-- | Return the number of elements in the array.
sizeofSmallArray# :: () => SmallArray# a -> Int#

-- | Return the number of elements in the array.
sizeofSmallMutableArray# :: () => SmallMutableArray# d a -> Int#

-- | Read from specified index of immutable array. Result is packaged into
gran unboxed singleton; the result itself is not yet evaluated.
indexSmallArray# :: () => SmallArray# a -> Int# -> (# a #)

-- | Make a mutable array immutable, without copying.
unsafeFreezeSmallArray# :: () => SmallMutableArray# d a -> State# d -> (# State# d, SmallArray# a #)

-- | Make an immutable array mutable, without copying.
unsafeThawSmallArray# :: () => SmallArray# a -> State# d -> (# State# d, SmallMutableArray# d a #)

-- | Given a source array, an offset into the source array, a destination
grarray, an offset into the destination array, and a number of elements
grto copy, copy the elements from the source array to the destination
grarray. Both arrays must fully contain the specified ranges, but this
gris not checked. The two arrays must not be the same array in different
grstates, but this is not checked either.
copySmallArray# :: () => SmallArray# a -> Int# -> SmallMutableArray# d a -> Int# -> Int# -> State# d -> State# d

-- | Given a source array, an offset into the source array, a destination
grarray, an offset into the destination array, and a number of elements
grto copy, copy the elements from the source array to the destination
grarray. The source and destination arrays can refer to the same array.
grBoth arrays must fully contain the specified ranges, but this is not
grchecked. The regions are allowed to overlap, although this is only
grpossible when the same array is provided as both the source and the
grdestination.
copySmallMutableArray# :: () => SmallMutableArray# d a -> Int# -> SmallMutableArray# d a -> Int# -> Int# -> State# d -> State# d

-- | Given a source array, an offset into the source array, and a number of
grelements to copy, create a new array with the elements from the source
grarray. The provided array must fully contain the specified range, but
grthis is not checked.
cloneSmallArray# :: () => SmallArray# a -> Int# -> Int# -> SmallArray# a

-- | Given a source array, an offset into the source array, and a number of
grelements to copy, create a new array with the elements from the source
grarray. The provided array must fully contain the specified range, but
grthis is not checked.
cloneSmallMutableArray# :: () => SmallMutableArray# d a -> Int# -> Int# -> State# d -> (# State# d, SmallMutableArray# d a #)

-- | Given a source array, an offset into the source array, and a number of
grelements to copy, create a new array with the elements from the source
grarray. The provided array must fully contain the specified range, but
grthis is not checked.
freezeSmallArray# :: () => SmallMutableArray# d a -> Int# -> Int# -> State# d -> (# State# d, SmallArray# a #)

-- | Given a source array, an offset into the source array, and a number of
grelements to copy, create a new array with the elements from the source
grarray. The provided array must fully contain the specified range, but
grthis is not checked.
thawSmallArray# :: () => SmallArray# a -> Int# -> Int# -> State# d -> (# State# d, SmallMutableArray# d a #)

-- | Unsafe, machine-level atomic compare and swap on an element within an
grarray.
casSmallArray# :: () => SmallMutableArray# d a -> Int# -> a -> a -> State# d -> (# State# d, Int#, a #)

-- | Create a new mutable byte array of specified size (in bytes), in the
grspecified state thread.
newByteArray# :: () => Int# -> State# d -> (# State# d, MutableByteArray# d #)

-- | Create a mutable byte array that the GC guarantees not to move.
newPinnedByteArray# :: () => Int# -> State# d -> (# State# d, MutableByteArray# d #)

-- | Create a mutable byte array, aligned by the specified amount, that the
grGC guarantees not to move.
newAlignedPinnedByteArray# :: () => Int# -> Int# -> State# d -> (# State# d, MutableByteArray# d #)

-- | Determine whether a <tt>MutableByteArray#</tt> is guaranteed not to
grmove during GC.
isMutableByteArrayPinned# :: () => MutableByteArray# d -> Int#

-- | Determine whether a <tt>ByteArray#</tt> is guaranteed not to move
grduring GC.
isByteArrayPinned# :: ByteArray# -> Int#

-- | Intended for use with pinned arrays; otherwise very unsafe!
byteArrayContents# :: ByteArray# -> Addr#
sameMutableByteArray# :: () => MutableByteArray# d -> MutableByteArray# d -> Int#

-- | Shrink mutable byte array to new specified size (in bytes), in the
grspecified state thread. The new size argument must be less than or
grequal to the current size as reported by <tt>sizeofMutableArray#</tt>.
shrinkMutableByteArray# :: () => MutableByteArray# d -> Int# -> State# d -> State# d

-- | Resize (unpinned) mutable byte array to new specified size (in bytes).
grThe returned <tt>MutableByteArray#</tt> is either the original
gr<tt>MutableByteArray#</tt> resized in-place or, if not possible, a
grnewly allocated (unpinned) <tt>MutableByteArray#</tt> (with the
groriginal content copied over).
gr
grTo avoid undefined behaviour, the original <tt>MutableByteArray#</tt>
grshall not be accessed anymore after a <tt>resizeMutableByteArray#</tt>
grhas been performed. Moreover, no reference to the old one should be
grkept in order to allow garbage collection of the original
gr<tt>MutableByteArray#</tt> in case a new <tt>MutableByteArray#</tt>
grhad to be allocated.
resizeMutableByteArray# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, MutableByteArray# d #)

-- | Make a mutable byte array immutable, without copying.
unsafeFreezeByteArray# :: () => MutableByteArray# d -> State# d -> (# State# d, ByteArray# #)

-- | Return the size of the array in bytes.
sizeofByteArray# :: ByteArray# -> Int#

-- | Return the size of the array in bytes. Note that this is deprecated as
grit is unsafe in the presence of concurrent resize operations on the
grsame byte array. See <tt>getSizeofMutableByteArray</tt>.
sizeofMutableByteArray# :: () => MutableByteArray# d -> Int#

-- | Return the number of elements in the array.
getSizeofMutableByteArray# :: () => MutableByteArray# d -> State# d -> (# State# d, Int# #)

-- | Read 8-bit character; offset in bytes.
indexCharArray# :: ByteArray# -> Int# -> Char#

-- | Read 31-bit character; offset in 4-byte words.
indexWideCharArray# :: ByteArray# -> Int# -> Char#
indexIntArray# :: ByteArray# -> Int# -> Int#
indexWordArray# :: ByteArray# -> Int# -> Word#
indexAddrArray# :: ByteArray# -> Int# -> Addr#
indexFloatArray# :: ByteArray# -> Int# -> Float#
indexDoubleArray# :: ByteArray# -> Int# -> Double#
indexStablePtrArray# :: () => ByteArray# -> Int# -> StablePtr# a

-- | Read 8-bit integer; offset in bytes.
indexInt8Array# :: ByteArray# -> Int# -> Int#

-- | Read 16-bit integer; offset in 16-bit words.
indexInt16Array# :: ByteArray# -> Int# -> Int#

-- | Read 32-bit integer; offset in 32-bit words.
indexInt32Array# :: ByteArray# -> Int# -> Int#

-- | Read 64-bit integer; offset in 64-bit words.
indexInt64Array# :: ByteArray# -> Int# -> Int#

-- | Read 8-bit word; offset in bytes.
indexWord8Array# :: ByteArray# -> Int# -> Word#

-- | Read 16-bit word; offset in 16-bit words.
indexWord16Array# :: ByteArray# -> Int# -> Word#

-- | Read 32-bit word; offset in 32-bit words.
indexWord32Array# :: ByteArray# -> Int# -> Word#

-- | Read 64-bit word; offset in 64-bit words.
indexWord64Array# :: ByteArray# -> Int# -> Word#

-- | Read 8-bit character; offset in bytes.
readCharArray# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Char# #)

-- | Read 31-bit character; offset in 4-byte words.
readWideCharArray# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Char# #)

-- | Read integer; offset in words.
readIntArray# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Int# #)

-- | Read word; offset in words.
readWordArray# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Word# #)
readAddrArray# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Addr# #)
readFloatArray# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Float# #)
readDoubleArray# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Double# #)
readStablePtrArray# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, StablePtr# a #)
readInt8Array# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Int# #)
readInt16Array# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Int# #)
readInt32Array# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Int# #)
readInt64Array# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Int# #)
readWord8Array# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Word# #)
readWord16Array# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Word# #)
readWord32Array# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Word# #)
readWord64Array# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Word# #)

-- | Write 8-bit character; offset in bytes.
writeCharArray# :: () => MutableByteArray# d -> Int# -> Char# -> State# d -> State# d

-- | Write 31-bit character; offset in 4-byte words.
writeWideCharArray# :: () => MutableByteArray# d -> Int# -> Char# -> State# d -> State# d
writeIntArray# :: () => MutableByteArray# d -> Int# -> Int# -> State# d -> State# d
writeWordArray# :: () => MutableByteArray# d -> Int# -> Word# -> State# d -> State# d
writeAddrArray# :: () => MutableByteArray# d -> Int# -> Addr# -> State# d -> State# d
writeFloatArray# :: () => MutableByteArray# d -> Int# -> Float# -> State# d -> State# d
writeDoubleArray# :: () => MutableByteArray# d -> Int# -> Double# -> State# d -> State# d
writeStablePtrArray# :: () => MutableByteArray# d -> Int# -> StablePtr# a -> State# d -> State# d
writeInt8Array# :: () => MutableByteArray# d -> Int# -> Int# -> State# d -> State# d
writeInt16Array# :: () => MutableByteArray# d -> Int# -> Int# -> State# d -> State# d
writeInt32Array# :: () => MutableByteArray# d -> Int# -> Int# -> State# d -> State# d
writeInt64Array# :: () => MutableByteArray# d -> Int# -> Int# -> State# d -> State# d
writeWord8Array# :: () => MutableByteArray# d -> Int# -> Word# -> State# d -> State# d
writeWord16Array# :: () => MutableByteArray# d -> Int# -> Word# -> State# d -> State# d
writeWord32Array# :: () => MutableByteArray# d -> Int# -> Word# -> State# d -> State# d
writeWord64Array# :: () => MutableByteArray# d -> Int# -> Word# -> State# d -> State# d

-- | <tt>compareByteArrays# src1 src1_ofs src2 src2_ofs n</tt> compares
gr<tt>n</tt> bytes starting at offset <tt>src1_ofs</tt> in the first
gr<tt>ByteArray#</tt> <tt>src1</tt> to the range of <tt>n</tt> bytes
gr(i.e. same length) starting at offset <tt>src2_ofs</tt> of the second
gr<tt>ByteArray#</tt> <tt>src2</tt>. Both arrays must fully contain the
grspecified ranges, but this is not checked. Returns an <tt>Int#</tt>
grless than, equal to, or greater than zero if the range is found,
grrespectively, to be byte-wise lexicographically less than, to match,
gror be greater than the second range.
compareByteArrays# :: ByteArray# -> Int# -> ByteArray# -> Int# -> Int# -> Int#

-- | <tt>copyByteArray# src src_ofs dst dst_ofs n</tt> copies the range
grstarting at offset <tt>src_ofs</tt> of length <tt>n</tt> from the
gr<tt>ByteArray#</tt> <tt>src</tt> to the <tt>MutableByteArray#</tt>
gr<tt>dst</tt> starting at offset <tt>dst_ofs</tt>. Both arrays must
grfully contain the specified ranges, but this is not checked. The two
grarrays must not be the same array in different states, but this is not
grchecked either.
copyByteArray# :: () => ByteArray# -> Int# -> MutableByteArray# d -> Int# -> Int# -> State# d -> State# d

-- | Copy a range of the first MutableByteArray. Both arrays must fully
grcontain the specified ranges, but this is not checked. The regions are
grallowed to overlap, although this is only possible when the same array
gris provided as both the source and the destination.
copyMutableByteArray# :: () => MutableByteArray# d -> Int# -> MutableByteArray# d -> Int# -> Int# -> State# d -> State# d

-- | Copy a range of the ByteArray. The ByteArray must fully contain the
grspecified ranges, but this is not checked. The Addr# must not point
grinto the ByteArray were pinned), but this is not checked either.
copyByteArrayToAddr# :: () => ByteArray# -> Int# -> Addr# -> Int# -> State# d -> State# d

-- | Copy a range of the MutableByteArray# to the memory range starting at
grthe Addr and the memory region at Addr# must fully contain the
grspecified ranges, but this is not checked. The Addr# must not point
grinto the MutableByteArray were pinned), but this is not checked
greither.
copyMutableByteArrayToAddr# :: () => MutableByteArray# d -> Int# -> Addr# -> Int# -> State# d -> State# d

-- | Copy a memory range starting at the Addr# to the specified range in
grthe MutableByteArray and the ByteArray# must fully contain the
grspecified ranges, but this is not checked. The Addr# must not point
grinto the MutableByteArray were pinned), but this is not checked
greither.
copyAddrToByteArray# :: () => Addr# -> MutableByteArray# d -> Int# -> Int# -> State# d -> State# d

-- | <tt>setByteArray# ba off len c</tt> sets the byte range <tt>[off,
groff+len]</tt> of the <tt>MutableByteArray#</tt> to the byte
gr<tt>c</tt>.
setByteArray# :: () => MutableByteArray# d -> Int# -> Int# -> Int# -> State# d -> State# d

-- | Given an array and an offset in Int units, read an element. The index
gris assumed to be in bounds. Implies a full memory barrier.
atomicReadIntArray# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Int# #)

-- | Given an array and an offset in Int units, write an element. The index
gris assumed to be in bounds. Implies a full memory barrier.
atomicWriteIntArray# :: () => MutableByteArray# d -> Int# -> Int# -> State# d -> State# d

-- | Given an array, an offset in Int units, the expected old value, and
grthe new value, perform an atomic compare and swap i.e. write the new
grvalue if the current value matches the provided old value. Returns the
grvalue of the element before the operation. Implies a full memory
grbarrier.
casIntArray# :: () => MutableByteArray# d -> Int# -> Int# -> Int# -> State# d -> (# State# d, Int# #)

-- | Given an array, and offset in Int units, and a value to add,
gratomically add the value to the element. Returns the value of the
grelement before the operation. Implies a full memory barrier.
fetchAddIntArray# :: () => MutableByteArray# d -> Int# -> Int# -> State# d -> (# State# d, Int# #)

-- | Given an array, and offset in Int units, and a value to subtract,
gratomically substract the value to the element. Returns the value of
grthe element before the operation. Implies a full memory barrier.
fetchSubIntArray# :: () => MutableByteArray# d -> Int# -> Int# -> State# d -> (# State# d, Int# #)

-- | Given an array, and offset in Int units, and a value to AND,
gratomically AND the value to the element. Returns the value of the
grelement before the operation. Implies a full memory barrier.
fetchAndIntArray# :: () => MutableByteArray# d -> Int# -> Int# -> State# d -> (# State# d, Int# #)

-- | Given an array, and offset in Int units, and a value to NAND,
gratomically NAND the value to the element. Returns the value of the
grelement before the operation. Implies a full memory barrier.
fetchNandIntArray# :: () => MutableByteArray# d -> Int# -> Int# -> State# d -> (# State# d, Int# #)

-- | Given an array, and offset in Int units, and a value to OR, atomically
grOR the value to the element. Returns the value of the element before
grthe operation. Implies a full memory barrier.
fetchOrIntArray# :: () => MutableByteArray# d -> Int# -> Int# -> State# d -> (# State# d, Int# #)

-- | Given an array, and offset in Int units, and a value to XOR,
gratomically XOR the value to the element. Returns the value of the
grelement before the operation. Implies a full memory barrier.
fetchXorIntArray# :: () => MutableByteArray# d -> Int# -> Int# -> State# d -> (# State# d, Int# #)

-- | Create a new mutable array of arrays with the specified number of
grelements, in the specified state thread, with each element recursively
grreferring to the newly created array.
newArrayArray# :: () => Int# -> State# d -> (# State# d, MutableArrayArray# d #)
sameMutableArrayArray# :: () => MutableArrayArray# d -> MutableArrayArray# d -> Int#

-- | Make a mutable array of arrays immutable, without copying.
unsafeFreezeArrayArray# :: () => MutableArrayArray# d -> State# d -> (# State# d, ArrayArray# #)

-- | Return the number of elements in the array.
sizeofArrayArray# :: ArrayArray# -> Int#

-- | Return the number of elements in the array.
sizeofMutableArrayArray# :: () => MutableArrayArray# d -> Int#
indexByteArrayArray# :: ArrayArray# -> Int# -> ByteArray#
indexArrayArrayArray# :: ArrayArray# -> Int# -> ArrayArray#
readByteArrayArray# :: () => MutableArrayArray# d -> Int# -> State# d -> (# State# d, ByteArray# #)
readMutableByteArrayArray# :: () => MutableArrayArray# d -> Int# -> State# d -> (# State# d, MutableByteArray# d #)
readArrayArrayArray# :: () => MutableArrayArray# d -> Int# -> State# d -> (# State# d, ArrayArray# #)
readMutableArrayArrayArray# :: () => MutableArrayArray# d -> Int# -> State# d -> (# State# d, MutableArrayArray# d #)
writeByteArrayArray# :: () => MutableArrayArray# d -> Int# -> ByteArray# -> State# d -> State# d
writeMutableByteArrayArray# :: () => MutableArrayArray# d -> Int# -> MutableByteArray# d -> State# d -> State# d
writeArrayArrayArray# :: () => MutableArrayArray# d -> Int# -> ArrayArray# -> State# d -> State# d
writeMutableArrayArrayArray# :: () => MutableArrayArray# d -> Int# -> MutableArrayArray# d -> State# d -> State# d

-- | Copy a range of the ArrayArray. Both arrays must fully contain the
grspecified ranges, but this is not checked. The two arrays must not be
grthe same array in different states, but this is not checked either.
copyArrayArray# :: () => ArrayArray# -> Int# -> MutableArrayArray# d -> Int# -> Int# -> State# d -> State# d

-- | Copy a range of the first MutableArrayArray# to the specified region
grin the second MutableArrayArray#. Both arrays must fully contain the
grspecified ranges, but this is not checked. The regions are allowed to
groverlap, although this is only possible when the same array is
grprovided as both the source and the destination.
copyMutableArrayArray# :: () => MutableArrayArray# d -> Int# -> MutableArrayArray# d -> Int# -> Int# -> State# d -> State# d
plusAddr# :: Addr# -> Int# -> Addr#

-- | Result is meaningless if two <tt>Addr#</tt>s are so far apart that
grtheir difference doesn't fit in an <tt>Int#</tt>.
minusAddr# :: Addr# -> Addr# -> Int#

-- | Return the remainder when the <tt>Addr#</tt> arg, treated like an
gr<tt>Int#</tt>, is divided by the <tt>Int#</tt> arg.
remAddr# :: Addr# -> Int# -> Int#

-- | Coerce directly from address to int. Strongly deprecated.
addr2Int# :: Addr# -> Int#

-- | Coerce directly from int to address. Strongly deprecated.
int2Addr# :: Int# -> Addr#
gtAddr# :: Addr# -> Addr# -> Int#
geAddr# :: Addr# -> Addr# -> Int#
eqAddr# :: Addr# -> Addr# -> Int#
neAddr# :: Addr# -> Addr# -> Int#
ltAddr# :: Addr# -> Addr# -> Int#
leAddr# :: Addr# -> Addr# -> Int#

-- | Reads 8-bit character; offset in bytes.
indexCharOffAddr# :: Addr# -> Int# -> Char#

-- | Reads 31-bit character; offset in 4-byte words.
indexWideCharOffAddr# :: Addr# -> Int# -> Char#
indexIntOffAddr# :: Addr# -> Int# -> Int#
indexWordOffAddr# :: Addr# -> Int# -> Word#
indexAddrOffAddr# :: Addr# -> Int# -> Addr#
indexFloatOffAddr# :: Addr# -> Int# -> Float#
indexDoubleOffAddr# :: Addr# -> Int# -> Double#
indexStablePtrOffAddr# :: () => Addr# -> Int# -> StablePtr# a
indexInt8OffAddr# :: Addr# -> Int# -> Int#
indexInt16OffAddr# :: Addr# -> Int# -> Int#
indexInt32OffAddr# :: Addr# -> Int# -> Int#
indexInt64OffAddr# :: Addr# -> Int# -> Int#
indexWord8OffAddr# :: Addr# -> Int# -> Word#
indexWord16OffAddr# :: Addr# -> Int# -> Word#
indexWord32OffAddr# :: Addr# -> Int# -> Word#
indexWord64OffAddr# :: Addr# -> Int# -> Word#

-- | Reads 8-bit character; offset in bytes.
readCharOffAddr# :: () => Addr# -> Int# -> State# d -> (# State# d, Char# #)

-- | Reads 31-bit character; offset in 4-byte words.
readWideCharOffAddr# :: () => Addr# -> Int# -> State# d -> (# State# d, Char# #)
readIntOffAddr# :: () => Addr# -> Int# -> State# d -> (# State# d, Int# #)
readWordOffAddr# :: () => Addr# -> Int# -> State# d -> (# State# d, Word# #)
readAddrOffAddr# :: () => Addr# -> Int# -> State# d -> (# State# d, Addr# #)
readFloatOffAddr# :: () => Addr# -> Int# -> State# d -> (# State# d, Float# #)
readDoubleOffAddr# :: () => Addr# -> Int# -> State# d -> (# State# d, Double# #)
readStablePtrOffAddr# :: () => Addr# -> Int# -> State# d -> (# State# d, StablePtr# a #)
readInt8OffAddr# :: () => Addr# -> Int# -> State# d -> (# State# d, Int# #)
readInt16OffAddr# :: () => Addr# -> Int# -> State# d -> (# State# d, Int# #)
readInt32OffAddr# :: () => Addr# -> Int# -> State# d -> (# State# d, Int# #)
readInt64OffAddr# :: () => Addr# -> Int# -> State# d -> (# State# d, Int# #)
readWord8OffAddr# :: () => Addr# -> Int# -> State# d -> (# State# d, Word# #)
readWord16OffAddr# :: () => Addr# -> Int# -> State# d -> (# State# d, Word# #)
readWord32OffAddr# :: () => Addr# -> Int# -> State# d -> (# State# d, Word# #)
readWord64OffAddr# :: () => Addr# -> Int# -> State# d -> (# State# d, Word# #)
writeCharOffAddr# :: () => Addr# -> Int# -> Char# -> State# d -> State# d
writeWideCharOffAddr# :: () => Addr# -> Int# -> Char# -> State# d -> State# d
writeIntOffAddr# :: () => Addr# -> Int# -> Int# -> State# d -> State# d
writeWordOffAddr# :: () => Addr# -> Int# -> Word# -> State# d -> State# d
writeAddrOffAddr# :: () => Addr# -> Int# -> Addr# -> State# d -> State# d
writeFloatOffAddr# :: () => Addr# -> Int# -> Float# -> State# d -> State# d
writeDoubleOffAddr# :: () => Addr# -> Int# -> Double# -> State# d -> State# d
writeStablePtrOffAddr# :: () => Addr# -> Int# -> StablePtr# a -> State# d -> State# d
writeInt8OffAddr# :: () => Addr# -> Int# -> Int# -> State# d -> State# d
writeInt16OffAddr# :: () => Addr# -> Int# -> Int# -> State# d -> State# d
writeInt32OffAddr# :: () => Addr# -> Int# -> Int# -> State# d -> State# d
writeInt64OffAddr# :: () => Addr# -> Int# -> Int# -> State# d -> State# d
writeWord8OffAddr# :: () => Addr# -> Int# -> Word# -> State# d -> State# d
writeWord16OffAddr# :: () => Addr# -> Int# -> Word# -> State# d -> State# d
writeWord32OffAddr# :: () => Addr# -> Int# -> Word# -> State# d -> State# d
writeWord64OffAddr# :: () => Addr# -> Int# -> Word# -> State# d -> State# d

-- | Create <tt>MutVar#</tt> with specified initial value in specified
grstate thread.
newMutVar# :: () => a -> State# d -> (# State# d, MutVar# d a #)

-- | Read contents of <tt>MutVar#</tt>. Result is not yet evaluated.
readMutVar# :: () => MutVar# d a -> State# d -> (# State# d, a #)

-- | Write contents of <tt>MutVar#</tt>.
writeMutVar# :: () => MutVar# d a -> a -> State# d -> State# d
sameMutVar# :: () => MutVar# d a -> MutVar# d a -> Int#

-- | Modify the contents of a <tt>MutVar#</tt>. Note that this isn't
grstrictly speaking the correct type for this function, it should really
grbe <tt>MutVar s -&gt; ( s, b #)</tt>, however we don't know about
grpairs here.
atomicModifyMutVar# :: () => MutVar# d a -> a -> b -> State# d -> (# State# d, c #)
casMutVar# :: () => MutVar# d a -> a -> a -> State# d -> (# State# d, Int#, a #)
catch# :: () => State# RealWorld -> (# State# RealWorld, a #) -> b -> State# RealWorld -> (# State# RealWorld, a #) -> State# RealWorld -> (# State# RealWorld, a #)
raise# :: () => b -> a
raiseIO# :: () => a -> State# RealWorld -> (# State# RealWorld, b #)
maskAsyncExceptions# :: () => State# RealWorld -> (# State# RealWorld, a #) -> State# RealWorld -> (# State# RealWorld, a #)
maskUninterruptible# :: () => State# RealWorld -> (# State# RealWorld, a #) -> State# RealWorld -> (# State# RealWorld, a #)
unmaskAsyncExceptions# :: () => State# RealWorld -> (# State# RealWorld, a #) -> State# RealWorld -> (# State# RealWorld, a #)
getMaskingState# :: State# RealWorld -> (# State# RealWorld, Int# #)
atomically# :: () => State# RealWorld -> (# State# RealWorld, a #) -> State# RealWorld -> (# State# RealWorld, a #)
retry# :: () => State# RealWorld -> (# State# RealWorld, a #)
catchRetry# :: () => State# RealWorld -> (# State# RealWorld, a #) -> State# RealWorld -> (# State# RealWorld, a #) -> State# RealWorld -> (# State# RealWorld, a #)
catchSTM# :: () => State# RealWorld -> (# State# RealWorld, a #) -> b -> State# RealWorld -> (# State# RealWorld, a #) -> State# RealWorld -> (# State# RealWorld, a #)
check# :: () => State# RealWorld -> (# State# RealWorld, a #) -> State# RealWorld -> State# RealWorld

-- | Create a new <tt>TVar#</tt> holding a specified initial value.
newTVar# :: () => a -> State# d -> (# State# d, TVar# d a #)

-- | Read contents of <tt>TVar#</tt>. Result is not yet evaluated.
readTVar# :: () => TVar# d a -> State# d -> (# State# d, a #)

-- | Read contents of <tt>TVar#</tt> outside an STM transaction
readTVarIO# :: () => TVar# d a -> State# d -> (# State# d, a #)

-- | Write contents of <tt>TVar#</tt>.
writeTVar# :: () => TVar# d a -> a -> State# d -> State# d
sameTVar# :: () => TVar# d a -> TVar# d a -> Int#

-- | Create new <tt>MVar#</tt>; initially empty.
newMVar# :: () => State# d -> (# State# d, MVar# d a #)

-- | If <tt>MVar#</tt> is empty, block until it becomes full. Then remove
grand return its contents, and set it empty.
takeMVar# :: () => MVar# d a -> State# d -> (# State# d, a #)

-- | If <tt>MVar#</tt> is empty, immediately return with integer 0 and
grvalue undefined. Otherwise, return with integer 1 and contents of
gr<tt>MVar#</tt>, and set <tt>MVar#</tt> empty.
tryTakeMVar# :: () => MVar# d a -> State# d -> (# State# d, Int#, a #)

-- | If <tt>MVar#</tt> is full, block until it becomes empty. Then store
grvalue arg as its new contents.
putMVar# :: () => MVar# d a -> a -> State# d -> State# d

-- | If <tt>MVar#</tt> is full, immediately return with integer 0.
grOtherwise, store value arg as <tt>MVar#</tt>'s new contents, and
grreturn with integer 1.
tryPutMVar# :: () => MVar# d a -> a -> State# d -> (# State# d, Int# #)

-- | If <tt>MVar#</tt> is empty, block until it becomes full. Then read its
grcontents without modifying the MVar, without possibility of
grintervention from other threads.
readMVar# :: () => MVar# d a -> State# d -> (# State# d, a #)

-- | If <tt>MVar#</tt> is empty, immediately return with integer 0 and
grvalue undefined. Otherwise, return with integer 1 and contents of
gr<tt>MVar#</tt>.
tryReadMVar# :: () => MVar# d a -> State# d -> (# State# d, Int#, a #)
sameMVar# :: () => MVar# d a -> MVar# d a -> Int#

-- | Return 1 if <tt>MVar#</tt> is empty; 0 otherwise.
isEmptyMVar# :: () => MVar# d a -> State# d -> (# State# d, Int# #)

-- | Sleep specified number of microseconds.
delay# :: () => Int# -> State# d -> State# d

-- | Block until input is available on specified file descriptor.
waitRead# :: () => Int# -> State# d -> State# d

-- | Block until output is possible on specified file descriptor.
waitWrite# :: () => Int# -> State# d -> State# d
fork# :: () => a -> State# RealWorld -> (# State# RealWorld, ThreadId# #)
forkOn# :: () => Int# -> a -> State# RealWorld -> (# State# RealWorld, ThreadId# #)
killThread# :: () => ThreadId# -> a -> State# RealWorld -> State# RealWorld
yield# :: State# RealWorld -> State# RealWorld
myThreadId# :: State# RealWorld -> (# State# RealWorld, ThreadId# #)
labelThread# :: ThreadId# -> Addr# -> State# RealWorld -> State# RealWorld
isCurrentThreadBound# :: State# RealWorld -> (# State# RealWorld, Int# #)
noDuplicate# :: () => State# d -> State# d
threadStatus# :: ThreadId# -> State# RealWorld -> (# State# RealWorld, Int#, Int#, Int# #)

-- | <tt>mkWeak# k v finalizer s</tt> creates a weak reference to value
gr<tt>k</tt>, with an associated reference to some value <tt>v</tt>. If
gr<tt>k</tt> is still alive then <tt>v</tt> can be retrieved using
gr<tt>deRefWeak#</tt>. Note that the type of <tt>k</tt> must be
grrepresented by a pointer (i.e. of kind <tt>TYPE 'LiftedRep</tt> or
gr<tt>TYPE 'UnliftedRep</tt>).
mkWeak# :: () => a -> b -> State# RealWorld -> (# State# RealWorld, c #) -> State# RealWorld -> (# State# RealWorld, Weak# b #)
mkWeakNoFinalizer# :: () => a -> b -> State# RealWorld -> (# State# RealWorld, Weak# b #)

-- | <tt>addCFinalizerToWeak# fptr ptr flag eptr w</tt> attaches a C
grfunction pointer <tt>fptr</tt> to a weak pointer <tt>w</tt> as a
grfinalizer. If <tt>flag</tt> is zero, <tt>fptr</tt> will be called with
grone argument, <tt>ptr</tt>. Otherwise, it will be called with two
grarguments, <tt>eptr</tt> and <tt>ptr</tt>.
gr<tt>addCFinalizerToWeak#</tt> returns 1 on success, or 0 if <tt>w</tt>
gris already dead.
addCFinalizerToWeak# :: () => Addr# -> Addr# -> Int# -> Addr# -> Weak# b -> State# RealWorld -> (# State# RealWorld, Int# #)
deRefWeak# :: () => Weak# a -> State# RealWorld -> (# State# RealWorld, Int#, a #)

-- | Finalize a weak pointer. The return value is an unboxed tuple
grcontaining the new state of the world and an "unboxed Maybe",
grrepresented by an <tt>Int#</tt> and a (possibly invalid) finalization
graction. An <tt>Int#</tt> of <tt>1</tt> indicates that the finalizer is
grvalid. The return value <tt>b</tt> from the finalizer should be
grignored.
finalizeWeak# :: () => Weak# a -> State# RealWorld -> (# State# RealWorld, Int#, State# RealWorld -> (# State# RealWorld, b #) #)
touch# :: () => a -> State# RealWorld -> State# RealWorld
makeStablePtr# :: () => a -> State# RealWorld -> (# State# RealWorld, StablePtr# a #)
deRefStablePtr# :: () => StablePtr# a -> State# RealWorld -> (# State# RealWorld, a #)
eqStablePtr# :: () => StablePtr# a -> StablePtr# a -> Int#
makeStableName# :: () => a -> State# RealWorld -> (# State# RealWorld, StableName# a #)
eqStableName# :: () => StableName# a -> StableName# b -> Int#
stableNameToInt# :: () => StableName# a -> Int#

-- | Create a new Compact with the given size (in bytes, not words). The
grsize is rounded up to a multiple of the allocator block size, and
grcapped to one mega block.
compactNew# :: Word# -> State# RealWorld -> (# State# RealWorld, Compact# #)

-- | Set the new allocation size of the compact. This value (in bytes)
grdetermines the size of each block in the compact chain.
compactResize# :: Compact# -> Word# -> State# RealWorld -> State# RealWorld

-- | Returns 1 otherwise.
compactContains# :: () => Compact# -> a -> State# RealWorld -> (# State# RealWorld, Int# #)

-- | Returns 1 otherwise.
compactContainsAny# :: () => a -> State# RealWorld -> (# State# RealWorld, Int# #)

-- | Returns the address and the size (in bytes) of the first block of a
grcompact.
compactGetFirstBlock# :: Compact# -> State# RealWorld -> (# State# RealWorld, Addr#, Word# #)

-- | Given a compact and the address of one its blocks, returns the next
grblock and its size, or #nullAddr if the argument was the last block in
grthe compact.
compactGetNextBlock# :: Compact# -> Addr# -> State# RealWorld -> (# State# RealWorld, Addr#, Word# #)

-- | Attempt to allocate a compact block with the given size (in bytes) at
grthe given address. The first argument is a hint to the allocator,
grallocation might be satisfied at a different address (which is
grreturned). The resulting block is not known to the GC until
grcompactFixupPointers# is called on it, and care must be taken so that
grthe address does not escape or memory will be leaked.
compactAllocateBlock# :: Word# -> Addr# -> State# RealWorld -> (# State# RealWorld, Addr# #)

-- | Given the pointer to the first block of a compact, and the address of
grthe root object in the old address space, fix up the internal pointers
grinside the compact to account for a different position in memory than
grwhen it was serialized. This method must be called exactly once after
grimporting a serialized compact, and returns the new compact and the
grnew adjusted root address.
compactFixupPointers# :: Addr# -> Addr# -> State# RealWorld -> (# State# RealWorld, Compact#, Addr# #)

-- | Recursively add a closure and its transitive closure to a {texttt
grCompact#}, evaluating any unevaluated components at the same time.
grNote: {texttt compactAdd#} is not thread-safe, so only one thread may
grcall {texttt compactAdd#} with a particular {texttt Compact#} at any
grgiven time. The primop does not enforce any mutual exclusion; the
grcaller is expected to arrange this.
compactAdd# :: () => Compact# -> a -> State# RealWorld -> (# State# RealWorld, a #)

-- | Like {texttt compactAdd#}, but retains sharing and cycles during
grcompaction.
compactAddWithSharing# :: () => Compact# -> a -> State# RealWorld -> (# State# RealWorld, a #)

-- | Return the size (in bytes) of the total amount of data in the Compact#
compactSize# :: Compact# -> State# RealWorld -> (# State# RealWorld, Word# #)

-- | Returns {texttt 1#} if the given pointers are equal and {texttt 0#}
grotherwise.
reallyUnsafePtrEquality# :: () => a -> a -> Int#
par# :: () => a -> Int#
spark# :: () => a -> State# d -> (# State# d, a #)
seq# :: () => a -> State# d -> (# State# d, a #)
getSpark# :: () => State# d -> (# State# d, Int#, a #)

-- | Returns the number of sparks in the local spark pool.
numSparks# :: () => State# d -> (# State# d, Int# #)
dataToTag# :: () => a -> Int#

-- | <ul>
gr<li>Note [dataToTag#] ~~~~~~~~~~~~~~~~~~~~ The dataToTag# primop
grshould always be applied to an evaluated argument. The way to ensure
grthis is to invoke it via the 'getTag' wrapper in GHC.Base: getTag :: a
gr-&gt; Int# getTag !x = dataToTag# x</li>
gr</ul>
gr
grBut now consider z. case x of y -&gt; let v = dataToTag# y in ...
gr
grTo improve floating, the FloatOut pass (deliberately) does a
grbinder-swap on the case, to give z. case x of y -&gt; let v =
grdataToTag# x in ...
gr
grNow FloatOut might float that v-binding outside the z. But that is bad
grbecause that might mean x gest evaluated much too early! (CorePrep
gradds an eval to a dataToTag# call, to ensure that the argument really
gris evaluated; see CorePrep Note [dataToTag magic].)
gr
grSolution: make DataToTag into a can_fail primop. That will stop it
grfloating (see Note [PrimOp can_fail and has_side_effects] in PrimOp).
grIt's a bit of a hack but never mind. -
tagToEnum# :: () => Int# -> a

-- | Convert an <tt>Addr#</tt> to a followable Any type.
addrToAny# :: () => Addr# -> (# a #)

-- | Retrieve the address of any Haskell value. This is essentially an
gr{texttt unsafeCoerce#}, but if implemented as such the core lint pass
grcomplains and fails to compile. As a primop, it is opaque to core/stg,
grand only appears in cmm (where the copy propagation pass will get rid
grof it). Note that "a" must be a value, not a thunk! It's too late for
grstrictness analysis to enforce this, so you're on your own to
grguarantee this. Also note that {texttt Addr#} is not a GC pointer - up
grto you to guarantee that it does not become a dangling pointer
grimmediately after you get it.
anyToAddr# :: () => a -> State# RealWorld -> (# State# RealWorld, Addr# #)

-- | Wrap a BCO in a <tt>AP_UPD</tt> thunk which will be updated with the
grvalue of the BCO when evaluated.
mkApUpd0# :: () => BCO# -> (# a #)

-- | <tt>newBCO# instrs lits ptrs arity bitmap</tt> creates a new bytecode
grobject. The resulting object encodes a function of the given arity
grwith the instructions encoded in <tt>instrs</tt>, and a static
grreference table usage bitmap given by <tt>bitmap</tt>.
newBCO# :: () => ByteArray# -> ByteArray# -> Array# a -> Int# -> ByteArray# -> State# d -> (# State# d, BCO# #)

-- | <tt>unpackClosure# closure</tt> copies non-pointers and pointers in
grthe payload of the given closure into two new arrays, and returns a
grpointer to the first word of the closure's info table, a pointer array
grfor the pointers in the payload, and a non-pointer array for the
grnon-pointers in the payload.
unpackClosure# :: () => a -> (# Addr#, Array# b, ByteArray# #)
getApStackVal# :: () => a -> Int# -> (# Int#, b #)
getCCSOf# :: () => a -> State# d -> (# State# d, Addr# #)

-- | Returns the current <tt>CostCentreStack</tt> (value is <tt>NULL</tt>
grif not profiling). Takes a dummy argument which can be used to avoid
grthe call to <tt>getCurrentCCS#</tt> being floated out by the
grsimplifier, which would result in an uninformative stack ("CAF").
getCurrentCCS# :: () => a -> State# d -> (# State# d, Addr# #)

-- | Run the supplied IO action with an empty CCS. For example, this is
grused by the interpreter to run an interpreted computation without the
grcall stack showing that it was invoked from GHC.
clearCCS# :: () => State# d -> (# State# d, a #) -> State# d -> (# State# d, a #)

-- | Emits an event via the RTS tracing framework. The contents of the
grevent is the zero-terminated byte string passed as the first argument.
grThe event will be emitted either to the .eventlog file, or to stderr,
grdepending on the runtime RTS flags.
traceEvent# :: () => Addr# -> State# d -> State# d

-- | Emits a marker event via the RTS tracing framework. The contents of
grthe event is the zero-terminated byte string passed as the first
grargument. The event will be emitted either to the .eventlog file, or
grto stderr, depending on the runtime RTS flags.
traceMarker# :: () => Addr# -> State# d -> State# d

-- | Broadcast a scalar to all elements of a vector.
broadcastInt8X16# :: Int# -> Int8X16#

-- | Broadcast a scalar to all elements of a vector.
broadcastInt16X8# :: Int# -> Int16X8#

-- | Broadcast a scalar to all elements of a vector.
broadcastInt32X4# :: Int# -> Int32X4#

-- | Broadcast a scalar to all elements of a vector.
broadcastInt64X2# :: Int# -> Int64X2#

-- | Broadcast a scalar to all elements of a vector.
broadcastInt8X32# :: Int# -> Int8X32#

-- | Broadcast a scalar to all elements of a vector.
broadcastInt16X16# :: Int# -> Int16X16#

-- | Broadcast a scalar to all elements of a vector.
broadcastInt32X8# :: Int# -> Int32X8#

-- | Broadcast a scalar to all elements of a vector.
broadcastInt64X4# :: Int# -> Int64X4#

-- | Broadcast a scalar to all elements of a vector.
broadcastInt8X64# :: Int# -> Int8X64#

-- | Broadcast a scalar to all elements of a vector.
broadcastInt16X32# :: Int# -> Int16X32#

-- | Broadcast a scalar to all elements of a vector.
broadcastInt32X16# :: Int# -> Int32X16#

-- | Broadcast a scalar to all elements of a vector.
broadcastInt64X8# :: Int# -> Int64X8#

-- | Broadcast a scalar to all elements of a vector.
broadcastWord8X16# :: Word# -> Word8X16#

-- | Broadcast a scalar to all elements of a vector.
broadcastWord16X8# :: Word# -> Word16X8#

-- | Broadcast a scalar to all elements of a vector.
broadcastWord32X4# :: Word# -> Word32X4#

-- | Broadcast a scalar to all elements of a vector.
broadcastWord64X2# :: Word# -> Word64X2#

-- | Broadcast a scalar to all elements of a vector.
broadcastWord8X32# :: Word# -> Word8X32#

-- | Broadcast a scalar to all elements of a vector.
broadcastWord16X16# :: Word# -> Word16X16#

-- | Broadcast a scalar to all elements of a vector.
broadcastWord32X8# :: Word# -> Word32X8#

-- | Broadcast a scalar to all elements of a vector.
broadcastWord64X4# :: Word# -> Word64X4#

-- | Broadcast a scalar to all elements of a vector.
broadcastWord8X64# :: Word# -> Word8X64#

-- | Broadcast a scalar to all elements of a vector.
broadcastWord16X32# :: Word# -> Word16X32#

-- | Broadcast a scalar to all elements of a vector.
broadcastWord32X16# :: Word# -> Word32X16#

-- | Broadcast a scalar to all elements of a vector.
broadcastWord64X8# :: Word# -> Word64X8#

-- | Broadcast a scalar to all elements of a vector.
broadcastFloatX4# :: Float# -> FloatX4#

-- | Broadcast a scalar to all elements of a vector.
broadcastDoubleX2# :: Double# -> DoubleX2#

-- | Broadcast a scalar to all elements of a vector.
broadcastFloatX8# :: Float# -> FloatX8#

-- | Broadcast a scalar to all elements of a vector.
broadcastDoubleX4# :: Double# -> DoubleX4#

-- | Broadcast a scalar to all elements of a vector.
broadcastFloatX16# :: Float# -> FloatX16#

-- | Broadcast a scalar to all elements of a vector.
broadcastDoubleX8# :: Double# -> DoubleX8#

-- | Pack the elements of an unboxed tuple into a vector.
packInt8X16# :: (# Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int# #) -> Int8X16#

-- | Pack the elements of an unboxed tuple into a vector.
packInt16X8# :: (# Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int# #) -> Int16X8#

-- | Pack the elements of an unboxed tuple into a vector.
packInt32X4# :: (# Int#, Int#, Int#, Int# #) -> Int32X4#

-- | Pack the elements of an unboxed tuple into a vector.
packInt64X2# :: (# Int#, Int# #) -> Int64X2#

-- | Pack the elements of an unboxed tuple into a vector.
packInt8X32# :: (# Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int# #) -> Int8X32#

-- | Pack the elements of an unboxed tuple into a vector.
packInt16X16# :: (# Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int# #) -> Int16X16#

-- | Pack the elements of an unboxed tuple into a vector.
packInt32X8# :: (# Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int# #) -> Int32X8#

-- | Pack the elements of an unboxed tuple into a vector.
packInt64X4# :: (# Int#, Int#, Int#, Int# #) -> Int64X4#

-- | Pack the elements of an unboxed tuple into a vector.
packInt8X64# :: (# Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int# #) -> Int8X64#

-- | Pack the elements of an unboxed tuple into a vector.
packInt16X32# :: (# Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int# #) -> Int16X32#

-- | Pack the elements of an unboxed tuple into a vector.
packInt32X16# :: (# Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int# #) -> Int32X16#

-- | Pack the elements of an unboxed tuple into a vector.
packInt64X8# :: (# Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int# #) -> Int64X8#

-- | Pack the elements of an unboxed tuple into a vector.
packWord8X16# :: (# Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word# #) -> Word8X16#

-- | Pack the elements of an unboxed tuple into a vector.
packWord16X8# :: (# Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word# #) -> Word16X8#

-- | Pack the elements of an unboxed tuple into a vector.
packWord32X4# :: (# Word#, Word#, Word#, Word# #) -> Word32X4#

-- | Pack the elements of an unboxed tuple into a vector.
packWord64X2# :: (# Word#, Word# #) -> Word64X2#

-- | Pack the elements of an unboxed tuple into a vector.
packWord8X32# :: (# Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word# #) -> Word8X32#

-- | Pack the elements of an unboxed tuple into a vector.
packWord16X16# :: (# Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word# #) -> Word16X16#

-- | Pack the elements of an unboxed tuple into a vector.
packWord32X8# :: (# Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word# #) -> Word32X8#

-- | Pack the elements of an unboxed tuple into a vector.
packWord64X4# :: (# Word#, Word#, Word#, Word# #) -> Word64X4#

-- | Pack the elements of an unboxed tuple into a vector.
packWord8X64# :: (# Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word# #) -> Word8X64#

-- | Pack the elements of an unboxed tuple into a vector.
packWord16X32# :: (# Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word# #) -> Word16X32#

-- | Pack the elements of an unboxed tuple into a vector.
packWord32X16# :: (# Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word# #) -> Word32X16#

-- | Pack the elements of an unboxed tuple into a vector.
packWord64X8# :: (# Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word# #) -> Word64X8#

-- | Pack the elements of an unboxed tuple into a vector.
packFloatX4# :: (# Float#, Float#, Float#, Float# #) -> FloatX4#

-- | Pack the elements of an unboxed tuple into a vector.
packDoubleX2# :: (# Double#, Double# #) -> DoubleX2#

-- | Pack the elements of an unboxed tuple into a vector.
packFloatX8# :: (# Float#, Float#, Float#, Float#, Float#, Float#, Float#, Float# #) -> FloatX8#

-- | Pack the elements of an unboxed tuple into a vector.
packDoubleX4# :: (# Double#, Double#, Double#, Double# #) -> DoubleX4#

-- | Pack the elements of an unboxed tuple into a vector.
packFloatX16# :: (# Float#, Float#, Float#, Float#, Float#, Float#, Float#, Float#, Float#, Float#, Float#, Float#, Float#, Float#, Float#, Float# #) -> FloatX16#

-- | Pack the elements of an unboxed tuple into a vector.
packDoubleX8# :: (# Double#, Double#, Double#, Double#, Double#, Double#, Double#, Double# #) -> DoubleX8#

-- | Unpack the elements of a vector into an unboxed tuple. #
unpackInt8X16# :: Int8X16# -> (# Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int# #)

-- | Unpack the elements of a vector into an unboxed tuple. #
unpackInt16X8# :: Int16X8# -> (# Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int# #)

-- | Unpack the elements of a vector into an unboxed tuple. #
unpackInt32X4# :: Int32X4# -> (# Int#, Int#, Int#, Int# #)

-- | Unpack the elements of a vector into an unboxed tuple. #
unpackInt64X2# :: Int64X2# -> (# Int#, Int# #)

-- | Unpack the elements of a vector into an unboxed tuple. #
unpackInt8X32# :: Int8X32# -> (# Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int# #)

-- | Unpack the elements of a vector into an unboxed tuple. #
unpackInt16X16# :: Int16X16# -> (# Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int# #)

-- | Unpack the elements of a vector into an unboxed tuple. #
unpackInt32X8# :: Int32X8# -> (# Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int# #)

-- | Unpack the elements of a vector into an unboxed tuple. #
unpackInt64X4# :: Int64X4# -> (# Int#, Int#, Int#, Int# #)

-- | Unpack the elements of a vector into an unboxed tuple. #
unpackInt8X64# :: Int8X64# -> (# Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int# #)

-- | Unpack the elements of a vector into an unboxed tuple. #
unpackInt16X32# :: Int16X32# -> (# Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int# #)

-- | Unpack the elements of a vector into an unboxed tuple. #
unpackInt32X16# :: Int32X16# -> (# Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int# #)

-- | Unpack the elements of a vector into an unboxed tuple. #
unpackInt64X8# :: Int64X8# -> (# Int#, Int#, Int#, Int#, Int#, Int#, Int#, Int# #)

-- | Unpack the elements of a vector into an unboxed tuple. #
unpackWord8X16# :: Word8X16# -> (# Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word# #)

-- | Unpack the elements of a vector into an unboxed tuple. #
unpackWord16X8# :: Word16X8# -> (# Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word# #)

-- | Unpack the elements of a vector into an unboxed tuple. #
unpackWord32X4# :: Word32X4# -> (# Word#, Word#, Word#, Word# #)

-- | Unpack the elements of a vector into an unboxed tuple. #
unpackWord64X2# :: Word64X2# -> (# Word#, Word# #)

-- | Unpack the elements of a vector into an unboxed tuple. #
unpackWord8X32# :: Word8X32# -> (# Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word# #)

-- | Unpack the elements of a vector into an unboxed tuple. #
unpackWord16X16# :: Word16X16# -> (# Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word# #)

-- | Unpack the elements of a vector into an unboxed tuple. #
unpackWord32X8# :: Word32X8# -> (# Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word# #)

-- | Unpack the elements of a vector into an unboxed tuple. #
unpackWord64X4# :: Word64X4# -> (# Word#, Word#, Word#, Word# #)

-- | Unpack the elements of a vector into an unboxed tuple. #
unpackWord8X64# :: Word8X64# -> (# Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word# #)

-- | Unpack the elements of a vector into an unboxed tuple. #
unpackWord16X32# :: Word16X32# -> (# Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word# #)

-- | Unpack the elements of a vector into an unboxed tuple. #
unpackWord32X16# :: Word32X16# -> (# Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word# #)

-- | Unpack the elements of a vector into an unboxed tuple. #
unpackWord64X8# :: Word64X8# -> (# Word#, Word#, Word#, Word#, Word#, Word#, Word#, Word# #)

-- | Unpack the elements of a vector into an unboxed tuple. #
unpackFloatX4# :: FloatX4# -> (# Float#, Float#, Float#, Float# #)

-- | Unpack the elements of a vector into an unboxed tuple. #
unpackDoubleX2# :: DoubleX2# -> (# Double#, Double# #)

-- | Unpack the elements of a vector into an unboxed tuple. #
unpackFloatX8# :: FloatX8# -> (# Float#, Float#, Float#, Float#, Float#, Float#, Float#, Float# #)

-- | Unpack the elements of a vector into an unboxed tuple. #
unpackDoubleX4# :: DoubleX4# -> (# Double#, Double#, Double#, Double# #)

-- | Unpack the elements of a vector into an unboxed tuple. #
unpackFloatX16# :: FloatX16# -> (# Float#, Float#, Float#, Float#, Float#, Float#, Float#, Float#, Float#, Float#, Float#, Float#, Float#, Float#, Float#, Float# #)

-- | Unpack the elements of a vector into an unboxed tuple. #
unpackDoubleX8# :: DoubleX8# -> (# Double#, Double#, Double#, Double#, Double#, Double#, Double#, Double# #)

-- | Insert a scalar at the given position in a vector.
insertInt8X16# :: Int8X16# -> Int# -> Int# -> Int8X16#

-- | Insert a scalar at the given position in a vector.
insertInt16X8# :: Int16X8# -> Int# -> Int# -> Int16X8#

-- | Insert a scalar at the given position in a vector.
insertInt32X4# :: Int32X4# -> Int# -> Int# -> Int32X4#

-- | Insert a scalar at the given position in a vector.
insertInt64X2# :: Int64X2# -> Int# -> Int# -> Int64X2#

-- | Insert a scalar at the given position in a vector.
insertInt8X32# :: Int8X32# -> Int# -> Int# -> Int8X32#

-- | Insert a scalar at the given position in a vector.
insertInt16X16# :: Int16X16# -> Int# -> Int# -> Int16X16#

-- | Insert a scalar at the given position in a vector.
insertInt32X8# :: Int32X8# -> Int# -> Int# -> Int32X8#

-- | Insert a scalar at the given position in a vector.
insertInt64X4# :: Int64X4# -> Int# -> Int# -> Int64X4#

-- | Insert a scalar at the given position in a vector.
insertInt8X64# :: Int8X64# -> Int# -> Int# -> Int8X64#

-- | Insert a scalar at the given position in a vector.
insertInt16X32# :: Int16X32# -> Int# -> Int# -> Int16X32#

-- | Insert a scalar at the given position in a vector.
insertInt32X16# :: Int32X16# -> Int# -> Int# -> Int32X16#

-- | Insert a scalar at the given position in a vector.
insertInt64X8# :: Int64X8# -> Int# -> Int# -> Int64X8#

-- | Insert a scalar at the given position in a vector.
insertWord8X16# :: Word8X16# -> Word# -> Int# -> Word8X16#

-- | Insert a scalar at the given position in a vector.
insertWord16X8# :: Word16X8# -> Word# -> Int# -> Word16X8#

-- | Insert a scalar at the given position in a vector.
insertWord32X4# :: Word32X4# -> Word# -> Int# -> Word32X4#

-- | Insert a scalar at the given position in a vector.
insertWord64X2# :: Word64X2# -> Word# -> Int# -> Word64X2#

-- | Insert a scalar at the given position in a vector.
insertWord8X32# :: Word8X32# -> Word# -> Int# -> Word8X32#

-- | Insert a scalar at the given position in a vector.
insertWord16X16# :: Word16X16# -> Word# -> Int# -> Word16X16#

-- | Insert a scalar at the given position in a vector.
insertWord32X8# :: Word32X8# -> Word# -> Int# -> Word32X8#

-- | Insert a scalar at the given position in a vector.
insertWord64X4# :: Word64X4# -> Word# -> Int# -> Word64X4#

-- | Insert a scalar at the given position in a vector.
insertWord8X64# :: Word8X64# -> Word# -> Int# -> Word8X64#

-- | Insert a scalar at the given position in a vector.
insertWord16X32# :: Word16X32# -> Word# -> Int# -> Word16X32#

-- | Insert a scalar at the given position in a vector.
insertWord32X16# :: Word32X16# -> Word# -> Int# -> Word32X16#

-- | Insert a scalar at the given position in a vector.
insertWord64X8# :: Word64X8# -> Word# -> Int# -> Word64X8#

-- | Insert a scalar at the given position in a vector.
insertFloatX4# :: FloatX4# -> Float# -> Int# -> FloatX4#

-- | Insert a scalar at the given position in a vector.
insertDoubleX2# :: DoubleX2# -> Double# -> Int# -> DoubleX2#

-- | Insert a scalar at the given position in a vector.
insertFloatX8# :: FloatX8# -> Float# -> Int# -> FloatX8#

-- | Insert a scalar at the given position in a vector.
insertDoubleX4# :: DoubleX4# -> Double# -> Int# -> DoubleX4#

-- | Insert a scalar at the given position in a vector.
insertFloatX16# :: FloatX16# -> Float# -> Int# -> FloatX16#

-- | Insert a scalar at the given position in a vector.
insertDoubleX8# :: DoubleX8# -> Double# -> Int# -> DoubleX8#

-- | Add two vectors element-wise.
plusInt8X16# :: Int8X16# -> Int8X16# -> Int8X16#

-- | Add two vectors element-wise.
plusInt16X8# :: Int16X8# -> Int16X8# -> Int16X8#

-- | Add two vectors element-wise.
plusInt32X4# :: Int32X4# -> Int32X4# -> Int32X4#

-- | Add two vectors element-wise.
plusInt64X2# :: Int64X2# -> Int64X2# -> Int64X2#

-- | Add two vectors element-wise.
plusInt8X32# :: Int8X32# -> Int8X32# -> Int8X32#

-- | Add two vectors element-wise.
plusInt16X16# :: Int16X16# -> Int16X16# -> Int16X16#

-- | Add two vectors element-wise.
plusInt32X8# :: Int32X8# -> Int32X8# -> Int32X8#

-- | Add two vectors element-wise.
plusInt64X4# :: Int64X4# -> Int64X4# -> Int64X4#

-- | Add two vectors element-wise.
plusInt8X64# :: Int8X64# -> Int8X64# -> Int8X64#

-- | Add two vectors element-wise.
plusInt16X32# :: Int16X32# -> Int16X32# -> Int16X32#

-- | Add two vectors element-wise.
plusInt32X16# :: Int32X16# -> Int32X16# -> Int32X16#

-- | Add two vectors element-wise.
plusInt64X8# :: Int64X8# -> Int64X8# -> Int64X8#

-- | Add two vectors element-wise.
plusWord8X16# :: Word8X16# -> Word8X16# -> Word8X16#

-- | Add two vectors element-wise.
plusWord16X8# :: Word16X8# -> Word16X8# -> Word16X8#

-- | Add two vectors element-wise.
plusWord32X4# :: Word32X4# -> Word32X4# -> Word32X4#

-- | Add two vectors element-wise.
plusWord64X2# :: Word64X2# -> Word64X2# -> Word64X2#

-- | Add two vectors element-wise.
plusWord8X32# :: Word8X32# -> Word8X32# -> Word8X32#

-- | Add two vectors element-wise.
plusWord16X16# :: Word16X16# -> Word16X16# -> Word16X16#

-- | Add two vectors element-wise.
plusWord32X8# :: Word32X8# -> Word32X8# -> Word32X8#

-- | Add two vectors element-wise.
plusWord64X4# :: Word64X4# -> Word64X4# -> Word64X4#

-- | Add two vectors element-wise.
plusWord8X64# :: Word8X64# -> Word8X64# -> Word8X64#

-- | Add two vectors element-wise.
plusWord16X32# :: Word16X32# -> Word16X32# -> Word16X32#

-- | Add two vectors element-wise.
plusWord32X16# :: Word32X16# -> Word32X16# -> Word32X16#

-- | Add two vectors element-wise.
plusWord64X8# :: Word64X8# -> Word64X8# -> Word64X8#

-- | Add two vectors element-wise.
plusFloatX4# :: FloatX4# -> FloatX4# -> FloatX4#

-- | Add two vectors element-wise.
plusDoubleX2# :: DoubleX2# -> DoubleX2# -> DoubleX2#

-- | Add two vectors element-wise.
plusFloatX8# :: FloatX8# -> FloatX8# -> FloatX8#

-- | Add two vectors element-wise.
plusDoubleX4# :: DoubleX4# -> DoubleX4# -> DoubleX4#

-- | Add two vectors element-wise.
plusFloatX16# :: FloatX16# -> FloatX16# -> FloatX16#

-- | Add two vectors element-wise.
plusDoubleX8# :: DoubleX8# -> DoubleX8# -> DoubleX8#

-- | Subtract two vectors element-wise.
minusInt8X16# :: Int8X16# -> Int8X16# -> Int8X16#

-- | Subtract two vectors element-wise.
minusInt16X8# :: Int16X8# -> Int16X8# -> Int16X8#

-- | Subtract two vectors element-wise.
minusInt32X4# :: Int32X4# -> Int32X4# -> Int32X4#

-- | Subtract two vectors element-wise.
minusInt64X2# :: Int64X2# -> Int64X2# -> Int64X2#

-- | Subtract two vectors element-wise.
minusInt8X32# :: Int8X32# -> Int8X32# -> Int8X32#

-- | Subtract two vectors element-wise.
minusInt16X16# :: Int16X16# -> Int16X16# -> Int16X16#

-- | Subtract two vectors element-wise.
minusInt32X8# :: Int32X8# -> Int32X8# -> Int32X8#

-- | Subtract two vectors element-wise.
minusInt64X4# :: Int64X4# -> Int64X4# -> Int64X4#

-- | Subtract two vectors element-wise.
minusInt8X64# :: Int8X64# -> Int8X64# -> Int8X64#

-- | Subtract two vectors element-wise.
minusInt16X32# :: Int16X32# -> Int16X32# -> Int16X32#

-- | Subtract two vectors element-wise.
minusInt32X16# :: Int32X16# -> Int32X16# -> Int32X16#

-- | Subtract two vectors element-wise.
minusInt64X8# :: Int64X8# -> Int64X8# -> Int64X8#

-- | Subtract two vectors element-wise.
minusWord8X16# :: Word8X16# -> Word8X16# -> Word8X16#

-- | Subtract two vectors element-wise.
minusWord16X8# :: Word16X8# -> Word16X8# -> Word16X8#

-- | Subtract two vectors element-wise.
minusWord32X4# :: Word32X4# -> Word32X4# -> Word32X4#

-- | Subtract two vectors element-wise.
minusWord64X2# :: Word64X2# -> Word64X2# -> Word64X2#

-- | Subtract two vectors element-wise.
minusWord8X32# :: Word8X32# -> Word8X32# -> Word8X32#

-- | Subtract two vectors element-wise.
minusWord16X16# :: Word16X16# -> Word16X16# -> Word16X16#

-- | Subtract two vectors element-wise.
minusWord32X8# :: Word32X8# -> Word32X8# -> Word32X8#

-- | Subtract two vectors element-wise.
minusWord64X4# :: Word64X4# -> Word64X4# -> Word64X4#

-- | Subtract two vectors element-wise.
minusWord8X64# :: Word8X64# -> Word8X64# -> Word8X64#

-- | Subtract two vectors element-wise.
minusWord16X32# :: Word16X32# -> Word16X32# -> Word16X32#

-- | Subtract two vectors element-wise.
minusWord32X16# :: Word32X16# -> Word32X16# -> Word32X16#

-- | Subtract two vectors element-wise.
minusWord64X8# :: Word64X8# -> Word64X8# -> Word64X8#

-- | Subtract two vectors element-wise.
minusFloatX4# :: FloatX4# -> FloatX4# -> FloatX4#

-- | Subtract two vectors element-wise.
minusDoubleX2# :: DoubleX2# -> DoubleX2# -> DoubleX2#

-- | Subtract two vectors element-wise.
minusFloatX8# :: FloatX8# -> FloatX8# -> FloatX8#

-- | Subtract two vectors element-wise.
minusDoubleX4# :: DoubleX4# -> DoubleX4# -> DoubleX4#

-- | Subtract two vectors element-wise.
minusFloatX16# :: FloatX16# -> FloatX16# -> FloatX16#

-- | Subtract two vectors element-wise.
minusDoubleX8# :: DoubleX8# -> DoubleX8# -> DoubleX8#

-- | Multiply two vectors element-wise.
timesInt8X16# :: Int8X16# -> Int8X16# -> Int8X16#

-- | Multiply two vectors element-wise.
timesInt16X8# :: Int16X8# -> Int16X8# -> Int16X8#

-- | Multiply two vectors element-wise.
timesInt32X4# :: Int32X4# -> Int32X4# -> Int32X4#

-- | Multiply two vectors element-wise.
timesInt64X2# :: Int64X2# -> Int64X2# -> Int64X2#

-- | Multiply two vectors element-wise.
timesInt8X32# :: Int8X32# -> Int8X32# -> Int8X32#

-- | Multiply two vectors element-wise.
timesInt16X16# :: Int16X16# -> Int16X16# -> Int16X16#

-- | Multiply two vectors element-wise.
timesInt32X8# :: Int32X8# -> Int32X8# -> Int32X8#

-- | Multiply two vectors element-wise.
timesInt64X4# :: Int64X4# -> Int64X4# -> Int64X4#

-- | Multiply two vectors element-wise.
timesInt8X64# :: Int8X64# -> Int8X64# -> Int8X64#

-- | Multiply two vectors element-wise.
timesInt16X32# :: Int16X32# -> Int16X32# -> Int16X32#

-- | Multiply two vectors element-wise.
timesInt32X16# :: Int32X16# -> Int32X16# -> Int32X16#

-- | Multiply two vectors element-wise.
timesInt64X8# :: Int64X8# -> Int64X8# -> Int64X8#

-- | Multiply two vectors element-wise.
timesWord8X16# :: Word8X16# -> Word8X16# -> Word8X16#

-- | Multiply two vectors element-wise.
timesWord16X8# :: Word16X8# -> Word16X8# -> Word16X8#

-- | Multiply two vectors element-wise.
timesWord32X4# :: Word32X4# -> Word32X4# -> Word32X4#

-- | Multiply two vectors element-wise.
timesWord64X2# :: Word64X2# -> Word64X2# -> Word64X2#

-- | Multiply two vectors element-wise.
timesWord8X32# :: Word8X32# -> Word8X32# -> Word8X32#

-- | Multiply two vectors element-wise.
timesWord16X16# :: Word16X16# -> Word16X16# -> Word16X16#

-- | Multiply two vectors element-wise.
timesWord32X8# :: Word32X8# -> Word32X8# -> Word32X8#

-- | Multiply two vectors element-wise.
timesWord64X4# :: Word64X4# -> Word64X4# -> Word64X4#

-- | Multiply two vectors element-wise.
timesWord8X64# :: Word8X64# -> Word8X64# -> Word8X64#

-- | Multiply two vectors element-wise.
timesWord16X32# :: Word16X32# -> Word16X32# -> Word16X32#

-- | Multiply two vectors element-wise.
timesWord32X16# :: Word32X16# -> Word32X16# -> Word32X16#

-- | Multiply two vectors element-wise.
timesWord64X8# :: Word64X8# -> Word64X8# -> Word64X8#

-- | Multiply two vectors element-wise.
timesFloatX4# :: FloatX4# -> FloatX4# -> FloatX4#

-- | Multiply two vectors element-wise.
timesDoubleX2# :: DoubleX2# -> DoubleX2# -> DoubleX2#

-- | Multiply two vectors element-wise.
timesFloatX8# :: FloatX8# -> FloatX8# -> FloatX8#

-- | Multiply two vectors element-wise.
timesDoubleX4# :: DoubleX4# -> DoubleX4# -> DoubleX4#

-- | Multiply two vectors element-wise.
timesFloatX16# :: FloatX16# -> FloatX16# -> FloatX16#

-- | Multiply two vectors element-wise.
timesDoubleX8# :: DoubleX8# -> DoubleX8# -> DoubleX8#

-- | Divide two vectors element-wise.
divideFloatX4# :: FloatX4# -> FloatX4# -> FloatX4#

-- | Divide two vectors element-wise.
divideDoubleX2# :: DoubleX2# -> DoubleX2# -> DoubleX2#

-- | Divide two vectors element-wise.
divideFloatX8# :: FloatX8# -> FloatX8# -> FloatX8#

-- | Divide two vectors element-wise.
divideDoubleX4# :: DoubleX4# -> DoubleX4# -> DoubleX4#

-- | Divide two vectors element-wise.
divideFloatX16# :: FloatX16# -> FloatX16# -> FloatX16#

-- | Divide two vectors element-wise.
divideDoubleX8# :: DoubleX8# -> DoubleX8# -> DoubleX8#

-- | Rounds towards zero element-wise.
quotInt8X16# :: Int8X16# -> Int8X16# -> Int8X16#

-- | Rounds towards zero element-wise.
quotInt16X8# :: Int16X8# -> Int16X8# -> Int16X8#

-- | Rounds towards zero element-wise.
quotInt32X4# :: Int32X4# -> Int32X4# -> Int32X4#

-- | Rounds towards zero element-wise.
quotInt64X2# :: Int64X2# -> Int64X2# -> Int64X2#

-- | Rounds towards zero element-wise.
quotInt8X32# :: Int8X32# -> Int8X32# -> Int8X32#

-- | Rounds towards zero element-wise.
quotInt16X16# :: Int16X16# -> Int16X16# -> Int16X16#

-- | Rounds towards zero element-wise.
quotInt32X8# :: Int32X8# -> Int32X8# -> Int32X8#

-- | Rounds towards zero element-wise.
quotInt64X4# :: Int64X4# -> Int64X4# -> Int64X4#

-- | Rounds towards zero element-wise.
quotInt8X64# :: Int8X64# -> Int8X64# -> Int8X64#

-- | Rounds towards zero element-wise.
quotInt16X32# :: Int16X32# -> Int16X32# -> Int16X32#

-- | Rounds towards zero element-wise.
quotInt32X16# :: Int32X16# -> Int32X16# -> Int32X16#

-- | Rounds towards zero element-wise.
quotInt64X8# :: Int64X8# -> Int64X8# -> Int64X8#

-- | Rounds towards zero element-wise.
quotWord8X16# :: Word8X16# -> Word8X16# -> Word8X16#

-- | Rounds towards zero element-wise.
quotWord16X8# :: Word16X8# -> Word16X8# -> Word16X8#

-- | Rounds towards zero element-wise.
quotWord32X4# :: Word32X4# -> Word32X4# -> Word32X4#

-- | Rounds towards zero element-wise.
quotWord64X2# :: Word64X2# -> Word64X2# -> Word64X2#

-- | Rounds towards zero element-wise.
quotWord8X32# :: Word8X32# -> Word8X32# -> Word8X32#

-- | Rounds towards zero element-wise.
quotWord16X16# :: Word16X16# -> Word16X16# -> Word16X16#

-- | Rounds towards zero element-wise.
quotWord32X8# :: Word32X8# -> Word32X8# -> Word32X8#

-- | Rounds towards zero element-wise.
quotWord64X4# :: Word64X4# -> Word64X4# -> Word64X4#

-- | Rounds towards zero element-wise.
quotWord8X64# :: Word8X64# -> Word8X64# -> Word8X64#

-- | Rounds towards zero element-wise.
quotWord16X32# :: Word16X32# -> Word16X32# -> Word16X32#

-- | Rounds towards zero element-wise.
quotWord32X16# :: Word32X16# -> Word32X16# -> Word32X16#

-- | Rounds towards zero element-wise.
quotWord64X8# :: Word64X8# -> Word64X8# -> Word64X8#

-- | Satisfies <tt>(quot# x y) times# y plus# (rem# x y) == x</tt>.
remInt8X16# :: Int8X16# -> Int8X16# -> Int8X16#

-- | Satisfies <tt>(quot# x y) times# y plus# (rem# x y) == x</tt>.
remInt16X8# :: Int16X8# -> Int16X8# -> Int16X8#

-- | Satisfies <tt>(quot# x y) times# y plus# (rem# x y) == x</tt>.
remInt32X4# :: Int32X4# -> Int32X4# -> Int32X4#

-- | Satisfies <tt>(quot# x y) times# y plus# (rem# x y) == x</tt>.
remInt64X2# :: Int64X2# -> Int64X2# -> Int64X2#

-- | Satisfies <tt>(quot# x y) times# y plus# (rem# x y) == x</tt>.
remInt8X32# :: Int8X32# -> Int8X32# -> Int8X32#

-- | Satisfies <tt>(quot# x y) times# y plus# (rem# x y) == x</tt>.
remInt16X16# :: Int16X16# -> Int16X16# -> Int16X16#

-- | Satisfies <tt>(quot# x y) times# y plus# (rem# x y) == x</tt>.
remInt32X8# :: Int32X8# -> Int32X8# -> Int32X8#

-- | Satisfies <tt>(quot# x y) times# y plus# (rem# x y) == x</tt>.
remInt64X4# :: Int64X4# -> Int64X4# -> Int64X4#

-- | Satisfies <tt>(quot# x y) times# y plus# (rem# x y) == x</tt>.
remInt8X64# :: Int8X64# -> Int8X64# -> Int8X64#

-- | Satisfies <tt>(quot# x y) times# y plus# (rem# x y) == x</tt>.
remInt16X32# :: Int16X32# -> Int16X32# -> Int16X32#

-- | Satisfies <tt>(quot# x y) times# y plus# (rem# x y) == x</tt>.
remInt32X16# :: Int32X16# -> Int32X16# -> Int32X16#

-- | Satisfies <tt>(quot# x y) times# y plus# (rem# x y) == x</tt>.
remInt64X8# :: Int64X8# -> Int64X8# -> Int64X8#

-- | Satisfies <tt>(quot# x y) times# y plus# (rem# x y) == x</tt>.
remWord8X16# :: Word8X16# -> Word8X16# -> Word8X16#

-- | Satisfies <tt>(quot# x y) times# y plus# (rem# x y) == x</tt>.
remWord16X8# :: Word16X8# -> Word16X8# -> Word16X8#

-- | Satisfies <tt>(quot# x y) times# y plus# (rem# x y) == x</tt>.
remWord32X4# :: Word32X4# -> Word32X4# -> Word32X4#

-- | Satisfies <tt>(quot# x y) times# y plus# (rem# x y) == x</tt>.
remWord64X2# :: Word64X2# -> Word64X2# -> Word64X2#

-- | Satisfies <tt>(quot# x y) times# y plus# (rem# x y) == x</tt>.
remWord8X32# :: Word8X32# -> Word8X32# -> Word8X32#

-- | Satisfies <tt>(quot# x y) times# y plus# (rem# x y) == x</tt>.
remWord16X16# :: Word16X16# -> Word16X16# -> Word16X16#

-- | Satisfies <tt>(quot# x y) times# y plus# (rem# x y) == x</tt>.
remWord32X8# :: Word32X8# -> Word32X8# -> Word32X8#

-- | Satisfies <tt>(quot# x y) times# y plus# (rem# x y) == x</tt>.
remWord64X4# :: Word64X4# -> Word64X4# -> Word64X4#

-- | Satisfies <tt>(quot# x y) times# y plus# (rem# x y) == x</tt>.
remWord8X64# :: Word8X64# -> Word8X64# -> Word8X64#

-- | Satisfies <tt>(quot# x y) times# y plus# (rem# x y) == x</tt>.
remWord16X32# :: Word16X32# -> Word16X32# -> Word16X32#

-- | Satisfies <tt>(quot# x y) times# y plus# (rem# x y) == x</tt>.
remWord32X16# :: Word32X16# -> Word32X16# -> Word32X16#

-- | Satisfies <tt>(quot# x y) times# y plus# (rem# x y) == x</tt>.
remWord64X8# :: Word64X8# -> Word64X8# -> Word64X8#

-- | Negate element-wise.
negateInt8X16# :: Int8X16# -> Int8X16#

-- | Negate element-wise.
negateInt16X8# :: Int16X8# -> Int16X8#

-- | Negate element-wise.
negateInt32X4# :: Int32X4# -> Int32X4#

-- | Negate element-wise.
negateInt64X2# :: Int64X2# -> Int64X2#

-- | Negate element-wise.
negateInt8X32# :: Int8X32# -> Int8X32#

-- | Negate element-wise.
negateInt16X16# :: Int16X16# -> Int16X16#

-- | Negate element-wise.
negateInt32X8# :: Int32X8# -> Int32X8#

-- | Negate element-wise.
negateInt64X4# :: Int64X4# -> Int64X4#

-- | Negate element-wise.
negateInt8X64# :: Int8X64# -> Int8X64#

-- | Negate element-wise.
negateInt16X32# :: Int16X32# -> Int16X32#

-- | Negate element-wise.
negateInt32X16# :: Int32X16# -> Int32X16#

-- | Negate element-wise.
negateInt64X8# :: Int64X8# -> Int64X8#

-- | Negate element-wise.
negateFloatX4# :: FloatX4# -> FloatX4#

-- | Negate element-wise.
negateDoubleX2# :: DoubleX2# -> DoubleX2#

-- | Negate element-wise.
negateFloatX8# :: FloatX8# -> FloatX8#

-- | Negate element-wise.
negateDoubleX4# :: DoubleX4# -> DoubleX4#

-- | Negate element-wise.
negateFloatX16# :: FloatX16# -> FloatX16#

-- | Negate element-wise.
negateDoubleX8# :: DoubleX8# -> DoubleX8#

-- | Read a vector from specified index of immutable array.
indexInt8X16Array# :: ByteArray# -> Int# -> Int8X16#

-- | Read a vector from specified index of immutable array.
indexInt16X8Array# :: ByteArray# -> Int# -> Int16X8#

-- | Read a vector from specified index of immutable array.
indexInt32X4Array# :: ByteArray# -> Int# -> Int32X4#

-- | Read a vector from specified index of immutable array.
indexInt64X2Array# :: ByteArray# -> Int# -> Int64X2#

-- | Read a vector from specified index of immutable array.
indexInt8X32Array# :: ByteArray# -> Int# -> Int8X32#

-- | Read a vector from specified index of immutable array.
indexInt16X16Array# :: ByteArray# -> Int# -> Int16X16#

-- | Read a vector from specified index of immutable array.
indexInt32X8Array# :: ByteArray# -> Int# -> Int32X8#

-- | Read a vector from specified index of immutable array.
indexInt64X4Array# :: ByteArray# -> Int# -> Int64X4#

-- | Read a vector from specified index of immutable array.
indexInt8X64Array# :: ByteArray# -> Int# -> Int8X64#

-- | Read a vector from specified index of immutable array.
indexInt16X32Array# :: ByteArray# -> Int# -> Int16X32#

-- | Read a vector from specified index of immutable array.
indexInt32X16Array# :: ByteArray# -> Int# -> Int32X16#

-- | Read a vector from specified index of immutable array.
indexInt64X8Array# :: ByteArray# -> Int# -> Int64X8#

-- | Read a vector from specified index of immutable array.
indexWord8X16Array# :: ByteArray# -> Int# -> Word8X16#

-- | Read a vector from specified index of immutable array.
indexWord16X8Array# :: ByteArray# -> Int# -> Word16X8#

-- | Read a vector from specified index of immutable array.
indexWord32X4Array# :: ByteArray# -> Int# -> Word32X4#

-- | Read a vector from specified index of immutable array.
indexWord64X2Array# :: ByteArray# -> Int# -> Word64X2#

-- | Read a vector from specified index of immutable array.
indexWord8X32Array# :: ByteArray# -> Int# -> Word8X32#

-- | Read a vector from specified index of immutable array.
indexWord16X16Array# :: ByteArray# -> Int# -> Word16X16#

-- | Read a vector from specified index of immutable array.
indexWord32X8Array# :: ByteArray# -> Int# -> Word32X8#

-- | Read a vector from specified index of immutable array.
indexWord64X4Array# :: ByteArray# -> Int# -> Word64X4#

-- | Read a vector from specified index of immutable array.
indexWord8X64Array# :: ByteArray# -> Int# -> Word8X64#

-- | Read a vector from specified index of immutable array.
indexWord16X32Array# :: ByteArray# -> Int# -> Word16X32#

-- | Read a vector from specified index of immutable array.
indexWord32X16Array# :: ByteArray# -> Int# -> Word32X16#

-- | Read a vector from specified index of immutable array.
indexWord64X8Array# :: ByteArray# -> Int# -> Word64X8#

-- | Read a vector from specified index of immutable array.
indexFloatX4Array# :: ByteArray# -> Int# -> FloatX4#

-- | Read a vector from specified index of immutable array.
indexDoubleX2Array# :: ByteArray# -> Int# -> DoubleX2#

-- | Read a vector from specified index of immutable array.
indexFloatX8Array# :: ByteArray# -> Int# -> FloatX8#

-- | Read a vector from specified index of immutable array.
indexDoubleX4Array# :: ByteArray# -> Int# -> DoubleX4#

-- | Read a vector from specified index of immutable array.
indexFloatX16Array# :: ByteArray# -> Int# -> FloatX16#

-- | Read a vector from specified index of immutable array.
indexDoubleX8Array# :: ByteArray# -> Int# -> DoubleX8#

-- | Read a vector from specified index of mutable array.
readInt8X16Array# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Int8X16# #)

-- | Read a vector from specified index of mutable array.
readInt16X8Array# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Int16X8# #)

-- | Read a vector from specified index of mutable array.
readInt32X4Array# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Int32X4# #)

-- | Read a vector from specified index of mutable array.
readInt64X2Array# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Int64X2# #)

-- | Read a vector from specified index of mutable array.
readInt8X32Array# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Int8X32# #)

-- | Read a vector from specified index of mutable array.
readInt16X16Array# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Int16X16# #)

-- | Read a vector from specified index of mutable array.
readInt32X8Array# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Int32X8# #)

-- | Read a vector from specified index of mutable array.
readInt64X4Array# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Int64X4# #)

-- | Read a vector from specified index of mutable array.
readInt8X64Array# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Int8X64# #)

-- | Read a vector from specified index of mutable array.
readInt16X32Array# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Int16X32# #)

-- | Read a vector from specified index of mutable array.
readInt32X16Array# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Int32X16# #)

-- | Read a vector from specified index of mutable array.
readInt64X8Array# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Int64X8# #)

-- | Read a vector from specified index of mutable array.
readWord8X16Array# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Word8X16# #)

-- | Read a vector from specified index of mutable array.
readWord16X8Array# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Word16X8# #)

-- | Read a vector from specified index of mutable array.
readWord32X4Array# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Word32X4# #)

-- | Read a vector from specified index of mutable array.
readWord64X2Array# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Word64X2# #)

-- | Read a vector from specified index of mutable array.
readWord8X32Array# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Word8X32# #)

-- | Read a vector from specified index of mutable array.
readWord16X16Array# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Word16X16# #)

-- | Read a vector from specified index of mutable array.
readWord32X8Array# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Word32X8# #)

-- | Read a vector from specified index of mutable array.
readWord64X4Array# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Word64X4# #)

-- | Read a vector from specified index of mutable array.
readWord8X64Array# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Word8X64# #)

-- | Read a vector from specified index of mutable array.
readWord16X32Array# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Word16X32# #)

-- | Read a vector from specified index of mutable array.
readWord32X16Array# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Word32X16# #)

-- | Read a vector from specified index of mutable array.
readWord64X8Array# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Word64X8# #)

-- | Read a vector from specified index of mutable array.
readFloatX4Array# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, FloatX4# #)

-- | Read a vector from specified index of mutable array.
readDoubleX2Array# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, DoubleX2# #)

-- | Read a vector from specified index of mutable array.
readFloatX8Array# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, FloatX8# #)

-- | Read a vector from specified index of mutable array.
readDoubleX4Array# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, DoubleX4# #)

-- | Read a vector from specified index of mutable array.
readFloatX16Array# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, FloatX16# #)

-- | Read a vector from specified index of mutable array.
readDoubleX8Array# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, DoubleX8# #)

-- | Write a vector to specified index of mutable array.
writeInt8X16Array# :: () => MutableByteArray# d -> Int# -> Int8X16# -> State# d -> State# d

-- | Write a vector to specified index of mutable array.
writeInt16X8Array# :: () => MutableByteArray# d -> Int# -> Int16X8# -> State# d -> State# d

-- | Write a vector to specified index of mutable array.
writeInt32X4Array# :: () => MutableByteArray# d -> Int# -> Int32X4# -> State# d -> State# d

-- | Write a vector to specified index of mutable array.
writeInt64X2Array# :: () => MutableByteArray# d -> Int# -> Int64X2# -> State# d -> State# d

-- | Write a vector to specified index of mutable array.
writeInt8X32Array# :: () => MutableByteArray# d -> Int# -> Int8X32# -> State# d -> State# d

-- | Write a vector to specified index of mutable array.
writeInt16X16Array# :: () => MutableByteArray# d -> Int# -> Int16X16# -> State# d -> State# d

-- | Write a vector to specified index of mutable array.
writeInt32X8Array# :: () => MutableByteArray# d -> Int# -> Int32X8# -> State# d -> State# d

-- | Write a vector to specified index of mutable array.
writeInt64X4Array# :: () => MutableByteArray# d -> Int# -> Int64X4# -> State# d -> State# d

-- | Write a vector to specified index of mutable array.
writeInt8X64Array# :: () => MutableByteArray# d -> Int# -> Int8X64# -> State# d -> State# d

-- | Write a vector to specified index of mutable array.
writeInt16X32Array# :: () => MutableByteArray# d -> Int# -> Int16X32# -> State# d -> State# d

-- | Write a vector to specified index of mutable array.
writeInt32X16Array# :: () => MutableByteArray# d -> Int# -> Int32X16# -> State# d -> State# d

-- | Write a vector to specified index of mutable array.
writeInt64X8Array# :: () => MutableByteArray# d -> Int# -> Int64X8# -> State# d -> State# d

-- | Write a vector to specified index of mutable array.
writeWord8X16Array# :: () => MutableByteArray# d -> Int# -> Word8X16# -> State# d -> State# d

-- | Write a vector to specified index of mutable array.
writeWord16X8Array# :: () => MutableByteArray# d -> Int# -> Word16X8# -> State# d -> State# d

-- | Write a vector to specified index of mutable array.
writeWord32X4Array# :: () => MutableByteArray# d -> Int# -> Word32X4# -> State# d -> State# d

-- | Write a vector to specified index of mutable array.
writeWord64X2Array# :: () => MutableByteArray# d -> Int# -> Word64X2# -> State# d -> State# d

-- | Write a vector to specified index of mutable array.
writeWord8X32Array# :: () => MutableByteArray# d -> Int# -> Word8X32# -> State# d -> State# d

-- | Write a vector to specified index of mutable array.
writeWord16X16Array# :: () => MutableByteArray# d -> Int# -> Word16X16# -> State# d -> State# d

-- | Write a vector to specified index of mutable array.
writeWord32X8Array# :: () => MutableByteArray# d -> Int# -> Word32X8# -> State# d -> State# d

-- | Write a vector to specified index of mutable array.
writeWord64X4Array# :: () => MutableByteArray# d -> Int# -> Word64X4# -> State# d -> State# d

-- | Write a vector to specified index of mutable array.
writeWord8X64Array# :: () => MutableByteArray# d -> Int# -> Word8X64# -> State# d -> State# d

-- | Write a vector to specified index of mutable array.
writeWord16X32Array# :: () => MutableByteArray# d -> Int# -> Word16X32# -> State# d -> State# d

-- | Write a vector to specified index of mutable array.
writeWord32X16Array# :: () => MutableByteArray# d -> Int# -> Word32X16# -> State# d -> State# d

-- | Write a vector to specified index of mutable array.
writeWord64X8Array# :: () => MutableByteArray# d -> Int# -> Word64X8# -> State# d -> State# d

-- | Write a vector to specified index of mutable array.
writeFloatX4Array# :: () => MutableByteArray# d -> Int# -> FloatX4# -> State# d -> State# d

-- | Write a vector to specified index of mutable array.
writeDoubleX2Array# :: () => MutableByteArray# d -> Int# -> DoubleX2# -> State# d -> State# d

-- | Write a vector to specified index of mutable array.
writeFloatX8Array# :: () => MutableByteArray# d -> Int# -> FloatX8# -> State# d -> State# d

-- | Write a vector to specified index of mutable array.
writeDoubleX4Array# :: () => MutableByteArray# d -> Int# -> DoubleX4# -> State# d -> State# d

-- | Write a vector to specified index of mutable array.
writeFloatX16Array# :: () => MutableByteArray# d -> Int# -> FloatX16# -> State# d -> State# d

-- | Write a vector to specified index of mutable array.
writeDoubleX8Array# :: () => MutableByteArray# d -> Int# -> DoubleX8# -> State# d -> State# d

-- | Reads vector; offset in bytes.
indexInt8X16OffAddr# :: Addr# -> Int# -> Int8X16#

-- | Reads vector; offset in bytes.
indexInt16X8OffAddr# :: Addr# -> Int# -> Int16X8#

-- | Reads vector; offset in bytes.
indexInt32X4OffAddr# :: Addr# -> Int# -> Int32X4#

-- | Reads vector; offset in bytes.
indexInt64X2OffAddr# :: Addr# -> Int# -> Int64X2#

-- | Reads vector; offset in bytes.
indexInt8X32OffAddr# :: Addr# -> Int# -> Int8X32#

-- | Reads vector; offset in bytes.
indexInt16X16OffAddr# :: Addr# -> Int# -> Int16X16#

-- | Reads vector; offset in bytes.
indexInt32X8OffAddr# :: Addr# -> Int# -> Int32X8#

-- | Reads vector; offset in bytes.
indexInt64X4OffAddr# :: Addr# -> Int# -> Int64X4#

-- | Reads vector; offset in bytes.
indexInt8X64OffAddr# :: Addr# -> Int# -> Int8X64#

-- | Reads vector; offset in bytes.
indexInt16X32OffAddr# :: Addr# -> Int# -> Int16X32#

-- | Reads vector; offset in bytes.
indexInt32X16OffAddr# :: Addr# -> Int# -> Int32X16#

-- | Reads vector; offset in bytes.
indexInt64X8OffAddr# :: Addr# -> Int# -> Int64X8#

-- | Reads vector; offset in bytes.
indexWord8X16OffAddr# :: Addr# -> Int# -> Word8X16#

-- | Reads vector; offset in bytes.
indexWord16X8OffAddr# :: Addr# -> Int# -> Word16X8#

-- | Reads vector; offset in bytes.
indexWord32X4OffAddr# :: Addr# -> Int# -> Word32X4#

-- | Reads vector; offset in bytes.
indexWord64X2OffAddr# :: Addr# -> Int# -> Word64X2#

-- | Reads vector; offset in bytes.
indexWord8X32OffAddr# :: Addr# -> Int# -> Word8X32#

-- | Reads vector; offset in bytes.
indexWord16X16OffAddr# :: Addr# -> Int# -> Word16X16#

-- | Reads vector; offset in bytes.
indexWord32X8OffAddr# :: Addr# -> Int# -> Word32X8#

-- | Reads vector; offset in bytes.
indexWord64X4OffAddr# :: Addr# -> Int# -> Word64X4#

-- | Reads vector; offset in bytes.
indexWord8X64OffAddr# :: Addr# -> Int# -> Word8X64#

-- | Reads vector; offset in bytes.
indexWord16X32OffAddr# :: Addr# -> Int# -> Word16X32#

-- | Reads vector; offset in bytes.
indexWord32X16OffAddr# :: Addr# -> Int# -> Word32X16#

-- | Reads vector; offset in bytes.
indexWord64X8OffAddr# :: Addr# -> Int# -> Word64X8#

-- | Reads vector; offset in bytes.
indexFloatX4OffAddr# :: Addr# -> Int# -> FloatX4#

-- | Reads vector; offset in bytes.
indexDoubleX2OffAddr# :: Addr# -> Int# -> DoubleX2#

-- | Reads vector; offset in bytes.
indexFloatX8OffAddr# :: Addr# -> Int# -> FloatX8#

-- | Reads vector; offset in bytes.
indexDoubleX4OffAddr# :: Addr# -> Int# -> DoubleX4#

-- | Reads vector; offset in bytes.
indexFloatX16OffAddr# :: Addr# -> Int# -> FloatX16#

-- | Reads vector; offset in bytes.
indexDoubleX8OffAddr# :: Addr# -> Int# -> DoubleX8#

-- | Reads vector; offset in bytes.
readInt8X16OffAddr# :: () => Addr# -> Int# -> State# d -> (# State# d, Int8X16# #)

-- | Reads vector; offset in bytes.
readInt16X8OffAddr# :: () => Addr# -> Int# -> State# d -> (# State# d, Int16X8# #)

-- | Reads vector; offset in bytes.
readInt32X4OffAddr# :: () => Addr# -> Int# -> State# d -> (# State# d, Int32X4# #)

-- | Reads vector; offset in bytes.
readInt64X2OffAddr# :: () => Addr# -> Int# -> State# d -> (# State# d, Int64X2# #)

-- | Reads vector; offset in bytes.
readInt8X32OffAddr# :: () => Addr# -> Int# -> State# d -> (# State# d, Int8X32# #)

-- | Reads vector; offset in bytes.
readInt16X16OffAddr# :: () => Addr# -> Int# -> State# d -> (# State# d, Int16X16# #)

-- | Reads vector; offset in bytes.
readInt32X8OffAddr# :: () => Addr# -> Int# -> State# d -> (# State# d, Int32X8# #)

-- | Reads vector; offset in bytes.
readInt64X4OffAddr# :: () => Addr# -> Int# -> State# d -> (# State# d, Int64X4# #)

-- | Reads vector; offset in bytes.
readInt8X64OffAddr# :: () => Addr# -> Int# -> State# d -> (# State# d, Int8X64# #)

-- | Reads vector; offset in bytes.
readInt16X32OffAddr# :: () => Addr# -> Int# -> State# d -> (# State# d, Int16X32# #)

-- | Reads vector; offset in bytes.
readInt32X16OffAddr# :: () => Addr# -> Int# -> State# d -> (# State# d, Int32X16# #)

-- | Reads vector; offset in bytes.
readInt64X8OffAddr# :: () => Addr# -> Int# -> State# d -> (# State# d, Int64X8# #)

-- | Reads vector; offset in bytes.
readWord8X16OffAddr# :: () => Addr# -> Int# -> State# d -> (# State# d, Word8X16# #)

-- | Reads vector; offset in bytes.
readWord16X8OffAddr# :: () => Addr# -> Int# -> State# d -> (# State# d, Word16X8# #)

-- | Reads vector; offset in bytes.
readWord32X4OffAddr# :: () => Addr# -> Int# -> State# d -> (# State# d, Word32X4# #)

-- | Reads vector; offset in bytes.
readWord64X2OffAddr# :: () => Addr# -> Int# -> State# d -> (# State# d, Word64X2# #)

-- | Reads vector; offset in bytes.
readWord8X32OffAddr# :: () => Addr# -> Int# -> State# d -> (# State# d, Word8X32# #)

-- | Reads vector; offset in bytes.
readWord16X16OffAddr# :: () => Addr# -> Int# -> State# d -> (# State# d, Word16X16# #)

-- | Reads vector; offset in bytes.
readWord32X8OffAddr# :: () => Addr# -> Int# -> State# d -> (# State# d, Word32X8# #)

-- | Reads vector; offset in bytes.
readWord64X4OffAddr# :: () => Addr# -> Int# -> State# d -> (# State# d, Word64X4# #)

-- | Reads vector; offset in bytes.
readWord8X64OffAddr# :: () => Addr# -> Int# -> State# d -> (# State# d, Word8X64# #)

-- | Reads vector; offset in bytes.
readWord16X32OffAddr# :: () => Addr# -> Int# -> State# d -> (# State# d, Word16X32# #)

-- | Reads vector; offset in bytes.
readWord32X16OffAddr# :: () => Addr# -> Int# -> State# d -> (# State# d, Word32X16# #)

-- | Reads vector; offset in bytes.
readWord64X8OffAddr# :: () => Addr# -> Int# -> State# d -> (# State# d, Word64X8# #)

-- | Reads vector; offset in bytes.
readFloatX4OffAddr# :: () => Addr# -> Int# -> State# d -> (# State# d, FloatX4# #)

-- | Reads vector; offset in bytes.
readDoubleX2OffAddr# :: () => Addr# -> Int# -> State# d -> (# State# d, DoubleX2# #)

-- | Reads vector; offset in bytes.
readFloatX8OffAddr# :: () => Addr# -> Int# -> State# d -> (# State# d, FloatX8# #)

-- | Reads vector; offset in bytes.
readDoubleX4OffAddr# :: () => Addr# -> Int# -> State# d -> (# State# d, DoubleX4# #)

-- | Reads vector; offset in bytes.
readFloatX16OffAddr# :: () => Addr# -> Int# -> State# d -> (# State# d, FloatX16# #)

-- | Reads vector; offset in bytes.
readDoubleX8OffAddr# :: () => Addr# -> Int# -> State# d -> (# State# d, DoubleX8# #)

-- | Write vector; offset in bytes.
writeInt8X16OffAddr# :: () => Addr# -> Int# -> Int8X16# -> State# d -> State# d

-- | Write vector; offset in bytes.
writeInt16X8OffAddr# :: () => Addr# -> Int# -> Int16X8# -> State# d -> State# d

-- | Write vector; offset in bytes.
writeInt32X4OffAddr# :: () => Addr# -> Int# -> Int32X4# -> State# d -> State# d

-- | Write vector; offset in bytes.
writeInt64X2OffAddr# :: () => Addr# -> Int# -> Int64X2# -> State# d -> State# d

-- | Write vector; offset in bytes.
writeInt8X32OffAddr# :: () => Addr# -> Int# -> Int8X32# -> State# d -> State# d

-- | Write vector; offset in bytes.
writeInt16X16OffAddr# :: () => Addr# -> Int# -> Int16X16# -> State# d -> State# d

-- | Write vector; offset in bytes.
writeInt32X8OffAddr# :: () => Addr# -> Int# -> Int32X8# -> State# d -> State# d

-- | Write vector; offset in bytes.
writeInt64X4OffAddr# :: () => Addr# -> Int# -> Int64X4# -> State# d -> State# d

-- | Write vector; offset in bytes.
writeInt8X64OffAddr# :: () => Addr# -> Int# -> Int8X64# -> State# d -> State# d

-- | Write vector; offset in bytes.
writeInt16X32OffAddr# :: () => Addr# -> Int# -> Int16X32# -> State# d -> State# d

-- | Write vector; offset in bytes.
writeInt32X16OffAddr# :: () => Addr# -> Int# -> Int32X16# -> State# d -> State# d

-- | Write vector; offset in bytes.
writeInt64X8OffAddr# :: () => Addr# -> Int# -> Int64X8# -> State# d -> State# d

-- | Write vector; offset in bytes.
writeWord8X16OffAddr# :: () => Addr# -> Int# -> Word8X16# -> State# d -> State# d

-- | Write vector; offset in bytes.
writeWord16X8OffAddr# :: () => Addr# -> Int# -> Word16X8# -> State# d -> State# d

-- | Write vector; offset in bytes.
writeWord32X4OffAddr# :: () => Addr# -> Int# -> Word32X4# -> State# d -> State# d

-- | Write vector; offset in bytes.
writeWord64X2OffAddr# :: () => Addr# -> Int# -> Word64X2# -> State# d -> State# d

-- | Write vector; offset in bytes.
writeWord8X32OffAddr# :: () => Addr# -> Int# -> Word8X32# -> State# d -> State# d

-- | Write vector; offset in bytes.
writeWord16X16OffAddr# :: () => Addr# -> Int# -> Word16X16# -> State# d -> State# d

-- | Write vector; offset in bytes.
writeWord32X8OffAddr# :: () => Addr# -> Int# -> Word32X8# -> State# d -> State# d

-- | Write vector; offset in bytes.
writeWord64X4OffAddr# :: () => Addr# -> Int# -> Word64X4# -> State# d -> State# d

-- | Write vector; offset in bytes.
writeWord8X64OffAddr# :: () => Addr# -> Int# -> Word8X64# -> State# d -> State# d

-- | Write vector; offset in bytes.
writeWord16X32OffAddr# :: () => Addr# -> Int# -> Word16X32# -> State# d -> State# d

-- | Write vector; offset in bytes.
writeWord32X16OffAddr# :: () => Addr# -> Int# -> Word32X16# -> State# d -> State# d

-- | Write vector; offset in bytes.
writeWord64X8OffAddr# :: () => Addr# -> Int# -> Word64X8# -> State# d -> State# d

-- | Write vector; offset in bytes.
writeFloatX4OffAddr# :: () => Addr# -> Int# -> FloatX4# -> State# d -> State# d

-- | Write vector; offset in bytes.
writeDoubleX2OffAddr# :: () => Addr# -> Int# -> DoubleX2# -> State# d -> State# d

-- | Write vector; offset in bytes.
writeFloatX8OffAddr# :: () => Addr# -> Int# -> FloatX8# -> State# d -> State# d

-- | Write vector; offset in bytes.
writeDoubleX4OffAddr# :: () => Addr# -> Int# -> DoubleX4# -> State# d -> State# d

-- | Write vector; offset in bytes.
writeFloatX16OffAddr# :: () => Addr# -> Int# -> FloatX16# -> State# d -> State# d

-- | Write vector; offset in bytes.
writeDoubleX8OffAddr# :: () => Addr# -> Int# -> DoubleX8# -> State# d -> State# d

-- | Read a vector from specified index of immutable array of scalars;
groffset is in scalar elements.
indexInt8ArrayAsInt8X16# :: ByteArray# -> Int# -> Int8X16#

-- | Read a vector from specified index of immutable array of scalars;
groffset is in scalar elements.
indexInt16ArrayAsInt16X8# :: ByteArray# -> Int# -> Int16X8#

-- | Read a vector from specified index of immutable array of scalars;
groffset is in scalar elements.
indexInt32ArrayAsInt32X4# :: ByteArray# -> Int# -> Int32X4#

-- | Read a vector from specified index of immutable array of scalars;
groffset is in scalar elements.
indexInt64ArrayAsInt64X2# :: ByteArray# -> Int# -> Int64X2#

-- | Read a vector from specified index of immutable array of scalars;
groffset is in scalar elements.
indexInt8ArrayAsInt8X32# :: ByteArray# -> Int# -> Int8X32#

-- | Read a vector from specified index of immutable array of scalars;
groffset is in scalar elements.
indexInt16ArrayAsInt16X16# :: ByteArray# -> Int# -> Int16X16#

-- | Read a vector from specified index of immutable array of scalars;
groffset is in scalar elements.
indexInt32ArrayAsInt32X8# :: ByteArray# -> Int# -> Int32X8#

-- | Read a vector from specified index of immutable array of scalars;
groffset is in scalar elements.
indexInt64ArrayAsInt64X4# :: ByteArray# -> Int# -> Int64X4#

-- | Read a vector from specified index of immutable array of scalars;
groffset is in scalar elements.
indexInt8ArrayAsInt8X64# :: ByteArray# -> Int# -> Int8X64#

-- | Read a vector from specified index of immutable array of scalars;
groffset is in scalar elements.
indexInt16ArrayAsInt16X32# :: ByteArray# -> Int# -> Int16X32#

-- | Read a vector from specified index of immutable array of scalars;
groffset is in scalar elements.
indexInt32ArrayAsInt32X16# :: ByteArray# -> Int# -> Int32X16#

-- | Read a vector from specified index of immutable array of scalars;
groffset is in scalar elements.
indexInt64ArrayAsInt64X8# :: ByteArray# -> Int# -> Int64X8#

-- | Read a vector from specified index of immutable array of scalars;
groffset is in scalar elements.
indexWord8ArrayAsWord8X16# :: ByteArray# -> Int# -> Word8X16#

-- | Read a vector from specified index of immutable array of scalars;
groffset is in scalar elements.
indexWord16ArrayAsWord16X8# :: ByteArray# -> Int# -> Word16X8#

-- | Read a vector from specified index of immutable array of scalars;
groffset is in scalar elements.
indexWord32ArrayAsWord32X4# :: ByteArray# -> Int# -> Word32X4#

-- | Read a vector from specified index of immutable array of scalars;
groffset is in scalar elements.
indexWord64ArrayAsWord64X2# :: ByteArray# -> Int# -> Word64X2#

-- | Read a vector from specified index of immutable array of scalars;
groffset is in scalar elements.
indexWord8ArrayAsWord8X32# :: ByteArray# -> Int# -> Word8X32#

-- | Read a vector from specified index of immutable array of scalars;
groffset is in scalar elements.
indexWord16ArrayAsWord16X16# :: ByteArray# -> Int# -> Word16X16#

-- | Read a vector from specified index of immutable array of scalars;
groffset is in scalar elements.
indexWord32ArrayAsWord32X8# :: ByteArray# -> Int# -> Word32X8#

-- | Read a vector from specified index of immutable array of scalars;
groffset is in scalar elements.
indexWord64ArrayAsWord64X4# :: ByteArray# -> Int# -> Word64X4#

-- | Read a vector from specified index of immutable array of scalars;
groffset is in scalar elements.
indexWord8ArrayAsWord8X64# :: ByteArray# -> Int# -> Word8X64#

-- | Read a vector from specified index of immutable array of scalars;
groffset is in scalar elements.
indexWord16ArrayAsWord16X32# :: ByteArray# -> Int# -> Word16X32#

-- | Read a vector from specified index of immutable array of scalars;
groffset is in scalar elements.
indexWord32ArrayAsWord32X16# :: ByteArray# -> Int# -> Word32X16#

-- | Read a vector from specified index of immutable array of scalars;
groffset is in scalar elements.
indexWord64ArrayAsWord64X8# :: ByteArray# -> Int# -> Word64X8#

-- | Read a vector from specified index of immutable array of scalars;
groffset is in scalar elements.
indexFloatArrayAsFloatX4# :: ByteArray# -> Int# -> FloatX4#

-- | Read a vector from specified index of immutable array of scalars;
groffset is in scalar elements.
indexDoubleArrayAsDoubleX2# :: ByteArray# -> Int# -> DoubleX2#

-- | Read a vector from specified index of immutable array of scalars;
groffset is in scalar elements.
indexFloatArrayAsFloatX8# :: ByteArray# -> Int# -> FloatX8#

-- | Read a vector from specified index of immutable array of scalars;
groffset is in scalar elements.
indexDoubleArrayAsDoubleX4# :: ByteArray# -> Int# -> DoubleX4#

-- | Read a vector from specified index of immutable array of scalars;
groffset is in scalar elements.
indexFloatArrayAsFloatX16# :: ByteArray# -> Int# -> FloatX16#

-- | Read a vector from specified index of immutable array of scalars;
groffset is in scalar elements.
indexDoubleArrayAsDoubleX8# :: ByteArray# -> Int# -> DoubleX8#

-- | Read a vector from specified index of mutable array of scalars; offset
gris in scalar elements.
readInt8ArrayAsInt8X16# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Int8X16# #)

-- | Read a vector from specified index of mutable array of scalars; offset
gris in scalar elements.
readInt16ArrayAsInt16X8# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Int16X8# #)

-- | Read a vector from specified index of mutable array of scalars; offset
gris in scalar elements.
readInt32ArrayAsInt32X4# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Int32X4# #)

-- | Read a vector from specified index of mutable array of scalars; offset
gris in scalar elements.
readInt64ArrayAsInt64X2# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Int64X2# #)

-- | Read a vector from specified index of mutable array of scalars; offset
gris in scalar elements.
readInt8ArrayAsInt8X32# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Int8X32# #)

-- | Read a vector from specified index of mutable array of scalars; offset
gris in scalar elements.
readInt16ArrayAsInt16X16# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Int16X16# #)

-- | Read a vector from specified index of mutable array of scalars; offset
gris in scalar elements.
readInt32ArrayAsInt32X8# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Int32X8# #)

-- | Read a vector from specified index of mutable array of scalars; offset
gris in scalar elements.
readInt64ArrayAsInt64X4# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Int64X4# #)

-- | Read a vector from specified index of mutable array of scalars; offset
gris in scalar elements.
readInt8ArrayAsInt8X64# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Int8X64# #)

-- | Read a vector from specified index of mutable array of scalars; offset
gris in scalar elements.
readInt16ArrayAsInt16X32# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Int16X32# #)

-- | Read a vector from specified index of mutable array of scalars; offset
gris in scalar elements.
readInt32ArrayAsInt32X16# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Int32X16# #)

-- | Read a vector from specified index of mutable array of scalars; offset
gris in scalar elements.
readInt64ArrayAsInt64X8# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Int64X8# #)

-- | Read a vector from specified index of mutable array of scalars; offset
gris in scalar elements.
readWord8ArrayAsWord8X16# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Word8X16# #)

-- | Read a vector from specified index of mutable array of scalars; offset
gris in scalar elements.
readWord16ArrayAsWord16X8# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Word16X8# #)

-- | Read a vector from specified index of mutable array of scalars; offset
gris in scalar elements.
readWord32ArrayAsWord32X4# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Word32X4# #)

-- | Read a vector from specified index of mutable array of scalars; offset
gris in scalar elements.
readWord64ArrayAsWord64X2# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Word64X2# #)

-- | Read a vector from specified index of mutable array of scalars; offset
gris in scalar elements.
readWord8ArrayAsWord8X32# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Word8X32# #)

-- | Read a vector from specified index of mutable array of scalars; offset
gris in scalar elements.
readWord16ArrayAsWord16X16# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Word16X16# #)

-- | Read a vector from specified index of mutable array of scalars; offset
gris in scalar elements.
readWord32ArrayAsWord32X8# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Word32X8# #)

-- | Read a vector from specified index of mutable array of scalars; offset
gris in scalar elements.
readWord64ArrayAsWord64X4# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Word64X4# #)

-- | Read a vector from specified index of mutable array of scalars; offset
gris in scalar elements.
readWord8ArrayAsWord8X64# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Word8X64# #)

-- | Read a vector from specified index of mutable array of scalars; offset
gris in scalar elements.
readWord16ArrayAsWord16X32# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Word16X32# #)

-- | Read a vector from specified index of mutable array of scalars; offset
gris in scalar elements.
readWord32ArrayAsWord32X16# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Word32X16# #)

-- | Read a vector from specified index of mutable array of scalars; offset
gris in scalar elements.
readWord64ArrayAsWord64X8# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Word64X8# #)

-- | Read a vector from specified index of mutable array of scalars; offset
gris in scalar elements.
readFloatArrayAsFloatX4# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, FloatX4# #)

-- | Read a vector from specified index of mutable array of scalars; offset
gris in scalar elements.
readDoubleArrayAsDoubleX2# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, DoubleX2# #)

-- | Read a vector from specified index of mutable array of scalars; offset
gris in scalar elements.
readFloatArrayAsFloatX8# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, FloatX8# #)

-- | Read a vector from specified index of mutable array of scalars; offset
gris in scalar elements.
readDoubleArrayAsDoubleX4# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, DoubleX4# #)

-- | Read a vector from specified index of mutable array of scalars; offset
gris in scalar elements.
readFloatArrayAsFloatX16# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, FloatX16# #)

-- | Read a vector from specified index of mutable array of scalars; offset
gris in scalar elements.
readDoubleArrayAsDoubleX8# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, DoubleX8# #)

-- | Write a vector to specified index of mutable array of scalars; offset
gris in scalar elements.
writeInt8ArrayAsInt8X16# :: () => MutableByteArray# d -> Int# -> Int8X16# -> State# d -> State# d

-- | Write a vector to specified index of mutable array of scalars; offset
gris in scalar elements.
writeInt16ArrayAsInt16X8# :: () => MutableByteArray# d -> Int# -> Int16X8# -> State# d -> State# d

-- | Write a vector to specified index of mutable array of scalars; offset
gris in scalar elements.
writeInt32ArrayAsInt32X4# :: () => MutableByteArray# d -> Int# -> Int32X4# -> State# d -> State# d

-- | Write a vector to specified index of mutable array of scalars; offset
gris in scalar elements.
writeInt64ArrayAsInt64X2# :: () => MutableByteArray# d -> Int# -> Int64X2# -> State# d -> State# d

-- | Write a vector to specified index of mutable array of scalars; offset
gris in scalar elements.
writeInt8ArrayAsInt8X32# :: () => MutableByteArray# d -> Int# -> Int8X32# -> State# d -> State# d

-- | Write a vector to specified index of mutable array of scalars; offset
gris in scalar elements.
writeInt16ArrayAsInt16X16# :: () => MutableByteArray# d -> Int# -> Int16X16# -> State# d -> State# d

-- | Write a vector to specified index of mutable array of scalars; offset
gris in scalar elements.
writeInt32ArrayAsInt32X8# :: () => MutableByteArray# d -> Int# -> Int32X8# -> State# d -> State# d

-- | Write a vector to specified index of mutable array of scalars; offset
gris in scalar elements.
writeInt64ArrayAsInt64X4# :: () => MutableByteArray# d -> Int# -> Int64X4# -> State# d -> State# d

-- | Write a vector to specified index of mutable array of scalars; offset
gris in scalar elements.
writeInt8ArrayAsInt8X64# :: () => MutableByteArray# d -> Int# -> Int8X64# -> State# d -> State# d

-- | Write a vector to specified index of mutable array of scalars; offset
gris in scalar elements.
writeInt16ArrayAsInt16X32# :: () => MutableByteArray# d -> Int# -> Int16X32# -> State# d -> State# d

-- | Write a vector to specified index of mutable array of scalars; offset
gris in scalar elements.
writeInt32ArrayAsInt32X16# :: () => MutableByteArray# d -> Int# -> Int32X16# -> State# d -> State# d

-- | Write a vector to specified index of mutable array of scalars; offset
gris in scalar elements.
writeInt64ArrayAsInt64X8# :: () => MutableByteArray# d -> Int# -> Int64X8# -> State# d -> State# d

-- | Write a vector to specified index of mutable array of scalars; offset
gris in scalar elements.
writeWord8ArrayAsWord8X16# :: () => MutableByteArray# d -> Int# -> Word8X16# -> State# d -> State# d

-- | Write a vector to specified index of mutable array of scalars; offset
gris in scalar elements.
writeWord16ArrayAsWord16X8# :: () => MutableByteArray# d -> Int# -> Word16X8# -> State# d -> State# d

-- | Write a vector to specified index of mutable array of scalars; offset
gris in scalar elements.
writeWord32ArrayAsWord32X4# :: () => MutableByteArray# d -> Int# -> Word32X4# -> State# d -> State# d

-- | Write a vector to specified index of mutable array of scalars; offset
gris in scalar elements.
writeWord64ArrayAsWord64X2# :: () => MutableByteArray# d -> Int# -> Word64X2# -> State# d -> State# d

-- | Write a vector to specified index of mutable array of scalars; offset
gris in scalar elements.
writeWord8ArrayAsWord8X32# :: () => MutableByteArray# d -> Int# -> Word8X32# -> State# d -> State# d

-- | Write a vector to specified index of mutable array of scalars; offset
gris in scalar elements.
writeWord16ArrayAsWord16X16# :: () => MutableByteArray# d -> Int# -> Word16X16# -> State# d -> State# d

-- | Write a vector to specified index of mutable array of scalars; offset
gris in scalar elements.
writeWord32ArrayAsWord32X8# :: () => MutableByteArray# d -> Int# -> Word32X8# -> State# d -> State# d

-- | Write a vector to specified index of mutable array of scalars; offset
gris in scalar elements.
writeWord64ArrayAsWord64X4# :: () => MutableByteArray# d -> Int# -> Word64X4# -> State# d -> State# d

-- | Write a vector to specified index of mutable array of scalars; offset
gris in scalar elements.
writeWord8ArrayAsWord8X64# :: () => MutableByteArray# d -> Int# -> Word8X64# -> State# d -> State# d

-- | Write a vector to specified index of mutable array of scalars; offset
gris in scalar elements.
writeWord16ArrayAsWord16X32# :: () => MutableByteArray# d -> Int# -> Word16X32# -> State# d -> State# d

-- | Write a vector to specified index of mutable array of scalars; offset
gris in scalar elements.
writeWord32ArrayAsWord32X16# :: () => MutableByteArray# d -> Int# -> Word32X16# -> State# d -> State# d

-- | Write a vector to specified index of mutable array of scalars; offset
gris in scalar elements.
writeWord64ArrayAsWord64X8# :: () => MutableByteArray# d -> Int# -> Word64X8# -> State# d -> State# d

-- | Write a vector to specified index of mutable array of scalars; offset
gris in scalar elements.
writeFloatArrayAsFloatX4# :: () => MutableByteArray# d -> Int# -> FloatX4# -> State# d -> State# d

-- | Write a vector to specified index of mutable array of scalars; offset
gris in scalar elements.
writeDoubleArrayAsDoubleX2# :: () => MutableByteArray# d -> Int# -> DoubleX2# -> State# d -> State# d

-- | Write a vector to specified index of mutable array of scalars; offset
gris in scalar elements.
writeFloatArrayAsFloatX8# :: () => MutableByteArray# d -> Int# -> FloatX8# -> State# d -> State# d

-- | Write a vector to specified index of mutable array of scalars; offset
gris in scalar elements.
writeDoubleArrayAsDoubleX4# :: () => MutableByteArray# d -> Int# -> DoubleX4# -> State# d -> State# d

-- | Write a vector to specified index of mutable array of scalars; offset
gris in scalar elements.
writeFloatArrayAsFloatX16# :: () => MutableByteArray# d -> Int# -> FloatX16# -> State# d -> State# d

-- | Write a vector to specified index of mutable array of scalars; offset
gris in scalar elements.
writeDoubleArrayAsDoubleX8# :: () => MutableByteArray# d -> Int# -> DoubleX8# -> State# d -> State# d

-- | Reads vector; offset in scalar elements.
indexInt8OffAddrAsInt8X16# :: Addr# -> Int# -> Int8X16#

-- | Reads vector; offset in scalar elements.
indexInt16OffAddrAsInt16X8# :: Addr# -> Int# -> Int16X8#

-- | Reads vector; offset in scalar elements.
indexInt32OffAddrAsInt32X4# :: Addr# -> Int# -> Int32X4#

-- | Reads vector; offset in scalar elements.
indexInt64OffAddrAsInt64X2# :: Addr# -> Int# -> Int64X2#

-- | Reads vector; offset in scalar elements.
indexInt8OffAddrAsInt8X32# :: Addr# -> Int# -> Int8X32#

-- | Reads vector; offset in scalar elements.
indexInt16OffAddrAsInt16X16# :: Addr# -> Int# -> Int16X16#

-- | Reads vector; offset in scalar elements.
indexInt32OffAddrAsInt32X8# :: Addr# -> Int# -> Int32X8#

-- | Reads vector; offset in scalar elements.
indexInt64OffAddrAsInt64X4# :: Addr# -> Int# -> Int64X4#

-- | Reads vector; offset in scalar elements.
indexInt8OffAddrAsInt8X64# :: Addr# -> Int# -> Int8X64#

-- | Reads vector; offset in scalar elements.
indexInt16OffAddrAsInt16X32# :: Addr# -> Int# -> Int16X32#

-- | Reads vector; offset in scalar elements.
indexInt32OffAddrAsInt32X16# :: Addr# -> Int# -> Int32X16#

-- | Reads vector; offset in scalar elements.
indexInt64OffAddrAsInt64X8# :: Addr# -> Int# -> Int64X8#

-- | Reads vector; offset in scalar elements.
indexWord8OffAddrAsWord8X16# :: Addr# -> Int# -> Word8X16#

-- | Reads vector; offset in scalar elements.
indexWord16OffAddrAsWord16X8# :: Addr# -> Int# -> Word16X8#

-- | Reads vector; offset in scalar elements.
indexWord32OffAddrAsWord32X4# :: Addr# -> Int# -> Word32X4#

-- | Reads vector; offset in scalar elements.
indexWord64OffAddrAsWord64X2# :: Addr# -> Int# -> Word64X2#

-- | Reads vector; offset in scalar elements.
indexWord8OffAddrAsWord8X32# :: Addr# -> Int# -> Word8X32#

-- | Reads vector; offset in scalar elements.
indexWord16OffAddrAsWord16X16# :: Addr# -> Int# -> Word16X16#

-- | Reads vector; offset in scalar elements.
indexWord32OffAddrAsWord32X8# :: Addr# -> Int# -> Word32X8#

-- | Reads vector; offset in scalar elements.
indexWord64OffAddrAsWord64X4# :: Addr# -> Int# -> Word64X4#

-- | Reads vector; offset in scalar elements.
indexWord8OffAddrAsWord8X64# :: Addr# -> Int# -> Word8X64#

-- | Reads vector; offset in scalar elements.
indexWord16OffAddrAsWord16X32# :: Addr# -> Int# -> Word16X32#

-- | Reads vector; offset in scalar elements.
indexWord32OffAddrAsWord32X16# :: Addr# -> Int# -> Word32X16#

-- | Reads vector; offset in scalar elements.
indexWord64OffAddrAsWord64X8# :: Addr# -> Int# -> Word64X8#

-- | Reads vector; offset in scalar elements.
indexFloatOffAddrAsFloatX4# :: Addr# -> Int# -> FloatX4#

-- | Reads vector; offset in scalar elements.
indexDoubleOffAddrAsDoubleX2# :: Addr# -> Int# -> DoubleX2#

-- | Reads vector; offset in scalar elements.
indexFloatOffAddrAsFloatX8# :: Addr# -> Int# -> FloatX8#

-- | Reads vector; offset in scalar elements.
indexDoubleOffAddrAsDoubleX4# :: Addr# -> Int# -> DoubleX4#

-- | Reads vector; offset in scalar elements.
indexFloatOffAddrAsFloatX16# :: Addr# -> Int# -> FloatX16#

-- | Reads vector; offset in scalar elements.
indexDoubleOffAddrAsDoubleX8# :: Addr# -> Int# -> DoubleX8#

-- | Reads vector; offset in scalar elements.
readInt8OffAddrAsInt8X16# :: () => Addr# -> Int# -> State# d -> (# State# d, Int8X16# #)

-- | Reads vector; offset in scalar elements.
readInt16OffAddrAsInt16X8# :: () => Addr# -> Int# -> State# d -> (# State# d, Int16X8# #)

-- | Reads vector; offset in scalar elements.
readInt32OffAddrAsInt32X4# :: () => Addr# -> Int# -> State# d -> (# State# d, Int32X4# #)

-- | Reads vector; offset in scalar elements.
readInt64OffAddrAsInt64X2# :: () => Addr# -> Int# -> State# d -> (# State# d, Int64X2# #)

-- | Reads vector; offset in scalar elements.
readInt8OffAddrAsInt8X32# :: () => Addr# -> Int# -> State# d -> (# State# d, Int8X32# #)

-- | Reads vector; offset in scalar elements.
readInt16OffAddrAsInt16X16# :: () => Addr# -> Int# -> State# d -> (# State# d, Int16X16# #)

-- | Reads vector; offset in scalar elements.
readInt32OffAddrAsInt32X8# :: () => Addr# -> Int# -> State# d -> (# State# d, Int32X8# #)

-- | Reads vector; offset in scalar elements.
readInt64OffAddrAsInt64X4# :: () => Addr# -> Int# -> State# d -> (# State# d, Int64X4# #)

-- | Reads vector; offset in scalar elements.
readInt8OffAddrAsInt8X64# :: () => Addr# -> Int# -> State# d -> (# State# d, Int8X64# #)

-- | Reads vector; offset in scalar elements.
readInt16OffAddrAsInt16X32# :: () => Addr# -> Int# -> State# d -> (# State# d, Int16X32# #)

-- | Reads vector; offset in scalar elements.
readInt32OffAddrAsInt32X16# :: () => Addr# -> Int# -> State# d -> (# State# d, Int32X16# #)

-- | Reads vector; offset in scalar elements.
readInt64OffAddrAsInt64X8# :: () => Addr# -> Int# -> State# d -> (# State# d, Int64X8# #)

-- | Reads vector; offset in scalar elements.
readWord8OffAddrAsWord8X16# :: () => Addr# -> Int# -> State# d -> (# State# d, Word8X16# #)

-- | Reads vector; offset in scalar elements.
readWord16OffAddrAsWord16X8# :: () => Addr# -> Int# -> State# d -> (# State# d, Word16X8# #)

-- | Reads vector; offset in scalar elements.
readWord32OffAddrAsWord32X4# :: () => Addr# -> Int# -> State# d -> (# State# d, Word32X4# #)

-- | Reads vector; offset in scalar elements.
readWord64OffAddrAsWord64X2# :: () => Addr# -> Int# -> State# d -> (# State# d, Word64X2# #)

-- | Reads vector; offset in scalar elements.
readWord8OffAddrAsWord8X32# :: () => Addr# -> Int# -> State# d -> (# State# d, Word8X32# #)

-- | Reads vector; offset in scalar elements.
readWord16OffAddrAsWord16X16# :: () => Addr# -> Int# -> State# d -> (# State# d, Word16X16# #)

-- | Reads vector; offset in scalar elements.
readWord32OffAddrAsWord32X8# :: () => Addr# -> Int# -> State# d -> (# State# d, Word32X8# #)

-- | Reads vector; offset in scalar elements.
readWord64OffAddrAsWord64X4# :: () => Addr# -> Int# -> State# d -> (# State# d, Word64X4# #)

-- | Reads vector; offset in scalar elements.
readWord8OffAddrAsWord8X64# :: () => Addr# -> Int# -> State# d -> (# State# d, Word8X64# #)

-- | Reads vector; offset in scalar elements.
readWord16OffAddrAsWord16X32# :: () => Addr# -> Int# -> State# d -> (# State# d, Word16X32# #)

-- | Reads vector; offset in scalar elements.
readWord32OffAddrAsWord32X16# :: () => Addr# -> Int# -> State# d -> (# State# d, Word32X16# #)

-- | Reads vector; offset in scalar elements.
readWord64OffAddrAsWord64X8# :: () => Addr# -> Int# -> State# d -> (# State# d, Word64X8# #)

-- | Reads vector; offset in scalar elements.
readFloatOffAddrAsFloatX4# :: () => Addr# -> Int# -> State# d -> (# State# d, FloatX4# #)

-- | Reads vector; offset in scalar elements.
readDoubleOffAddrAsDoubleX2# :: () => Addr# -> Int# -> State# d -> (# State# d, DoubleX2# #)

-- | Reads vector; offset in scalar elements.
readFloatOffAddrAsFloatX8# :: () => Addr# -> Int# -> State# d -> (# State# d, FloatX8# #)

-- | Reads vector; offset in scalar elements.
readDoubleOffAddrAsDoubleX4# :: () => Addr# -> Int# -> State# d -> (# State# d, DoubleX4# #)

-- | Reads vector; offset in scalar elements.
readFloatOffAddrAsFloatX16# :: () => Addr# -> Int# -> State# d -> (# State# d, FloatX16# #)

-- | Reads vector; offset in scalar elements.
readDoubleOffAddrAsDoubleX8# :: () => Addr# -> Int# -> State# d -> (# State# d, DoubleX8# #)

-- | Write vector; offset in scalar elements.
writeInt8OffAddrAsInt8X16# :: () => Addr# -> Int# -> Int8X16# -> State# d -> State# d

-- | Write vector; offset in scalar elements.
writeInt16OffAddrAsInt16X8# :: () => Addr# -> Int# -> Int16X8# -> State# d -> State# d

-- | Write vector; offset in scalar elements.
writeInt32OffAddrAsInt32X4# :: () => Addr# -> Int# -> Int32X4# -> State# d -> State# d

-- | Write vector; offset in scalar elements.
writeInt64OffAddrAsInt64X2# :: () => Addr# -> Int# -> Int64X2# -> State# d -> State# d

-- | Write vector; offset in scalar elements.
writeInt8OffAddrAsInt8X32# :: () => Addr# -> Int# -> Int8X32# -> State# d -> State# d

-- | Write vector; offset in scalar elements.
writeInt16OffAddrAsInt16X16# :: () => Addr# -> Int# -> Int16X16# -> State# d -> State# d

-- | Write vector; offset in scalar elements.
writeInt32OffAddrAsInt32X8# :: () => Addr# -> Int# -> Int32X8# -> State# d -> State# d

-- | Write vector; offset in scalar elements.
writeInt64OffAddrAsInt64X4# :: () => Addr# -> Int# -> Int64X4# -> State# d -> State# d

-- | Write vector; offset in scalar elements.
writeInt8OffAddrAsInt8X64# :: () => Addr# -> Int# -> Int8X64# -> State# d -> State# d

-- | Write vector; offset in scalar elements.
writeInt16OffAddrAsInt16X32# :: () => Addr# -> Int# -> Int16X32# -> State# d -> State# d

-- | Write vector; offset in scalar elements.
writeInt32OffAddrAsInt32X16# :: () => Addr# -> Int# -> Int32X16# -> State# d -> State# d

-- | Write vector; offset in scalar elements.
writeInt64OffAddrAsInt64X8# :: () => Addr# -> Int# -> Int64X8# -> State# d -> State# d

-- | Write vector; offset in scalar elements.
writeWord8OffAddrAsWord8X16# :: () => Addr# -> Int# -> Word8X16# -> State# d -> State# d

-- | Write vector; offset in scalar elements.
writeWord16OffAddrAsWord16X8# :: () => Addr# -> Int# -> Word16X8# -> State# d -> State# d

-- | Write vector; offset in scalar elements.
writeWord32OffAddrAsWord32X4# :: () => Addr# -> Int# -> Word32X4# -> State# d -> State# d

-- | Write vector; offset in scalar elements.
writeWord64OffAddrAsWord64X2# :: () => Addr# -> Int# -> Word64X2# -> State# d -> State# d

-- | Write vector; offset in scalar elements.
writeWord8OffAddrAsWord8X32# :: () => Addr# -> Int# -> Word8X32# -> State# d -> State# d

-- | Write vector; offset in scalar elements.
writeWord16OffAddrAsWord16X16# :: () => Addr# -> Int# -> Word16X16# -> State# d -> State# d

-- | Write vector; offset in scalar elements.
writeWord32OffAddrAsWord32X8# :: () => Addr# -> Int# -> Word32X8# -> State# d -> State# d

-- | Write vector; offset in scalar elements.
writeWord64OffAddrAsWord64X4# :: () => Addr# -> Int# -> Word64X4# -> State# d -> State# d

-- | Write vector; offset in scalar elements.
writeWord8OffAddrAsWord8X64# :: () => Addr# -> Int# -> Word8X64# -> State# d -> State# d

-- | Write vector; offset in scalar elements.
writeWord16OffAddrAsWord16X32# :: () => Addr# -> Int# -> Word16X32# -> State# d -> State# d

-- | Write vector; offset in scalar elements.
writeWord32OffAddrAsWord32X16# :: () => Addr# -> Int# -> Word32X16# -> State# d -> State# d

-- | Write vector; offset in scalar elements.
writeWord64OffAddrAsWord64X8# :: () => Addr# -> Int# -> Word64X8# -> State# d -> State# d

-- | Write vector; offset in scalar elements.
writeFloatOffAddrAsFloatX4# :: () => Addr# -> Int# -> FloatX4# -> State# d -> State# d

-- | Write vector; offset in scalar elements.
writeDoubleOffAddrAsDoubleX2# :: () => Addr# -> Int# -> DoubleX2# -> State# d -> State# d

-- | Write vector; offset in scalar elements.
writeFloatOffAddrAsFloatX8# :: () => Addr# -> Int# -> FloatX8# -> State# d -> State# d

-- | Write vector; offset in scalar elements.
writeDoubleOffAddrAsDoubleX4# :: () => Addr# -> Int# -> DoubleX4# -> State# d -> State# d

-- | Write vector; offset in scalar elements.
writeFloatOffAddrAsFloatX16# :: () => Addr# -> Int# -> FloatX16# -> State# d -> State# d

-- | Write vector; offset in scalar elements.
writeDoubleOffAddrAsDoubleX8# :: () => Addr# -> Int# -> DoubleX8# -> State# d -> State# d
prefetchByteArray3# :: () => ByteArray# -> Int# -> State# d -> State# d
prefetchMutableByteArray3# :: () => MutableByteArray# d -> Int# -> State# d -> State# d
prefetchAddr3# :: () => Addr# -> Int# -> State# d -> State# d
prefetchValue3# :: () => a -> State# d -> State# d
prefetchByteArray2# :: () => ByteArray# -> Int# -> State# d -> State# d
prefetchMutableByteArray2# :: () => MutableByteArray# d -> Int# -> State# d -> State# d
prefetchAddr2# :: () => Addr# -> Int# -> State# d -> State# d
prefetchValue2# :: () => a -> State# d -> State# d
prefetchByteArray1# :: () => ByteArray# -> Int# -> State# d -> State# d
prefetchMutableByteArray1# :: () => MutableByteArray# d -> Int# -> State# d -> State# d
prefetchAddr1# :: () => Addr# -> Int# -> State# d -> State# d
prefetchValue1# :: () => a -> State# d -> State# d
prefetchByteArray0# :: () => ByteArray# -> Int# -> State# d -> State# d
prefetchMutableByteArray0# :: () => MutableByteArray# d -> Int# -> State# d -> State# d
prefetchAddr0# :: () => Addr# -> Int# -> State# d -> State# d
prefetchValue0# :: () => a -> State# d -> State# d

-- | Shift the argument left by the specified number of bits (which must be
grnon-negative).
shiftL# :: Word# -> Int# -> Word#

-- | Shift the argument right by the specified number of bits (which must
grbe non-negative). The <a>RL</a> means "right, logical" (as opposed to
grRA for arithmetic) (although an arithmetic right shift wouldn't make
grsense for Word#)
shiftRL# :: Word# -> Int# -> Word#

-- | Shift the argument left by the specified number of bits (which must be
grnon-negative).
iShiftL# :: Int# -> Int# -> Int#

-- | Shift the argument right (signed) by the specified number of bits
gr(which must be non-negative). The <a>RA</a> means "right, arithmetic"
gr(as opposed to RL for logical)
iShiftRA# :: Int# -> Int# -> Int#

-- | Shift the argument right (unsigned) by the specified number of bits
gr(which must be non-negative). The <a>RL</a> means "right, logical" (as
gropposed to RA for arithmetic)
iShiftRL# :: Int# -> Int# -> Int#
uncheckedShiftL64# :: Word# -> Int# -> Word#
uncheckedShiftRL64# :: Word# -> Int# -> Word#
uncheckedIShiftL64# :: Int# -> Int# -> Int#
uncheckedIShiftRA64# :: Int# -> Int# -> Int#

-- | Alias for <a>tagToEnum#</a>. Returns True if its parameter is 1# and
grFalse if it is 0#.
isTrue# :: Int# -> Bool

-- | A list producer that can be fused with <a>foldr</a>. This function is
grmerely
gr
gr<pre>
grbuild g = g (:) []
gr</pre>
gr
grbut GHC's simplifier will transform an expression of the form
gr<tt><a>foldr</a> k z (<a>build</a> g)</tt>, which may arise after
grinlining, to <tt>g k z</tt>, which avoids producing an intermediate
grlist.
build :: forall a. (forall b. (a -> b -> b) -> b -> b) -> [a]

-- | A list producer that can be fused with <a>foldr</a>. This function is
grmerely
gr
gr<pre>
graugment g xs = g (:) xs
gr</pre>
gr
grbut GHC's simplifier will transform an expression of the form
gr<tt><a>foldr</a> k z (<a>augment</a> g xs)</tt>, which may arise after
grinlining, to <tt>g k (<a>foldr</a> k z xs)</tt>, which avoids
grproducing an intermediate list.
augment :: forall a. (forall b. (a -> b -> b) -> b -> b) -> [a] -> [a]

-- | Class for string-like datastructures; used by the overloaded string
grextension (-XOverloadedStrings in GHC).
class IsString a
fromString :: IsString a => String -> a
breakpoint :: a -> a
breakpointCond :: Bool -> a -> a

-- | The <a>lazy</a> function restrains strictness analysis a little. The
grcall <tt>lazy e</tt> means the same as <tt>e</tt>, but <a>lazy</a> has
gra magical property so far as strictness analysis is concerned: it is
grlazy in its first argument, even though its semantics is strict. After
grstrictness analysis has run, calls to <a>lazy</a> are inlined to be
grthe identity function.
gr
grThis behaviour is occasionally useful when controlling evaluation
grorder. Notably, <a>lazy</a> is used in the library definition of
gr<a>par</a>:
gr
gr<pre>
grpar :: a -&gt; b -&gt; b
grpar x y = case (par# x) of _ -&gt; lazy y
gr</pre>
gr
grIf <a>lazy</a> were not lazy, <tt>par</tt> would look strict in
gr<tt>y</tt> which would defeat the whole purpose of <tt>par</tt>.
gr
grLike <a>seq</a>, the argument of <a>lazy</a> can have an unboxed type.
lazy :: () => a -> a

-- | The call <tt>inline f</tt> arranges that <tt>f</tt> is inlined,
grregardless of its size. More precisely, the call <tt>inline f</tt>
grrewrites to the right-hand side of <tt>f</tt>'s definition. This
grallows the programmer to control inlining from a particular call site
grrather than the definition site of the function (c.f. <tt>INLINE</tt>
grpragmas).
gr
grThis inlining occurs regardless of the argument to the call or the
grsize of <tt>f</tt>'s definition; it is unconditional. The main caveat
gris that <tt>f</tt>'s definition must be visible to the compiler; it is
grtherefore recommended to mark the function with an <tt>INLINABLE</tt>
grpragma at its definition so that GHC guarantees to record its
grunfolding regardless of size.
gr
grIf no inlining takes place, the <a>inline</a> function expands to the
gridentity function in Phase zero, so its use imposes no overhead.
inline :: () => a -> a

-- | The <a>oneShot</a> function can be used to give a hint to the compiler
grthat its argument will be called at most once, which may (or may not)
grenable certain optimizations. It can be useful to improve the
grperformance of code in continuation passing style.
gr
grIf <a>oneShot</a> is used wrongly, then it may be that computations
grwhose result that would otherwise be shared are re-evaluated every
grtime they are used. Otherwise, the use of <a>oneShot</a> is safe.
gr
gr<a>oneShot</a> is representation polymorphic: the type variables may
grrefer to lifted or unlifted types.
oneShot :: () => a -> b -> a -> b

-- | Apply a function to a 'State# RealWorld' token. When manually applying
gra function to <tt>realWorld#</tt>, it is necessary to use
gr<tt>NOINLINE</tt> to prevent semantically undesirable floating.
gr<a>runRW#</a> is inlined, but only very late in compilation after all
grfloating is complete.
runRW# :: () => State# RealWorld -> a -> a

-- | The function <tt>coerce</tt> allows you to safely convert between
grvalues of types that have the same representation with no run-time
groverhead. In the simplest case you can use it instead of a newtype
grconstructor, to go from the newtype's concrete type to the abstract
grtype. But it also works in more complicated settings, e.g. converting
gra list of newtypes to a list of concrete types.
coerce :: Coercible a b => a -> b

-- | <tt>Coercible</tt> is a two-parameter class that has instances for
grtypes <tt>a</tt> and <tt>b</tt> if the compiler can infer that they
grhave the same representation. This class does not have regular
grinstances; instead they are created on-the-fly during type-checking.
grTrying to manually declare an instance of <tt>Coercible</tt> is an
grerror.
gr
grNevertheless one can pretend that the following three kinds of
grinstances exist. First, as a trivial base-case:
gr
gr<pre>
grinstance Coercible a a
gr</pre>
gr
grFurthermore, for every type constructor there is an instance that
grallows to coerce under the type constructor. For example, let
gr<tt>D</tt> be a prototypical type constructor (<tt>data</tt> or
gr<tt>newtype</tt>) with three type arguments, which have roles
gr<tt>nominal</tt>, <tt>representational</tt> resp. <tt>phantom</tt>.
grThen there is an instance of the form
gr
gr<pre>
grinstance Coercible b b' =&gt; Coercible (D a b c) (D a b' c')
gr</pre>
gr
grNote that the <tt>nominal</tt> type arguments are equal, the
gr<tt>representational</tt> type arguments can differ, but need to have
gra <tt>Coercible</tt> instance themself, and the <tt>phantom</tt> type
grarguments can be changed arbitrarily.
gr
grThe third kind of instance exists for every <tt>newtype NT = MkNT
grT</tt> and comes in two variants, namely
gr
gr<pre>
grinstance Coercible a T =&gt; Coercible a NT
gr</pre>
gr
gr<pre>
grinstance Coercible T b =&gt; Coercible NT b
gr</pre>
gr
grThis instance is only usable if the constructor <tt>MkNT</tt> is in
grscope.
gr
grIf, as a library author of a type constructor like <tt>Set a</tt>, you
grwant to prevent a user of your module to write <tt>coerce :: Set T
gr-&gt; Set NT</tt>, you need to set the role of <tt>Set</tt>'s type
grparameter to <tt>nominal</tt>, by writing
gr
gr<pre>
grtype role Set nominal
gr</pre>
gr
grFor more details about this feature, please refer to <a>Safe
grCoercions</a> by Joachim Breitner, Richard A. Eisenberg, Simon Peyton
grJones and Stephanie Weirich.
class a ~R# b => Coercible (a :: k0) (b :: k0)

-- | Lifted, heterogeneous equality. By lifted, we mean that it can be
grbogus (deferred type error). By heterogeneous, the two types
gr<tt>a</tt> and <tt>b</tt> might have different kinds. Because
gr<tt>~~</tt> can appear unexpectedly in error messages to users who do
grnot care about the difference between heterogeneous equality
gr<tt>~~</tt> and homogeneous equality <tt>~</tt>, this is printed as
gr<tt>~</tt> unless <tt>-fprint-equality-relations</tt> is set.
class a ~# b => (~~) (a :: k0) (b :: k1)
data TYPE (a :: RuntimeRep)

-- | GHC maintains a property that the kind of all inhabited types (as
grdistinct from type constructors or type-level data) tells us the
grruntime representation of values of that type. This datatype encodes
grthe choice of runtime value. Note that <a>TYPE</a> is parameterised by
gr<a>RuntimeRep</a>; this is precisely what we mean by the fact that a
grtype's kind encodes the runtime representation.
gr
grFor boxed values (that is, values that are represented by a pointer),
gra further distinction is made, between lifted types (that contain ⊥),
grand unlifted ones (that don't).
data RuntimeRep

-- | a SIMD vector type
VecRep :: VecCount -> VecElem -> RuntimeRep

-- | An unboxed tuple of the given reps
TupleRep :: [RuntimeRep] -> RuntimeRep

-- | An unboxed sum of the given reps
SumRep :: [RuntimeRep] -> RuntimeRep

-- | lifted; represented by a pointer
LiftedRep :: RuntimeRep

-- | unlifted; represented by a pointer
UnliftedRep :: RuntimeRep

-- | signed, word-sized value
IntRep :: RuntimeRep

-- | unsigned, word-sized value
WordRep :: RuntimeRep

-- | signed, 64-bit value (on 32-bit only)
Int64Rep :: RuntimeRep

-- | unsigned, 64-bit value (on 32-bit only)
Word64Rep :: RuntimeRep

-- | A pointer, but <i>not</i> to a Haskell value
AddrRep :: RuntimeRep

-- | a 32-bit floating point number
FloatRep :: RuntimeRep

-- | a 64-bit floating point number
DoubleRep :: RuntimeRep

-- | Length of a SIMD vector type
data VecCount
Vec2 :: VecCount
Vec4 :: VecCount
Vec8 :: VecCount
Vec16 :: VecCount
Vec32 :: VecCount
Vec64 :: VecCount

-- | Element of a SIMD vector type
data VecElem
Int8ElemRep :: VecElem
Int16ElemRep :: VecElem
Int32ElemRep :: VecElem
Int64ElemRep :: VecElem
Word8ElemRep :: VecElem
Word16ElemRep :: VecElem
Word32ElemRep :: VecElem
Word64ElemRep :: VecElem
FloatElemRep :: VecElem
DoubleElemRep :: VecElem

-- | The <a>Down</a> type allows you to reverse sort order conveniently. A
grvalue of type <tt><a>Down</a> a</tt> contains a value of type
gr<tt>a</tt> (represented as <tt><a>Down</a> a</tt>). If <tt>a</tt> has
gran <tt><a>Ord</a></tt> instance associated with it then comparing two
grvalues thus wrapped will give you the opposite of their normal sort
grorder. This is particularly useful when sorting in generalised list
grcomprehensions, as in: <tt>then sortWith by <a>Down</a> x</tt>
newtype Down a
Down :: a -> Down a

-- | The <a>groupWith</a> function uses the user supplied function which
grprojects an element out of every list element in order to first sort
grthe input list and then to form groups by equality on these projected
grelements
groupWith :: Ord b => (a -> b) -> [a] -> [[a]]

-- | The <a>sortWith</a> function sorts a list of elements using the user
grsupplied function to project something out of each element
sortWith :: Ord b => (a -> b) -> [a] -> [a]

-- | <a>the</a> ensures that all the elements of the list are identical and
grthen returns that unique element
the :: Eq a => [a] -> a

-- | <i>Deprecated: Use <a>traceEvent</a> or <a>traceEventIO</a></i>
traceEvent :: String -> IO ()
data SpecConstrAnnotation
NoSpecConstr :: SpecConstrAnnotation
ForceSpecConstr :: SpecConstrAnnotation

-- | Returns a <tt>[String]</tt> representing the current call stack. This
grcan be useful for debugging.
gr
grThe implementation uses the call-stack simulation maintained by the
grprofiler, so it only works if the program was compiled with
gr<tt>-prof</tt> and contains suitable SCC annotations (e.g. by using
gr<tt>-fprof-auto</tt>). Otherwise, the list returned is likely to be
grempty or uninformative.
currentCallStack :: IO [String]

-- | The kind of constraints, like <tt>Show a</tt>
data Constraint

-- | The type constructor <a>Any</a> is type to which you can unsafely
grcoerce any lifted type, and back. More concretely, for a lifted type
gr<tt>t</tt> and value <tt>x :: t</tt>, -- <tt>unsafeCoerce
gr(unsafeCoerce x :: Any) :: t</tt> is equivalent to <tt>x</tt>.

-- | The <a>IsList</a> class and its methods are intended to be used in
grconjunction with the OverloadedLists extension.
class IsList l where {
    type family Item l;
}

-- | The <a>fromList</a> function constructs the structure <tt>l</tt> from
grthe given list of <tt>Item l</tt>
fromList :: IsList l => [Item l] -> l

-- | The <a>fromListN</a> function takes the input list's length as a hint.
grIts behaviour should be equivalent to <a>fromList</a>. The hint can be
grused to construct the structure <tt>l</tt> more efficiently compared
grto <a>fromList</a>. If the given hint does not equal to the input
grlist's length the behaviour of <a>fromListN</a> is not specified.
fromListN :: IsList l => Int -> [Item l] -> l

-- | The <a>toList</a> function extracts a list of <tt>Item l</tt> from the
grstructure <tt>l</tt>. It should satisfy fromList . toList = id.
toList :: IsList l => l -> [Item l]
instance GHC.Classes.Eq GHC.Exts.SpecConstrAnnotation
instance Data.Data.Data GHC.Exts.SpecConstrAnnotation
instance GHC.Exts.IsList [a]
instance GHC.Exts.IsList (GHC.Base.NonEmpty a)
instance GHC.Exts.IsList Data.Version.Version
instance GHC.Exts.IsList GHC.Stack.Types.CallStack


-- | Symbolic references to values.
gr
grReferences to values are usually implemented with memory addresses,
grand this is practical when communicating values between the different
grpieces of a single process.
gr
grWhen values are communicated across different processes running in
grpossibly different machines, though, addresses are no longer useful
grsince each process may use different addresses to store a given value.
gr
grTo solve such concern, the references provided by this module offer a
grkey that can be used to locate the values on each process. Each
grprocess maintains a global table of references which can be looked up
grwith a given key. This table is known as the Static Pointer Table. The
grreference can then be dereferenced to obtain the value.
gr
grThe various communicating processes need to aggree on the keys used to
grrefer to the values in the Static Pointer Table, or lookups will fail.
grOnly processes launched from the same program binary are guaranteed to
gruse the same set of keys.
module GHC.StaticPtr

-- | A reference to a value of type <tt>a</tt>.
data StaticPtr a

-- | Dereferences a static pointer.
deRefStaticPtr :: StaticPtr a -> a

-- | A key for <tt>StaticPtrs</tt> that can be serialized and used with
gr<a>unsafeLookupStaticPtr</a>.
type StaticKey = Fingerprint

-- | The <a>StaticKey</a> that can be used to look up the given
gr<a>StaticPtr</a>.
staticKey :: StaticPtr a -> StaticKey

-- | Looks up a <a>StaticPtr</a> by its <a>StaticKey</a>.
gr
grIf the <a>StaticPtr</a> is not found returns <tt>Nothing</tt>.
gr
grThis function is unsafe because the program behavior is undefined if
grthe type of the returned <a>StaticPtr</a> does not match the expected
grone.
unsafeLookupStaticPtr :: StaticKey -> IO (Maybe (StaticPtr a))

-- | Miscelaneous information available for debugging purposes.
data StaticPtrInfo
StaticPtrInfo :: String -> String -> (Int, Int) -> StaticPtrInfo

-- | Package key of the package where the static pointer is defined
[spInfoUnitId] :: StaticPtrInfo -> String

-- | Name of the module where the static pointer is defined
[spInfoModuleName] :: StaticPtrInfo -> String

-- | Source location of the definition of the static pointer as a
gr<tt>(Line, Column)</tt> pair.
[spInfoSrcLoc] :: StaticPtrInfo -> (Int, Int)

-- | <a>StaticPtrInfo</a> of the given <a>StaticPtr</a>.
staticPtrInfo :: StaticPtr a -> StaticPtrInfo

-- | A list of all known keys.
staticPtrKeys :: IO [StaticKey]

-- | A class for things buildable from static pointers.
class IsStatic p
fromStaticPtr :: IsStatic p => StaticPtr a -> p a
instance GHC.Show.Show GHC.StaticPtr.StaticPtrInfo
instance GHC.StaticPtr.IsStatic GHC.StaticPtr.StaticPtr


-- | In mathematics, a semigroup is an algebraic structure consisting of a
grset together with an associative binary operation. A semigroup
grgeneralizes a monoid in that there might not exist an identity
grelement. It also (originally) generalized a group (a monoid with all
grinverses) to a type where every element did not have to have an
grinverse, thus the name semigroup.
gr
grThe use of <tt>(&lt;&gt;)</tt> in this module conflicts with an
groperator with the same name that is being exported by Data.Monoid.
grHowever, this package re-exports (most of) the contents of
grData.Monoid, so to use semigroups and monoids in the same package just
gr
gr<pre>
grimport Data.Semigroup
gr</pre>
module Data.Semigroup

-- | The class of semigroups (types with an associative binary operation).
gr
grInstances should satisfy the associativity law:
gr
gr<ul>
gr<li><pre>x <a>&lt;&gt;</a> (y <a>&lt;&gt;</a> z) = (x <a>&lt;&gt;</a>
gry) <a>&lt;&gt;</a> z</pre></li>
gr</ul>
class Semigroup a

-- | An associative operation.
(<>) :: Semigroup a => a -> a -> a

-- | Reduce a non-empty list with <tt>&lt;&gt;</tt>
gr
grThe default definition should be sufficient, but this can be
groverridden for efficiency.
sconcat :: Semigroup a => NonEmpty a -> a

-- | Repeat a value <tt>n</tt> times.
gr
grGiven that this works on a <a>Semigroup</a> it is allowed to fail if
gryou request 0 or fewer repetitions, and the default definition will do
grso.
gr
grBy making this a member of the class, idempotent semigroups and
grmonoids can upgrade this to execute in <i>O(1)</i> by picking
gr<tt>stimes = <tt>stimesIdempotent</tt></tt> or <tt>stimes =
gr<a>stimesIdempotentMonoid</a></tt> respectively.
stimes :: (Semigroup a, Integral b) => b -> a -> a

-- | This is a valid definition of <a>stimes</a> for a <a>Monoid</a>.
gr
grUnlike the default definition of <a>stimes</a>, it is defined for 0
grand so it should be preferred where possible.
stimesMonoid :: (Integral b, Monoid a) => b -> a -> a

-- | This is a valid definition of <a>stimes</a> for an idempotent
gr<a>Semigroup</a>.
gr
grWhen <tt>x &lt;&gt; x = x</tt>, this definition should be preferred,
grbecause it works in <i>O(1)</i> rather than <i>O(log n)</i>.
stimesIdempotent :: Integral b => b -> a -> a

-- | This is a valid definition of <a>stimes</a> for an idempotent
gr<a>Monoid</a>.
gr
grWhen <tt>mappend x x = x</tt>, this definition should be preferred,
grbecause it works in <i>O(1)</i> rather than <i>O(log n)</i>
stimesIdempotentMonoid :: (Integral b, Monoid a) => b -> a -> a

-- | Repeat a value <tt>n</tt> times.
gr
gr<pre>
grmtimesDefault n a = a &lt;&gt; a &lt;&gt; ... &lt;&gt; a  -- using &lt;&gt; (n-1) times
gr</pre>
gr
grImplemented using <a>stimes</a> and <a>mempty</a>.
gr
grThis is a suitable definition for an <tt>mtimes</tt> member of
gr<a>Monoid</a>.
mtimesDefault :: (Integral b, Monoid a) => b -> a -> a
newtype Min a
Min :: a -> Min a
[getMin] :: Min a -> a
newtype Max a
Max :: a -> Max a
[getMax] :: Max a -> a

-- | Use <tt><a>Option</a> (<a>First</a> a)</tt> to get the behavior of
gr<a>First</a> from <a>Data.Monoid</a>.
newtype First a
First :: a -> First a
[getFirst] :: First a -> a

-- | Use <tt><a>Option</a> (<a>Last</a> a)</tt> to get the behavior of
gr<a>Last</a> from <a>Data.Monoid</a>
newtype Last a
Last :: a -> Last a
[getLast] :: Last a -> a

-- | Provide a Semigroup for an arbitrary Monoid.
gr
gr<b>NOTE</b>: This is not needed anymore since <a>Semigroup</a> became
gra superclass of <a>Monoid</a> in <i>base-4.11</i> and this newtype be
grdeprecated at some point in the future.
newtype WrappedMonoid m
WrapMonoid :: m -> WrappedMonoid m
[unwrapMonoid] :: WrappedMonoid m -> m

-- | The dual of a <a>Monoid</a>, obtained by swapping the arguments of
gr<a>mappend</a>.
gr
gr<pre>
gr&gt;&gt;&gt; getDual (mappend (Dual "Hello") (Dual "World"))
gr"WorldHello"
gr</pre>
newtype Dual a
Dual :: a -> Dual a
[getDual] :: Dual a -> a

-- | The monoid of endomorphisms under composition.
gr
gr<pre>
gr&gt;&gt;&gt; let computation = Endo ("Hello, " ++) &lt;&gt; Endo (++ "!")
gr
gr&gt;&gt;&gt; appEndo computation "Haskell"
gr"Hello, Haskell!"
gr</pre>
newtype Endo a
Endo :: a -> a -> Endo a
[appEndo] :: Endo a -> a -> a

-- | Boolean monoid under conjunction (<a>&amp;&amp;</a>).
gr
gr<pre>
gr&gt;&gt;&gt; getAll (All True &lt;&gt; mempty &lt;&gt; All False)
grFalse
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; getAll (mconcat (map (\x -&gt; All (even x)) [2,4,6,7,8]))
grFalse
gr</pre>
newtype All
All :: Bool -> All
[getAll] :: All -> Bool

-- | Boolean monoid under disjunction (<a>||</a>).
gr
gr<pre>
gr&gt;&gt;&gt; getAny (Any True &lt;&gt; mempty &lt;&gt; Any False)
grTrue
gr</pre>
gr
gr<pre>
gr&gt;&gt;&gt; getAny (mconcat (map (\x -&gt; Any (even x)) [2,4,6,7,8]))
grTrue
gr</pre>
newtype Any
Any :: Bool -> Any
[getAny] :: Any -> Bool

-- | Monoid under addition.
gr
gr<pre>
gr&gt;&gt;&gt; getSum (Sum 1 &lt;&gt; Sum 2 &lt;&gt; mempty)
gr3
gr</pre>
newtype Sum a
Sum :: a -> Sum a
[getSum] :: Sum a -> a

-- | Monoid under multiplication.
gr
gr<pre>
gr&gt;&gt;&gt; getProduct (Product 3 &lt;&gt; Product 4 &lt;&gt; mempty)
gr12
gr</pre>
newtype Product a
Product :: a -> Product a
[getProduct] :: Product a -> a

-- | <a>Option</a> is effectively <a>Maybe</a> with a better instance of
gr<a>Monoid</a>, built off of an underlying <a>Semigroup</a> instead of
gran underlying <a>Monoid</a>.
gr
grIdeally, this type would not exist at all and we would just fix the
gr<a>Monoid</a> instance of <a>Maybe</a>
newtype Option a
Option :: Maybe a -> Option a
[getOption] :: Option a -> Maybe a

-- | Fold an <a>Option</a> case-wise, just like <a>maybe</a>.
option :: b -> (a -> b) -> Option a -> b

-- | This lets you use a difference list of a <a>Semigroup</a> as a
gr<a>Monoid</a>.
diff :: Semigroup m => m -> Endo m

-- | A generalization of <a>cycle</a> to an arbitrary <a>Semigroup</a>. May
grfail to terminate for some values in some semigroups.
cycle1 :: Semigroup m => m -> m

-- | <a>Arg</a> isn't itself a <a>Semigroup</a> in its own right, but it
grcan be placed inside <a>Min</a> and <a>Max</a> to compute an arg min
gror arg max.
data Arg a b
Arg :: a -> b -> Arg a b
type ArgMin a b = Min (Arg a b)
type ArgMax a b = Max (Arg a b)
instance GHC.Generics.Generic1 Data.Semigroup.Option
instance GHC.Generics.Generic (Data.Semigroup.Option a)
instance Data.Data.Data a => Data.Data.Data (Data.Semigroup.Option a)
instance GHC.Read.Read a => GHC.Read.Read (Data.Semigroup.Option a)
instance GHC.Show.Show a => GHC.Show.Show (Data.Semigroup.Option a)
instance GHC.Classes.Ord a => GHC.Classes.Ord (Data.Semigroup.Option a)
instance GHC.Classes.Eq a => GHC.Classes.Eq (Data.Semigroup.Option a)
instance GHC.Generics.Generic1 Data.Semigroup.WrappedMonoid
instance GHC.Generics.Generic (Data.Semigroup.WrappedMonoid m)
instance Data.Data.Data m => Data.Data.Data (Data.Semigroup.WrappedMonoid m)
instance GHC.Read.Read m => GHC.Read.Read (Data.Semigroup.WrappedMonoid m)
instance GHC.Show.Show m => GHC.Show.Show (Data.Semigroup.WrappedMonoid m)
instance GHC.Classes.Ord m => GHC.Classes.Ord (Data.Semigroup.WrappedMonoid m)
instance GHC.Classes.Eq m => GHC.Classes.Eq (Data.Semigroup.WrappedMonoid m)
instance GHC.Enum.Bounded m => GHC.Enum.Bounded (Data.Semigroup.WrappedMonoid m)
instance GHC.Generics.Generic1 Data.Semigroup.Last
instance GHC.Generics.Generic (Data.Semigroup.Last a)
instance Data.Data.Data a => Data.Data.Data (Data.Semigroup.Last a)
instance GHC.Read.Read a => GHC.Read.Read (Data.Semigroup.Last a)
instance GHC.Show.Show a => GHC.Show.Show (Data.Semigroup.Last a)
instance GHC.Classes.Ord a => GHC.Classes.Ord (Data.Semigroup.Last a)
instance GHC.Classes.Eq a => GHC.Classes.Eq (Data.Semigroup.Last a)
instance GHC.Enum.Bounded a => GHC.Enum.Bounded (Data.Semigroup.Last a)
instance GHC.Generics.Generic1 Data.Semigroup.First
instance GHC.Generics.Generic (Data.Semigroup.First a)
instance Data.Data.Data a => Data.Data.Data (Data.Semigroup.First a)
instance GHC.Read.Read a => GHC.Read.Read (Data.Semigroup.First a)
instance GHC.Show.Show a => GHC.Show.Show (Data.Semigroup.First a)
instance GHC.Classes.Ord a => GHC.Classes.Ord (Data.Semigroup.First a)
instance GHC.Classes.Eq a => GHC.Classes.Eq (Data.Semigroup.First a)
instance GHC.Enum.Bounded a => GHC.Enum.Bounded (Data.Semigroup.First a)
instance GHC.Generics.Generic1 (Data.Semigroup.Arg a)
instance GHC.Generics.Generic (Data.Semigroup.Arg a b)
instance (Data.Data.Data a, Data.Data.Data b) => Data.Data.Data (Data.Semigroup.Arg a b)
instance (GHC.Read.Read a, GHC.Read.Read b) => GHC.Read.Read (Data.Semigroup.Arg a b)
instance (GHC.Show.Show a, GHC.Show.Show b) => GHC.Show.Show (Data.Semigroup.Arg a b)
instance GHC.Generics.Generic1 Data.Semigroup.Max
instance GHC.Generics.Generic (Data.Semigroup.Max a)
instance Data.Data.Data a => Data.Data.Data (Data.Semigroup.Max a)
instance GHC.Read.Read a => GHC.Read.Read (Data.Semigroup.Max a)
instance GHC.Show.Show a => GHC.Show.Show (Data.Semigroup.Max a)
instance GHC.Classes.Ord a => GHC.Classes.Ord (Data.Semigroup.Max a)
instance GHC.Classes.Eq a => GHC.Classes.Eq (Data.Semigroup.Max a)
instance GHC.Enum.Bounded a => GHC.Enum.Bounded (Data.Semigroup.Max a)
instance GHC.Generics.Generic1 Data.Semigroup.Min
instance GHC.Generics.Generic (Data.Semigroup.Min a)
instance Data.Data.Data a => Data.Data.Data (Data.Semigroup.Min a)
instance GHC.Read.Read a => GHC.Read.Read (Data.Semigroup.Min a)
instance GHC.Show.Show a => GHC.Show.Show (Data.Semigroup.Min a)
instance GHC.Classes.Ord a => GHC.Classes.Ord (Data.Semigroup.Min a)
instance GHC.Classes.Eq a => GHC.Classes.Eq (Data.Semigroup.Min a)
instance GHC.Enum.Bounded a => GHC.Enum.Bounded (Data.Semigroup.Min a)
instance GHC.Base.Functor Data.Semigroup.Option
instance GHC.Base.Applicative Data.Semigroup.Option
instance GHC.Base.Monad Data.Semigroup.Option
instance GHC.Base.Alternative Data.Semigroup.Option
instance GHC.Base.MonadPlus Data.Semigroup.Option
instance Control.Monad.Fix.MonadFix Data.Semigroup.Option
instance Data.Foldable.Foldable Data.Semigroup.Option
instance Data.Traversable.Traversable Data.Semigroup.Option
instance GHC.Base.Semigroup a => GHC.Base.Semigroup (Data.Semigroup.Option a)
instance GHC.Base.Semigroup a => GHC.Base.Monoid (Data.Semigroup.Option a)
instance GHC.Base.Monoid m => GHC.Base.Semigroup (Data.Semigroup.WrappedMonoid m)
instance GHC.Base.Monoid m => GHC.Base.Monoid (Data.Semigroup.WrappedMonoid m)
instance GHC.Enum.Enum a => GHC.Enum.Enum (Data.Semigroup.WrappedMonoid a)
instance GHC.Enum.Enum a => GHC.Enum.Enum (Data.Semigroup.Last a)
instance GHC.Base.Semigroup (Data.Semigroup.Last a)
instance GHC.Base.Functor Data.Semigroup.Last
instance Data.Foldable.Foldable Data.Semigroup.Last
instance Data.Traversable.Traversable Data.Semigroup.Last
instance GHC.Base.Applicative Data.Semigroup.Last
instance GHC.Base.Monad Data.Semigroup.Last
instance Control.Monad.Fix.MonadFix Data.Semigroup.Last
instance GHC.Enum.Enum a => GHC.Enum.Enum (Data.Semigroup.First a)
instance GHC.Base.Semigroup (Data.Semigroup.First a)
instance GHC.Base.Functor Data.Semigroup.First
instance Data.Foldable.Foldable Data.Semigroup.First
instance Data.Traversable.Traversable Data.Semigroup.First
instance GHC.Base.Applicative Data.Semigroup.First
instance GHC.Base.Monad Data.Semigroup.First
instance Control.Monad.Fix.MonadFix Data.Semigroup.First
instance GHC.Base.Functor (Data.Semigroup.Arg a)
instance Data.Foldable.Foldable (Data.Semigroup.Arg a)
instance Data.Traversable.Traversable (Data.Semigroup.Arg a)
instance GHC.Classes.Eq a => GHC.Classes.Eq (Data.Semigroup.Arg a b)
instance GHC.Classes.Ord a => GHC.Classes.Ord (Data.Semigroup.Arg a b)
instance Data.Bifunctor.Bifunctor Data.Semigroup.Arg
instance Data.Bifoldable.Bifoldable Data.Semigroup.Arg
instance Data.Bitraversable.Bitraversable Data.Semigroup.Arg
instance GHC.Enum.Enum a => GHC.Enum.Enum (Data.Semigroup.Max a)
instance GHC.Classes.Ord a => GHC.Base.Semigroup (Data.Semigroup.Max a)
instance (GHC.Classes.Ord a, GHC.Enum.Bounded a) => GHC.Base.Monoid (Data.Semigroup.Max a)
instance GHC.Base.Functor Data.Semigroup.Max
instance Data.Foldable.Foldable Data.Semigroup.Max
instance Data.Traversable.Traversable Data.Semigroup.Max
instance GHC.Base.Applicative Data.Semigroup.Max
instance GHC.Base.Monad Data.Semigroup.Max
instance Control.Monad.Fix.MonadFix Data.Semigroup.Max
instance GHC.Num.Num a => GHC.Num.Num (Data.Semigroup.Max a)
instance GHC.Enum.Enum a => GHC.Enum.Enum (Data.Semigroup.Min a)
instance GHC.Classes.Ord a => GHC.Base.Semigroup (Data.Semigroup.Min a)
instance (GHC.Classes.Ord a, GHC.Enum.Bounded a) => GHC.Base.Monoid (Data.Semigroup.Min a)
instance GHC.Base.Functor Data.Semigroup.Min
instance Data.Foldable.Foldable Data.Semigroup.Min
instance Data.Traversable.Traversable Data.Semigroup.Min
instance GHC.Base.Applicative Data.Semigroup.Min
instance GHC.Base.Monad Data.Semigroup.Min
instance Control.Monad.Fix.MonadFix Data.Semigroup.Min
instance GHC.Num.Num a => GHC.Num.Num (Data.Semigroup.Min a)


-- | A logically uninhabited data type, used to indicate that a given term
grshould not exist.
module Data.Void

-- | Uninhabited data type
data Void

-- | Since <a>Void</a> values logically don't exist, this witnesses the
grlogical reasoning tool of "ex falso quodlibet".
gr
gr<pre>
gr&gt;&gt;&gt; let x :: Either Void Int; x = Right 5
gr
gr&gt;&gt;&gt; :{
grcase x of
gr    Right r -&gt; r
gr    Left l  -&gt; absurd l
gr:}
gr5
gr</pre>
absurd :: Void -> a

-- | If <a>Void</a> is uninhabited then any <a>Functor</a> that holds only
grvalues of type <a>Void</a> is holding no values.
vacuous :: Functor f => f Void -> f a
instance GHC.Show.Show Data.Void.Void
instance GHC.Read.Read Data.Void.Void
instance GHC.Classes.Ord Data.Void.Void
instance GHC.Generics.Generic Data.Void.Void
instance Data.Data.Data Data.Void.Void
instance GHC.Classes.Eq Data.Void.Void
instance GHC.Arr.Ix Data.Void.Void
instance GHC.Exception.Exception Data.Void.Void
instance GHC.Base.Semigroup Data.Void.Void


-- | Sums, lifted to functors.
module Data.Functor.Sum

-- | Lifted sum of functors.
data Sum f g a
InL :: (f a) -> Sum f g a
InR :: (g a) -> Sum f g a
instance forall k (f :: k -> *) (g :: k -> *). GHC.Generics.Generic1 (Data.Functor.Sum.Sum f g)
instance forall k (f :: k -> *) (g :: k -> *) (a :: k). GHC.Generics.Generic (Data.Functor.Sum.Sum f g a)
instance forall k (f :: k -> *) (g :: k -> *) (a :: k). (Data.Typeable.Internal.Typeable a, Data.Typeable.Internal.Typeable f, Data.Typeable.Internal.Typeable g, Data.Typeable.Internal.Typeable k, Data.Data.Data (f a), Data.Data.Data (g a)) => Data.Data.Data (Data.Functor.Sum.Sum f g a)
instance (Data.Functor.Classes.Eq1 f, Data.Functor.Classes.Eq1 g) => Data.Functor.Classes.Eq1 (Data.Functor.Sum.Sum f g)
instance (Data.Functor.Classes.Ord1 f, Data.Functor.Classes.Ord1 g) => Data.Functor.Classes.Ord1 (Data.Functor.Sum.Sum f g)
instance (Data.Functor.Classes.Read1 f, Data.Functor.Classes.Read1 g) => Data.Functor.Classes.Read1 (Data.Functor.Sum.Sum f g)
instance (Data.Functor.Classes.Show1 f, Data.Functor.Classes.Show1 g) => Data.Functor.Classes.Show1 (Data.Functor.Sum.Sum f g)
instance (Data.Functor.Classes.Eq1 f, Data.Functor.Classes.Eq1 g, GHC.Classes.Eq a) => GHC.Classes.Eq (Data.Functor.Sum.Sum f g a)
instance (Data.Functor.Classes.Ord1 f, Data.Functor.Classes.Ord1 g, GHC.Classes.Ord a) => GHC.Classes.Ord (Data.Functor.Sum.Sum f g a)
instance (Data.Functor.Classes.Read1 f, Data.Functor.Classes.Read1 g, GHC.Read.Read a) => GHC.Read.Read (Data.Functor.Sum.Sum f g a)
instance (Data.Functor.Classes.Show1 f, Data.Functor.Classes.Show1 g, GHC.Show.Show a) => GHC.Show.Show (Data.Functor.Sum.Sum f g a)
instance (GHC.Base.Functor f, GHC.Base.Functor g) => GHC.Base.Functor (Data.Functor.Sum.Sum f g)
instance (Data.Foldable.Foldable f, Data.Foldable.Foldable g) => Data.Foldable.Foldable (Data.Functor.Sum.Sum f g)
instance (Data.Traversable.Traversable f, Data.Traversable.Traversable g) => Data.Traversable.Traversable (Data.Functor.Sum.Sum f g)


-- | Products, lifted to functors.
module Data.Functor.Product

-- | Lifted product of functors.
data Product f g a
Pair :: (f a) -> (g a) -> Product f g a
instance forall k (f :: k -> *) (g :: k -> *). GHC.Generics.Generic1 (Data.Functor.Product.Product f g)
instance forall k (f :: k -> *) (g :: k -> *) (a :: k). GHC.Generics.Generic (Data.Functor.Product.Product f g a)
instance forall k (f :: k -> *) (g :: k -> *) (a :: k). (Data.Typeable.Internal.Typeable a, Data.Typeable.Internal.Typeable f, Data.Typeable.Internal.Typeable g, Data.Typeable.Internal.Typeable k, Data.Data.Data (f a), Data.Data.Data (g a)) => Data.Data.Data (Data.Functor.Product.Product f g a)
instance (Data.Functor.Classes.Eq1 f, Data.Functor.Classes.Eq1 g) => Data.Functor.Classes.Eq1 (Data.Functor.Product.Product f g)
instance (Data.Functor.Classes.Ord1 f, Data.Functor.Classes.Ord1 g) => Data.Functor.Classes.Ord1 (Data.Functor.Product.Product f g)
instance (Data.Functor.Classes.Read1 f, Data.Functor.Classes.Read1 g) => Data.Functor.Classes.Read1 (Data.Functor.Product.Product f g)
instance (Data.Functor.Classes.Show1 f, Data.Functor.Classes.Show1 g) => Data.Functor.Classes.Show1 (Data.Functor.Product.Product f g)
instance (Data.Functor.Classes.Eq1 f, Data.Functor.Classes.Eq1 g, GHC.Classes.Eq a) => GHC.Classes.Eq (Data.Functor.Product.Product f g a)
instance (Data.Functor.Classes.Ord1 f, Data.Functor.Classes.Ord1 g, GHC.Classes.Ord a) => GHC.Classes.Ord (Data.Functor.Product.Product f g a)
instance (Data.Functor.Classes.Read1 f, Data.Functor.Classes.Read1 g, GHC.Read.Read a) => GHC.Read.Read (Data.Functor.Product.Product f g a)
instance (Data.Functor.Classes.Show1 f, Data.Functor.Classes.Show1 g, GHC.Show.Show a) => GHC.Show.Show (Data.Functor.Product.Product f g a)
instance (GHC.Base.Functor f, GHC.Base.Functor g) => GHC.Base.Functor (Data.Functor.Product.Product f g)
instance (Data.Foldable.Foldable f, Data.Foldable.Foldable g) => Data.Foldable.Foldable (Data.Functor.Product.Product f g)
instance (Data.Traversable.Traversable f, Data.Traversable.Traversable g) => Data.Traversable.Traversable (Data.Functor.Product.Product f g)
instance (GHC.Base.Applicative f, GHC.Base.Applicative g) => GHC.Base.Applicative (Data.Functor.Product.Product f g)
instance (GHC.Base.Alternative f, GHC.Base.Alternative g) => GHC.Base.Alternative (Data.Functor.Product.Product f g)
instance (GHC.Base.Monad f, GHC.Base.Monad g) => GHC.Base.Monad (Data.Functor.Product.Product f g)
instance (GHC.Base.MonadPlus f, GHC.Base.MonadPlus g) => GHC.Base.MonadPlus (Data.Functor.Product.Product f g)
instance (Control.Monad.Fix.MonadFix f, Control.Monad.Fix.MonadFix g) => Control.Monad.Fix.MonadFix (Data.Functor.Product.Product f g)
instance (Control.Monad.Zip.MonadZip f, Control.Monad.Zip.MonadZip g) => Control.Monad.Zip.MonadZip (Data.Functor.Product.Product f g)


-- | Composition of functors.
module Data.Functor.Compose

-- | Right-to-left composition of functors. The composition of applicative
grfunctors is always applicative, but the composition of monads is not
gralways a monad.
newtype Compose f g a
Compose :: f (g a) -> Compose f g a
[getCompose] :: Compose f g a -> f (g a)
instance forall (f :: * -> *) k (g :: k -> *). GHC.Base.Functor f => GHC.Generics.Generic1 (Data.Functor.Compose.Compose f g)
instance forall k1 (f :: k1 -> *) k2 (g :: k2 -> k1) (a :: k2). GHC.Generics.Generic (Data.Functor.Compose.Compose f g a)
instance forall k1 (f :: k1 -> *) k2 (g :: k2 -> k1) (a :: k2). (Data.Typeable.Internal.Typeable a, Data.Typeable.Internal.Typeable f, Data.Typeable.Internal.Typeable g, Data.Typeable.Internal.Typeable k1, Data.Typeable.Internal.Typeable k2, Data.Data.Data (f (g a))) => Data.Data.Data (Data.Functor.Compose.Compose f g a)
instance (Data.Functor.Classes.Eq1 f, Data.Functor.Classes.Eq1 g) => Data.Functor.Classes.Eq1 (Data.Functor.Compose.Compose f g)
instance (Data.Functor.Classes.Ord1 f, Data.Functor.Classes.Ord1 g) => Data.Functor.Classes.Ord1 (Data.Functor.Compose.Compose f g)
instance (Data.Functor.Classes.Read1 f, Data.Functor.Classes.Read1 g) => Data.Functor.Classes.Read1 (Data.Functor.Compose.Compose f g)
instance (Data.Functor.Classes.Show1 f, Data.Functor.Classes.Show1 g) => Data.Functor.Classes.Show1 (Data.Functor.Compose.Compose f g)
instance (Data.Functor.Classes.Eq1 f, Data.Functor.Classes.Eq1 g, GHC.Classes.Eq a) => GHC.Classes.Eq (Data.Functor.Compose.Compose f g a)
instance (Data.Functor.Classes.Ord1 f, Data.Functor.Classes.Ord1 g, GHC.Classes.Ord a) => GHC.Classes.Ord (Data.Functor.Compose.Compose f g a)
instance (Data.Functor.Classes.Read1 f, Data.Functor.Classes.Read1 g, GHC.Read.Read a) => GHC.Read.Read (Data.Functor.Compose.Compose f g a)
instance (Data.Functor.Classes.Show1 f, Data.Functor.Classes.Show1 g, GHC.Show.Show a) => GHC.Show.Show (Data.Functor.Compose.Compose f g a)
instance (GHC.Base.Functor f, GHC.Base.Functor g) => GHC.Base.Functor (Data.Functor.Compose.Compose f g)
instance (Data.Foldable.Foldable f, Data.Foldable.Foldable g) => Data.Foldable.Foldable (Data.Functor.Compose.Compose f g)
instance (Data.Traversable.Traversable f, Data.Traversable.Traversable g) => Data.Traversable.Traversable (Data.Functor.Compose.Compose f g)
instance (GHC.Base.Applicative f, GHC.Base.Applicative g) => GHC.Base.Applicative (Data.Functor.Compose.Compose f g)
instance (GHC.Base.Alternative f, GHC.Base.Applicative g) => GHC.Base.Alternative (Data.Functor.Compose.Compose f g)


-- | This module defines a "Fixed" type for fixed-precision arithmetic. The
grparameter to Fixed is any type that's an instance of HasResolution.
grHasResolution has a single method that gives the resolution of the
grFixed type.
gr
grThis module also contains generalisations of div, mod, and divmod to
grwork with any Real instance.
module Data.Fixed

-- | generalisation of <a>div</a> to any instance of Real
div' :: (Real a, Integral b) => a -> a -> b

-- | generalisation of <a>mod</a> to any instance of Real
mod' :: (Real a) => a -> a -> a

-- | generalisation of <a>divMod</a> to any instance of Real
divMod' :: (Real a, Integral b) => a -> a -> (b, a)

-- | The type parameter should be an instance of <a>HasResolution</a>.
newtype Fixed a

MkFixed :: Integer -> Fixed a
class HasResolution a
resolution :: HasResolution a => p a -> Integer

-- | First arg is whether to chop off trailing zeros
showFixed :: (HasResolution a) => Bool -> Fixed a -> String
data E0

-- | resolution of 1, this works the same as Integer
type Uni = Fixed E0
data E1

-- | resolution of 10^-1 = .1
type Deci = Fixed E1
data E2

-- | resolution of 10^-2 = .01, useful for many monetary currencies
type Centi = Fixed E2
data E3

-- | resolution of 10^-3 = .001
type Milli = Fixed E3
data E6

-- | resolution of 10^-6 = .000001
type Micro = Fixed E6
data E9

-- | resolution of 10^-9 = .000000001
type Nano = Fixed E9
data E12

-- | resolution of 10^-12 = .000000000001
type Pico = Fixed E12
instance GHC.Classes.Ord (Data.Fixed.Fixed a)
instance GHC.Classes.Eq (Data.Fixed.Fixed a)
instance Data.Fixed.HasResolution Data.Fixed.E12
instance Data.Fixed.HasResolution Data.Fixed.E9
instance Data.Fixed.HasResolution Data.Fixed.E6
instance Data.Fixed.HasResolution Data.Fixed.E3
instance Data.Fixed.HasResolution Data.Fixed.E2
instance Data.Fixed.HasResolution Data.Fixed.E1
instance Data.Fixed.HasResolution Data.Fixed.E0
instance Data.Fixed.HasResolution a => GHC.Num.Num (Data.Fixed.Fixed a)
instance Data.Fixed.HasResolution a => GHC.Real.Real (Data.Fixed.Fixed a)
instance Data.Fixed.HasResolution a => GHC.Real.Fractional (Data.Fixed.Fixed a)
instance Data.Fixed.HasResolution a => GHC.Real.RealFrac (Data.Fixed.Fixed a)
instance Data.Fixed.HasResolution a => GHC.Show.Show (Data.Fixed.Fixed a)
instance Data.Fixed.HasResolution a => GHC.Read.Read (Data.Fixed.Fixed a)
instance Data.Typeable.Internal.Typeable a => Data.Data.Data (Data.Fixed.Fixed a)
instance GHC.Enum.Enum (Data.Fixed.Fixed a)


-- | Complex numbers.
module Data.Complex

-- | Complex numbers are an algebraic type.
gr
grFor a complex number <tt>z</tt>, <tt><a>abs</a> z</tt> is a number
grwith the magnitude of <tt>z</tt>, but oriented in the positive real
grdirection, whereas <tt><a>signum</a> z</tt> has the phase of
gr<tt>z</tt>, but unit magnitude.
gr
grThe <a>Foldable</a> and <a>Traversable</a> instances traverse the real
grpart first.
data Complex a

-- | forms a complex number from its real and imaginary rectangular
grcomponents.
(:+) :: !a -> !a -> Complex a

-- | Extracts the real part of a complex number.
realPart :: Complex a -> a

-- | Extracts the imaginary part of a complex number.
imagPart :: Complex a -> a

-- | Form a complex number from polar components of magnitude and phase.
mkPolar :: Floating a => a -> a -> Complex a

-- | <tt><a>cis</a> t</tt> is a complex value with magnitude <tt>1</tt> and
grphase <tt>t</tt> (modulo <tt>2*<a>pi</a></tt>).
cis :: Floating a => a -> Complex a

-- | The function <a>polar</a> takes a complex number and returns a
gr(magnitude, phase) pair in canonical form: the magnitude is
grnonnegative, and the phase in the range <tt>(-<a>pi</a>,
gr<a>pi</a>]</tt>; if the magnitude is zero, then so is the phase.
polar :: (RealFloat a) => Complex a -> (a, a)

-- | The nonnegative magnitude of a complex number.
magnitude :: (RealFloat a) => Complex a -> a

-- | The phase of a complex number, in the range <tt>(-<a>pi</a>,
gr<a>pi</a>]</tt>. If the magnitude is zero, then so is the phase.
phase :: (RealFloat a) => Complex a -> a

-- | The conjugate of a complex number.
conjugate :: Num a => Complex a -> Complex a
instance Data.Traversable.Traversable Data.Complex.Complex
instance Data.Foldable.Foldable Data.Complex.Complex
instance GHC.Base.Functor Data.Complex.Complex
instance GHC.Generics.Generic1 Data.Complex.Complex
instance GHC.Generics.Generic (Data.Complex.Complex a)
instance Data.Data.Data a => Data.Data.Data (Data.Complex.Complex a)
instance GHC.Read.Read a => GHC.Read.Read (Data.Complex.Complex a)
instance GHC.Show.Show a => GHC.Show.Show (Data.Complex.Complex a)
instance GHC.Classes.Eq a => GHC.Classes.Eq (Data.Complex.Complex a)
instance GHC.Float.RealFloat a => GHC.Num.Num (Data.Complex.Complex a)
instance GHC.Float.RealFloat a => GHC.Real.Fractional (Data.Complex.Complex a)
instance GHC.Float.RealFloat a => GHC.Float.Floating (Data.Complex.Complex a)
instance Foreign.Storable.Storable a => Foreign.Storable.Storable (Data.Complex.Complex a)
instance GHC.Base.Applicative Data.Complex.Complex
instance GHC.Base.Monad Data.Complex.Complex
