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


-- | Basic libraries
°5u
°5uThis package contains the <a>Prelude</a> and its support libraries,
°5uand a large collection of useful libraries ranging from data
°5ustructures 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
°5uattributed.
stopProfTimer :: IO ()

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

module GHC.IO.Encoding.CodePage

module GHC.Constants


-- | NB. the contents of this module are only available on Windows.
°5u
°5uInstalling 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.
°5u
°5u<h4><b>Examples</b></h4>
°5u
°5u<pre>
°5u&gt;&gt;&gt; curry fst 1 2
°5u1
°5u</pre>
curry :: ((a, b) -> c) -> a -> b -> c

-- | <a>uncurry</a> converts a curried function to a function on pairs.
°5u
°5u<h4><b>Examples</b></h4>
°5u
°5u<pre>
°5u&gt;&gt;&gt; uncurry (+) (1,2)
°5u3
°5u</pre>
°5u
°5u<pre>
°5u&gt;&gt;&gt; uncurry ($) (show, 1)
°5u"1"
°5u</pre>
°5u
°5u<pre>
°5u&gt;&gt;&gt; map (uncurry max) [(1,2), (3,4), (6,8)]
°5u[2,4,8]
°5u</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
°5u<tt><a>Maybe</a> a</tt> either contains a value of type <tt>a</tt>
°5u(represented as <tt><a>Just</a> a</tt>), or it is empty (represented
°5uas <a>Nothing</a>). Using <a>Maybe</a> is a good way to deal with
°5uerrors or exceptional cases without resorting to drastic measures such
°5uas <a>error</a>.
°5u
°5uThe <a>Maybe</a> type is also a monad. It is a simple kind of error
°5umonad, where all errors are represented by <a>Nothing</a>. A richer
°5uerror 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
°5u<a>Maybe</a> value. If the <a>Maybe</a> value is <a>Nothing</a>, the
°5ufunction returns the default value. Otherwise, it applies the function
°5uto the value inside the <a>Just</a> and returns the result.
°5u
°5u<h4><b>Examples</b></h4>
°5u
°5uBasic usage:
°5u
°5u<pre>
°5u&gt;&gt;&gt; maybe False odd (Just 3)
°5uTrue
°5u</pre>
°5u
°5u<pre>
°5u&gt;&gt;&gt; maybe False odd Nothing
°5uFalse
°5u</pre>
°5u
°5uRead an integer from a string using <tt>readMaybe</tt>. If we succeed,
°5ureturn twice the integer; that is, apply <tt>(*2)</tt> to it. If
°5uinstead we fail to parse an integer, return <tt>0</tt> by default:
°5u
°5u<pre>
°5u&gt;&gt;&gt; import Text.Read ( readMaybe )
°5u
°5u&gt;&gt;&gt; maybe 0 (*2) (readMaybe "5")
°5u10
°5u
°5u&gt;&gt;&gt; maybe 0 (*2) (readMaybe "")
°5u0
°5u</pre>
°5u
°5uApply <tt>show</tt> to a <tt>Maybe Int</tt>. If we have <tt>Just
°5un</tt>, we want to show the underlying <a>Int</a> <tt>n</tt>. But if
°5uwe have <a>Nothing</a>, we return the empty string instead of (for
°5uexample) "Nothing":
°5u
°5u<pre>
°5u&gt;&gt;&gt; maybe "" show (Just 5)
°5u"5"
°5u
°5u&gt;&gt;&gt; maybe "" show Nothing
°5u""
°5u</pre>
maybe :: b -> (a -> b) -> Maybe a -> b

-- | The <a>isJust</a> function returns <a>True</a> iff its argument is of
°5uthe form <tt>Just _</tt>.
°5u
°5u<h4><b>Examples</b></h4>
°5u
°5uBasic usage:
°5u
°5u<pre>
°5u&gt;&gt;&gt; isJust (Just 3)
°5uTrue
°5u</pre>
°5u
°5u<pre>
°5u&gt;&gt;&gt; isJust (Just ())
°5uTrue
°5u</pre>
°5u
°5u<pre>
°5u&gt;&gt;&gt; isJust Nothing
°5uFalse
°5u</pre>
°5u
°5uOnly the outer constructor is taken into consideration:
°5u
°5u<pre>
°5u&gt;&gt;&gt; isJust (Just Nothing)
°5uTrue
°5u</pre>
isJust :: Maybe a -> Bool

-- | The <a>isNothing</a> function returns <a>True</a> iff its argument is
°5u<a>Nothing</a>.
°5u
°5u<h4><b>Examples</b></h4>
°5u
°5uBasic usage:
°5u
°5u<pre>
°5u&gt;&gt;&gt; isNothing (Just 3)
°5uFalse
°5u</pre>
°5u
°5u<pre>
°5u&gt;&gt;&gt; isNothing (Just ())
°5uFalse
°5u</pre>
°5u
°5u<pre>
°5u&gt;&gt;&gt; isNothing Nothing
°5uTrue
°5u</pre>
°5u
°5uOnly the outer constructor is taken into consideration:
°5u
°5u<pre>
°5u&gt;&gt;&gt; isNothing (Just Nothing)
°5uFalse
°5u</pre>
isNothing :: Maybe a -> Bool

-- | The <a>fromJust</a> function extracts the element out of a <a>Just</a>
°5uand throws an error if its argument is <a>Nothing</a>.
°5u
°5u<h4><b>Examples</b></h4>
°5u
°5uBasic usage:
°5u
°5u<pre>
°5u&gt;&gt;&gt; fromJust (Just 1)
°5u1
°5u</pre>
°5u
°5u<pre>
°5u&gt;&gt;&gt; 2 * (fromJust (Just 10))
°5u20
°5u</pre>
°5u
°5u<pre>
°5u&gt;&gt;&gt; 2 * (fromJust Nothing)
°5u*** Exception: Maybe.fromJust: Nothing
°5u</pre>
fromJust :: Maybe a -> a

-- | The <a>fromMaybe</a> function takes a default value and and
°5u<a>Maybe</a> value. If the <a>Maybe</a> is <a>Nothing</a>, it returns
°5uthe default values; otherwise, it returns the value contained in the
°5u<a>Maybe</a>.
°5u
°5u<h4><b>Examples</b></h4>
°5u
°5uBasic usage:
°5u
°5u<pre>
°5u&gt;&gt;&gt; fromMaybe "" (Just "Hello, World!")
°5u"Hello, World!"
°5u</pre>
°5u
°5u<pre>
°5u&gt;&gt;&gt; fromMaybe "" Nothing
°5u""
°5u</pre>
°5u
°5uRead an integer from a string using <tt>readMaybe</tt>. If we fail to
°5uparse an integer, we want to return <tt>0</tt> by default:
°5u
°5u<pre>
°5u&gt;&gt;&gt; import Text.Read ( readMaybe )
°5u
°5u&gt;&gt;&gt; fromMaybe 0 (readMaybe "5")
°5u5
°5u
°5u&gt;&gt;&gt; fromMaybe 0 (readMaybe "")
°5u0
°5u</pre>
fromMaybe :: a -> Maybe a -> a

-- | The <a>listToMaybe</a> function returns <a>Nothing</a> on an empty
°5ulist or <tt><a>Just</a> a</tt> where <tt>a</tt> is the first element
°5uof the list.
°5u
°5u<h4><b>Examples</b></h4>
°5u
°5uBasic usage:
°5u
°5u<pre>
°5u&gt;&gt;&gt; listToMaybe []
°5uNothing
°5u</pre>
°5u
°5u<pre>
°5u&gt;&gt;&gt; listToMaybe [9]
°5uJust 9
°5u</pre>
°5u
°5u<pre>
°5u&gt;&gt;&gt; listToMaybe [1,2,3]
°5uJust 1
°5u</pre>
°5u
°5uComposing <a>maybeToList</a> with <a>listToMaybe</a> should be the
°5uidentity on singleton/empty lists:
°5u
°5u<pre>
°5u&gt;&gt;&gt; maybeToList $ listToMaybe [5]
°5u[5]
°5u
°5u&gt;&gt;&gt; maybeToList $ listToMaybe []
°5u[]
°5u</pre>
°5u
°5uBut not on lists with more than one element:
°5u
°5u<pre>
°5u&gt;&gt;&gt; maybeToList $ listToMaybe [1,2,3]
°5u[1]
°5u</pre>
listToMaybe :: [a] -> Maybe a

-- | The <a>maybeToList</a> function returns an empty list when given
°5u<a>Nothing</a> or a singleton list when not given <a>Nothing</a>.
°5u
°5u<h4><b>Examples</b></h4>
°5u
°5uBasic usage:
°5u
°5u<pre>
°5u&gt;&gt;&gt; maybeToList (Just 7)
°5u[7]
°5u</pre>
°5u
°5u<pre>
°5u&gt;&gt;&gt; maybeToList Nothing
°5u[]
°5u</pre>
°5u
°5uOne can use <a>maybeToList</a> to avoid pattern matching when combined
°5uwith a function that (safely) works on lists:
°5u
°5u<pre>
°5u&gt;&gt;&gt; import Text.Read ( readMaybe )
°5u
°5u&gt;&gt;&gt; sum $ maybeToList (readMaybe "3")
°5u3
°5u
°5u&gt;&gt;&gt; sum $ maybeToList (readMaybe "")
°5u0
°5u</pre>
maybeToList :: Maybe a -> [a]

-- | The <a>catMaybes</a> function takes a list of <a>Maybe</a>s and
°5ureturns a list of all the <a>Just</a> values.
°5u
°5u<h4><b>Examples</b></h4>
°5u
°5uBasic usage:
°5u
°5u<pre>
°5u&gt;&gt;&gt; catMaybes [Just 1, Nothing, Just 3]
°5u[1,3]
°5u</pre>
°5u
°5uWhen constructing a list of <a>Maybe</a> values, <a>catMaybes</a> can
°5ube used to return all of the "success" results (if the list is the
°5uresult of a <a>map</a>, then <a>mapMaybe</a> would be more
°5uappropriate):
°5u
°5u<pre>
°5u&gt;&gt;&gt; import Text.Read ( readMaybe )
°5u
°5u&gt;&gt;&gt; [readMaybe x :: Maybe Int | x &lt;- ["1", "Foo", "3"] ]
°5u[Just 1,Nothing,Just 3]
°5u
°5u&gt;&gt;&gt; catMaybes $ [readMaybe x :: Maybe Int | x &lt;- ["1", "Foo", "3"] ]
°5u[1,3]
°5u</pre>
catMaybes :: [Maybe a] -> [a]

-- | The <a>mapMaybe</a> function is a version of <a>map</a> which can
°5uthrow out elements. In particular, the functional argument returns
°5usomething of type <tt><a>Maybe</a> b</tt>. If this is <a>Nothing</a>,
°5uno element is added on to the result list. If it is <tt><a>Just</a>
°5ub</tt>, then <tt>b</tt> is included in the result list.
°5u
°5u<h4><b>Examples</b></h4>
°5u
°5uUsing <tt><a>mapMaybe</a> f x</tt> is a shortcut for
°5u<tt><a>catMaybes</a> $ <a>map</a> f x</tt> in most cases:
°5u
°5u<pre>
°5u&gt;&gt;&gt; import Text.Read ( readMaybe )
°5u
°5u&gt;&gt;&gt; let readMaybeInt = readMaybe :: String -&gt; Maybe Int
°5u
°5u&gt;&gt;&gt; mapMaybe readMaybeInt ["1", "Foo", "3"]
°5u[1,3]
°5u
°5u&gt;&gt;&gt; catMaybes $ map readMaybeInt ["1", "Foo", "3"]
°5u[1,3]
°5u</pre>
°5u
°5uIf we map the <a>Just</a> constructor, the entire list should be
°5ureturned:
°5u
°5u<pre>
°5u&gt;&gt;&gt; mapMaybe Just [1,2,3]
°5u[1,2,3]
°5u</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
°5u<a>map</a> function on lists.
module Data.Functor

-- | The <a>Functor</a> class is used for types that can be mapped over.
°5uInstances of <a>Functor</a> should satisfy the following laws:
°5u
°5u<pre>
°5ufmap id  ==  id
°5ufmap (f . g)  ==  fmap f . fmap g
°5u</pre>
°5u
°5uThe instances of <a>Functor</a> for lists, <a>Maybe</a> and <a>IO</a>
°5usatisfy 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
°5udefinition is <tt><a>fmap</a> . <a>const</a></tt>, but this may be
°5uoverridden with a more efficient version.
(<$) :: Functor f => a -> f b -> f a
infixl 4 <$

-- | Flipped version of <a>&lt;$</a>.
°5u
°5u<h4><b>Examples</b></h4>
°5u
°5uReplace the contents of a <tt><tt>Maybe</tt> <tt>Int</tt></tt> with a
°5uconstant <tt>String</tt>:
°5u
°5u<pre>
°5u&gt;&gt;&gt; Nothing $&gt; "foo"
°5uNothing
°5u
°5u&gt;&gt;&gt; Just 90210 $&gt; "foo"
°5uJust "foo"
°5u</pre>
°5u
°5uReplace the contents of an <tt><tt>Either</tt> <tt>Int</tt>
°5u<tt>Int</tt></tt> with a constant <tt>String</tt>, resulting in an
°5u<tt><tt>Either</tt> <tt>Int</tt> <tt>String</tt></tt>:
°5u
°5u<pre>
°5u&gt;&gt;&gt; Left 8675309 $&gt; "foo"
°5uLeft 8675309
°5u
°5u&gt;&gt;&gt; Right 8675309 $&gt; "foo"
°5uRight "foo"
°5u</pre>
°5u
°5uReplace each element of a list with a constant <tt>String</tt>:
°5u
°5u<pre>
°5u&gt;&gt;&gt; [1,2,3] $&gt; "foo"
°5u["foo","foo","foo"]
°5u</pre>
°5u
°5uReplace the second element of a pair with a constant <tt>String</tt>:
°5u
°5u<pre>
°5u&gt;&gt;&gt; (1,2) $&gt; "foo"
°5u(1,"foo")
°5u</pre>
($>) :: Functor f => f a -> b -> f b
infixl 4 $>

-- | An infix synonym for <a>fmap</a>.
°5u
°5uThe name of this operator is an allusion to <tt>$</tt>. Note the
°5usimilarities between their types:
°5u
°5u<pre>
°5u ($)  ::              (a -&gt; b) -&gt;   a -&gt;   b
°5u(&lt;$&gt;) :: Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
°5u</pre>
°5u
°5uWhereas <tt>$</tt> is function application, <a>&lt;$&gt;</a> is
°5ufunction application lifted over a <a>Functor</a>.
°5u
°5u<h4><b>Examples</b></h4>
°5u
°5uConvert from a <tt><tt>Maybe</tt> <tt>Int</tt></tt> to a
°5u<tt><tt>Maybe</tt> <tt>String</tt></tt> using <tt>show</tt>:
°5u
°5u<pre>
°5u&gt;&gt;&gt; show &lt;$&gt; Nothing
°5uNothing
°5u
°5u&gt;&gt;&gt; show &lt;$&gt; Just 3
°5uJust "3"
°5u</pre>
°5u
°5uConvert from an <tt><tt>Either</tt> <tt>Int</tt> <tt>Int</tt></tt> to
°5uan <tt><tt>Either</tt> <tt>Int</tt></tt> <tt>String</tt> using
°5u<tt>show</tt>:
°5u
°5u<pre>
°5u&gt;&gt;&gt; show &lt;$&gt; Left 17
°5uLeft 17
°5u
°5u&gt;&gt;&gt; show &lt;$&gt; Right 17
°5uRight "17"
°5u</pre>
°5u
°5uDouble each element of a list:
°5u
°5u<pre>
°5u&gt;&gt;&gt; (*2) &lt;$&gt; [1,2,3]
°5u[2,4,6]
°5u</pre>
°5u
°5uApply <tt>even</tt> to the second element of a pair:
°5u
°5u<pre>
°5u&gt;&gt;&gt; even &lt;$&gt; (2,2)
°5u(2,True)
°5u</pre>
(<$>) :: Functor f => (a -> b) -> f a -> f b
infixl 4 <$>

-- | Flipped version of <a>&lt;$&gt;</a>.
°5u
°5u<pre>
°5u(<a>&lt;&amp;&gt;</a>) = <a>flip</a> <a>fmap</a>
°5u</pre>
°5u
°5u<h4><b>Examples</b></h4>
°5u
°5uApply <tt>(+1)</tt> to a list, a <a>Just</a> and a <a>Right</a>:
°5u
°5u<pre>
°5u&gt;&gt;&gt; Just 2 &lt;&amp;&gt; (+1)
°5uJust 3
°5u</pre>
°5u
°5u<pre>
°5u&gt;&gt;&gt; [1,2,3] &lt;&amp;&gt; (+1)
°5u[2,3,4]
°5u</pre>
°5u
°5u<pre>
°5u&gt;&gt;&gt; Right 3 &lt;&amp;&gt; (+1)
°5uRight 4
°5u</pre>
(<&>) :: Functor f => f a -> (a -> b) -> f b
infixl 1 <&>

-- | <tt><a>void</a> value</tt> discards or ignores the result of
°5uevaluation, such as the return value of an <a>IO</a> action.
°5u
°5u<h4><b>Examples</b></h4>
°5u
°5uReplace the contents of a <tt><tt>Maybe</tt> <tt>Int</tt></tt> with
°5uunit:
°5u
°5u<pre>
°5u&gt;&gt;&gt; void Nothing
°5uNothing
°5u
°5u&gt;&gt;&gt; void (Just 3)
°5uJust ()
°5u</pre>
°5u
°5uReplace the contents of an <tt><tt>Either</tt> <tt>Int</tt>
°5u<tt>Int</tt></tt> with unit, resulting in an <tt><tt>Either</tt>
°5u<tt>Int</tt> '()'</tt>:
°5u
°5u<pre>
°5u&gt;&gt;&gt; void (Left 8675309)
°5uLeft 8675309
°5u
°5u&gt;&gt;&gt; void (Right 8675309)
°5uRight ()
°5u</pre>
°5u
°5uReplace every element of a list with unit:
°5u
°5u<pre>
°5u&gt;&gt;&gt; void [1,2,3]
°5u[(),(),()]
°5u</pre>
°5u
°5uReplace the second element of a pair with unit:
°5u
°5u<pre>
°5u&gt;&gt;&gt; void (1,2)
°5u(1,())
°5u</pre>
°5u
°5uDiscard the result of an <a>IO</a> action:
°5u
°5u<pre>
°5u&gt;&gt;&gt; mapM print [1,2]
°5u1
°5u2
°5u[(),()]
°5u
°5u&gt;&gt;&gt; void $ mapM print [1,2]
°5u1
°5u2
°5u</pre>
void :: Functor f => f a -> f ()


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

-- | Identity function.
°5u
°5u<pre>
°5uid x = x
°5u</pre>
id :: a -> a

-- | <tt>const x</tt> is a unary function which evaluates to <tt>x</tt> for
°5uall inputs.
°5u
°5u<pre>
°5u&gt;&gt;&gt; const 42 "hello"
°5u42
°5u</pre>
°5u
°5u<pre>
°5u&gt;&gt;&gt; map (const 42) [0..3]
°5u[42,42,42,42]
°5u</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
°5uorder of <tt>f</tt>.
°5u
°5u<pre>
°5u&gt;&gt;&gt; flip (++) "hello" "world"
°5u"worldhello"
°5u</pre>
flip :: (a -> b -> c) -> b -> a -> c

-- | Application operator. This operator is redundant, since ordinary
°5uapplication <tt>(f x)</tt> means the same as <tt>(f <a>$</a> x)</tt>.
°5uHowever, <a>$</a> has low, right-associative binding precedence, so it
°5usometimes allows parentheses to be omitted; for example:
°5u
°5u<pre>
°5uf $ g $ h x  =  f (g (h x))
°5u</pre>
°5u
°5uIt is also useful in higher-order situations, such as <tt><a>map</a>
°5u(<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
°5unotational convenience. Its precedence is one higher than that of the
°5uforward application operator <a>$</a>, which allows <a>&amp;</a> to be
°5unested in <a>$</a>.
°5u
°5u<pre>
°5u&gt;&gt;&gt; 5 &amp; (+1) &amp; show
°5u"6"
°5u</pre>
(&) :: a -> (a -> b) -> b
infixl 1 &

-- | <tt><a>fix</a> f</tt> is the least fixed point of the function
°5u<tt>f</tt>, i.e. the least defined <tt>x</tt> such that <tt>f x =
°5ux</tt>.
°5u
°5uFor example, we can write the factorial function using direct
°5urecursion as
°5u
°5u<pre>
°5u&gt;&gt;&gt; let fac n = if n &lt;= 1 then 1 else n * fac (n-1) in fac 5
°5u120
°5u</pre>
°5u
°5uThis uses the fact that Haskell’s <tt>let</tt> introduces recursive
°5ubindings. We can rewrite this definition using <a>fix</a>,
°5u
°5u<pre>
°5u&gt;&gt;&gt; fix (\rec n -&gt; if n &lt;= 1 then 1 else n * rec (n-1)) 5
°5u120
°5u</pre>
°5u
°5uInstead of making a recursive call, we introduce a dummy parameter
°5u<tt>rec</tt>; when used within <a>fix</a>, this parameter then refers
°5uto <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
°5u(<a>/=</a>). All the basic datatypes exported by the <a>Prelude</a>
°5uare instances of <a>Eq</a>, and <a>Eq</a> may be derived for any
°5udatatype whose constituents are also instances of <a>Eq</a>.
°5u
°5uMinimal 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.
°5u
°5uMore 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
°5uvalues of types that have the same representation with no run-time
°5uoverhead. In the simplest case you can use it instead of a newtype
°5uconstructor, to go from the newtype's concrete type to the abstract
°5utype. But it also works in more complicated settings, e.g. converting
°5ua 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
°5utypes <tt>a</tt> and <tt>b</tt> if the compiler can infer that they
°5uhave the same representation. This class does not have regular
°5uinstances; instead they are created on-the-fly during type-checking.
°5uTrying to manually declare an instance of <tt>Coercible</tt> is an
°5uerror.
°5u
°5uNevertheless one can pretend that the following three kinds of
°5uinstances exist. First, as a trivial base-case:
°5u
°5u<pre>
°5uinstance Coercible a a
°5u</pre>
°5u
°5uFurthermore, for every type constructor there is an instance that
°5uallows to coerce under the type constructor. For example, let
°5u<tt>D</tt> be a prototypical type constructor (<tt>data</tt> or
°5u<tt>newtype</tt>) with three type arguments, which have roles
°5u<tt>nominal</tt>, <tt>representational</tt> resp. <tt>phantom</tt>.
°5uThen there is an instance of the form
°5u
°5u<pre>
°5uinstance Coercible b b' =&gt; Coercible (D a b c) (D a b' c')
°5u</pre>
°5u
°5uNote that the <tt>nominal</tt> type arguments are equal, the
°5u<tt>representational</tt> type arguments can differ, but need to have
°5ua <tt>Coercible</tt> instance themself, and the <tt>phantom</tt> type
°5uarguments can be changed arbitrarily.
°5u
°5uThe third kind of instance exists for every <tt>newtype NT = MkNT
°5uT</tt> and comes in two variants, namely
°5u
°5u<pre>
°5uinstance Coercible a T =&gt; Coercible a NT
°5u</pre>
°5u
°5u<pre>
°5uinstance Coercible T b =&gt; Coercible NT b
°5u</pre>
°5u
°5uThis instance is only usable if the constructor <tt>MkNT</tt> is in
°5uscope.
°5u
°5uIf, as a library author of a type constructor like <tt>Set a</tt>, you
°5uwant to prevent a user of your module to write <tt>coerce :: Set T
°5u-&gt; Set NT</tt>, you need to set the role of <tt>Set</tt>'s type
°5uparameter to <tt>nominal</tt>, by writing
°5u
°5u<pre>
°5utype role Set nominal
°5u</pre>
°5u
°5uFor more details about this feature, please refer to <a>Safe
°5uCoercions</a> by Joachim Breitner, Richard A. Eisenberg, Simon Peyton
°5uJones 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
°5uguards more readable. eg.
°5u
°5u<pre>
°5uf x | x &lt; 0     = ...
°5u    | otherwise = ...
°5u</pre>
otherwise :: Bool

-- | Case analysis for the <a>Bool</a> type. <tt><a>bool</a> x y p</tt>
°5uevaluates to <tt>x</tt> when <tt>p</tt> is <a>False</a>, and evaluates
°5uto <tt>y</tt> when <tt>p</tt> is <a>True</a>.
°5u
°5uThis is equivalent to <tt>if p then y else x</tt>; that is, one can
°5uthink of it as an if-then-else construct with its arguments reordered.
°5u
°5u<h4><b>Examples</b></h4>
°5u
°5uBasic usage:
°5u
°5u<pre>
°5u&gt;&gt;&gt; bool "foo" "bar" True
°5u"bar"
°5u
°5u&gt;&gt;&gt; bool "foo" "bar" False
°5u"foo"
°5u</pre>
°5u
°5uConfirm that <tt><a>bool</a> x y p</tt> and <tt>if p then y else
°5ux</tt> are equivalent:
°5u
°5u<pre>
°5u&gt;&gt;&gt; let p = True; x = "bar"; y = "foo"
°5u
°5u&gt;&gt;&gt; bool x y p == if p then y else x
°5uTrue
°5u
°5u&gt;&gt;&gt; let p = False
°5u
°5u&gt;&gt;&gt; bool x y p == if p then y else x
°5uTrue
°5u</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
°5uFalse 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
°5uintegers. Instances of the class <a>Bits</a> for the <a>Int</a> and
°5u<a>Integer</a> types are available from this module, and instances for
°5uexplicitly sized integral types are available from the <a>Data.Int</a>
°5uand <a>Data.Word</a> modules.
module Data.Bits

-- | The <a>Bits</a> class defines bitwise operations over integral types.
°5u
°5u<ul>
°5u<li>Bits are numbered from 0 with bit 0 being the least significant
°5ubit.</li>
°5u</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
°5u<tt>i</tt> is positive, or right by <tt>-i</tt> bits otherwise. Right
°5ushifts perform sign extension on signed number types; i.e. they fill
°5uthe top bits with 1 if the <tt>x</tt> is negative and with 0
°5uotherwise.
°5u
°5uAn instance can define either this unified <a>shift</a> or
°5u<a>shiftL</a> and <a>shiftR</a>, depending on which is more convenient
°5ufor 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
°5uif <tt>i</tt> is positive, or right by <tt>-i</tt> bits otherwise.
°5u
°5uFor unbounded types like <a>Integer</a>, <a>rotate</a> is equivalent
°5uto <a>shift</a>.
°5u
°5uAn instance can define either this unified <a>rotate</a> or
°5u<a>rotateL</a> and <a>rotateR</a>, depending on which is more
°5uconvenient for the type in question.
rotate :: Bits a => a -> Int -> a

-- | <a>zeroBits</a> is the value with all bits unset.
°5u
°5uThe following laws ought to hold (for all valid bit indices
°5u<tt><i>n</i></tt>):
°5u
°5u<ul>
°5u<li><pre><a>clearBit</a> <a>zeroBits</a> <i>n</i> ==
°5u<a>zeroBits</a></pre></li>
°5u<li><pre><a>setBit</a> <a>zeroBits</a> <i>n</i> == <a>bit</a>
°5u<i>n</i></pre></li>
°5u<li><pre><a>testBit</a> <a>zeroBits</a> <i>n</i> == False</pre></li>
°5u<li><pre><a>popCount</a> <a>zeroBits</a> == 0</pre></li>
°5u</ul>
°5u
°5uThis method uses <tt><a>clearBit</a> (<a>bit</a> 0) 0</tt> as its
°5udefault implementation (which ought to be equivalent to
°5u<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
°5uand all other bits clear.
°5u
°5uCan be implemented using <a>bitDefault</a> if <tt>a</tt> is also an
°5uinstance of <a>Num</a>.
°5u
°5uSee 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
°5ui)</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
°5u
°5uCan be implemented using <a>testBitDefault</a> if <tt>a</tt> is also
°5uan instance of <a>Num</a>.
testBit :: Bits a => a -> Int -> Bool

-- | Return the number of bits in the type of the argument. The actual
°5uvalue of the argument is ignored. Returns Nothing for types that do
°5unot 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
°5uvalue of the argument is ignored. The function <a>bitSize</a> is
°5uundefined for types that do not have a fixed bitsize, like
°5u<a>Integer</a>.

-- | <i>Deprecated: Use <a>bitSizeMaybe</a> or <a>finiteBitSize</a>
°5uinstead</i>
bitSize :: Bits a => a -> Int

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

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

-- | Shift the argument left by the specified number of bits. The result is
°5uundefined for negative shift amounts and shift amounts greater or
°5uequal to the <a>bitSize</a>.
°5u
°5uDefaults 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
°5uresult is undefined for negative shift amounts and shift amounts
°5ugreater or equal to the <a>bitSize</a>.
°5u
°5uRight shifts perform sign extension on signed number types; i.e. they
°5ufill the top bits with 1 if the <tt>x</tt> is negative and with 0
°5uotherwise.
°5u
°5uAn instance can define either this and <a>shiftL</a> or the unified
°5u<a>shift</a>, depending on which is more convenient for the type in
°5uquestion.
shiftR :: Bits a => a -> Int -> a

-- | Shift the first argument right by the specified number of bits, which
°5umust be non-negative and smaller than the number of bits in the type.
°5u
°5uRight shifts perform sign extension on signed number types; i.e. they
°5ufill the top bits with 1 if the <tt>x</tt> is negative and with 0
°5uotherwise.
°5u
°5uDefaults 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
°5ube non-negative).
°5u
°5uAn instance can define either this and <a>rotateR</a> or the unified
°5u<a>rotate</a>, depending on which is more convenient for the type in
°5uquestion.
rotateL :: Bits a => a -> Int -> a

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

-- | Return the number of set bits in the argument. This number is known as
°5uthe population count or the Hamming weight.
°5u
°5uCan be implemented using <a>popCountDefault</a> if <tt>a</tt> is also
°5uan instance of <a>Num</a>.
popCount :: Bits a => a -> Int

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

-- | Return the number of bits in the type of the argument. The actual
°5uvalue of the argument is ignored. Moreover, <a>finiteBitSize</a> is
°5utotal, in contrast to the deprecated <a>bitSize</a> function it
°5ureplaces.
°5u
°5u<pre>
°5u<a>finiteBitSize</a> = <a>bitSize</a>
°5u<a>bitSizeMaybe</a> = <a>Just</a> . <a>finiteBitSize</a>
°5u</pre>
finiteBitSize :: FiniteBits b => b -> Int

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

-- | Count number of zero bits following the least significant set bit.
°5u
°5u<pre>
°5u<a>countTrailingZeros</a> (<a>zeroBits</a> :: a) = finiteBitSize (<a>zeroBits</a> :: a)
°5u<a>countTrailingZeros</a> . <a>negate</a> = <a>countTrailingZeros</a>
°5u</pre>
°5u
°5uThe related <a>find-first-set operation</a> can be expressed in terms
°5uof <a>countTrailingZeros</a> as follows
°5u
°5u<pre>
°5ufindFirstSet x = 1 + <a>countTrailingZeros</a> x
°5u</pre>
°5u
°5uNote: The default implementation for this method is intentionally
°5unaive. However, the instances provided for the primitive integral
°5utypes are implemented using CPU specific machine instructions.
countTrailingZeros :: FiniteBits b => b -> Int

-- | Default implementation for <a>bit</a>.
°5u
°5uNote that: <tt>bitDefault i = 1 <a>shiftL</a> i</tt>
bitDefault :: (Bits a, Num a) => Int -> a

-- | Default implementation for <a>testBit</a>.
°5u
°5uNote 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>.
°5u
°5uThis implementation is intentionally naive. Instances are expected to
°5uprovide 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
°5u<a>Integral</a> type <tt>b</tt> using the size of the types as
°5umeasured by <a>Bits</a> methods.
°5u
°5uA simpler version of this function is:
°5u
°5u<pre>
°5utoIntegral :: (Integral a, Integral b) =&gt; a -&gt; Maybe b
°5utoIntegral x
°5u  | toInteger x == y = Just (fromInteger y)
°5u  | otherwise        = Nothing
°5u  where
°5u    y = toInteger x
°5u</pre>
°5u
°5uThis version requires going through <a>Integer</a>, which can be
°5uinefficient. However, <tt>toIntegralSized</tt> is optimized to allow
°5uGHC to statically determine the relative type sizes (as measured by
°5u<a>bitSizeMaybe</a> and <a>isSigned</a>) and avoid going through
°5u<a>Integer</a> for many types. (The implementation uses
°5u<a>fromIntegral</a>, which is itself optimized with rules for
°5u<tt>base</tt> types but may go through <a>Integer</a> for some type
°5upairs.)
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
°5uinstances.
°5u
°5uThis module can be imported for defining forward compatible
°5u<a>MonadFail</a> instances:
°5u
°5u<pre>
°5uimport qualified Control.Monad.Fail as Fail
°5u
°5uinstance Monad Foo where
°5u  (&gt;&gt;=) = {- ...bind impl... -}
°5u
°5u  -- Provide legacy <a>fail</a> implementation for when
°5u  -- new-style MonadFail desugaring is not enabled.
°5u  fail = Fail.fail
°5u
°5uinstance Fail.MonadFail Foo where
°5u  fail = {- ...fail implementation... -}
°5u</pre>
°5u
°5uSee
°5u<a>https://prime.haskell.org/wiki/Libraries/Proposals/MonadFail</a>
°5ufor more details.
module Control.Monad.Fail

-- | When a value is bound in <tt>do</tt>-notation, the pattern on the left
°5uhand side of <tt>&lt;-</tt> might not match. In this case, this class
°5uprovides a function to recover.
°5u
°5uA <a>Monad</a> without a <a>MonadFail</a> instance may only be used in
°5uconjunction with pattern that always match, such as newtypes, tuples,
°5udata types with only a single data constructor, and irrefutable
°5upatterns (<tt>~pat</tt>).
°5u
°5uInstances of <a>MonadFail</a> should satisfy the following law:
°5u<tt>fail s</tt> should be a left zero for <tt>&gt;&gt;=</tt>,
°5u
°5u<pre>
°5ufail s &gt;&gt;= f  =  fail s
°5u</pre>
°5u
°5uIf your <a>Monad</a> is also <tt>MonadPlus</tt>, a popular definition
°5uis
°5u
°5u<pre>
°5ufail _ = mzero
°5u</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
°5uClaessen. It parses all alternatives in parallel, so it never keeps
°5uhold of the beginning of the input string, a common source of space
°5uleaks with other parsers. The '(+++)' choice combinator is genuinely
°5ucommutative; 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
°5uleft.
get :: ReadP Char

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

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

-- | Local, exclusive, left-biased choice: If left parser locally produces
°5uany 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
°5ureturns the exact characters read. IMPORTANT NOTE: <a>gather</a> gives
°5ua runtime error if its first argument is built using any occurrences
°5uof 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
°5upredicate.
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.
°5uAlways succeeds, exactly once having consumed all the characters Hence
°5uNOT the same as (many (satisfy p))
munch :: (Char -> Bool) -> ReadP String

-- | Parses the first one or more characters satisfying the predicate.
°5uFails if none, else succeeds exactly once having consumed all the
°5ucharacters 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
°5usequence. A list of results is returned.
count :: Int -> ReadP a -> ReadP [a]

-- | <tt>between open close p</tt> parses <tt>open</tt>, followed by
°5u<tt>p</tt> and finally <tt>close</tt>. Only the value of <tt>p</tt> is
°5ureturned.
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>
°5uwithout consuming any input.
option :: a -> ReadP a -> ReadP a

-- | <tt>optional p</tt> optionally parses <tt>p</tt> and always returns
°5u<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>,
°5useparated by <tt>sep</tt>. Returns a list of values returned by
°5u<tt>p</tt>.
sepBy :: ReadP a -> ReadP sep -> ReadP [a]

-- | <tt>sepBy1 p sep</tt> parses one or more occurrences of <tt>p</tt>,
°5useparated by <tt>sep</tt>. Returns a list of values returned by
°5u<tt>p</tt>.
sepBy1 :: ReadP a -> ReadP sep -> ReadP [a]

-- | <tt>endBy p sep</tt> parses zero or more occurrences of <tt>p</tt>,
°5useparated 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>,
°5useparated 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>,
°5useparated by <tt>op</tt>. Returns a value produced by a <i>right</i>
°5uassociative application of all functions returned by <tt>op</tt>. If
°5uthere 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>,
°5useparated by <tt>op</tt>. Returns a value produced by a <i>left</i>
°5uassociative application of all functions returned by <tt>op</tt>. If
°5uthere 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>,
°5uuntil <tt>end</tt> succeeds. Returns a list of values returned by
°5u<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
°5u<a>String</a> and returns a list of possible parses as
°5u<tt>(a,<a>String</a>)</tt> pairs.
°5u
°5uNote that this kind of backtracking parser is very inefficient;
°5ureading 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
°5umain way in which you can "run" a <a>ReadP</a> parser: the expanded
°5utype is <tt> readP_to_S :: ReadP a -&gt; String -&gt; [(a,String)]
°5u</tt>
readP_to_S :: ReadP a -> ReadS a

-- | Converts a Haskell ReadS-style function into a parser. Warning: This
°5uintroduces local backtracking in the resulting parser, and therefore a
°5upossible 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
°5uor equal to <tt>n</tt>, and
°5u
°5u<ul>
°5u<li>if not, fails</li>
°5u<li>if so, parses <tt>p</tt> in context <tt>n</tt>.</li>
°5u</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
°5uleft.
get :: ReadPrec Char

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

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

-- | Local, exclusive, left-biased choice: If left parser locally produces
°5uany 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
°5u<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
°5uspecified by the first argument, and the character representation
°5uspecified 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)
°5unotation (e.g. <tt>2.45e2</tt>, <tt>1.5e-3</tt>).
°5u
°5uIn the call <tt><a>showEFloat</a> digs val</tt>, if <tt>digs</tt> is
°5u<a>Nothing</a>, the value is shown to full precision; if <tt>digs</tt>
°5uis <tt><a>Just</a> d</tt>, then at most <tt>d</tt> digits after the
°5udecimal point are shown.
showEFloat :: (RealFloat a) => Maybe Int -> a -> ShowS

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

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

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

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

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

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

-- | <a>floatToDigits</a> takes a base and a non-negative <a>RealFloat</a>
°5unumber, and returns a list of digits and an exponent. In particular,
°5uif <tt>x&gt;=0</tt>, and
°5u
°5u<pre>
°5ufloatToDigits base x = ([d1,d2,...,dn], e)
°5u</pre>
°5u
°5uthen
°5u
°5u<ol>
°5u<li><pre>n &gt;= 1</pre></li>
°5u<li><pre>x = 0.d1d2...dn * (base**e)</pre></li>
°5u<li><pre>0 &lt;= di &lt;= base-1</pre></li>
°5u</ol>
floatToDigits :: (RealFloat a) => Integer -> a -> ([Int], Int)

-- | Reads a <i>signed</i> <a>Real</a> value, given a reader for an
°5uunsigned 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.
°5u
°5u<pre>
°5u&gt;&gt;&gt; readDec "0644"
°5u[(644,"")]
°5u</pre>
readDec :: (Eq a, Num a) => ReadS a

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

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

-- | Reads an <i>unsigned</i> <a>RealFrac</a> value, expressed in decimal
°5uscientific 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
°5u<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, log, sqrt :: Floating a => a -> a
exp, log, sqrt :: Floating a => a -> a
exp, log, sqrt :: Floating a => a -> a
(**, logBase) :: Floating a => a -> a -> a
(**, logBase) :: Floating a => a -> a -> a
sin, cos, tan :: Floating a => a -> a
sin, cos, tan :: Floating a => a -> a
sin, cos, tan :: Floating a => a -> a
asin, acos, atan :: Floating a => a -> a
asin, acos, atan :: Floating a => a -> a
asin, acos, atan :: Floating a => a -> a
sinh, cosh, tanh :: Floating a => a -> a
sinh, cosh, tanh :: Floating a => a -> a
sinh, cosh, tanh :: Floating a => a -> a
asinh, acosh, atanh :: Floating a => a -> a
asinh, acosh, atanh :: Floating a => a -> a
asinh, acosh, atanh :: Floating a => a -> a

-- | <tt><a>log1p</a> x</tt> computes <tt><a>log</a> (1 + x)</tt>, but
°5uprovides more precise results for small (absolute) values of
°5u<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
°5uprovides more precise results for small (absolute) values of
°5u<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>
°5ux)</tt>, but provides more precise results if possible.
°5u
°5uExamples:
°5u
°5u<ul>
°5u<li>if <tt>x</tt> is a large negative number, <tt><a>log</a> (1 +
°5u<a>exp</a> x)</tt> will be imprecise for the reasons given in
°5u<a>log1p</a>.</li>
°5u<li>if <tt><a>exp</a> x</tt> is close to <tt>-1</tt>, <tt><a>log</a>
°5u(1 + <a>exp</a> x)</tt> will be imprecise for the reasons given in
°5u<a>expm1</a>.</li>
°5u</ul>
log1pexp :: Floating a => a -> a

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


-- | This module is part of the Foreign Function Interface (FFI) and will
°5uusually 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
°5uguaranteed not to be affected by garbage collection, i.e., it will
°5uneither be deallocated nor will the value of the stable pointer itself
°5uchange during garbage collection (ordinary references may be relocated
°5uduring garbage collection). Consequently, stable pointers can be
°5upassed to foreign code, which can treat it as an opaque reference to a
°5uHaskell value.
°5u
°5uA value of type <tt>StablePtr a</tt> is a stable pointer to a Haskell
°5uexpression 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
°5usame value that was passed to the corresponding call to
°5u<tt>makeStablePtr</tt>. If the argument to <a>deRefStablePtr</a> has
°5ualready been freed using <a>freeStablePtr</a>, the behaviour of
°5u<a>deRefStablePtr</a> is undefined.
deRefStablePtr :: StablePtr a -> IO a

-- | Dissolve the association between the stable pointer and the Haskell
°5uvalue. Afterwards, if the stable pointer is passed to
°5u<a>deRefStablePtr</a> or <a>freeStablePtr</a>, the behaviour is
°5uundefined. However, the stable pointer may still be passed to
°5u<a>castStablePtrToPtr</a>, but the <tt><a>Ptr</a> ()</tt> value
°5ureturned by <a>castStablePtrToPtr</a>, in this case, is undefined (in
°5uparticular, it may be <a>nullPtr</a>). Nevertheless, the call to
°5u<a>castStablePtrToPtr</a> is guaranteed not to diverge.
freeStablePtr :: StablePtr a -> IO ()

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

-- | The inverse of <a>castStablePtrToPtr</a>, i.e., we have the identity
°5u
°5u<pre>
°5usp == castPtrToStablePtr (castStablePtrToPtr sp)
°5u</pre>
°5u
°5ufor any stable pointer <tt>sp</tt> on which <a>freeStablePtr</a> has
°5unot been executed yet. Moreover, <a>castPtrToStablePtr</a> may only be
°5uapplied to pointers that have been produced by
°5u<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
°5ufor marshalling and is part of the language-independent portion of the
°5uForeign Function Interface (FFI), and will normally be imported via
°5uthe <a>Foreign</a> module.
module Foreign.Storable

-- | The member functions of this class facilitate writing values of
°5uprimitive types to raw memory (which may have been allocated with the
°5uabove mentioned routines) and reading values from blocks of raw
°5umemory. The class, furthermore, includes support for computing the
°5ustorage requirements and alignment restrictions of storable types.
°5u
°5uMemory addresses are represented as values of type <tt><a>Ptr</a>
°5ua</tt>, for some <tt>a</tt> which is an instance of class
°5u<a>Storable</a>. The type argument to <a>Ptr</a> helps provide some
°5uvaluable type safety in FFI code (you can't mix pointers of different
°5utypes without an explicit cast), while helping the Haskell type system
°5ufigure out which marshalling method is needed for a given pointer.
°5u
°5uAll marshalling between Haskell and a foreign language ultimately
°5uboils down to translating Haskell data structures into the binary
°5urepresentation of a corresponding data structure of the foreign
°5ulanguage and vice versa. To code this marshalling in Haskell, it is
°5unecessary to manipulate primitive data types stored in unstructured
°5umemory blocks. The class <a>Storable</a> facilitates this manipulation
°5uon all types for which it is instantiated, which are the standard
°5ubasic types of Haskell, the fixed size <tt>Int</tt> types
°5u(<a>Int8</a>, <a>Int16</a>, <a>Int32</a>, <a>Int64</a>), the fixed
°5usize <tt>Word</tt> types (<a>Word8</a>, <a>Word16</a>, <a>Word32</a>,
°5u<a>Word64</a>), <a>StablePtr</a>, all types from
°5u<a>Foreign.C.Types</a>, as well as <a>Ptr</a>.
class Storable a

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

-- | Computes the alignment constraint of the argument. An alignment
°5uconstraint <tt>x</tt> is fulfilled by any address divisible by
°5u<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
°5usame kind. The first argument specifies the start address of the array
°5uand the second the index into the array (the first element of the
°5uarray has index <tt>0</tt>). The following equality holds,
°5u
°5u<pre>
°5upeekElemOff addr idx = IOExts.fixIO $ \result -&gt;
°5u  peek (addr `plusPtr` (idx * sizeOf result))
°5u</pre>
°5u
°5uNote that this is only a specification, not necessarily the concrete
°5uimplementation 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
°5usame kind. The following equality holds:
°5u
°5u<pre>
°5upokeElemOff addr idx x = 
°5u  poke (addr `plusPtr` (idx * sizeOf x)) x
°5u</pre>
pokeElemOff :: Storable a => Ptr a -> Int -> a -> IO ()

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

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

-- | Read a value from the given memory location.
°5u
°5uNote that the peek and poke functions might require properly aligned
°5uaddresses to function correctly. This is architecture dependent; thus,
°5uportable code should ensure that when peeking or poking values of some
°5utype <tt>a</tt>, the alignment constraint for <tt>a</tt>, as given by
°5uthe function <a>alignment</a> is fulfilled.
peek :: Storable a => Ptr a -> IO a

-- | Write the given value to the given memory location. Alignment
°5urestrictions 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 ..
°5u2^29-1]</tt>. The exact range for a given implementation can be
°5udetermined by using <a>minBound</a> and <a>maxBound</a> from the
°5u<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
°5uForeign Function Interface (FFI) and will normally be imported via the
°5u<a>Foreign</a> module.
module Foreign.Ptr

-- | A value of type <tt><a>Ptr</a> a</tt> represents a pointer to an
°5uobject, or an array of objects, which may be marshalled to or from
°5uHaskell values of type <tt>a</tt>.
°5u
°5uThe type <tt>a</tt> will often be an instance of class <a>Storable</a>
°5uwhich provides the marshalling operations. However this is not
°5uessential, and you can provide your own operations to access the
°5upointer. For example you might write small foreign functions to get or
°5uset the fields of a C <tt>struct</tt>.
data Ptr a

-- | The constant <a>nullPtr</a> contains a distinguished value of
°5u<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,
°5u<a>alignPtr</a> yields the next higher address that fulfills the
°5ualignment constraint. An alignment constraint <tt>x</tt> is fulfilled
°5uby 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
°5uargument. We have
°5u
°5u<pre>
°5up2 == p1 `plusPtr` (p2 `minusPtr` p1)
°5u</pre>
minusPtr :: Ptr a -> Ptr b -> Int

-- | A value of type <tt><a>FunPtr</a> a</tt> is a pointer to a function
°5ucallable from foreign code. The type <tt>a</tt> will normally be a
°5u<i>foreign type</i>, a function type with zero or more arguments where
°5u
°5u<ul>
°5u<li>the argument types are <i>marshallable foreign types</i>, i.e.
°5u<a>Char</a>, <a>Int</a>, <a>Double</a>, <a>Float</a>, <a>Bool</a>,
°5u<a>Int8</a>, <a>Int16</a>, <a>Int32</a>, <a>Int64</a>, <a>Word8</a>,
°5u<a>Word16</a>, <a>Word32</a>, <a>Word64</a>, <tt><a>Ptr</a> a</tt>,
°5u<tt><a>FunPtr</a> a</tt>, <tt><a>StablePtr</a> a</tt> or a renaming of
°5uany of these using <tt>newtype</tt>.</li>
°5u<li>the return type is either a marshallable foreign type or has the
°5uform <tt><a>IO</a> t</tt> where <tt>t</tt> is a marshallable foreign
°5utype or <tt>()</tt>.</li>
°5u</ul>
°5u
°5uA value of type <tt><a>FunPtr</a> a</tt> may be a pointer to a foreign
°5ufunction, either returned by another foreign function or imported with
°5ua a static address import like
°5u
°5u<pre>
°5uforeign import ccall "stdlib.h &amp;free"
°5u  p_free :: FunPtr (Ptr a -&gt; IO ())
°5u</pre>
°5u
°5uor a pointer to a Haskell function created using a <i>wrapper</i> stub
°5udeclared to produce a <a>FunPtr</a> of the correct type. For example:
°5u
°5u<pre>
°5utype Compare = Int -&gt; Int -&gt; Bool
°5uforeign import ccall "wrapper"
°5u  mkCompare :: Compare -&gt; IO (FunPtr Compare)
°5u</pre>
°5u
°5uCalls to wrapper stubs like <tt>mkCompare</tt> allocate storage, which
°5ushould be released with <a>freeHaskellFunPtr</a> when no longer
°5urequired.
°5u
°5uTo convert <a>FunPtr</a> values to corresponding Haskell functions,
°5uone can define a <i>dynamic</i> stub for the specific foreign type,
°5ue.g.
°5u
°5u<pre>
°5utype IntFunction = CInt -&gt; IO ()
°5uforeign import ccall "dynamic"
°5u  mkFun :: FunPtr IntFunction -&gt; IntFunction
°5u</pre>
data FunPtr a

-- | The constant <a>nullFunPtr</a> contains a distinguished value of
°5u<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>.
°5u
°5u<i>Note:</i> this is valid only on architectures where data and
°5ufunction pointers range over the same set of addresses, and should
°5uonly be used for bindings to external libraries whose interface
°5ualready relies on this assumption.
castFunPtrToPtr :: FunPtr a -> Ptr b

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

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

-- | A signed integral type that can be losslessly converted to and from
°5u<tt>Ptr</tt>. This type is also compatible with the C99 type
°5u<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
°5u<tt>Ptr</tt>. This type is also compatible with the C99 type
°5u<tt>uintptr_t</tt>, and can be marshalled to and from that type
°5usafely.
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
°5u<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.
°5u
°5u<b>Note</b>: This is an internal GHC module with an API subject to
°5uchange. It's recommended use the <a>Numeric.Natural</a> module to
°5uimport the <a>Natural</a> type.
module GHC.Natural

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

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

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

-- | Test whether all internal invariants are satisfied by <a>Natural</a>
°5uvalue
°5u
°5uThis operation is mostly useful for test-suites and/or code which
°5uconstructs <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
°5u<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
°5uresults.
minusNaturalMaybe :: Natural -> Natural -> Maybe Natural

-- | "<tt><a>powModNatural</a> <i>b</i> <i>e</i> <i>m</i></tt>" computes
°5ubase <tt><i>b</i></tt> raised to exponent <tt><i>e</i></tt> modulo
°5u<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.
°5u
°5u<pre>
°5u&gt;&gt;&gt; 2^20 :: Natural
°5u1267650600228229401496703205376
°5u</pre>
°5u
°5uOperations whose result would be negative <tt><tt>throw</tt>
°5u(<tt>Underflow</tt> :: <tt>ArithException</tt>)</tt>,
°5u
°5u<pre>
°5u&gt;&gt;&gt; -1 :: Natural
°5u*** Exception: arithmetic underflow
°5u</pre>
data Natural

module GHC.Clock

-- | Return monotonic time in seconds, since some unspecified starting
°5upoint
getMonotonicTime :: IO Double

-- | Return monotonic time in nanoseconds, since some unspecified starting
°5upoint
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
°5uon a variable of type <tt>(a :~: b)</tt> produces a proof that <tt>a ~
°5ub</tt>.
module Data.Type.Equality

-- | Propositional equality. If <tt>a :~: b</tt> is inhabited by some
°5uterminating value, then the type <tt>a</tt> is the same as the type
°5u<tt>b</tt>. To use this equality in practice, pattern-match on the
°5u<tt>a :~: b</tt> to get out the <tt>Refl</tt> constructor; in the body
°5uof 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
°5ubogus (deferred type error). By heterogeneous, the two types
°5u<tt>a</tt> and <tt>b</tt> might have different kinds. Because
°5u<tt>~~</tt> can appear unexpectedly in error messages to users who do
°5unot care about the difference between heterogeneous equality
°5u<tt>~~</tt> and homogeneous equality <tt>~</tt>, this is printed as
°5u<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 :~~:
°5ub</tt> is inhabited by a terminating value if and only if <tt>a</tt>
°5uis 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
°5utypes
outer :: (f a :~: g b) -> (f :~: g)

-- | This class contains types where you can learn the equality of two
°5utypes from information contained in <i>terms</i>. Typically, only
°5usingleton 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
°5usome terminating value, then the type <tt>a</tt> has the same
°5uunderlying representation as the type <tt>b</tt>.
°5u
°5uTo use this equality in practice, pattern-match on the <tt>Coercion a
°5ub</tt> to get out the <tt>Coercible a b</tt> instance, and then use
°5u<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
°5utypes from information contained in <i>terms</i>. Typically, only
°5usingleton types should inhabit this class.
class TestCoercion f

-- | Conditionally prove the representational equality of <tt>a</tt> and
°5u<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
°5u
°5u<pre>
°5uf <a>.</a> <a>id</a>  =  f  -- (right identity)
°5u<a>id</a> <a>.</a> f  =  f  -- (left identity)
°5uf <a>.</a> (g <a>.</a> h)  =  (f <a>.</a> g) <a>.</a> h  -- (associativity)
°5u</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
°5uof arbitrary type (or even kind). Its use is to provide type
°5uinformation, even though there is no value available of that type (or
°5uit may be too costly to create one).
°5u
°5uHistorically, <tt><a>Proxy</a> :: <a>Proxy</a> a</tt> is a safer
°5ualternative to the <tt>'undefined :: a'</tt> idiom.
°5u
°5u<pre>
°5u&gt;&gt;&gt; Proxy :: Proxy (Void, Int -&gt; Int)
°5uProxy
°5u</pre>
°5u
°5uProxy can even hold types of higher kinds,
°5u
°5u<pre>
°5u&gt;&gt;&gt; Proxy :: Proxy Either
°5uProxy
°5u</pre>
°5u
°5u<pre>
°5u&gt;&gt;&gt; Proxy :: Proxy Functor
°5uProxy
°5u</pre>
°5u
°5u<pre>
°5u&gt;&gt;&gt; Proxy :: Proxy complicatedStructure
°5uProxy
°5u</pre>
data Proxy t
Proxy :: Proxy t

-- | <a>asProxyTypeOf</a> is a type-restricted version of <a>const</a>. It
°5uis usually used as an infix operator, and its typing forces its first
°5uargument (which is usually overloaded) to have the same type as the
°5utag of the second.
°5u
°5u<pre>
°5u&gt;&gt;&gt; import Data.Word
°5u
°5u&gt;&gt;&gt; :type asProxyTypeOf 123 (Proxy :: Proxy Word8)
°5uasProxyTypeOf 123 (Proxy :: Proxy Word8) :: Word8
°5u</pre>
°5u
°5uNote the lower-case <tt>proxy</tt> in the definition. This allows any
°5utype constructor with just one argument to be passed to the function,
°5ufor example we could also write
°5u
°5u<pre>
°5u&gt;&gt;&gt; import Data.Word
°5u
°5u&gt;&gt;&gt; :type asProxyTypeOf 123 (Just (undefined :: Word8))
°5uasProxyTypeOf 123 (Just (undefined :: Word8)) :: Word8
°5u</pre>
asProxyTypeOf :: a -> proxy a -> a

-- | A concrete, promotable proxy type, for use at the kind level There are
°5uno 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.
°5u
°5uInstances of <a>Ord</a> can be derived for any user-defined datatype
°5uwhose constituent types are in <a>Ord</a>. The declared order of the
°5uconstructors in the data declaration determines the ordering in
°5uderived <a>Ord</a> instances. The <a>Ordering</a> datatype allows a
°5usingle comparison to determine the precise ordering of two objects.
°5u
°5uMinimal complete definition: either <a>compare</a> or <a>&lt;=</a>.
°5uUsing <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
°5uvalue of type <tt><a>Down</a> a</tt> contains a value of type
°5u<tt>a</tt> (represented as <tt><a>Down</a> a</tt>). If <tt>a</tt> has
°5uan <tt><a>Ord</a></tt> instance associated with it then comparing two
°5uvalues thus wrapped will give you the opposite of their normal sort
°5uorder. This is particularly useful when sorting in generalised list
°5ucomprehensions, as in: <tt>then sortWith by <a>Down</a> x</tt>
newtype Down a
Down :: a -> Down a

-- | <pre>
°5ucomparing p x y = compare (p x) (p y)
°5u</pre>
°5u
°5uUseful combinator for use in conjunction with the <tt>xxxBy</tt>
°5ufamily of functions from <a>Data.List</a>, for example:
°5u
°5u<pre>
°5u... sortBy (comparing fst) ...
°5u</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
°5uvalue of type <tt><a>Either</a> a b</tt> is either <tt><a>Left</a>
°5ua</tt> or <tt><a>Right</a> b</tt>.
°5u
°5uThe <a>Either</a> type is sometimes used to represent a value which is
°5ueither correct or an error; by convention, the <a>Left</a> constructor
°5uis used to hold an error value and the <a>Right</a> constructor is
°5uused to hold a correct value (mnemonic: "right" also means "correct").
°5u
°5u<h4><b>Examples</b></h4>
°5u
°5uThe type <tt><a>Either</a> <a>String</a> <a>Int</a></tt> is the type
°5uof values which can be either a <a>String</a> or an <a>Int</a>. The
°5u<a>Left</a> constructor can be used only on <a>String</a>s, and the
°5u<a>Right</a> constructor can be used only on <a>Int</a>s:
°5u
°5u<pre>
°5u&gt;&gt;&gt; let s = Left "foo" :: Either String Int
°5u
°5u&gt;&gt;&gt; s
°5uLeft "foo"
°5u
°5u&gt;&gt;&gt; let n = Right 3 :: Either String Int
°5u
°5u&gt;&gt;&gt; n
°5uRight 3
°5u
°5u&gt;&gt;&gt; :type s
°5us :: Either String Int
°5u
°5u&gt;&gt;&gt; :type n
°5un :: Either String Int
°5u</pre>
°5u
°5uThe <a>fmap</a> from our <a>Functor</a> instance will ignore
°5u<a>Left</a> values, but will apply the supplied function to values
°5ucontained in a <a>Right</a>:
°5u
°5u<pre>
°5u&gt;&gt;&gt; let s = Left "foo" :: Either String Int
°5u
°5u&gt;&gt;&gt; let n = Right 3 :: Either String Int
°5u
°5u&gt;&gt;&gt; fmap (*2) s
°5uLeft "foo"
°5u
°5u&gt;&gt;&gt; fmap (*2) n
°5uRight 6
°5u</pre>
°5u
°5uThe <a>Monad</a> instance for <a>Either</a> allows us to chain
°5utogether multiple actions which may fail, and fail overall if any of
°5uthe individual steps failed. First we'll write a function that can
°5ueither parse an <a>Int</a> from a <a>Char</a>, or fail.
°5u
°5u<pre>
°5u&gt;&gt;&gt; import Data.Char ( digitToInt, isDigit )
°5u
°5u&gt;&gt;&gt; :{
°5u    let parseEither :: Char -&gt; Either String Int
°5u        parseEither c
°5u          | isDigit c = Right (digitToInt c)
°5u          | otherwise = Left "parse error"
°5u
°5u&gt;&gt;&gt; :}
°5u</pre>
°5u
°5uThe following should work, since both <tt>'1'</tt> and <tt>'2'</tt>
°5ucan be parsed as <a>Int</a>s.
°5u
°5u<pre>
°5u&gt;&gt;&gt; :{
°5u    let parseMultiple :: Either String Int
°5u        parseMultiple = do
°5u          x &lt;- parseEither '1'
°5u          y &lt;- parseEither '2'
°5u          return (x + y)
°5u
°5u&gt;&gt;&gt; :}
°5u</pre>
°5u
°5u<pre>
°5u&gt;&gt;&gt; parseMultiple
°5uRight 3
°5u</pre>
°5u
°5uBut the following should fail overall, since the first operation where
°5uwe attempt to parse <tt>'m'</tt> as an <a>Int</a> will fail:
°5u
°5u<pre>
°5u&gt;&gt;&gt; :{
°5u    let parseMultiple :: Either String Int
°5u        parseMultiple = do
°5u          x &lt;- parseEither 'm'
°5u          y &lt;- parseEither '2'
°5u          return (x + y)
°5u
°5u&gt;&gt;&gt; :}
°5u</pre>
°5u
°5u<pre>
°5u&gt;&gt;&gt; parseMultiple
°5uLeft "parse error"
°5u</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
°5u<tt><a>Left</a> a</tt>, apply the first function to <tt>a</tt>; if it
°5uis <tt><a>Right</a> b</tt>, apply the second function to <tt>b</tt>.
°5u
°5u<h4><b>Examples</b></h4>
°5u
°5uWe create two values of type <tt><a>Either</a> <a>String</a>
°5u<a>Int</a></tt>, one using the <a>Left</a> constructor and another
°5uusing the <a>Right</a> constructor. Then we apply "either" the
°5u<tt>length</tt> function (if we have a <a>String</a>) or the
°5u"times-two" function (if we have an <a>Int</a>):
°5u
°5u<pre>
°5u&gt;&gt;&gt; let s = Left "foo" :: Either String Int
°5u
°5u&gt;&gt;&gt; let n = Right 3 :: Either String Int
°5u
°5u&gt;&gt;&gt; either length (*2) s
°5u3
°5u
°5u&gt;&gt;&gt; either length (*2) n
°5u6
°5u</pre>
either :: (a -> c) -> (b -> c) -> Either a b -> c

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

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

-- | Return <a>True</a> if the given value is a <a>Left</a>-value,
°5u<a>False</a> otherwise.
°5u
°5u<h4><b>Examples</b></h4>
°5u
°5uBasic usage:
°5u
°5u<pre>
°5u&gt;&gt;&gt; isLeft (Left "foo")
°5uTrue
°5u
°5u&gt;&gt;&gt; isLeft (Right 3)
°5uFalse
°5u</pre>
°5u
°5uAssuming a <a>Left</a> value signifies some sort of error, we can use
°5u<a>isLeft</a> to write a very simple error-reporting function that
°5udoes absolutely nothing in the case of success, and outputs "ERROR" if
°5uany error occurred.
°5u
°5uThis example shows how <a>isLeft</a> might be used to avoid pattern
°5umatching when one does not care about the value contained in the
°5uconstructor:
°5u
°5u<pre>
°5u&gt;&gt;&gt; import Control.Monad ( when )
°5u
°5u&gt;&gt;&gt; let report e = when (isLeft e) $ putStrLn "ERROR"
°5u
°5u&gt;&gt;&gt; report (Right 1)
°5u
°5u&gt;&gt;&gt; report (Left "parse error")
°5uERROR
°5u</pre>
isLeft :: Either a b -> Bool

-- | Return <a>True</a> if the given value is a <a>Right</a>-value,
°5u<a>False</a> otherwise.
°5u
°5u<h4><b>Examples</b></h4>
°5u
°5uBasic usage:
°5u
°5u<pre>
°5u&gt;&gt;&gt; isRight (Left "foo")
°5uFalse
°5u
°5u&gt;&gt;&gt; isRight (Right 3)
°5uTrue
°5u</pre>
°5u
°5uAssuming a <a>Left</a> value signifies some sort of error, we can use
°5u<a>isRight</a> to write a very simple reporting function that only
°5uoutputs "SUCCESS" when a computation has succeeded.
°5u
°5uThis example shows how <a>isRight</a> might be used to avoid pattern
°5umatching when one does not care about the value contained in the
°5uconstructor:
°5u
°5u<pre>
°5u&gt;&gt;&gt; import Control.Monad ( when )
°5u
°5u&gt;&gt;&gt; let report e = when (isRight e) $ putStrLn "SUCCESS"
°5u
°5u&gt;&gt;&gt; report (Left "parse error")
°5u
°5u&gt;&gt;&gt; report (Right 1)
°5uSUCCESS
°5u</pre>
isRight :: Either a b -> Bool

-- | Return the contents of a <a>Left</a>-value or a default value
°5uotherwise.
°5u
°5u<h4><b>Examples</b></h4>
°5u
°5uBasic usage:
°5u
°5u<pre>
°5u&gt;&gt;&gt; fromLeft 1 (Left 3)
°5u3
°5u
°5u&gt;&gt;&gt; fromLeft 1 (Right "foo")
°5u1
°5u</pre>
fromLeft :: a -> Either a b -> a

-- | Return the contents of a <a>Right</a>-value or a default value
°5uotherwise.
°5u
°5u<h4><b>Examples</b></h4>
°5u
°5uBasic usage:
°5u
°5u<pre>
°5u&gt;&gt;&gt; fromRight 1 (Right 3)
°5u3
°5u
°5u&gt;&gt;&gt; fromRight 1 (Left "foo")
°5u1
°5u</pre>
fromRight :: b -> Either a b -> b

-- | Partitions a list of <a>Either</a> into two lists. All the <a>Left</a>
°5uelements are extracted, in order, to the first component of the
°5uoutput. Similarly the <a>Right</a> elements are extracted to the
°5usecond component of the output.
°5u
°5u<h4><b>Examples</b></h4>
°5u
°5uBasic usage:
°5u
°5u<pre>
°5u&gt;&gt;&gt; let list = [ Left "foo", Right 3, Left "bar", Right 7, Left "baz" ]
°5u
°5u&gt;&gt;&gt; partitionEithers list
°5u(["foo","bar","baz"],[3,7])
°5u</pre>
°5u
°5uThe pair returned by <tt><a>partitionEithers</a> x</tt> should be the
°5usame pair as <tt>(<a>lefts</a> x, <a>rights</a> x)</tt>:
°5u
°5u<pre>
°5u&gt;&gt;&gt; let list = [ Left "foo", Right 3, Left "bar", Right 7, Left "baz" ]
°5u
°5u&gt;&gt;&gt; partitionEithers list == (lefts list, rights list)
°5uTrue
°5u</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.
°5u
°5uThe <a>Text.Read</a> library is the canonical library to import for
°5u<a>Read</a>-class facilities. For GHC only, it offers an extended and
°5umuch improved <a>Read</a> class, which constitutes a proposed
°5ualternative to the Haskell 2010 <a>Read</a>. In particular, writing
°5uparsers is easier, and the parsers are much more efficient.
module Text.Read

-- | Parsing of <a>String</a>s, producing values.
°5u
°5uDerived instances of <a>Read</a> make the following assumptions, which
°5uderived instances of <a>Show</a> obey:
°5u
°5u<ul>
°5u<li>If the constructor is defined to be an infix operator, then the
°5uderived <a>Read</a> instance will parse only infix applications of the
°5uconstructor (not the prefix form).</li>
°5u<li>Associativity is not used to reduce the occurrence of parentheses,
°5ualthough precedence may be.</li>
°5u<li>If the constructor is defined using record syntax, the derived
°5u<a>Read</a> will parse only the record-syntax form, and furthermore,
°5uthe fields must be given in the same order as the original
°5udeclaration.</li>
°5u<li>The derived <a>Read</a> instance allows arbitrary Haskell
°5uwhitespace between tokens of the input string. Extra parentheses are
°5ualso allowed.</li>
°5u</ul>
°5u
°5uFor example, given the declarations
°5u
°5u<pre>
°5uinfixr 5 :^:
°5udata Tree a =  Leaf a  |  Tree a :^: Tree a
°5u</pre>
°5u
°5uthe derived instance of <a>Read</a> in Haskell 2010 is equivalent to
°5u
°5u<pre>
°5uinstance (Read a) =&gt; Read (Tree a) where
°5u
°5u        readsPrec d r =  readParen (d &gt; app_prec)
°5u                         (\r -&gt; [(Leaf m,t) |
°5u                                 ("Leaf",s) &lt;- lex r,
°5u                                 (m,t) &lt;- readsPrec (app_prec+1) s]) r
°5u
°5u                      ++ readParen (d &gt; up_prec)
°5u                         (\r -&gt; [(u:^:v,w) |
°5u                                 (u,s) &lt;- readsPrec (up_prec+1) r,
°5u                                 (":^:",t) &lt;- lex s,
°5u                                 (v,w) &lt;- readsPrec (up_prec+1) t]) r
°5u
°5u          where app_prec = 10
°5u                up_prec = 5
°5u</pre>
°5u
°5uNote that right-associativity of <tt>:^:</tt> is unused.
°5u
°5uThe derived instance in GHC is equivalent to
°5u
°5u<pre>
°5uinstance (Read a) =&gt; Read (Tree a) where
°5u
°5u        readPrec = parens $ (prec app_prec $ do
°5u                                 Ident "Leaf" &lt;- lexP
°5u                                 m &lt;- step readPrec
°5u                                 return (Leaf m))
°5u
°5u                     +++ (prec up_prec $ do
°5u                                 u &lt;- step readPrec
°5u                                 Symbol ":^:" &lt;- lexP
°5u                                 v &lt;- step readPrec
°5u                                 return (u :^: v))
°5u
°5u          where app_prec = 10
°5u                up_prec = 5
°5u
°5u        readListPrec = readListPrecDefault
°5u</pre>
°5u
°5uWhy do both <a>readsPrec</a> and <a>readPrec</a> exist, and why does
°5uGHC opt to implement <a>readPrec</a> in derived <a>Read</a> instances
°5uinstead of <a>readsPrec</a>? The reason is that <a>readsPrec</a> is
°5ubased on the <a>ReadS</a> type, and although <a>ReadS</a> is mentioned
°5uin the Haskell 2010 Report, it is not a very efficient parser data
°5ustructure.
°5u
°5u<a>readPrec</a>, on the other hand, is based on a much more efficient
°5u<a>ReadPrec</a> datatype (a.k.a "new-style parsers"), but its
°5udefinition relies on the use of the <tt>RankNTypes</tt> language
°5uextension. Therefore, <a>readPrec</a> (and its cousin,
°5u<a>readListPrec</a>) are marked as GHC-only. Nevertheless, it is
°5urecommended to use <a>readPrec</a> instead of <a>readsPrec</a>
°5uwhenever possible for the efficiency improvements it brings.
°5u
°5uAs mentioned above, derived <a>Read</a> instances in GHC will
°5uimplement <a>readPrec</a> instead of <a>readsPrec</a>. The default
°5uimplementations of <a>readsPrec</a> (and its cousin, <a>readList</a>)
°5uwill simply use <a>readPrec</a> under the hood. If you are writing a
°5u<a>Read</a> instance by hand, it is recommended to write it like so:
°5u
°5u<pre>
°5uinstance <a>Read</a> T where
°5u  <a>readPrec</a>     = ...
°5u  <a>readListPrec</a> = <a>readListPrecDefault</a>
°5u</pre>
class Read a

-- | attempts to parse a value from the front of the string, returning a
°5ulist of (parsed value, remaining string) pairs. If there is no
°5usuccessful parse, the returned list is empty.
°5u
°5uDerived instances of <a>Read</a> and <a>Show</a> satisfy the
°5ufollowing:
°5u
°5u<ul>
°5u<li><tt>(x,"")</tt> is an element of <tt>(<a>readsPrec</a> d
°5u(<a>showsPrec</a> d x ""))</tt>.</li>
°5u</ul>
°5u
°5uThat is, <a>readsPrec</a> parses the string produced by
°5u<a>showsPrec</a>, and delivers the value that <a>showsPrec</a> started
°5uwith.
readsPrec :: Read a => Int -> ReadS a

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

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

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

-- | A parser for a type <tt>a</tt>, represented as a function that takes a
°5u<a>String</a> and returns a list of possible parses as
°5u<tt>(a,<a>String</a>)</tt> pairs.
°5u
°5uNote that this kind of backtracking parser is very inefficient;
°5ureading 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
°5ucompletely consumed by the input process. <a>read</a> fails with an
°5u<a>error</a> if the parse is unsuccessful, and it is therefore
°5udiscouraged from being used in real applications. Use <a>readMaybe</a>
°5uor <a>readEither</a> for safe alternatives.
°5u
°5u<pre>
°5u&gt;&gt;&gt; read "123" :: Int
°5u123
°5u</pre>
°5u
°5u<pre>
°5u&gt;&gt;&gt; read "hello" :: Int
°5u*** Exception: Prelude.read: no parse
°5u</pre>
read :: Read a => String -> a

-- | <tt><a>readParen</a> <a>True</a> p</tt> parses what <tt>p</tt> parses,
°5ubut surrounded with parentheses.
°5u
°5u<tt><a>readParen</a> <a>False</a> p</tt> parses what <tt>p</tt>
°5uparses, but optionally surrounded with parentheses.
readParen :: Bool -> ReadS a -> ReadS a

-- | The <a>lex</a> function reads a single lexeme from the input,
°5udiscarding initial white space, and returning the characters that
°5uconstitute the lexeme. If the input string contains only white space,
°5u<a>lex</a> returns a single successful `lexeme' consisting of the
°5uempty string. (Thus <tt><a>lex</a> "" = [("","")]</tt>.) If there is
°5uno legal lexeme at the beginning of the input string, <a>lex</a> fails
°5u(i.e. returns <tt>[]</tt>).
°5u
°5uThis lexer is not completely faithful to the Haskell lexical syntax in
°5uthe following respects:
°5u
°5u<ul>
°5u<li>Qualified names are not handled properly</li>
°5u<li>Octal and hexadecimal numerics are not recognized as a single
°5utoken</li>
°5u<li>Comments are not treated properly</li>
°5u</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
°5u<tt>p</tt> parses "P" in the current precedence context and parses
°5u"P0" in precedence context zero
parens :: ReadPrec a -> ReadPrec a

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

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

-- | Parse a string using the <a>Read</a> instance. Succeeds if there is
°5uexactly one valid result. A <a>Left</a> value indicates a parse error.
°5u
°5u<pre>
°5u&gt;&gt;&gt; readEither "123" :: Either String Int
°5uRight 123
°5u</pre>
°5u
°5u<pre>
°5u&gt;&gt;&gt; readEither "hello" :: Either String Int
°5uLeft "Prelude.read: no parse"
°5u</pre>
readEither :: Read a => String -> Either String a

-- | Parse a string using the <a>Read</a> instance. Succeeds if there is
°5uexactly one valid result.
°5u
°5u<pre>
°5u&gt;&gt;&gt; readMaybe "123" :: Maybe Int
°5uJust 123
°5u</pre>
°5u
°5u<pre>
°5u&gt;&gt;&gt; readMaybe "hello" :: Maybe Int
°5uNothing
°5u</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
°5urepresent Unicode (or equivalently ISO/IEC 10646) code points (i.e.
°5ucharacters, see <a>http://www.unicode.org/</a> for details). This set
°5uextends the ISO 8859-1 (Latin-1) character set (the first 256
°5ucharacters), which is itself an extension of the ASCII character set
°5u(the first 128 characters). A character literal in Haskell has type
°5u<a>Char</a>.
°5u
°5uTo convert a <a>Char</a> to or from the corresponding <a>Int</a> value
°5udefined by Unicode, use <a>toEnum</a> and <a>fromEnum</a> from the
°5u<a>Enum</a> class respectively (or equivalently <tt>ord</tt> and
°5u<tt>chr</tt>).
data Char

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

-- | Returns <a>True</a> for any Unicode space character, and the control
°5ucharacters <tt>\t</tt>, <tt>\n</tt>, <tt>\r</tt>, <tt>\f</tt>,
°5u<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
°5u(letters). Title case is used by a small number of letter ligatures
°5ulike the single-character form of <i>Lj</i>.
isUpper :: Char -> Bool

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

-- | Selects alphabetic or numeric digit Unicode characters.
°5u
°5uNote that numeric digits outside the ASCII range are selected by this
°5ufunction but not by <a>isDigit</a>. Such digits may be part of
°5uidentifiers but are not used by the printer and reader to represent
°5unumbers.
isAlphaNum :: Char -> Bool

-- | Selects printable Unicode characters (letters, numbers, marks,
°5upunctuation, 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>,
°5u<tt>'a'</tt>..<tt>'f'</tt>, <tt>'A'</tt>..<tt>'F'</tt>.
isHexDigit :: Char -> Bool

-- | Selects alphabetic Unicode characters (lower-case, upper-case and
°5utitle-case letters, plus letters of caseless scripts and modifiers
°5uletters). This function is equivalent to <a>isAlpha</a>.
°5u
°5uThis function returns <a>True</a> if its argument has one of the
°5ufollowing <a>GeneralCategory</a>s, or <a>False</a> otherwise:
°5u
°5u<ul>
°5u<li><a>UppercaseLetter</a></li>
°5u<li><a>LowercaseLetter</a></li>
°5u<li><a>TitlecaseLetter</a></li>
°5u<li><a>ModifierLetter</a></li>
°5u<li><a>OtherLetter</a></li>
°5u</ul>
°5u
°5uThese classes are defined in the <a>Unicode Character Database</a>,
°5upart of the Unicode standard. The same document defines what is and is
°5unot a "Letter".
°5u
°5u<h4><b>Examples</b></h4>
°5u
°5uBasic usage:
°5u
°5u<pre>
°5u&gt;&gt;&gt; isLetter 'a'
°5uTrue
°5u
°5u&gt;&gt;&gt; isLetter 'A'
°5uTrue
°5u
°5u&gt;&gt;&gt; isLetter 'λ'
°5uTrue
°5u
°5u&gt;&gt;&gt; isLetter '0'
°5uFalse
°5u
°5u&gt;&gt;&gt; isLetter '%'
°5uFalse
°5u
°5u&gt;&gt;&gt; isLetter '♥'
°5uFalse
°5u
°5u&gt;&gt;&gt; isLetter '\31'
°5uFalse
°5u</pre>
°5u
°5uEnsure that <a>isLetter</a> and <a>isAlpha</a> are equivalent.
°5u
°5u<pre>
°5u&gt;&gt;&gt; let chars = [(chr 0)..]
°5u
°5u&gt;&gt;&gt; let letters = map isLetter chars
°5u
°5u&gt;&gt;&gt; let alphas = map isAlpha chars
°5u
°5u&gt;&gt;&gt; letters == alphas
°5uTrue
°5u</pre>
isLetter :: Char -> Bool

-- | Selects Unicode mark characters, for example accents and the like,
°5uwhich combine with preceding characters.
°5u
°5uThis function returns <a>True</a> if its argument has one of the
°5ufollowing <a>GeneralCategory</a>s, or <a>False</a> otherwise:
°5u
°5u<ul>
°5u<li><a>NonSpacingMark</a></li>
°5u<li><a>SpacingCombiningMark</a></li>
°5u<li><a>EnclosingMark</a></li>
°5u</ul>
°5u
°5uThese classes are defined in the <a>Unicode Character Database</a>,
°5upart of the Unicode standard. The same document defines what is and is
°5unot a "Mark".
°5u
°5u<h4><b>Examples</b></h4>
°5u
°5uBasic usage:
°5u
°5u<pre>
°5u&gt;&gt;&gt; isMark 'a'
°5uFalse
°5u
°5u&gt;&gt;&gt; isMark '0'
°5uFalse
°5u</pre>
°5u
°5uCombining marks such as accent characters usually need to follow
°5uanother character before they become printable:
°5u
°5u<pre>
°5u&gt;&gt;&gt; map isMark "ò"
°5u[False,True]
°5u</pre>
°5u
°5uPuns are not necessarily supported:
°5u
°5u<pre>
°5u&gt;&gt;&gt; isMark '✓'
°5uFalse
°5u</pre>
isMark :: Char -> Bool

-- | Selects Unicode numeric characters, including digits from various
°5uscripts, Roman numerals, et cetera.
°5u
°5uThis function returns <a>True</a> if its argument has one of the
°5ufollowing <a>GeneralCategory</a>s, or <a>False</a> otherwise:
°5u
°5u<ul>
°5u<li><a>DecimalNumber</a></li>
°5u<li><a>LetterNumber</a></li>
°5u<li><a>OtherNumber</a></li>
°5u</ul>
°5u
°5uThese classes are defined in the <a>Unicode Character Database</a>,
°5upart of the Unicode standard. The same document defines what is and is
°5unot a "Number".
°5u
°5u<h4><b>Examples</b></h4>
°5u
°5uBasic usage:
°5u
°5u<pre>
°5u&gt;&gt;&gt; isNumber 'a'
°5uFalse
°5u
°5u&gt;&gt;&gt; isNumber '%'
°5uFalse
°5u
°5u&gt;&gt;&gt; isNumber '3'
°5uTrue
°5u</pre>
°5u
°5uASCII <tt>'0'</tt> through <tt>'9'</tt> are all numbers:
°5u
°5u<pre>
°5u&gt;&gt;&gt; and $ map isNumber ['0'..'9']
°5uTrue
°5u</pre>
°5u
°5uUnicode Roman numerals are "numbers" as well:
°5u
°5u<pre>
°5u&gt;&gt;&gt; isNumber 'Ⅸ'
°5uTrue
°5u</pre>
isNumber :: Char -> Bool

-- | Selects Unicode punctuation characters, including various kinds of
°5uconnectors, brackets and quotes.
°5u
°5uThis function returns <a>True</a> if its argument has one of the
°5ufollowing <a>GeneralCategory</a>s, or <a>False</a> otherwise:
°5u
°5u<ul>
°5u<li><a>ConnectorPunctuation</a></li>
°5u<li><a>DashPunctuation</a></li>
°5u<li><a>OpenPunctuation</a></li>
°5u<li><a>ClosePunctuation</a></li>
°5u<li><a>InitialQuote</a></li>
°5u<li><a>FinalQuote</a></li>
°5u<li><a>OtherPunctuation</a></li>
°5u</ul>
°5u
°5uThese classes are defined in the <a>Unicode Character Database</a>,
°5upart of the Unicode standard. The same document defines what is and is
°5unot a "Punctuation".
°5u
°5u<h4><b>Examples</b></h4>
°5u
°5uBasic usage:
°5u
°5u<pre>
°5u&gt;&gt;&gt; isPunctuation 'a'
°5uFalse
°5u
°5u&gt;&gt;&gt; isPunctuation '7'
°5uFalse
°5u
°5u&gt;&gt;&gt; isPunctuation '♥'
°5uFalse
°5u
°5u&gt;&gt;&gt; isPunctuation '"'
°5uTrue
°5u
°5u&gt;&gt;&gt; isPunctuation '?'
°5uTrue
°5u
°5u&gt;&gt;&gt; isPunctuation '—'
°5uTrue
°5u</pre>
isPunctuation :: Char -> Bool

-- | Selects Unicode symbol characters, including mathematical and currency
°5usymbols.
°5u
°5uThis function returns <a>True</a> if its argument has one of the
°5ufollowing <a>GeneralCategory</a>s, or <a>False</a> otherwise:
°5u
°5u<ul>
°5u<li><a>MathSymbol</a></li>
°5u<li><a>CurrencySymbol</a></li>
°5u<li><a>ModifierSymbol</a></li>
°5u<li><a>OtherSymbol</a></li>
°5u</ul>
°5u
°5uThese classes are defined in the <a>Unicode Character Database</a>,
°5upart of the Unicode standard. The same document defines what is and is
°5unot a "Symbol".
°5u
°5u<h4><b>Examples</b></h4>
°5u
°5uBasic usage:
°5u
°5u<pre>
°5u&gt;&gt;&gt; isSymbol 'a'
°5uFalse
°5u
°5u&gt;&gt;&gt; isSymbol '6'
°5uFalse
°5u
°5u&gt;&gt;&gt; isSymbol '='
°5uTrue
°5u</pre>
°5u
°5uThe definition of "math symbol" may be a little counter-intuitive
°5udepending on one's background:
°5u
°5u<pre>
°5u&gt;&gt;&gt; isSymbol '+'
°5uTrue
°5u
°5u&gt;&gt;&gt; isSymbol '-'
°5uFalse
°5u</pre>
isSymbol :: Char -> Bool

-- | Selects Unicode space and separator characters.
°5u
°5uThis function returns <a>True</a> if its argument has one of the
°5ufollowing <a>GeneralCategory</a>s, or <a>False</a> otherwise:
°5u
°5u<ul>
°5u<li><a>Space</a></li>
°5u<li><a>LineSeparator</a></li>
°5u<li><a>ParagraphSeparator</a></li>
°5u</ul>
°5u
°5uThese classes are defined in the <a>Unicode Character Database</a>,
°5upart of the Unicode standard. The same document defines what is and is
°5unot a "Separator".
°5u
°5u<h4><b>Examples</b></h4>
°5u
°5uBasic usage:
°5u
°5u<pre>
°5u&gt;&gt;&gt; isSeparator 'a'
°5uFalse
°5u
°5u&gt;&gt;&gt; isSeparator '6'
°5uFalse
°5u
°5u&gt;&gt;&gt; isSeparator ' '
°5uTrue
°5u</pre>
°5u
°5uWarning: newlines and tab characters are not considered separators.
°5u
°5u<pre>
°5u&gt;&gt;&gt; isSeparator '\n'
°5uFalse
°5u
°5u&gt;&gt;&gt; isSeparator '\t'
°5uFalse
°5u</pre>
°5u
°5uBut some more exotic characters are (like HTML's <tt>&amp;nbsp;</tt>):
°5u
°5u<pre>
°5u&gt;&gt;&gt; isSeparator '\160'
°5uTrue
°5u</pre>
isSeparator :: Char -> Bool

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

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

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

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

-- | Unicode General Categories (column 2 of the UnicodeData table) in the
°5uorder they are listed in the Unicode standard (the Unicode Character
°5uDatabase, in particular).
°5u
°5u<h4><b>Examples</b></h4>
°5u
°5uBasic usage:
°5u
°5u<pre>
°5u&gt;&gt;&gt; :t OtherLetter
°5uOtherLetter :: GeneralCategory
°5u</pre>
°5u
°5u<a>Eq</a> instance:
°5u
°5u<pre>
°5u&gt;&gt;&gt; UppercaseLetter == UppercaseLetter
°5uTrue
°5u
°5u&gt;&gt;&gt; UppercaseLetter == LowercaseLetter
°5uFalse
°5u</pre>
°5u
°5u<a>Ord</a> instance:
°5u
°5u<pre>
°5u&gt;&gt;&gt; NonSpacingMark &lt;= MathSymbol
°5uTrue
°5u</pre>
°5u
°5u<a>Enum</a> instance:
°5u
°5u<pre>
°5u&gt;&gt;&gt; enumFromTo ModifierLetter SpacingCombiningMark
°5u[ModifierLetter,OtherLetter,NonSpacingMark,SpacingCombiningMark]
°5u</pre>
°5u
°5u<tt>Read</tt> instance:
°5u
°5u<pre>
°5u&gt;&gt;&gt; read "DashPunctuation" :: GeneralCategory
°5uDashPunctuation
°5u
°5u&gt;&gt;&gt; read "17" :: GeneralCategory
°5u*** Exception: Prelude.read: no parse
°5u</pre>
°5u
°5u<a>Show</a> instance:
°5u
°5u<pre>
°5u&gt;&gt;&gt; show EnclosingMark
°5u"EnclosingMark"
°5u</pre>
°5u
°5u<a>Bounded</a> instance:
°5u
°5u<pre>
°5u&gt;&gt;&gt; minBound :: GeneralCategory
°5uUppercaseLetter
°5u
°5u&gt;&gt;&gt; maxBound :: GeneralCategory
°5uNotAssigned
°5u</pre>
°5u
°5u<a>Ix</a> instance:
°5u
°5u<pre>
°5u&gt;&gt;&gt; import Data.Ix ( index )
°5u
°5u&gt;&gt;&gt; index (OtherLetter,Control) FinalQuote
°5u12
°5u
°5u&gt;&gt;&gt; index (OtherLetter,Control) Format
°5u*** Exception: Error in array index
°5u</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
°5u<a>Enum</a> instance of <a>GeneralCategory</a>, which must remain in
°5uthe same order as the categories are presented in the Unicode
°5ustandard.
°5u
°5u<h4><b>Examples</b></h4>
°5u
°5uBasic usage:
°5u
°5u<pre>
°5u&gt;&gt;&gt; generalCategory 'a'
°5uLowercaseLetter
°5u
°5u&gt;&gt;&gt; generalCategory 'A'
°5uUppercaseLetter
°5u
°5u&gt;&gt;&gt; generalCategory '0'
°5uDecimalNumber
°5u
°5u&gt;&gt;&gt; generalCategory '%'
°5uOtherPunctuation
°5u
°5u&gt;&gt;&gt; generalCategory '♥'
°5uOtherSymbol
°5u
°5u&gt;&gt;&gt; generalCategory '\31'
°5uControl
°5u
°5u&gt;&gt;&gt; generalCategory ' '
°5uSpace
°5u</pre>
generalCategory :: Char -> GeneralCategory

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

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

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

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

-- | Convert an <a>Int</a> in the range <tt>0</tt>..<tt>15</tt> to the
°5ucorresponding single digit <a>Char</a>. This function fails on other
°5uinputs, 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
°5uHaskell source-language escape conventions. For example:
°5u
°5u<pre>
°5ushowLitChar '\n' s  =  "\\n" ++ s
°5u</pre>
showLitChar :: Char -> ShowS

-- | Read a string representation of a character, using Haskell
°5usource-language escape conventions. For example:
°5u
°5u<pre>
°5ulexLitChar  "\\nHello"  =  [("\\n", "Hello")]
°5u</pre>
lexLitChar :: ReadS String

-- | Read a string representation of a character, using Haskell
°5usource-language escape conventions, and convert it to the character
°5uthat it encodes. For example:
°5u
°5u<pre>
°5ureadLitChar "\\nHello"  =  [('\n', "Hello")]
°5u</pre>
readLitChar :: ReadS Char


-- | This legacy module provides access to the list-specialised operations
°5uof <a>Data.List</a>. This module may go away again in future GHC
°5uversions and is provided as transitional tool to access some of the
°5ulist-specialised operations that had to be generalised due to the
°5uimplementation of the <a>Foldable/Traversable-in-Prelude Proposal
°5u(FTP)</a>.
°5u
°5uIf the operations needed are available in <a>GHC.List</a>, it's
°5urecommended to avoid importing this module and use <a>GHC.List</a>
°5uinstead for now.
module GHC.OldList

-- | Append two lists, i.e.,
°5u
°5u<pre>
°5u[x1, ..., xm] ++ [y1, ..., yn] == [x1, ..., xm, y1, ..., yn]
°5u[x1, ..., xm] ++ [y1, ...] == [x1, ..., xm, y1, ...]
°5u</pre>
°5u
°5uIf 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
°5unon-empty.
last :: [a] -> a

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

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

-- | Decompose a list into its head and tail. If the list is empty, returns
°5u<a>Nothing</a>. If the list is non-empty, returns <tt><a>Just</a> (x,
°5uxs)</tt>, where <tt>x</tt> is the head of the list and <tt>xs</tt> its
°5utail.
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
°5u<a>Int</a>. It is an instance of the more general
°5u<a>genericLength</a>, the result type of which may be any kind of
°5unumber.
length :: [a] -> Int

-- | <a>map</a> <tt>f xs</tt> is the list obtained by applying <tt>f</tt>
°5uto each element of <tt>xs</tt>, i.e.,
°5u
°5u<pre>
°5umap f [x1, x2, ..., xn] == [f x1, f x2, ..., f xn]
°5umap f [x1, x2, ...] == [f x1, f x2, ...]
°5u</pre>
map :: (a -> b) -> [a] -> [b]

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

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

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

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

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

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

-- | <a>foldl</a>, applied to a binary operator, a starting value
°5u(typically the left-identity of the operator), and a list, reduces the
°5ulist using the binary operator, from left to right:
°5u
°5u<pre>
°5ufoldl f z [x1, x2, ..., xn] == (...((z `f` x1) `f` x2) `f`...) `f` xn
°5u</pre>
°5u
°5uThe 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
°5uargument, 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
°5u(typically the right-identity of the operator), and a list, reduces
°5uthe list using the binary operator, from right to left:
°5u
°5u<pre>
°5ufoldr f z [x1, x2, ..., xn] == x1 `f` (x2 `f` ... (xn `f` z)...)
°5u</pre>
foldr :: (a -> b -> b) -> b -> [a] -> b

-- | <a>foldr1</a> is a variant of <a>foldr</a> that has no starting value
°5uargument, 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
°5uto be <a>True</a>, the list must be finite; <a>False</a>, however,
°5uresults from a <a>False</a> value at a finite index of a finite or
°5uinfinite list.
and :: [Bool] -> Bool

-- | <a>or</a> returns the disjunction of a Boolean list. For the result to
°5ube <a>False</a>, the list must be finite; <a>True</a>, however,
°5uresults from a <a>True</a> value at a finite index of a finite or
°5uinfinite list.
or :: [Bool] -> Bool

-- | Applied to a predicate and a list, <a>any</a> determines if any
°5uelement of the list satisfies the predicate. For the result to be
°5u<a>False</a>, the list must be finite; <a>True</a>, however, results
°5ufrom a <a>True</a> value for the predicate applied to an element at a
°5ufinite 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
°5uelements of the list satisfy the predicate. For the result to be
°5u<a>True</a>, the list must be finite; <a>False</a>, however, results
°5ufrom a <a>False</a> value for the predicate applied to an element at a
°5ufinite 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
°5unumbers.
product :: (Num a) => [a] -> a

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

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

-- | <a>scanl</a> is similar to <a>foldl</a>, but returns a list of
°5usuccessive reduced values from the left:
°5u
°5u<pre>
°5uscanl f z [x1, x2, ...] == [z, z `f` x1, (z `f` x1) `f` x2, ...]
°5u</pre>
°5u
°5uNote that
°5u
°5u<pre>
°5ulast (scanl f z xs) == foldl f z xs.
°5u</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
°5uargument:
°5u
°5u<pre>
°5uscanl1 f [x1, x2, ...] == [x1, x1 `f` x2, ...]
°5u</pre>
scanl1 :: (a -> a -> a) -> [a] -> [a]

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

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

-- | The <a>mapAccumL</a> function behaves like a combination of <a>map</a>
°5uand <a>foldl</a>; it applies a function to each element of a list,
°5upassing an accumulating parameter from left to right, and returning a
°5ufinal 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>
°5uand <a>foldr</a>; it applies a function to each element of a list,
°5upassing an accumulating parameter from right to left, and returning a
°5ufinal 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
°5uapplications of <tt>f</tt> to <tt>x</tt>:
°5u
°5u<pre>
°5uiterate f x == [x, f x, f (f x), ...]
°5u</pre>
°5u
°5uNote that <a>iterate</a> is lazy, potentially leading to thunk
°5ubuild-up if the consumer doesn't force each iterate. See 'iterate\''
°5ufor a strict variant of this function.
iterate :: (a -> a) -> a -> [a]

-- | 'iterate\'' is the strict version of <a>iterate</a>.
°5u
°5uIt ensures that the result of each application of force to weak head
°5unormal form before proceeding.
iterate' :: (a -> a) -> a -> [a]

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

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

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

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

-- | <a>take</a> <tt>n</tt>, applied to a list <tt>xs</tt>, returns the
°5uprefix of <tt>xs</tt> of length <tt>n</tt>, or <tt>xs</tt> itself if
°5u<tt>n &gt; <a>length</a> xs</tt>:
°5u
°5u<pre>
°5utake 5 "Hello World!" == "Hello"
°5utake 3 [1,2,3,4,5] == [1,2,3]
°5utake 3 [1,2] == [1,2]
°5utake 3 [] == []
°5utake (-1) [1,2] == []
°5utake 0 [1,2] == []
°5u</pre>
°5u
°5uIt is an instance of the more general <a>genericTake</a>, in which
°5u<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
°5ufirst <tt>n</tt> elements, or <tt>[]</tt> if <tt>n &gt; <a>length</a>
°5uxs</tt>:
°5u
°5u<pre>
°5udrop 6 "Hello World!" == "World!"
°5udrop 3 [1,2,3,4,5] == [4,5]
°5udrop 3 [1,2] == []
°5udrop 3 [] == []
°5udrop (-1) [1,2] == [1,2]
°5udrop 0 [1,2] == [1,2]
°5u</pre>
°5u
°5uIt is an instance of the more general <a>genericDrop</a>, in which
°5u<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
°5u<tt>xs</tt> prefix of length <tt>n</tt> and second element is the
°5uremainder of the list:
°5u
°5u<pre>
°5usplitAt 6 "Hello World!" == ("Hello ","World!")
°5usplitAt 3 [1,2,3,4,5] == ([1,2,3],[4,5])
°5usplitAt 1 [1,2,3] == ([1],[2,3])
°5usplitAt 3 [1,2,3] == ([1,2,3],[])
°5usplitAt 4 [1,2,3] == ([1,2,3],[])
°5usplitAt 0 [1,2,3] == ([],[1,2,3])
°5usplitAt (-1) [1,2,3] == ([],[1,2,3])
°5u</pre>
°5u
°5uIt is equivalent to <tt>(<a>take</a> n xs, <a>drop</a> n xs)</tt> when
°5u<tt>n</tt> is not <tt>_|_</tt> (<tt>splitAt _|_ xs = _|_</tt>).
°5u<a>splitAt</a> is an instance of the more general
°5u<a>genericSplitAt</a>, in which <tt>n</tt> may be of any integral
°5utype.
splitAt :: Int -> [a] -> ([a], [a])

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

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

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

-- | <a>span</a>, applied to a predicate <tt>p</tt> and a list <tt>xs</tt>,
°5ureturns a tuple where first element is longest prefix (possibly empty)
°5uof <tt>xs</tt> of elements that satisfy <tt>p</tt> and second element
°5uis the remainder of the list:
°5u
°5u<pre>
°5uspan (&lt; 3) [1,2,3,4,1,2,3,4] == ([1,2],[3,4,1,2,3,4])
°5uspan (&lt; 9) [1,2,3] == ([1,2,3],[])
°5uspan (&lt; 0) [1,2,3] == ([],[1,2,3])
°5u</pre>
°5u
°5u<a>span</a> <tt>p xs</tt> is equivalent to <tt>(<a>takeWhile</a> p xs,
°5u<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
°5u<tt>xs</tt>, returns a tuple where first element is longest prefix
°5u(possibly empty) of <tt>xs</tt> of elements that <i>do not satisfy</i>
°5u<tt>p</tt> and second element is the remainder of the list:
°5u
°5u<pre>
°5ubreak (&gt; 3) [1,2,3,4,1,2,3,4] == ([1,2,3],[4,1,2,3,4])
°5ubreak (&lt; 9) [1,2,3] == ([],[1,2,3])
°5ubreak (&gt; 9) [1,2,3] == ([1,2,3],[])
°5u</pre>
°5u
°5u<a>break</a> <tt>p</tt> is equivalent to <tt><a>span</a> (<a>not</a> .
°5up)</tt>.
break :: (a -> Bool) -> [a] -> ([a], [a])

-- | The <a>stripPrefix</a> function drops the given prefix from a list. It
°5ureturns <a>Nothing</a> if the list did not start with the prefix
°5ugiven, or <a>Just</a> the list after the prefix, if it does.
°5u
°5u<pre>
°5u&gt;&gt;&gt; stripPrefix "foo" "foobar"
°5uJust "bar"
°5u</pre>
°5u
°5u<pre>
°5u&gt;&gt;&gt; stripPrefix "foo" "foo"
°5uJust ""
°5u</pre>
°5u
°5u<pre>
°5u&gt;&gt;&gt; stripPrefix "foo" "barfoo"
°5uNothing
°5u</pre>
°5u
°5u<pre>
°5u&gt;&gt;&gt; stripPrefix "foo" "barfoobaz"
°5uNothing
°5u</pre>
stripPrefix :: Eq a => [a] -> [a] -> Maybe [a]

-- | The <a>group</a> function takes a list and returns a list of lists
°5usuch that the concatenation of the result is equal to the argument.
°5uMoreover, each sublist in the result contains only equal elements. For
°5uexample,
°5u
°5u<pre>
°5u&gt;&gt;&gt; group "Mississippi"
°5u["M","i","ss","i","ss","i","pp","i"]
°5u</pre>
°5u
°5uIt is a special case of <a>groupBy</a>, which allows the programmer to
°5usupply their own equality test.
group :: Eq a => [a] -> [[a]]

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

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

-- | The <a>isPrefixOf</a> function takes two lists and returns <a>True</a>
°5uiff the first list is a prefix of the second.
°5u
°5u<pre>
°5u&gt;&gt;&gt; "Hello" `isPrefixOf` "Hello World!"
°5uTrue
°5u</pre>
°5u
°5u<pre>
°5u&gt;&gt;&gt; "Hello" `isPrefixOf` "Wello Horld!"
°5uFalse
°5u</pre>
isPrefixOf :: (Eq a) => [a] -> [a] -> Bool

-- | The <a>isSuffixOf</a> function takes two lists and returns <a>True</a>
°5uiff the first list is a suffix of the second. The second list must be
°5ufinite.
°5u
°5u<pre>
°5u&gt;&gt;&gt; "ld!" `isSuffixOf` "Hello World!"
°5uTrue
°5u</pre>
°5u
°5u<pre>
°5u&gt;&gt;&gt; "World" `isSuffixOf` "Hello World!"
°5uFalse
°5u</pre>
isSuffixOf :: (Eq a) => [a] -> [a] -> Bool

-- | The <a>isInfixOf</a> function takes two lists and returns <a>True</a>
°5uiff the first list is contained, wholly and intact, anywhere within
°5uthe second.
°5u
°5u<pre>
°5u&gt;&gt;&gt; isInfixOf "Haskell" "I really like Haskell."
°5uTrue
°5u</pre>
°5u
°5u<pre>
°5u&gt;&gt;&gt; isInfixOf "Ial" "I really like Haskell."
°5uFalse
°5u</pre>
isInfixOf :: (Eq a) => [a] -> [a] -> Bool

-- | <a>elem</a> is the list membership predicate, usually written in infix
°5uform, e.g., <tt>x `elem` xs</tt>. For the result to be <a>False</a>,
°5uthe list must be finite; <a>True</a>, however, results from an element
°5uequal to <tt>x</tt> found at a finite index of a finite or infinite
°5ulist.
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
°5ulist.
lookup :: (Eq a) => a -> [(a, b)] -> Maybe b

-- | The <a>find</a> function takes a predicate and a list and returns the
°5ufirst element in the list matching the predicate, or <a>Nothing</a> if
°5uthere is no such element.
°5u
°5u<pre>
°5u&gt;&gt;&gt; find (&gt; 4) [1..]
°5uJust 5
°5u</pre>
°5u
°5u<pre>
°5u&gt;&gt;&gt; find (&lt; 0) [1..10]
°5uNothing
°5u</pre>
find :: (a -> Bool) -> [a] -> Maybe a

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

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

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

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

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

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

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

-- | <a>zip</a> takes two lists and returns a list of corresponding pairs.
°5uIf one input list is short, excess elements of the longer list are
°5udiscarded.
°5u
°5u<a>zip</a> is right-lazy:
°5u
°5u<pre>
°5uzip [] _|_ = []
°5u</pre>
zip :: [a] -> [b] -> [(a, b)]

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

-- | The <a>zip4</a> function takes four lists and returns a list of
°5uquadruples, 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
°5ufive-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
°5usix-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
°5useven-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
°5ugiven as the first argument, instead of a tupling function. For
°5uexample, <tt><a>zipWith</a> (+)</tt> is applied to two lists to
°5uproduce the list of corresponding sums.
°5u
°5u<a>zipWith</a> is right-lazy:
°5u
°5u<pre>
°5uzipWith f [] _|_ = []
°5u</pre>
zipWith :: (a -> b -> c) -> [a] -> [b] -> [c]

-- | The <a>zipWith3</a> function takes a function which combines three
°5uelements, as well as three lists and returns a list of their
°5upoint-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
°5uelements, as well as four lists and returns a list of their point-wise
°5ucombination, 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
°5uelements, as well as five lists and returns a list of their point-wise
°5ucombination, 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
°5uelements, as well as six lists and returns a list of their point-wise
°5ucombination, 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
°5uelements, as well as seven lists and returns a list of their
°5upoint-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
°5ucomponents and a list of second components.
unzip :: [(a, b)] -> ([a], [b])

-- | The <a>unzip3</a> function takes a list of triples and returns three
°5ulists, 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
°5ulists, 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
°5ufive 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
°5ulists, 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
°5useven 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
°5ucharacters. The resulting strings do not contain newlines.
°5u
°5uNote that after splitting the string at newline characters, the last
°5upart of the string is considered a line even if it doesn't end with a
°5unewline. For example,
°5u
°5u<pre>
°5u&gt;&gt;&gt; lines ""
°5u[]
°5u</pre>
°5u
°5u<pre>
°5u&gt;&gt;&gt; lines "\n"
°5u[""]
°5u</pre>
°5u
°5u<pre>
°5u&gt;&gt;&gt; lines "one"
°5u["one"]
°5u</pre>
°5u
°5u<pre>
°5u&gt;&gt;&gt; lines "one\n"
°5u["one"]
°5u</pre>
°5u
°5u<pre>
°5u&gt;&gt;&gt; lines "one\n\n"
°5u["one",""]
°5u</pre>
°5u
°5u<pre>
°5u&gt;&gt;&gt; lines "one\ntwo"
°5u["one","two"]
°5u</pre>
°5u
°5u<pre>
°5u&gt;&gt;&gt; lines "one\ntwo\n"
°5u["one","two"]
°5u</pre>
°5u
°5uThus <tt><a>lines</a> s</tt> contains at least as many elements as
°5unewlines in <tt>s</tt>.
lines :: String -> [String]

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

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

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

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

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

-- | The <a>\\</a> function is list difference (non-associative). In the
°5uresult of <tt>xs</tt> <a>\\</a> <tt>ys</tt>, the first occurrence of
°5ueach element of <tt>ys</tt> in turn (if any) has been removed from
°5u<tt>xs</tt>. Thus
°5u
°5u<pre>
°5u(xs ++ ys) \\ xs == ys.
°5u</pre>
°5u
°5u<pre>
°5u&gt;&gt;&gt; "Hello World!" \\ "ell W"
°5u"Hoorld!"
°5u</pre>
°5u
°5uIt is a special case of <a>deleteFirstsBy</a>, which allows the
°5uprogrammer 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
°5uexample,
°5u
°5u<pre>
°5u&gt;&gt;&gt; "dog" `union` "cow"
°5u"dogcw"
°5u</pre>
°5u
°5uDuplicates, and elements of the first list, are removed from the the
°5usecond list, but if the first list contains duplicates, so will the
°5uresult. It is a special case of <a>unionBy</a>, which allows the
°5uprogrammer to supply their own equality test.
union :: (Eq a) => [a] -> [a] -> [a]

-- | The <a>intersect</a> function takes the list intersection of two
°5ulists. For example,
°5u
°5u<pre>
°5u&gt;&gt;&gt; [1,2,3,4] `intersect` [2,4,6,8]
°5u[2,4]
°5u</pre>
°5u
°5uIf the first list contains duplicates, so will the result.
°5u
°5u<pre>
°5u&gt;&gt;&gt; [1,2,2,3,4] `intersect` [6,4,4,2]
°5u[2,2,4]
°5u</pre>
°5u
°5uIt is a special case of <a>intersectBy</a>, which allows the
°5uprogrammer to supply their own equality test. If the element is found
°5uin both the first and the second list, the element from the first list
°5uwill be used.
intersect :: (Eq a) => [a] -> [a] -> [a]

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

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

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

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

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

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

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

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

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

-- | The <a>sortBy</a> function is the non-overloaded version of
°5u<a>sort</a>.
°5u
°5u<pre>
°5u&gt;&gt;&gt; sortBy (\(a,_) (b,_) -&gt; compare a b) [(2, "world"), (4, "!"), (1, "Hello")]
°5u[(1,"Hello"),(2,"world"),(4,"!")]
°5u</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
°5uand returns the greatest element of the list by the comparison
°5ufunction. The list must be finite and non-empty.
°5u
°5uWe can use this to find the longest entry of a list:
°5u
°5u<pre>
°5u&gt;&gt;&gt; maximumBy (\x y -&gt; compare (length x) (length y)) ["Hello", "World", "!", "Longest", "bar"]
°5u"Longest"
°5u</pre>
maximumBy :: (a -> a -> Ordering) -> [a] -> a

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

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

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

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

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

-- | The <a>genericIndex</a> function is an overloaded version of
°5u<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
°5u<a>replicate</a>, which accepts any <a>Integral</a> value as the
°5unumber of repetitions to make.
genericReplicate :: (Integral i) => i -> a -> [a]


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

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

-- | Conversion of values to readable <a>String</a>s.
°5u
°5uDerived instances of <a>Show</a> have the following properties, which
°5uare compatible with derived instances of <a>Read</a>:
°5u
°5u<ul>
°5u<li>The result of <a>show</a> is a syntactically correct Haskell
°5uexpression containing only constants, given the fixity declarations in
°5uforce at the point where the type is declared. It contains only the
°5uconstructor names defined in the data type, parentheses, and spaces.
°5uWhen labelled constructor fields are used, braces, commas, field
°5unames, and equal signs are also used.</li>
°5u<li>If the constructor is defined to be an infix operator, then
°5u<a>showsPrec</a> will produce infix applications of the
°5uconstructor.</li>
°5u<li>the representation will be enclosed in parentheses if the
°5uprecedence of the top-level constructor in <tt>x</tt> is less than
°5u<tt>d</tt> (associativity is ignored). Thus, if <tt>d</tt> is
°5u<tt>0</tt> then the result is never surrounded in parentheses; if
°5u<tt>d</tt> is <tt>11</tt> it is always surrounded in parentheses,
°5uunless it is an atomic expression.</li>
°5u<li>If the constructor is defined using record syntax, then
°5u<a>show</a> will produce the record-syntax form, with the fields given
°5uin the same order as the original declaration.</li>
°5u</ul>
°5u
°5uFor example, given the declarations
°5u
°5u<pre>
°5uinfixr 5 :^:
°5udata Tree a =  Leaf a  |  Tree a :^: Tree a
°5u</pre>
°5u
°5uthe derived instance of <a>Show</a> is equivalent to
°5u
°5u<pre>
°5uinstance (Show a) =&gt; Show (Tree a) where
°5u
°5u       showsPrec d (Leaf m) = showParen (d &gt; app_prec) $
°5u            showString "Leaf " . showsPrec (app_prec+1) m
°5u         where app_prec = 10
°5u
°5u       showsPrec d (u :^: v) = showParen (d &gt; up_prec) $
°5u            showsPrec (up_prec+1) u .
°5u            showString " :^: "      .
°5u            showsPrec (up_prec+1) v
°5u         where up_prec = 5
°5u</pre>
°5u
°5uNote that right-associativity of <tt>:^:</tt> is ignored. For example,
°5u
°5u<ul>
°5u<li><tt><a>show</a> (Leaf 1 :^: Leaf 2 :^: Leaf 3)</tt> produces the
°5ustring <tt>"Leaf 1 :^: (Leaf 2 :^: Leaf 3)"</tt>.</li>
°5u</ul>
class Show a

-- | Convert a value to a readable <a>String</a>.
°5u
°5u<a>showsPrec</a> should satisfy the law
°5u
°5u<pre>
°5ushowsPrec d x r ++ s  ==  showsPrec d x (r ++ s)
°5u</pre>
°5u
°5uDerived instances of <a>Read</a> and <a>Show</a> satisfy the
°5ufollowing:
°5u
°5u<ul>
°5u<li><tt>(x,"")</tt> is an element of <tt>(<a>readsPrec</a> d
°5u(<a>showsPrec</a> d x ""))</tt>.</li>
°5u</ul>
°5u
°5uThat is, <a>readsPrec</a> parses the string produced by
°5u<a>showsPrec</a>, and delivers the value that <a>showsPrec</a> started
°5uwith.
showsPrec :: Show a => Int -> a -> ShowS

-- | A specialised variant of <a>showsPrec</a>, using precedence context
°5uzero, 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
°5ua specialised way of showing lists of values. For example, this is
°5uused by the predefined <a>Show</a> instance of the <a>Char</a> type,
°5uwhere values of type <a>String</a> should be shown in double quotes,
°5urather 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
°5usimply prepends the character unchanged.
showChar :: Char -> ShowS

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

-- | utility function that surrounds the inner show function with
°5uparentheses 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
°5ushowing elements.
showListWith :: (a -> ShowS) -> [a] -> ShowS


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


-- | This module is an internal GHC module. It declares the constants used
°5uin the implementation of type-level natural numbers. The programmer
°5uinterface for working with type-level naturals should be defined in a
°5useparate 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.
°5uThere are instances of the class for every concrete literal: 0, 1, 2,
°5uetc.
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
°5usame 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
°5ufunctionality for this function should be subsumed by <a>CmpNat</a>,
°5uso this might go away in the future. Please let us know, if you
°5uencounter 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
°5uundefined (i.e., it cannot be reduced).

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

-- | Log base 2 (round down) of natural numbers. <tt>Log 0</tt> is
°5uundefined (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
°5uin the implementation of type-level natural numbers. The programmer
°5uinterface for working with type-level naturals should be defined in a
°5useparate 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
°5uclass IP needs it
data Symbol

-- | This class gives the integer associated with a type-level natural.
°5uThere are instances of the class for every concrete literal: 0, 1, 2,
°5uetc.
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
°5uare 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
°5usame 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
°5usame 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
°5ufunctionality for this function should be subsumed by <a>CmpNat</a>,
°5uso this might go away in the future. Please let us know, if you
°5uencounter 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
°5uundefined (i.e., it cannot be reduced).

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

-- | Log base 2 (round down) of natural numbers. <tt>Log 0</tt> is
°5uundefined (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>.
°5u
°5uThe polymorphic kind of this type allows it to be used in several
°5usettings. For instance, it can be used as a constraint, e.g. to
°5uprovide a better error message for a non-existent instance,
°5u
°5u<pre>
°5u-- in a context
°5uinstance TypeError (Text "Cannot <a>Show</a> functions." :$$:
°5u                    Text "Perhaps there is a missing argument?")
°5u      =&gt; Show (a -&gt; b) where
°5u    showsPrec = error "unreachable"
°5u</pre>
°5u
°5uIt can also be placed on the right-hand side of a type-level function
°5uto provide an error for an invalid case,
°5u
°5u<pre>
°5utype family ByteSize x where
°5u   ByteSize Word16   = 2
°5u   ByteSize Word8    = 1
°5u   ByteSize a        = TypeError (Text "The type " :&lt;&gt;: ShowType a :&lt;&gt;:
°5u                                  Text " is not exportable.")
°5u</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
°5u<a>http://hackage.haskell.org/package/generic-deriving</a> package,
°5uwhich 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;
°5u*</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 |
°5udeclaration 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.
°5uFor example, in the following data type:
°5u
°5u<pre>
°5udata E = ExampleConstructor     Int
°5u           {-# NOUNPACK #-} Int
°5u           {-#   UNPACK #-} Int
°5u</pre>
°5u
°5uThe fields of <tt>ExampleConstructor</tt> have
°5u<a>NoSourceUnpackedness</a>, <a>SourceNoUnpack</a>, and
°5u<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
°5uexample, in the following data type:
°5u
°5u<pre>
°5udata E = ExampleConstructor Int ~Int !Int
°5u</pre>
°5u
°5uThe fields of <tt>ExampleConstructor</tt> have
°5u<a>NoSourceStrictness</a>, <a>SourceLazy</a>, and <a>SourceStrict</a>,
°5urespectively.
data SourceStrictness
NoSourceStrictness :: SourceStrictness
SourceLazy :: SourceStrictness
SourceStrict :: SourceStrictness

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

-- | Datatype to represent metadata associated with a datatype
°5u(<tt>MetaData</tt>), constructor (<tt>MetaCons</tt>), or field
°5uselector (<tt>MetaSel</tt>).
°5u
°5u<ul>
°5u<li>In <tt>MetaData n m p nt</tt>, <tt>n</tt> is the datatype's name,
°5u<tt>m</tt> is the module in which the datatype is defined, <tt>p</tt>
°5uis the package in which the datatype is defined, and <tt>nt</tt> is
°5u<tt>'True</tt> if the datatype is a <tt>newtype</tt>.</li>
°5u<li>In <tt>MetaCons n f s</tt>, <tt>n</tt> is the constructor's name,
°5u<tt>f</tt> is its fixity, and <tt>s</tt> is <tt>'True</tt> if the
°5uconstructor contains record selectors.</li>
°5u<li>In <tt>MetaSel mn su ss ds</tt>, if the field uses record syntax,
°5uthen <tt>mn</tt> is <a>Just</a> the record name. Otherwise,
°5u<tt>mn</tt> is <a>Nothing</a>. <tt>su</tt> and <tt>ss</tt> are the
°5ufield's unpackedness and strictness annotations, and <tt>ds</tt> is
°5uthe strictness that GHC infers for the field.</li>
°5u</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
°5uwith the <tt>DeriveGeneric</tt> flag on.
°5u
°5uA <a>Generic</a> instance must satisfy the following laws:
°5u
°5u<pre>
°5u<a>from</a> . <a>to</a> ≡ <tt>id</tt>
°5u<a>to</a> . <a>from</a> ≡ <tt>id</tt>
°5u</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;
°5u*</tt>, when <tt>PolyKinds</tt> is enabled). This class is derivable
°5uin GHC with the <tt>DeriveGeneric</tt> flag on.
°5u
°5uA <a>Generic1</a> instance must satisfy the following laws:
°5u
°5u<pre>
°5u<a>from1</a> . <a>to1</a> ≡ <tt>id</tt>
°5u<a>to1</a> . <a>from1</a> ≡ <tt>id</tt>
°5u</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
°5uhas an identity) with various general-purpose instances.
module Data.Monoid

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

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

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

-- | Fold a list using the monoid.
°5u
°5uFor most types, the default definition for <a>mconcat</a> will be
°5uused, but the function is included in the class definition so that an
°5uoptimized 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
°5u<a>mappend</a>.
°5u
°5u<pre>
°5u&gt;&gt;&gt; getDual (mappend (Dual "Hello") (Dual "World"))
°5u"WorldHello"
°5u</pre>
newtype Dual a
Dual :: a -> Dual a
[getDual] :: Dual a -> a

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

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

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

-- | Monoid under addition.
°5u
°5u<pre>
°5u&gt;&gt;&gt; getSum (Sum 1 &lt;&gt; Sum 2 &lt;&gt; mempty)
°5u3
°5u</pre>
newtype Sum a
Sum :: a -> Sum a
[getSum] :: Sum a -> a

-- | Monoid under multiplication.
°5u
°5u<pre>
°5u&gt;&gt;&gt; getProduct (Product 3 &lt;&gt; Product 4 &lt;&gt; mempty)
°5u12
°5u</pre>
newtype Product a
Product :: a -> Product a
[getProduct] :: Product a -> a

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

-- | Maybe monoid returning the rightmost non-Nothing value.
°5u
°5u<tt><a>Last</a> a</tt> is isomorphic to <tt><a>Dual</a> (<a>First</a>
°5ua)</tt>, and thus to <tt><a>Dual</a> (<a>Alt</a> <a>Maybe</a> a)</tt>
°5u
°5u<pre>
°5u&gt;&gt;&gt; getLast (Last (Just "hello") &lt;&gt; Last Nothing &lt;&gt; Last (Just "world"))
°5uJust "world"
°5u</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.
°5u
°5uFor example, given a data type
°5u
°5u<pre>
°5udata Tree a = Empty | Leaf a | Node (Tree a) a (Tree a)
°5u</pre>
°5u
°5ua suitable instance would be
°5u
°5u<pre>
°5uinstance Foldable Tree where
°5u   foldMap f Empty = mempty
°5u   foldMap f (Leaf x) = f x
°5u   foldMap f (Node l k r) = foldMap f l `mappend` f k `mappend` foldMap f r
°5u</pre>
°5u
°5uThis is suitable even for abstract types, as the monoid is assumed to
°5usatisfy the monoid laws. Alternatively, one could define
°5u<tt>foldr</tt>:
°5u
°5u<pre>
°5uinstance Foldable Tree where
°5u   foldr f z Empty = z
°5u   foldr f z (Leaf x) = f x z
°5u   foldr f z (Node l k r) = foldr f (f k (foldr f z r)) l
°5u</pre>
°5u
°5u<tt>Foldable</tt> instances are expected to satisfy the following
°5ulaws:
°5u
°5u<pre>
°5ufoldr f z t = appEndo (foldMap (Endo . f) t ) z
°5u</pre>
°5u
°5u<pre>
°5ufoldl f z t = appEndo (getDual (foldMap (Dual . Endo . flip f) t)) z
°5u</pre>
°5u
°5u<pre>
°5ufold = foldMap id
°5u</pre>
°5u
°5u<pre>
°5ulength = getSum . foldMap (Sum . const  1)
°5u</pre>
°5u
°5u<tt>sum</tt>, <tt>product</tt>, <tt>maximum</tt>, and <tt>minimum</tt>
°5ushould all be essentially equivalent to <tt>foldMap</tt> forms, such
°5uas
°5u
°5u<pre>
°5usum = getSum . foldMap Sum
°5u</pre>
°5u
°5ubut may be less defined.
°5u
°5uIf the type is also a <a>Functor</a> instance, it should satisfy
°5u
°5u<pre>
°5ufoldMap f = fold . fmap f
°5u</pre>
°5u
°5uwhich implies that
°5u
°5u<pre>
°5ufoldMap f . fmap g = foldMap (f . g)
°5u</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
°5uresults.
foldMap :: (Foldable t, Monoid m) => (a -> m) -> t a -> m

-- | Right-associative fold of a structure.
°5u
°5uIn the case of lists, <a>foldr</a>, when applied to a binary operator,
°5ua starting value (typically the right-identity of the operator), and a
°5ulist, reduces the list using the binary operator, from right to left:
°5u
°5u<pre>
°5ufoldr f z [x1, x2, ..., xn] == x1 `f` (x2 `f` ... (xn `f` z)...)
°5u</pre>
°5u
°5uNote that, since the head of the resulting expression is produced by
°5uan application of the operator to the first element of the list,
°5u<a>foldr</a> can produce a terminating expression from an infinite
°5ulist.
°5u
°5uFor a general <a>Foldable</a> structure this should be semantically
°5uidentical to,
°5u
°5u<pre>
°5ufoldr f z = <a>foldr</a> f z . <a>toList</a>
°5u</pre>
foldr :: Foldable t => (a -> b -> b) -> b -> t a -> b

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

-- | Left-associative fold of a structure.
°5u
°5uIn the case of lists, <a>foldl</a>, when applied to a binary operator,
°5ua starting value (typically the left-identity of the operator), and a
°5ulist, reduces the list using the binary operator, from left to right:
°5u
°5u<pre>
°5ufoldl f z [x1, x2, ..., xn] == (...((z `f` x1) `f` x2) `f`...) `f` xn
°5u</pre>
°5u
°5uNote that to produce the outermost application of the operator the
°5uentire input list must be traversed. This means that <a>foldl'</a>
°5uwill diverge if given an infinite list.
°5u
°5uAlso note that if you want an efficient left-fold, you probably want
°5uto use <a>foldl'</a> instead of <a>foldl</a>. The reason for this is
°5uthat latter does not force the "inner" results (e.g. <tt>z <tt>f</tt>
°5ux1</tt> in the above example) before applying them to the operator
°5u(e.g. to <tt>(<tt>f</tt> x2)</tt>). This results in a thunk chain
°5u<tt>O(n)</tt> elements long, which then must be evaluated from the
°5uoutside-in.
°5u
°5uFor a general <a>Foldable</a> structure this should be semantically
°5uidentical to,
°5u
°5u<pre>
°5ufoldl f z = <a>foldl</a> f z . <a>toList</a>
°5u</pre>
foldl :: Foldable t => (b -> a -> b) -> b -> t a -> b

-- | Left-associative fold of a structure but with strict application of
°5uthe operator.
°5u
°5uThis ensures that each step of the fold is forced to weak head normal
°5uform before being applied, avoiding the collection of thunks that
°5uwould otherwise occur. This is often what you want to strictly reduce
°5ua finite list to a single, monolithic result (e.g. <a>length</a>).
°5u
°5uFor a general <a>Foldable</a> structure this should be semantically
°5uidentical to,
°5u
°5u<pre>
°5ufoldl f z = <a>foldl'</a> f z . <a>toList</a>
°5u</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
°5uapplied to non-empty structures.
°5u
°5u<pre>
°5u<a>foldr1</a> f = <a>foldr1</a> f . <a>toList</a>
°5u</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
°5uapplied to non-empty structures.
°5u
°5u<pre>
°5u<a>foldl1</a> f = <a>foldl1</a> f . <a>toList</a>
°5u</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
°5uoptimized for structures that are similar to cons-lists, because there
°5uis 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
°5udefault implementation is optimized for structures that are similar to
°5ucons-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
°5ustructure.
sum :: (Foldable t, Num a) => t a -> a

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

-- | Monadic fold over the elements of a structure, associating to the
°5uright, 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
°5uleft, 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
°5ufrom left to right, and ignore the results. For a version that doesn't
°5uignore 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
°5uversion that doesn't ignore the results see <a>for</a>.
°5u
°5u<pre>
°5u&gt;&gt;&gt; for_ [1..4] print
°5u1
°5u2
°5u3
°5u4
°5u</pre>
for_ :: (Foldable t, Applicative f) => t a -> (a -> f b) -> f ()

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

-- | The sum of a collection of actions, generalizing <a>concat</a>.
°5u
°5uasum [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
°5uactions from left to right, and ignore the results. For a version that
°5udoesn't ignore the results see <a>mapM</a>.
°5u
°5uAs of base 4.8.0.0, <a>mapM_</a> is just <a>traverse_</a>, specialized
°5uto <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
°5uthat doesn't ignore the results see <a>forM</a>.
°5u
°5uAs of base 4.8.0.0, <a>forM_</a> is just <a>for_</a>, specialized to
°5u<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
°5uignore the results. For a version that doesn't ignore the results see
°5u<a>sequence</a>.
°5u
°5uAs of base 4.8.0.0, <a>sequence_</a> is just <a>sequenceA_</a>,
°5uspecialized 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
°5ubase 4.8.0.0, <a>msum</a> is just <a>asum</a>, specialized to
°5u<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
°5uthe resulting lists.
concatMap :: Foldable t => (a -> [b]) -> t a -> [b]

-- | <a>and</a> returns the conjunction of a container of Bools. For the
°5uresult to be <a>True</a>, the container must be finite; <a>False</a>,
°5uhowever, results from a <a>False</a> value finitely far from the left
°5uend.
and :: Foldable t => t Bool -> Bool

-- | <a>or</a> returns the disjunction of a container of Bools. For the
°5uresult to be <a>False</a>, the container must be finite; <a>True</a>,
°5uhowever, results from a <a>True</a> value finitely far from the left
°5uend.
or :: Foldable t => t Bool -> Bool

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

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

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

-- | The least element of a non-empty structure with respect to the given
°5ucomparison 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
°5uthe leftmost element of the structure matching the predicate, or
°5u<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
°5uthat described by,
°5u
°5u<ul>
°5u<li>Simon Peyton-Jones, Stephanie Weirich, Richard Eisenberg,
°5uDimitrios Vytiniotis. "A reflection on types." /Proc. Philip Wadler's
°5u60th birthday Festschrift/, Edinburgh (April 2016).</li>
°5u</ul>
°5u
°5uThe interface provides <tt>TypeRep</tt>, a type representation which
°5ucan be safely decomposed and composed. See <a>Data.Dynamic</a> for an
°5uexample of this.
module Type.Reflection

-- | The class <a>Typeable</a> allows a concrete representation of a type
°5uto 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
°5uterminating value, then the type <tt>a</tt> is the same as the type
°5u<tt>b</tt>. To use this equality in practice, pattern-match on the
°5u<tt>a :~: b</tt> to get out the <tt>Refl</tt> constructor; in the body
°5uof 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 :~~:
°5ub</tt> is inhabited by a terminating value if and only if <tt>a</tt>
°5uis 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>
°5usupports reasonably efficient equality.
data TypeRep (a :: k)
typeOf :: Typeable a => a -> TypeRep a

-- | A type application.
°5u
°5uFor instance,
°5u
°5u<pre>
°5utypeRep @(Maybe Int) === App (typeRep @Maybe) (typeRep @Int)
°5u</pre>
°5u
°5uNote that this will also match a function type,
°5u
°5u<pre>
°5utypeRep @(Int# -&gt; Char)
°5u  ===
°5uApp (App arrow (typeRep @Int#)) (typeRep @Char)
°5u</pre>
°5u
°5uwhere <tt>arrow :: TypeRep ((-&gt;) :: TYPE IntRep -&gt; Type -&gt;
°5uType)</tt>.

-- | Pattern match on a type constructor

-- | Pattern match on a type constructor including its instantiated kind
°5uvariables.
°5u
°5uFor instance,
°5u
°5u<pre>
°5uApp (Con' proxyTyCon ks) intRep = typeRep @(Proxy @Int)
°5u</pre>
°5u
°5uwill bring into scope,
°5u
°5u<pre>
°5uproxyTyCon :: TyCon
°5uks         == [someTypeRep <tt>Type] :: [SomeTypeRep]
°5uintRep     == typeRep </tt>Int
°5u</pre>

-- | The function type constructor.
°5u
°5uFor instance,
°5u
°5u<pre>
°5utypeRep @(Int -&gt; Char) === Fun (typeRep @Int) (typeRep @Char)
°5u</pre>

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

-- | Helper to fully evaluate <a>TypeRep</a> for use as
°5u<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
°5uof 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
°5u<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>
°5uimplementation
rnfModule :: Module -> ()


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

-- | The class <a>Typeable</a> allows a concrete representation of a type
°5uto 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
°5uof that type.
typeRep :: forall proxy a. Typeable a => proxy a -> TypeRep

-- | Propositional equality. If <tt>a :~: b</tt> is inhabited by some
°5uterminating value, then the type <tt>a</tt> is the same as the type
°5u<tt>b</tt>. To use this equality in practice, pattern-match on the
°5u<tt>a :~: b</tt> to get out the <tt>Refl</tt> constructor; in the body
°5uof 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 :~~:
°5ub</tt> is inhabited by a terminating value if and only if <tt>a</tt>
°5uis 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
°5uof arbitrary type (or even kind). Its use is to provide type
°5uinformation, even though there is no value available of that type (or
°5uit may be too costly to create one).
°5u
°5uHistorically, <tt><a>Proxy</a> :: <a>Proxy</a> a</tt> is a safer
°5ualternative to the <tt>'undefined :: a'</tt> idiom.
°5u
°5u<pre>
°5u&gt;&gt;&gt; Proxy :: Proxy (Void, Int -&gt; Int)
°5uProxy
°5u</pre>
°5u
°5uProxy can even hold types of higher kinds,
°5u
°5u<pre>
°5u&gt;&gt;&gt; Proxy :: Proxy Either
°5uProxy
°5u</pre>
°5u
°5u<pre>
°5u&gt;&gt;&gt; Proxy :: Proxy Functor
°5uProxy
°5u</pre>
°5u
°5u<pre>
°5u&gt;&gt;&gt; Proxy :: Proxy complicatedStructure
°5uProxy
°5u</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
°5ufirst argument represents a function of type <tt>t -&gt; u</tt> and
°5uthe second argument represents a function of type <tt>t</tt>.
°5uOtherwise, returns <tt>Nothing</tt>.
funResultTy :: TypeRep -> TypeRep -> Maybe TypeRep

-- | Splits a type constructor application. Note that if the type
°5uconstructor is polymorphic, this will not return the kinds that were
°5uused.
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
°5uof 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
°5uForeign Function Interface (FFI) and will usually be imported via the
°5u<a>Foreign</a> module.
°5u
°5uUnsafe API Only.
module Foreign.ForeignPtr.Unsafe

-- | This function extracts the pointer component of a foreign pointer.
°5uThis is a potentially dangerous operations, as if the argument to
°5u<a>unsafeForeignPtrToPtr</a> is the last usage occurrence of the given
°5uforeign pointer, then its finalizer(s) will be run, which potentially
°5uinvalidates the plain pointer just obtained. Hence,
°5u<a>touchForeignPtr</a> must be used wherever it has to be guaranteed
°5uthat the pointer lives on - i.e., has another usage occurrence.
°5u
°5uTo avoid subtle coding errors, hand written marshalling code should
°5upreferably use <a>withForeignPtr</a> rather than combinations of
°5u<a>unsafeForeignPtrToPtr</a> and <a>touchForeignPtr</a>. However, the
°5ulatter routines are occasionally preferred in tool generated
°5umarshalling code.
unsafeForeignPtrToPtr :: ForeignPtr a -> Ptr a


-- | The <a>ForeignPtr</a> type and operations. This module is part of the
°5uForeign Function Interface (FFI) and will usually be imported via the
°5u<a>Foreign</a> module.
°5u
°5uSafe API Only.

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

-- | The type <a>ForeignPtr</a> represents references to objects that are
°5umaintained in a foreign language, i.e., that are not part of the data
°5ustructures usually managed by the Haskell storage manager. The
°5uessential difference between <a>ForeignPtr</a>s and vanilla memory
°5ureferences of type <tt>Ptr a</tt> is that the former may be associated
°5uwith <i>finalizers</i>. A finalizer is a routine that is invoked when
°5uthe Haskell storage manager detects that - within the Haskell heap and
°5ustack - there are no more references left that are pointing to the
°5u<a>ForeignPtr</a>. Typically, the finalizer will, then, invoke
°5uroutines in the foreign language that free the resources bound by the
°5uforeign object.
°5u
°5uThe <a>ForeignPtr</a> is parameterised in the same way as <a>Ptr</a>.
°5uThe type argument of <a>ForeignPtr</a> should normally be an instance
°5uof class <a>Storable</a>.
data ForeignPtr a

-- | A finalizer is represented as a pointer to a foreign function that, at
°5ufinalisation time, gets as an argument a plain pointer variant of the
°5uforeign pointer that the finalizer is associated with.
°5u
°5uNote that the foreign function <i>must</i> use the <tt>ccall</tt>
°5ucalling 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
°5ua finalizer with the reference. The finalizer will be executed after
°5uthe last reference to the foreign object is dropped. There is no
°5uguarantee of promptness, however the finalizer will be executed before
°5uthe program exits.
newForeignPtr :: FinalizerPtr a -> Ptr a -> IO (ForeignPtr a)

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

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

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

-- | Like <a>addForeignPtrFinalizerEnv</a> but allows the finalizer to be
°5upassed an additional environment parameter to be passed to the
°5ufinalizer. The environment passed to the finalizer is fixed by the
°5usecond 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.
°5uThis function takes a function which is applied to that pointer. The
°5uresulting <a>IO</a> action is then executed. The foreign object is
°5ukept alive at least during the whole action, even if it is not used
°5udirectly inside. Note that it is not safe to return the pointer from
°5uthe action and use it after the action completes. All uses of the
°5upointer should be inside the <a>withForeignPtr</a> bracket. The reason
°5ufor this unsafeness is the same as for <a>unsafeForeignPtrToPtr</a>
°5ubelow: the finalizer may run earlier than expected, because the
°5ucompiler can only track usage of the <a>ForeignPtr</a> object, not a
°5u<a>Ptr</a> object made from it.
°5u
°5uThis function is normally used for marshalling data to or from the
°5uobject pointed to by the <a>ForeignPtr</a>, using the operations from
°5uthe <a>Storable</a> class.
withForeignPtr :: ForeignPtr a -> (Ptr a -> IO b) -> IO b

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

-- | This function ensures that the foreign object in question is alive at
°5uthe given place in the sequence of IO actions. In particular
°5u<a>withForeignPtr</a> does a <a>touchForeignPtr</a> after it executes
°5uthe user action.
°5u
°5uNote that this function should not be used to express dependencies
°5ubetween finalizers on <a>ForeignPtr</a>s. For example, if the
°5ufinalizer for a <a>ForeignPtr</a> <tt>F1</tt> calls
°5u<a>touchForeignPtr</a> on a second <a>ForeignPtr</a> <tt>F2</tt>, then
°5uthe only guarantee is that the finalizer for <tt>F2</tt> is never
°5ustarted before the finalizer for <tt>F1</tt>. They might be started
°5utogether if for example both <tt>F1</tt> and <tt>F2</tt> are otherwise
°5uunreachable, and in that case the scheduler might end up running the
°5ufinalizer for <tt>F2</tt> first.
°5u
°5uIn general, it is not recommended to use finalizers on separate
°5uobjects with ordering constraints between them. To express the
°5uordering robustly requires explicit synchronisation using
°5u<tt>MVar</tt>s between the finalizers, but even then the runtime
°5usometimes runs multiple finalizers sequentially in a single thread
°5u(for performance reasons), so synchronisation between finalizers could
°5uresult in artificial deadlock. Another alternative is to use explicit
°5ureference counting.
touchForeignPtr :: ForeignPtr a -> IO ()

-- | This function casts a <a>ForeignPtr</a> parameterised by one type into
°5uanother type.
castForeignPtr :: ForeignPtr a -> ForeignPtr b

-- | Allocate some memory and return a <a>ForeignPtr</a> to it. The memory
°5uwill be released automatically when the <a>ForeignPtr</a> is
°5udiscarded.
°5u
°5u<a>mallocForeignPtr</a> is equivalent to
°5u
°5u<pre>
°5udo { p &lt;- malloc; newForeignPtr finalizerFree p }
°5u</pre>
°5u
°5ualthough it may be implemented differently internally: you may not
°5uassume that the memory returned by <a>mallocForeignPtr</a> has been
°5uallocated with <a>malloc</a>.
°5u
°5uGHC notes: <a>mallocForeignPtr</a> has a heavily optimised
°5uimplementation in GHC. It uses pinned memory in the garbage collected
°5uheap, so the <a>ForeignPtr</a> does not require a finalizer to free
°5uthe memory. Use of <a>mallocForeignPtr</a> and associated functions is
°5ustrongly recommended in preference to <tt>newForeignPtr</tt> with a
°5ufinalizer.
mallocForeignPtr :: Storable a => IO (ForeignPtr a)

-- | This function is similar to <a>mallocForeignPtr</a>, except that the
°5usize 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
°5uarea that has a finalizer attached that releases the memory area. As
°5uwith <a>mallocForeignPtr</a>, it is not guaranteed that the block of
°5umemory 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
°5uarea that has a finalizer attached that releases the memory area. As
°5uwith <a>mallocForeignPtr</a>, it is not guaranteed that the block of
°5umemory 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
°5uForeign Function Interface (FFI) and will usually be imported via the
°5u<a>Foreign</a> module.
°5u
°5uFor non-portable support of Haskell finalizers, see the
°5u<a>Foreign.Concurrent</a> module.
module Foreign.ForeignPtr

-- | The type <a>ForeignPtr</a> represents references to objects that are
°5umaintained in a foreign language, i.e., that are not part of the data
°5ustructures usually managed by the Haskell storage manager. The
°5uessential difference between <a>ForeignPtr</a>s and vanilla memory
°5ureferences of type <tt>Ptr a</tt> is that the former may be associated
°5uwith <i>finalizers</i>. A finalizer is a routine that is invoked when
°5uthe Haskell storage manager detects that - within the Haskell heap and
°5ustack - there are no more references left that are pointing to the
°5u<a>ForeignPtr</a>. Typically, the finalizer will, then, invoke
°5uroutines in the foreign language that free the resources bound by the
°5uforeign object.
°5u
°5uThe <a>ForeignPtr</a> is parameterised in the same way as <a>Ptr</a>.
°5uThe type argument of <a>ForeignPtr</a> should normally be an instance
°5uof class <a>Storable</a>.
data ForeignPtr a

-- | A finalizer is represented as a pointer to a foreign function that, at
°5ufinalisation time, gets as an argument a plain pointer variant of the
°5uforeign pointer that the finalizer is associated with.
°5u
°5uNote that the foreign function <i>must</i> use the <tt>ccall</tt>
°5ucalling 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
°5ua finalizer with the reference. The finalizer will be executed after
°5uthe last reference to the foreign object is dropped. There is no
°5uguarantee of promptness, however the finalizer will be executed before
°5uthe program exits.
newForeignPtr :: FinalizerPtr a -> Ptr a -> IO (ForeignPtr a)

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

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

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

-- | Like <a>addForeignPtrFinalizerEnv</a> but allows the finalizer to be
°5upassed an additional environment parameter to be passed to the
°5ufinalizer. The environment passed to the finalizer is fixed by the
°5usecond 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.
°5uThis function takes a function which is applied to that pointer. The
°5uresulting <a>IO</a> action is then executed. The foreign object is
°5ukept alive at least during the whole action, even if it is not used
°5udirectly inside. Note that it is not safe to return the pointer from
°5uthe action and use it after the action completes. All uses of the
°5upointer should be inside the <a>withForeignPtr</a> bracket. The reason
°5ufor this unsafeness is the same as for <a>unsafeForeignPtrToPtr</a>
°5ubelow: the finalizer may run earlier than expected, because the
°5ucompiler can only track usage of the <a>ForeignPtr</a> object, not a
°5u<a>Ptr</a> object made from it.
°5u
°5uThis function is normally used for marshalling data to or from the
°5uobject pointed to by the <a>ForeignPtr</a>, using the operations from
°5uthe <a>Storable</a> class.
withForeignPtr :: ForeignPtr a -> (Ptr a -> IO b) -> IO b

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

-- | This function ensures that the foreign object in question is alive at
°5uthe given place in the sequence of IO actions. In particular
°5u<a>withForeignPtr</a> does a <a>touchForeignPtr</a> after it executes
°5uthe user action.
°5u
°5uNote that this function should not be used to express dependencies
°5ubetween finalizers on <a>ForeignPtr</a>s. For example, if the
°5ufinalizer for a <a>ForeignPtr</a> <tt>F1</tt> calls
°5u<a>touchForeignPtr</a> on a second <a>ForeignPtr</a> <tt>F2</tt>, then
°5uthe only guarantee is that the finalizer for <tt>F2</tt> is never
°5ustarted before the finalizer for <tt>F1</tt>. They might be started
°5utogether if for example both <tt>F1</tt> and <tt>F2</tt> are otherwise
°5uunreachable, and in that case the scheduler might end up running the
°5ufinalizer for <tt>F2</tt> first.
°5u
°5uIn general, it is not recommended to use finalizers on separate
°5uobjects with ordering constraints between them. To express the
°5uordering robustly requires explicit synchronisation using
°5u<tt>MVar</tt>s between the finalizers, but even then the runtime
°5usometimes runs multiple finalizers sequentially in a single thread
°5u(for performance reasons), so synchronisation between finalizers could
°5uresult in artificial deadlock. Another alternative is to use explicit
°5ureference counting.
touchForeignPtr :: ForeignPtr a -> IO ()

-- | This function casts a <a>ForeignPtr</a> parameterised by one type into
°5uanother type.
castForeignPtr :: ForeignPtr a -> ForeignPtr b

-- | Advances the given address by the given offset in bytes.
°5u
°5uThe new <a>ForeignPtr</a> shares the finalizer of the original,
°5uequivalent from a finalization standpoint to just creating another
°5ureference to the original. That is, the finalizer will not be called
°5ubefore the new <a>ForeignPtr</a> is unreachable, nor will it be called
°5uan additional time due to this call, and the finalizer will be called
°5uwith the same address that it would have had this call not happened,
°5u*not* the new address.
plusForeignPtr :: ForeignPtr a -> Int -> ForeignPtr b

-- | Allocate some memory and return a <a>ForeignPtr</a> to it. The memory
°5uwill be released automatically when the <a>ForeignPtr</a> is
°5udiscarded.
°5u
°5u<a>mallocForeignPtr</a> is equivalent to
°5u
°5u<pre>
°5udo { p &lt;- malloc; newForeignPtr finalizerFree p }
°5u</pre>
°5u
°5ualthough it may be implemented differently internally: you may not
°5uassume that the memory returned by <a>mallocForeignPtr</a> has been
°5uallocated with <a>malloc</a>.
°5u
°5uGHC notes: <a>mallocForeignPtr</a> has a heavily optimised
°5uimplementation in GHC. It uses pinned memory in the garbage collected
°5uheap, so the <a>ForeignPtr</a> does not require a finalizer to free
°5uthe memory. Use of <a>mallocForeignPtr</a> and associated functions is
°5ustrongly recommended in preference to <tt>newForeignPtr</tt> with a
°5ufinalizer.
mallocForeignPtr :: Storable a => IO (ForeignPtr a)

-- | This function is similar to <a>mallocForeignPtr</a>, except that the
°5usize 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
°5uarea that has a finalizer attached that releases the memory area. As
°5uwith <a>mallocForeignPtr</a>, it is not guaranteed that the block of
°5umemory 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
°5uarea that has a finalizer attached that releases the memory area. As
°5uwith <a>mallocForeignPtr</a>, it is not guaranteed that the block of
°5umemory 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.
°5u
°5uThe buffer is represented by a record, where the record contains the
°5uraw buffer and the start/end points of the filled portion. The buffer
°5ucontents itself is mutable, but the rest of the record is immutable.
°5uThis is a slightly odd mix, but it turns out to be quite practical: by
°5umaking all the buffer metadata immutable, we can have operations on
°5ubuffer metadata outside of the IO monad.
°5u
°5uThe "live" elements of the buffer are those between the <a>bufL</a>
°5uand <a>bufR</a> offsets. In an empty buffer, <a>bufL</a> is equal to
°5u<a>bufR</a>, but they might not be zero: for example, the buffer might
°5ucorrespond to a memory-mapped file and in which case <a>bufL</a> will
°5upoint to the next location to be written, which is not necessarily the
°5ubeginning 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
°5u<tt>from</tt> to the buffer <tt>to</tt>. It should translate as many
°5uelements as possible given the sizes of the buffers, including
°5utranslating zero elements if there is either not enough room in
°5u<tt>to</tt>, or <tt>from</tt> does not contain a complete multibyte
°5usequence.
°5u
°5uIf multiple CodingProgress returns are possible, OutputUnderflow must
°5ube preferred to InvalidSequence. This allows GHC's IO library to
°5uassume that if we observe InvalidSequence there is at least a single
°5uelement available in the output buffer.
°5u
°5uThe fact that as many elements as possible are translated is used by
°5uthe IO library in order to report translation errors at the point they
°5uactually 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
°5upresence of invalid or unrepresentable sequences. This includes both
°5uthose detected by <tt>encode</tt> returning <tt>InvalidSequence</tt>
°5uand those that occur because the input byte sequence appears to be
°5utruncated.
°5u
°5uProgress will usually be made by skipping the first element of the
°5u<tt>from</tt> buffer. This function should only be called if you are
°5ucertain that you wish to do this skipping and if the <tt>to</tt>
°5ubuffer has at least one element of free space. Because this function
°5udeals with decoding failure, it assumes that the from buffer has at
°5uleast one element.
°5u
°5u<tt>recover</tt> may raise an exception rather than skipping anything.
°5u
°5uCurrently, some implementations of <tt>recover</tt> may mutate the
°5uinput buffer. In particular, this feature is used to implement
°5utransliteration.
[recover] :: BufferCodec from to state -> Buffer from -> Buffer to -> IO (Buffer from, Buffer to)

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

-- | Return the current state of the codec.
°5u
°5uMany codecs are not stateful, and in these case the state can be
°5urepresented as '()'. Other codecs maintain a state. For example,
°5uUTF-16 recognises a BOM (byte-order-mark) character at the beginning
°5uof the input, and remembers thereafter whether to use big-endian or
°5ulittle-endian mode. In this case, the state of the codec would include
°5utwo pieces of information: whether we are at the beginning of the
°5ustream (the BOM only occurs at the beginning), and if not, whether to
°5uuse 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
°5ubetween sequences of bytes and sequences of Unicode characters.
°5u
°5uFor example, UTF-8 is an encoding of Unicode characters into a
°5usequence 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
°5uequivalent <a>TextEncoding</a>.
[textEncodingName] :: TextEncoding -> String

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

-- | Creates a means of encode characters into bytes: the result must not
°5ube shared between several character sequences or simultaneously across
°5uthreads
[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
°5uall 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
°5uoutput at least one encoded ASCII character, but the input contains an
°5uinvalid 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>.
°5u
°5uBe warned that <a>modifyIORef</a> does not apply the function
°5ustrictly. This means if the program calls <a>modifyIORef</a> many
°5utimes, but seldomly uses the value, thunks will pile up in memory
°5uresulting in a space leak. This is a common mistake made when using an
°5uIORef as a counter. For example, the following will likely produce a
°5ustack overflow:
°5u
°5u<pre>
°5uref &lt;- newIORef 0
°5ureplicateM_ 1000000 $ modifyIORef ref (+1)
°5ureadIORef ref &gt;&gt;= print
°5u</pre>
°5u
°5uTo 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>.
°5u
°5uThis function is useful for using <a>IORef</a> in a safe way in a
°5umultithreaded program. If you only have one <a>IORef</a>, then using
°5u<a>atomicModifyIORef</a> to access and modify it will prevent race
°5uconditions.
°5u
°5uExtending the atomicity to multiple <a>IORef</a>s is problematic, so
°5uit is recommended that if you need to do anything more complicated
°5uthen using <a>MVar</a> instead is a good idea.
°5u
°5u<a>atomicModifyIORef</a> does not apply the function strictly. This is
°5uimportant to know even if all you are doing is replacing the value.
°5uFor example, this will leak memory:
°5u
°5u<pre>
°5uref &lt;- newIORef '1'
°5uforever $ atomicModifyIORef ref (\_ -&gt; ('2', ()))
°5u</pre>
°5u
°5uUse <a>atomicModifyIORef'</a> or <a>atomicWriteIORef</a> to avoid this
°5uproblem.
atomicModifyIORef :: IORef a -> (a -> (a, b)) -> IO b

-- | Strict version of <a>atomicModifyIORef</a>. This forces both the value
°5ustored 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
°5uthat <a>atomicModifyIORef</a> has.
atomicWriteIORef :: IORef a -> a -> IO ()

-- | Make a <a>Weak</a> pointer to an <a>IORef</a>, using the second
°5uargument 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
°5ubytes actually read. This function should only block if there is no
°5udata available. If there is not enough data available, then the
°5ufunction should just return the available data. A return value of zero
°5uindicates that the end of the data stream (e.g. end of file) has been
°5ureached.
read :: RawIO a => a -> Ptr Word8 -> Int -> IO Int

-- | Read up to the specified number of bytes, returning the number of
°5ubytes actually read, or <a>Nothing</a> if the end of the stream has
°5ubeen 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
°5uthe 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
°5udata to read (if <tt>write</tt> is <a>False</a>) or space to write new
°5udata (if <tt>write</tt> is <a>True</a>). <tt>msecs</tt> specifies how
°5ulong to wait, in milliseconds.
ready :: IODevice a => a -> Bool -> Int -> IO Bool

-- | closes the device. Further operations on the device should produce
°5uexceptions.
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
°5udevice.
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
°5uentered are immediately made available to the program. If available,
°5uthis 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
°5ushare a file pointer with the original device (like Unix
°5u<tt>dup</tt>).
dup :: IODevice a => a -> IO a

-- | <tt>dup2 source target</tt> replaces the target device with the source
°5udevice. The target device is closed first, if necessary, and then it
°5uis made into a duplicate of the first device (like Unix
°5u<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
°5u<a>mkFileHandle</a>). The standard libraries provide creation of
°5u<a>Handle</a>s via Posix file operations with file descriptors (see
°5u<a>mkHandleFromFD</a>) with FD being the underlying <a>IODevice</a>
°5uinstance.
°5u
°5uUsers may provide custom instances of <a>IODevice</a> which are
°5uexpected to conform the following rules:
data IODeviceType

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

-- | A duplex communications channel (results in creation of a duplex
°5u<a>Handle</a>). The standard libraries use this device type when
°5ucreating <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
°5uoperations and may be seekable only to positions of certain
°5ugranularity (block- aligned).
RawDevice :: IODeviceType

-- | A mode that determines the effect of <tt>hSeek</tt> <tt>hdl mode
°5ui</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
°5ucurrent position.
RelativeSeek :: SeekMode

-- | the position of <tt>hdl</tt> is set to offset <tt>i</tt> from the end
°5uof 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
°5uI/O devices that can read and write data through a buffer. Devices
°5uthat implement <a>BufferedIO</a> include ordinary files, memory-mapped
°5ufiles, and bytestrings. The underlying device implementing a
°5u<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
°5uthe device; e.g. for a memory-mapped file the buffer will probably
°5ucover the entire file.
newBuffer :: BufferedIO dev => dev -> BufferState -> IO (Buffer Word8)

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

-- | reads bytes into the buffer without blocking. Returns the number of
°5ubytes 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
°5uup a write buffer: the buffer may need to point to a specific location
°5uin memory, for example. This is typically used by the client when
°5uswitching from reading to writing on a buffered read/write device.
°5u
°5uThere is no corresponding operation for read buffers, because before
°5ureading 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.
°5uThe 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
°5ublocking. Returns the number of bytes written and the remaining
°5ubuffer.
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
°5u<tt>TextEncoding</tt>s, and specifies how they handle illegal
°5usequences.
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
°5usequences to be roundtripped.
RoundtripFailure :: CodingFailureMode
codingFailureModeSuffix :: CodingFailureMode -> String

-- | Some characters are actually "surrogate" codepoints defined for use in
°5uUTF-16. We need to signal an invalid character if we detect them when
°5uencoding a sequence of <a>Char</a>s into <a>Word8</a>s because they
°5uwon't give valid Unicode.
°5u
°5uWe may also need to signal an invalid character if we detect them when
°5uencoding a sequence of <a>Char</a>s into <a>Word8</a>s because the
°5u<a>RoundtripFailure</a> mode creates these to round-trip bytes through
°5uour 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
°5u
°5uPortions Copyright : (c) Tom Harper 2008-2009, (c) Bryan O'Sullivan
°5u2009, (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
°5u
°5uPortions Copyright : (c) Tom Harper 2008-2009, (c) Bryan O'Sullivan
°5u2009, (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
°5u
°5uPortions Copyright : (c) Tom Harper 2008-2009, (c) Bryan O'Sullivan
°5u2009, (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.
°5u
°5uPortions Copyright : (c) Tom Harper 2008-2009, (c) Bryan O'Sullivan
°5u2009, (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>
°5uexception 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
°5upredicate yields <a>True</a> when applied to the result returned by
°5uthe <a>IO</a> action. If no exception is raised, return the result of
°5uthe 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
°5uallocate and deallocate blocks of raw memory (i.e., unstructured
°5uchunks of memory outside of the area maintained by the Haskell storage
°5umanager). These memory blocks are commonly used to pass compound data
°5ustructures to foreign functions or to provide space in which compound
°5uresult values are obtained from foreign functions.
°5u
°5uIf any of the allocation functions fails, an exception is thrown. In
°5usome cases, memory exhaustion may mean the process is terminated. If
°5u<a>free</a> or <a>reallocBytes</a> is applied to a memory area that
°5uhas been allocated with <a>alloca</a> or <a>allocaBytes</a>, the
°5ubehaviour is undefined. Any further access to memory areas allocated
°5uwith <a>alloca</a> or <a>allocaBytes</a>, after the computation that
°5uwas passed to the allocation function has terminated, leads to
°5uundefined behaviour. Any further access to the memory area referenced
°5uby a pointer passed to <a>realloc</a>, <a>reallocBytes</a>, or
°5u<a>free</a> entails undefined behaviour.
°5u
°5uAll storage allocated by functions that allocate based on a <i>size in
°5ubytes</i> must be sufficiently aligned for any of the basic foreign
°5utypes that fits into the newly allocated storage. All storage
°5uallocated by functions that allocate based on a specific type must be
°5usufficiently aligned for that type. Array allocation routines need to
°5uobey 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
°5uas argument a pointer to a temporarily allocated block of memory
°5usufficient to hold values of type <tt>a</tt>.
°5u
°5uThe memory is freed when <tt>f</tt> terminates (either normally or via
°5uan exception), so the pointer passed to <tt>f</tt> must <i>not</i> be
°5uused after this.
alloca :: Storable a => (Ptr a -> IO b) -> IO b

-- | <tt><a>allocaBytes</a> n f</tt> executes the computation <tt>f</tt>,
°5upassing as argument a pointer to a temporarily allocated block of
°5umemory of <tt>n</tt> bytes. The block of memory is sufficiently
°5ualigned for any of the basic foreign types that fits into a memory
°5ublock of the allocated size.
°5u
°5uThe memory is freed when <tt>f</tt> terminates (either normally or via
°5uan exception), so the pointer passed to <tt>f</tt> must <i>not</i> be
°5uused 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
°5u<tt>a</tt>. The size of the area allocated is determined by the
°5u<a>sizeOf</a> method from the instance of <a>Storable</a> for the
°5uappropriate type.
°5u
°5uThe memory may be deallocated using <a>free</a> or
°5u<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
°5umemory is sufficiently aligned for any of the basic foreign types that
°5ufits into a memory block of the allocated size.
°5u
°5uThe memory may be deallocated using <a>free</a> or
°5u<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
°5uzero.
callocBytes :: Int -> IO (Ptr a)

-- | Resize a memory area that was allocated with <a>malloc</a> or
°5u<a>mallocBytes</a> to the size needed to store values of type
°5u<tt>b</tt>. The returned pointer may refer to an entirely different
°5umemory area, but will be suitably aligned to hold values of type
°5u<tt>b</tt>. The contents of the referenced memory area will be the
°5usame as of the original pointer up to the minimum of the original size
°5uand the size of values of type <tt>b</tt>.
°5u
°5uIf the argument to <a>realloc</a> is <a>nullPtr</a>, <a>realloc</a>
°5ubehaves like <a>malloc</a>.
realloc :: Storable b => Ptr a -> IO (Ptr b)

-- | Resize a memory area that was allocated with <a>malloc</a> or
°5u<a>mallocBytes</a> to the given size. The returned pointer may refer
°5uto an entirely different memory area, but will be sufficiently aligned
°5ufor any of the basic foreign types that fits into a memory block of
°5uthe given size. The contents of the referenced memory area will be the
°5usame as of the original pointer up to the minimum of the original size
°5uand the given size.
°5u
°5uIf the pointer argument to <a>reallocBytes</a> is <a>nullPtr</a>,
°5u<a>reallocBytes</a> behaves like <a>malloc</a>. If the requested size
°5uis 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>,
°5u<a>mallocBytes</a>, <a>realloc</a>, <a>reallocBytes</a>, <a>new</a> or
°5uany of the <tt>new</tt><i>X</i> functions in
°5u<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
°5ube used as a finalizer (cf <a>ForeignPtr</a>) for storage allocated
°5uwith <a>malloc</a>, <a>mallocBytes</a>, <a>realloc</a> or
°5u<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>,
°5upassing as argument a pointer to a temporarily allocated block of
°5umemory into which <tt>val</tt> has been marshalled (the combination of
°5u<a>alloca</a> and <a>poke</a>).
°5u
°5uThe memory is freed when <tt>f</tt> terminates (either normally or via
°5uan exception), so the pointer passed to <tt>f</tt> must <i>not</i> be
°5uused after this.
with :: Storable a => a -> (Ptr a -> IO b) -> IO b

-- | Allocate a block of memory and marshal a value into it (the
°5ucombination of <a>malloc</a> and <a>poke</a>). The size of the area
°5uallocated is determined by the <a>sizeOf</a> method from the instance
°5uof <a>Storable</a> for the appropriate type.
°5u
°5uThe memory may be deallocated using <a>free</a> or
°5u<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
°5u<a>Maybe</a>
°5u
°5u<ul>
°5u<li>the <a>nullPtr</a> is used to represent <a>Nothing</a></li>
°5u</ul>
maybeNew :: (a -> IO (Ptr b)) -> (Maybe a -> IO (Ptr b))

-- | Converts a <tt>withXXX</tt> combinator into one marshalling a value
°5uwrapped into a <a>Maybe</a>, using <a>nullPtr</a> to represent
°5u<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
°5uapplied 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,
°5uyielding 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
°5uthe 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
°5uthe 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
°5uHaskell 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
°5u(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
°5utermination element.
mallocArray0 :: Storable a => Int -> IO (Ptr a)

-- | Temporarily allocate space for the given number of elements (like
°5u<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
°5utermination 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
°5umarker.
reallocArray0 :: Storable a => Ptr a -> Int -> IO (Ptr a)

-- | Like <a>mallocArray</a>, but allocated memory is filled with bytes of
°5uvalue zero.
callocArray :: Storable a => Int -> IO (Ptr a)

-- | Like <a>callocArray0</a>, but allocated memory is filled with bytes of
°5uvalue zero.
callocArray0 :: Storable a => Int -> IO (Ptr a)

-- | Convert an array of given length into a Haskell list. The
°5uimplementation 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
°5ulist
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
°5uwith the given marker element
pokeArray0 :: Storable a => a -> Ptr a -> [a] -> IO ()

-- | Write a list of storable elements into a newly allocated, consecutive
°5usequence of storable values (like <a>new</a>, but for multiple
°5uelements).
newArray :: Storable a => [a] -> IO (Ptr a)

-- | Write a list of storable elements into a newly allocated, consecutive
°5usequence of storable values, where the end is fixed by the given end
°5umarker
newArray0 :: Storable a => a -> [a] -> IO (Ptr a)

-- | Temporarily store a list of storable values in memory (like
°5u<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
°5uadditional parameter
withArrayLen :: Storable a => [a] -> (Int -> Ptr a -> IO b) -> IO b

-- | Like <a>withArrayLen</a>, but a terminator indicates where the array
°5uends
withArrayLen0 :: Storable a => a -> [a] -> (Int -> Ptr a -> IO b) -> IO b

-- | Copy the given number of elements from the second array (source) into
°5uthe 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
°5uthe 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.
°5u
°5u<ul>
°5u<li>the Haskell string may <i>not</i> contain any NUL characters</li>
°5u<li>new storage is allocated for the C string and must be explicitly
°5ufreed using <a>free</a> or <a>finalizerFree</a>.</li>
°5u</ul>
newCString :: TextEncoding -> String -> IO CString

-- | Marshal a Haskell string into a C string (ie, character array) with
°5uexplicit length information.
°5u
°5u<ul>
°5u<li>new storage is allocated for the C string and must be explicitly
°5ufreed using <a>free</a> or <a>finalizerFree</a>.</li>
°5u</ul>
newCStringLen :: TextEncoding -> String -> IO CStringLen

-- | Marshal a Haskell string into a NUL terminated C string using
°5utemporary storage.
°5u
°5u<ul>
°5u<li>the Haskell string may <i>not</i> contain any NUL characters</li>
°5u<li>the memory is freed when the subcomputation terminates (either
°5unormally or via an exception), so the pointer to the temporary storage
°5umust <i>not</i> be used after this.</li>
°5u</ul>
withCString :: TextEncoding -> String -> (CString -> IO a) -> IO a

-- | Marshal a Haskell string into a C string (ie, character array) in
°5utemporary storage, with explicit length information.
°5u
°5u<ul>
°5u<li>the memory is freed when the subcomputation terminates (either
°5unormally or via an exception), so the pointer to the temporary storage
°5umust <i>not</i> be used after this.</li>
°5u</ul>
withCStringLen :: TextEncoding -> String -> (CStringLen -> IO a) -> IO a

-- | Marshal a list of Haskell strings into an array of NUL terminated C
°5ustrings using temporary storage.
°5u
°5u<ul>
°5u<li>the Haskell strings may <i>not</i> contain any NUL characters</li>
°5u<li>the memory is freed when the subcomputation terminates (either
°5unormally or via an exception), so the pointer to the temporary storage
°5umust <i>not</i> be used after this.</li>
°5u</ul>
withCStringsLen :: TextEncoding -> [String] -> (Int -> Ptr CString -> IO a) -> IO a

-- | Determines whether a character can be accurately encoded in a
°5u<a>CString</a>.
°5u
°5uPretty much anyone who uses this function is in a state of sin because
°5uwhether or not a character is encodable will, in general, depend on
°5uthe context in which it occurs.
charIsRepresentable :: TextEncoding -> Char -> IO Bool


-- | Utilities for primitive marshalling of C strings.
°5u
°5uThe marshalling converts each Haskell character, representing a
°5uUnicode code point, to one or more bytes in a manner that, by default,
°5uis determined by the current locale. As a consequence, no guarantees
°5ucan be made about the relative length of a Haskell string and its
°5ucorresponding C string, and therefore all the marshalling routines
°5uinclude memory allocation. The translation between Unicode and the
°5uencoding 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
°5uNUL.
type CString = Ptr CChar

-- | A string with explicit length information in bytes instead of a
°5uterminating 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.
°5u
°5u<ul>
°5u<li>the Haskell string may <i>not</i> contain any NUL characters</li>
°5u<li>new storage is allocated for the C string and must be explicitly
°5ufreed using <a>free</a> or <a>finalizerFree</a>.</li>
°5u</ul>
newCString :: String -> IO CString

-- | Marshal a Haskell string into a C string (ie, character array) with
°5uexplicit length information.
°5u
°5u<ul>
°5u<li>new storage is allocated for the C string and must be explicitly
°5ufreed using <a>free</a> or <a>finalizerFree</a>.</li>
°5u</ul>
newCStringLen :: String -> IO CStringLen

-- | Marshal a Haskell string into a NUL terminated C string using
°5utemporary storage.
°5u
°5u<ul>
°5u<li>the Haskell string may <i>not</i> contain any NUL characters</li>
°5u<li>the memory is freed when the subcomputation terminates (either
°5unormally or via an exception), so the pointer to the temporary storage
°5umust <i>not</i> be used after this.</li>
°5u</ul>
withCString :: String -> (CString -> IO a) -> IO a

-- | Marshal a Haskell string into a C string (ie, character array) in
°5utemporary storage, with explicit length information.
°5u
°5u<ul>
°5u<li>the memory is freed when the subcomputation terminates (either
°5unormally or via an exception), so the pointer to the temporary storage
°5umust <i>not</i> be used after this.</li>
°5u</ul>
withCStringLen :: String -> (CStringLen -> IO a) -> IO a
charIsRepresentable :: Char -> IO Bool

-- | Convert a Haskell character to a C character. This function is only
°5usafe on the first 256 characters.
castCharToCChar :: Char -> CChar

-- | Convert a C byte, representing a Latin-1 character, to the
°5ucorresponding Haskell character.
castCCharToChar :: CChar -> Char

-- | Convert a Haskell character to a C <tt>unsigned char</tt>. This
°5ufunction is only safe on the first 256 characters.
castCharToCUChar :: Char -> CUChar

-- | Convert a C <tt>unsigned char</tt>, representing a Latin-1 character,
°5uto the corresponding Haskell character.
castCUCharToChar :: CUChar -> Char

-- | Convert a Haskell character to a C <tt>signed char</tt>. This function
°5uis only safe on the first 256 characters.
castCharToCSChar :: Char -> CSChar

-- | Convert a C <tt>signed char</tt>, representing a Latin-1 character, to
°5uthe 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.
°5u
°5u<ul>
°5u<li>the Haskell string may <i>not</i> contain any NUL characters</li>
°5u<li>new storage is allocated for the C string and must be explicitly
°5ufreed using <a>free</a> or <a>finalizerFree</a>.</li>
°5u</ul>
newCAString :: String -> IO CString

-- | Marshal a Haskell string into a C string (ie, character array) with
°5uexplicit length information.
°5u
°5u<ul>
°5u<li>new storage is allocated for the C string and must be explicitly
°5ufreed using <a>free</a> or <a>finalizerFree</a>.</li>
°5u</ul>
newCAStringLen :: String -> IO CStringLen

-- | Marshal a Haskell string into a NUL terminated C string using
°5utemporary storage.
°5u
°5u<ul>
°5u<li>the Haskell string may <i>not</i> contain any NUL characters</li>
°5u<li>the memory is freed when the subcomputation terminates (either
°5unormally or via an exception), so the pointer to the temporary storage
°5umust <i>not</i> be used after this.</li>
°5u</ul>
withCAString :: String -> (CString -> IO a) -> IO a

-- | Marshal a Haskell string into a C string (ie, character array) in
°5utemporary storage, with explicit length information.
°5u
°5u<ul>
°5u<li>the memory is freed when the subcomputation terminates (either
°5unormally or via an exception), so the pointer to the temporary storage
°5umust <i>not</i> be used after this.</li>
°5u</ul>
withCAStringLen :: String -> (CStringLen -> IO a) -> IO a

-- | A C wide string is a reference to an array of C wide characters
°5uterminated by NUL.
type CWString = Ptr CWchar

-- | A wide character string with explicit length information in
°5u<a>CWchar</a>s instead of a terminating NUL (allowing NUL characters
°5uin 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.
°5u
°5u<ul>
°5u<li>the Haskell string may <i>not</i> contain any NUL characters</li>
°5u<li>new storage is allocated for the C wide string and must be
°5uexplicitly freed using <a>free</a> or <a>finalizerFree</a>.</li>
°5u</ul>
newCWString :: String -> IO CWString

-- | Marshal a Haskell string into a C wide string (ie, wide character
°5uarray) with explicit length information.
°5u
°5u<ul>
°5u<li>new storage is allocated for the C wide string and must be
°5uexplicitly freed using <a>free</a> or <a>finalizerFree</a>.</li>
°5u</ul>
newCWStringLen :: String -> IO CWStringLen

-- | Marshal a Haskell string into a NUL terminated C wide string using
°5utemporary storage.
°5u
°5u<ul>
°5u<li>the Haskell string may <i>not</i> contain any NUL characters</li>
°5u<li>the memory is freed when the subcomputation terminates (either
°5unormally or via an exception), so the pointer to the temporary storage
°5umust <i>not</i> be used after this.</li>
°5u</ul>
withCWString :: String -> (CWString -> IO a) -> IO a

-- | Marshal a Haskell string into a C wide string (i.e. wide character
°5uarray) in temporary storage, with explicit length information.
°5u
°5u<ul>
°5u<li>the memory is freed when the subcomputation terminates (either
°5unormally or via an exception), so the pointer to the temporary storage
°5umust <i>not</i> be used after this.</li>
°5u</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
°5uarguments and/or results via pointers. The function
°5u<tt>unsafeLocalState</tt> permits the packaging of such entities as
°5upure functions.
°5u
°5uThe only IO operations allowed in the IO action passed to
°5u<tt>unsafeLocalState</tt> are (a) local allocation (<tt>alloca</tt>,
°5u<tt>allocaBytes</tt> and derived operations such as <tt>withArray</tt>
°5uand <tt>withCString</tt>), and (b) pointer operations
°5u(<tt>Foreign.Storable</tt> and <tt>Foreign.Ptr</tt>) on the pointers
°5uto local storage, and (c) foreign functions whose only observable
°5ueffect is to read and/or write the locally allocated memory. Passing
°5uan IO operation that does not obey these rules results in undefined
°5ubehaviour.
°5u
°5uIt is expected that this operation will be replaced in a future
°5urevision of Haskell.
unsafeLocalState :: IO a -> a


-- | FFI datatypes and operations that use or require concurrency (GHC
°5uonly).
module Foreign.Concurrent

-- | Turns a plain memory reference into a foreign object by associating a
°5ufinalizer - given by the monadic operation - with the reference. The
°5ustorage manager will start the finalizer, in a separate thread, some
°5utime after the last reference to the <tt>ForeignPtr</tt> is dropped.
°5uThere is no guarantee of promptness, and in fact there is no guarantee
°5uthat the finalizer will eventually run at all.
°5u
°5uNote that references from a finalizer do not necessarily prevent
°5uanother object from being finalized. If A's finalizer refers to B
°5u(perhaps using <tt>touchForeignPtr</tt>, then the only guarantee is
°5uthat B's finalizer will never be started before A's. If both A and B
°5uare unreachable, then both finalizers will start together. See
°5u<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
°5ufinalizer will run <i>before</i> all other finalizers for the same
°5uobject which have already been registered.
°5u
°5uThis is a variant of
°5u<tt>Foreign.ForeignPtr.addForeignPtrFinalizer</tt>, where the
°5ufinalizer is an arbitrary <tt>IO</tt> action. When it is invoked, the
°5ufinalizer will run in a new thread.
°5u
°5uNB. Be very careful with these finalizers. One common trap is that if
°5ua finalizer references another finalized value, it does not prevent
°5uthat value from being finalized. In particular, <tt>Handle</tt>s are
°5ufinalized objects, so a finalizer should not refer to a
°5u<tt>Handle</tt> (including <tt>stdout</tt>, <tt>stdin</tt> or
°5u<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
°5uis deliberately exposed, to allow users to add their own definitions
°5uof <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
°5usystem. This implies that the <a>Eq</a> instance of <a>Errno</a> is
°5ualso system dependent as it is only defined for valid values of
°5u<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
°5uoptional information can be used to improve the accuracy of error
°5umessages.
errnoToIOError :: String -> Errno -> Maybe Handle -> Maybe String -> IOError

-- | Throw an <a>IOError</a> corresponding to the current value of
°5u<a>getErrno</a>.
throwErrno :: String -> IO a

-- | Throw an <a>IOError</a> corresponding to the current value of
°5u<a>getErrno</a> if the result value of the <a>IO</a> action meets the
°5ugiven predicate.
throwErrnoIf :: (a -> Bool) -> String -> IO a -> IO a

-- | as <a>throwErrnoIf</a>, but discards the result of the <a>IO</a>
°5uaction after error handling.
throwErrnoIf_ :: (a -> Bool) -> String -> IO a -> IO ()

-- | as <a>throwErrnoIf</a>, but retry the <a>IO</a> action when it yields
°5uthe error code <a>eINTR</a> - this amounts to the standard retry loop
°5ufor 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
°5u<a>getErrno</a> if the <a>IO</a> action returns a result of
°5u<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
°5u<a>getErrno</a> if the <a>IO</a> action returns a result of
°5u<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
°5u<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
°5u<a>getErrno</a> if the <a>IO</a> action returns <a>nullPtr</a>, but
°5uretry in case of an interrupted operation.
throwErrnoIfNullRetry :: String -> IO (Ptr a) -> IO (Ptr a)

-- | as <a>throwErrnoIfRetry</a>, but additionally if the operation yields
°5uthe error code <a>eAGAIN</a> or <a>eWOULDBLOCK</a>, an alternative
°5uaction 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
°5uwould 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
°5ublock.
throwErrnoIfNullRetryMayBlock :: String -> IO (Ptr a) -> IO b -> IO (Ptr a)

-- | as <a>throwErrno</a>, but exceptions include the given path when
°5uappropriate.
throwErrnoPath :: String -> FilePath -> IO a

-- | as <a>throwErrnoIf</a>, but exceptions include the given path when
°5uappropriate.
throwErrnoPathIf :: (a -> Bool) -> String -> FilePath -> IO a -> IO a

-- | as <a>throwErrnoIf_</a>, but exceptions include the given path when
°5uappropriate.
throwErrnoPathIf_ :: (a -> Bool) -> String -> FilePath -> IO a -> IO ()

-- | as <a>throwErrnoIfNull</a>, but exceptions include the given path when
°5uappropriate.
throwErrnoPathIfNull :: String -> FilePath -> IO (Ptr a) -> IO (Ptr a)

-- | as <a>throwErrnoIfMinus1</a>, but exceptions include the given path
°5uwhen appropriate.
throwErrnoPathIfMinus1 :: (Eq a, Num a) => String -> FilePath -> IO a -> IO a

-- | as <a>throwErrnoIfMinus1_</a>, but exceptions include the given path
°5uwhen 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
°5uscheme, (re-)allocations belong to a given pool, and everything in a
°5upool is deallocated when the pool itself is deallocated. This is
°5uuseful when <a>alloca</a> with its implicit allocation and
°5udeallocation is not flexible enough, but explicit uses of
°5u<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
°5uthe pool itself.
freePool :: Pool -> IO ()

-- | Execute an action with a fresh memory pool, which gets automatically
°5udeallocated (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
°5uarea allocated is determined by the <a>sizeOf</a> method from the
°5uinstance 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
°5uof 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
°5uin the pool.
pooledMallocArray :: Storable a => Pool -> Int -> IO (Ptr a)

-- | Allocate storage for the given number of elements of a storable type
°5uin the pool, but leave room for an extra element to signal the end of
°5uthe 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
°5uinto this storage.
pooledNew :: Storable a => Pool -> a -> IO (Ptr a)

-- | Allocate consecutive storage for a list of values in the given pool
°5uand 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
°5uand marshal these values into it, terminating the end with the given
°5umarker.
pooledNewArray0 :: Storable a => Pool -> a -> [a] -> IO (Ptr a)


-- | Marshalling support
°5u
°5uSafe API Only.

-- | <i>Deprecated: Safe is now the default, please use Foreign.Marshal
°5uinstead</i>
module Foreign.Marshal.Safe


-- | Marshalling support
module Foreign.Marshal


-- | A collection of data types, classes, and functions for interfacing
°5uwith another programming language.
°5u
°5uSafe 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
°5uwith another programming language.
module Foreign


-- | POSIX data types: Haskell equivalents of the types defined by the
°5u<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.
°5u
°5uOperations for injecting values of arbitrary type into a dynamically
°5utyped value, Dynamic, are provided, together with operations for
°5uconverting dynamic values into a concrete (monomorphic) type.
module Data.Dynamic

-- | A value of type <a>Dynamic</a> is an object encapsulated together with
°5uits type.
°5u
°5uA <a>Dynamic</a> may only represent a monomorphic value; an attempt to
°5ucreate a value of type <a>Dynamic</a> from a polymorphically-typed
°5uexpression will result in an ambiguity error (see <a>toDyn</a>).
°5u
°5u<a>Show</a>ing a value of type <a>Dynamic</a> returns a pretty-printed
°5urepresentation 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>.
°5u
°5uThe type of the object must be an instance of <a>Typeable</a>, which
°5uensures that only monomorphically-typed objects may be converted to
°5u<a>Dynamic</a>. To convert a polymorphic object into <a>Dynamic</a>,
°5ugive it a monomorphic type signature. For example:
°5u
°5u<pre>
°5utoDyn (id :: Int -&gt; Int)
°5u</pre>
toDyn :: Typeable a => a -> Dynamic

-- | Converts a <a>Dynamic</a> object back into an ordinary Haskell value
°5uof 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
°5uof 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
°5uto 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
°5uthread. <a>ThreadId</a> is an instance of <a>Eq</a>, <a>Ord</a> and
°5u<a>Show</a>, where the <a>Ord</a> instance implements an arbitrary
°5utotal ordering over <a>ThreadId</a>s. The <a>Show</a> instance lets
°5uyou convert an arbitrary-valued <a>ThreadId</a> to string form;
°5ushowing a <a>ThreadId</a> value is occasionally useful when debugging
°5uor diagnosing the behaviour of a concurrent program.
°5u
°5u<i>Note</i>: in GHC, if you have a <a>ThreadId</a>, you essentially
°5uhave a pointer to the thread itself. This means the thread itself
°5ucan't be garbage collected until you drop the <a>ThreadId</a>. This
°5umisfeature 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
°5ufirst argument, and returns the <a>ThreadId</a> of the newly created
°5uthread.
°5u
°5uThe new thread will be a lightweight, <i>unbound</i> thread. Foreign
°5ucalls made by this thread are not guaranteed to be made by any
°5uparticular OS thread; if you need foreign calls to be made by a
°5uparticular OS thread, then use <a>forkOS</a> instead.
°5u
°5uThe new thread inherits the <i>masked</i> state of the parent (see
°5u<a>mask</a>).
°5u
°5uThe newly created thread has an exception handler that discards the
°5uexceptions <a>BlockedIndefinitelyOnMVar</a>,
°5u<a>BlockedIndefinitelyOnSTM</a>, and <a>ThreadKilled</a>, and passes
°5uall 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
°5ube used to unmask asynchronous exceptions. This function is typically
°5uused in the following way
°5u
°5u<pre>
°5u... mask_ $ forkIOWithUnmask $ \unmask -&gt;
°5u               catch (unmask ...) handler
°5u</pre>
°5u
°5uso that the exception handler in the child thread is established with
°5uasynchronous exceptions masked, meanwhile the main body of the child
°5uthread is executed in the unmasked state.
°5u
°5uNote that the unmask function passed to the child thread should only
°5ube used in that thread; the behaviour is undefined if it is invoked in
°5ua different thread.
forkIOWithUnmask :: ((forall a. IO a -> IO a) -> IO ()) -> IO ThreadId

-- | Like <a>forkIO</a>, but lets you specify on which capability the
°5uthread should run. Unlike a <a>forkIO</a> thread, a thread created by
°5u<a>forkOn</a> will stay on the same capability for its entire lifetime
°5u(<a>forkIO</a> threads can migrate between capabilities according to
°5uthe scheduling policy). <a>forkOn</a> is useful for overriding the
°5uscheduling policy when you know in advance how best to distribute the
°5uthreads.
°5u
°5uThe <a>Int</a> argument specifies a <i>capability number</i> (see
°5u<a>getNumCapabilities</a>). Typically capabilities correspond to
°5uphysical processors, but the exact behaviour is
°5uimplementation-dependent. The value passed to <a>forkOn</a> is
°5uinterpreted modulo the total number of capabilities as returned by
°5u<a>getNumCapabilities</a>.
°5u
°5uGHC note: the number of capabilities is specified by the <tt>+RTS
°5u-N</tt> option when the program is started. Capabilities can be fixed
°5uto actual processor cores with <tt>+RTS -qa</tt> if the underlying
°5uoperating system supports that, although in practice this is usually
°5uunnecessary (and may actually degrade performance in some cases -
°5uexperimentation is recommended).
forkOn :: Int -> IO () -> IO ThreadId

-- | Like <a>forkIOWithUnmask</a>, but the child thread is pinned to the
°5ugiven 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
°5uHaskell threads that can run truly simultaneously at any given time,
°5uand is typically set to the number of physical processor cores on the
°5umachine.
°5u
°5uStrictly speaking it is better to use <a>getNumCapabilities</a>,
°5ubecause the number of capabilities might vary at runtime.
numCapabilities :: Int

-- | Returns the number of Haskell threads that can run truly
°5usimultaneously (on separate physical processors) at any given time. To
°5uchange this value, use <a>setNumCapabilities</a>.
getNumCapabilities :: IO Int

-- | Set the number of Haskell threads that can run truly simultaneously
°5u(on separate physical processors) at any given time. The number passed
°5uto <a>forkOn</a> is interpreted modulo this value. The initial value
°5uis given by the <tt>+RTS -N</tt> runtime flag.
°5u
°5uThis is also the number of threads that will participate in parallel
°5ugarbage collection. It is strongly recommended that the number of
°5ucapabilities is not set larger than the number of physical processor
°5ucores, and it may often be beneficial to leave one or more cores free
°5uto 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
°5ugiven thread (GHC only).
°5u
°5u<pre>
°5ukillThread tid = throwTo tid ThreadKilled
°5u</pre>
killThread :: ThreadId -> IO ()

-- | <a>throwTo</a> raises an arbitrary exception in the target thread (GHC
°5uonly).
°5u
°5uException delivery synchronizes between the source and target thread:
°5u<a>throwTo</a> does not return until the exception has been raised in
°5uthe target thread. The calling thread can thus be certain that the
°5utarget thread has received the exception. Exception delivery is also
°5uatomic with respect to other exceptions. Atomicity is a useful
°5uproperty to have when dealing with race conditions: e.g. if there are
°5utwo threads that can kill each other, it is guaranteed that only one
°5uof the threads will get to kill the other.
°5u
°5uWhatever work the target thread was doing when the exception was
°5uraised is not lost: the computation is suspended until required by
°5uanother thread.
°5u
°5uIf the target thread is currently making a foreign call, then the
°5uexception will not be raised (and hence <a>throwTo</a> will not
°5ureturn) until the call has completed. This is the case regardless of
°5uwhether the call is inside a <a>mask</a> or not. However, in GHC a
°5uforeign call can be annotated as <tt>interruptible</tt>, in which case
°5ua <a>throwTo</a> will cause the RTS to attempt to cause the call to
°5ureturn; see the GHC documentation for more details.
°5u
°5uImportant note: the behaviour of <a>throwTo</a> differs from that
°5udescribed in the paper "Asynchronous exceptions in Haskell"
°5u(<a>http://research.microsoft.com/~simonpj/Papers/asynch-exns.htm</a>).
°5uIn the paper, <a>throwTo</a> is non-blocking; but the library
°5uimplementation adopts a more synchronous design in which
°5u<a>throwTo</a> does not return until the exception is received by the
°5utarget thread. The trade-off is discussed in Section 9 of the paper.
°5uLike any blocking operation, <a>throwTo</a> is therefore interruptible
°5u(see Section 5.3 of the paper). Unlike other interruptible operations,
°5uhowever, <a>throwTo</a> is <i>always</i> interruptible, even if it
°5udoes not actually block.
°5u
°5uThere is no guarantee that the exception will be delivered promptly,
°5ualthough the runtime will endeavour to ensure that arbitrary delays
°5udon't occur. In GHC, an exception can only be raised when a thread
°5ureaches a <i>safe point</i>, where a safe point is where memory
°5uallocation occurs. Some loops do not perform any memory allocation
°5uinside the loop and therefore cannot be interrupted by a
°5u<a>throwTo</a>.
°5u
°5uIf the target of <a>throwTo</a> is the calling thread, then the
°5ubehaviour is the same as <a>throwIO</a>, except that the exception is
°5uthrown as an asynchronous exception. This means that if there is an
°5uenclosing pure computation, which would be the case if the current IO
°5uoperation is inside <a>unsafePerformIO</a> or
°5u<a>unsafeInterleaveIO</a>, that computation is not permanently
°5ureplaced by the exception, but is suspended as if it had received an
°5uasynchronous exception.
°5u
°5uNote that if <a>throwTo</a> is called with the current thread as the
°5utarget, the exception will be thrown even if the thread is currently
°5uinside <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
°5uimplementation) a context-switch to any other currently runnable
°5uthreads (if any), and is occasionally useful when implementing
°5uconcurrency abstractions.
yield :: IO ()

-- | <a>labelThread</a> stores a string as identifier for this thread if
°5uyou built a RTS with debugging support. This identifier will be used
°5uin the debugging output to make distinction of different threads
°5ueasier (otherwise you only have the thread state object's address in
°5uthe heap).
°5u
°5uOther applications like the graphical Concurrent Haskell Debugger
°5u(<a>http://www.informatik.uni-kiel.de/~fhu/chd/</a>) may choose to
°5uoverload <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
°5uthis if you want to hold a reference to a <a>ThreadId</a> while still
°5uallowing the thread to receive the <tt>BlockedIndefinitely</tt> family
°5uof exceptions (e.g. <a>BlockedIndefinitelyOnMVar</a>). Holding a
°5unormal <a>ThreadId</a> reference will prevent the delivery of
°5u<tt>BlockedIndefinitely</tt> exceptions because the reference could be
°5uused as the target of <a>throwTo</a> at any time, which would unblock
°5uthe thread.
°5u
°5uHolding a <tt>Weak ThreadId</tt>, on the other hand, will not prevent
°5uthe thread from receiving <tt>BlockedIndefinitely</tt> exceptions. It
°5uis still possible to throw an exception to a <tt>Weak ThreadId</tt>,
°5ubut the caller must use <tt>deRefWeak</tt> first to determine whether
°5uthe 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
°5u<tt>threadDelay</tt> show up as <a>BlockedOnOther</a>, with
°5u<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
°5urunning, and a boolean indicating whether the thread is locked to that
°5ucapability or not. A thread is locked to a capability if it was
°5ucreated with <tt>forkOn</tt>.
threadCapability :: ThreadId -> IO (Int, Bool)

-- | Make a StablePtr that can be passed to the C function
°5u<tt>hs_try_putmvar()</tt>. The RTS wants a <a>StablePtr</a> to the
°5uunderlying <a>MVar#</a>, but a <a>StablePtr#</a> can only refer to
°5ulifted 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
°5ubeen allocated by the thread. The counter is initialized to zero, and
°5u<a>setAllocationCounter</a> sets the current value. The allocation
°5ucounter counts *down*, so in the absence of a call to
°5u<a>setAllocationCounter</a> its value is the negation of the number of
°5ubytes of memory allocated by the thread.
°5u
°5uThere are two things that you can do with this counter:
°5u
°5u<ul>
°5u<li>Use it as a simple profiling mechanism, with
°5u<a>getAllocationCounter</a>.</li>
°5u<li>Use it as a resource limit. See <a>enableAllocationLimit</a>.</li>
°5u</ul>
°5u
°5uAllocation accounting is accurate only to about 4Kbytes.
setAllocationCounter :: Int64 -> IO ()

-- | Return the current value of the allocation counter for the current
°5uthread.
getAllocationCounter :: IO Int64

-- | Enables the allocation counter to be treated as a limit for the
°5ucurrent thread. When the allocation limit is enabled, if the
°5uallocation counter counts down below zero, the thread will be sent the
°5u<a>AllocationLimitExceeded</a> asynchronous exception. When this
°5uhappens, the counter is reinitialised (by default to 100K, but tunable
°5uwith the <tt>+RTS -xq</tt> option) so that it can handle the exception
°5uand perform any necessary clean up. If it exhausts this additional
°5uallowance, another <a>AllocationLimitExceeded</a> exception is sent,
°5uand so forth. Like other asynchronous exceptions, the
°5u<a>AllocationLimitExceeded</a> exception is deferred while the thread
°5uis inside <a>mask</a> or an exception handler in <a>catch</a>.
°5u
°5uNote that memory allocation is unrelated to <i>live memory</i>, also
°5uknown as <i>heap residency</i>. A thread can allocate a large amount
°5uof memory and retain anything between none and all of it. It is better
°5uto think of the allocation limit as a limit on <i>CPU time</i>, rather
°5uthan a limit on memory.
°5u
°5uCompared to using timeouts, allocation limits don't count time spent
°5ublocked 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.
°5u
°5uUsing <a>atomically</a> inside an <a>unsafePerformIO</a> or
°5u<a>unsafeInterleaveIO</a> subverts some of guarantees that STM
°5uprovides. It makes it possible to run a transaction inside of another
°5utransaction, depending on when the thunk is evaluated. If a nested
°5utransaction is attempted, an exception is thrown by the runtime. It is
°5upossible to safely use <a>atomically</a> inside <a>unsafePerformIO</a>
°5uor <a>unsafeInterleaveIO</a>, but the typechecker does not rule out
°5uprograms that may attempt nested transactions, meaning that the
°5uprogrammer must take special care to prevent these.
°5u
°5uHowever, there are functions for creating transactional variables that
°5ucan always be safely called in <a>unsafePerformIO</a>. See:
°5u<a>newTVarIO</a>, <tt>newTChanIO</tt>, <tt>newBroadcastTChanIO</tt>,
°5u<tt>newTQueueIO</tt>, <tt>newTBQueueIO</tt>, and <tt>newTMVarIO</tt>.
°5u
°5uUsing <a>unsafePerformIO</a> inside of <a>atomically</a> is also
°5udangerous but for different reasons. See <a>unsafeIOToSTM</a> for more
°5uon this.
atomically :: STM a -> IO a

-- | Retry execution of the current memory transaction because it has seen
°5uvalues in <a>TVar</a>s which mean that it should not continue (e.g.
°5uthe <a>TVar</a>s represent a shared buffer that is now empty). The
°5uimplementation may block the thread until one of the <a>TVar</a>s that
°5uit has read from has been updated. (GHC only)
retry :: STM a

-- | Compose two alternative STM actions (GHC only).
°5u
°5uIf the first action completes without retrying then it forms the
°5uresult of the <a>orElse</a>. Otherwise, if the first action retries,
°5uthen the second action is tried in its place. If both actions retry
°5uthen 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>
°5umonad.
°5u
°5uThrowing an exception in <tt>STM</tt> aborts the transaction and
°5upropagates the exception.
°5u
°5uAlthough <a>throwSTM</a> has a type that is an instance of the type of
°5u<a>throw</a>, the two functions are subtly different:
°5u
°5u<pre>
°5uthrow e    `seq` x  ===&gt; throw e
°5uthrowSTM e `seq` x  ===&gt; x
°5u</pre>
°5u
°5uThe first example will cause the exception <tt>e</tt> to be raised,
°5uwhereas the second one won't. In fact, <a>throwSTM</a> will only cause
°5uan exception to be raised when it is used within the <a>STM</a> monad.
°5uThe <a>throwSTM</a> variant should be used in preference to
°5u<a>throw</a> to raise an exception within the <a>STM</a> monad because
°5uit guarantees ordering with respect to other <a>STM</a> operations,
°5uwhereas <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
°5upassed to <a>alwaysSucceeds</a>, at the end of the current
°5utransaction, and at the end of every subsequent transaction. If it
°5ufails at any of those points then the transaction violating it is
°5uaborted 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
°5uinvariant is expressed as an <tt>STM Bool</tt> action that must return
°5u<tt>True</tt>. Returning <tt>False</tt> or raising an exception are
°5uboth 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
°5utop-level <a>TVar</a>s using <a>unsafePerformIO</a>, because using
°5u<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
°5uto
°5u
°5u<pre>
°5ureadTVarIO = atomically . readTVar
°5u</pre>
°5u
°5ubut works much faster, because it doesn't perform a complete
°5utransaction, 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
°5udangerous thing to do.
°5u
°5u<ul>
°5u<li>The STM implementation will often run transactions multiple times,
°5uso you need to be prepared for this if your IO has any side
°5ueffects.</li>
°5u<li>The STM implementation will abort transactions that are known to
°5ube invalid and need to be restarted. This may happen in the middle of
°5u<a>unsafeIOToSTM</a>, so make sure you don't acquire any resources
°5uthat need releasing (exception handlers are ignored when aborting the
°5utransaction). That includes doing any IO using Handles, for example.
°5uGetting this wrong will probably lead to random deadlocks.</li>
°5u<li>The transaction may have seen an inconsistent view of memory when
°5uthe IO runs. Invariants that you expect to be true throughout your
°5uprogram may not be true inside a transaction, due to the way
°5utransactions are implemented. Normally this wouldn't be visible to the
°5uprogrammer, but using <a>unsafeIOToSTM</a> can expose it.</li>
°5u</ul>
unsafeIOToSTM :: IO a -> STM a

-- | Provide an <a>IO</a> action with the current value of an <a>MVar</a>.
°5uThe <a>MVar</a> will be empty for the duration that the action is
°5urunning.
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
°5uhierarchy. When an exception of type <tt>e</tt> is thrown, behind the
°5uscenes 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
°5uinstance of the <tt>Exception</tt> class. The simplest case is a new
°5uexception type directly below the root:
°5u
°5u<pre>
°5udata MyException = ThisException | ThatException
°5u    deriving Show
°5u
°5uinstance Exception MyException
°5u</pre>
°5u
°5uThe default method definitions in the <tt>Exception</tt> class do what
°5uwe need in this case. You can now throw and catch
°5u<tt>ThisException</tt> and <tt>ThatException</tt> as exceptions:
°5u
°5u<pre>
°5u*Main&gt; throw ThisException `catch` \e -&gt; putStrLn ("Caught " ++ show (e :: MyException))
°5uCaught ThisException
°5u</pre>
°5u
°5uIn more complicated examples, you may wish to define a whole hierarchy
°5uof exceptions:
°5u
°5u<pre>
°5u---------------------------------------------------------------------
°5u-- Make the root exception type for all the exceptions in a compiler
°5u
°5udata SomeCompilerException = forall e . Exception e =&gt; SomeCompilerException e
°5u
°5uinstance Show SomeCompilerException where
°5u    show (SomeCompilerException e) = show e
°5u
°5uinstance Exception SomeCompilerException
°5u
°5ucompilerExceptionToException :: Exception e =&gt; e -&gt; SomeException
°5ucompilerExceptionToException = toException . SomeCompilerException
°5u
°5ucompilerExceptionFromException :: Exception e =&gt; SomeException -&gt; Maybe e
°5ucompilerExceptionFromException x = do
°5u    SomeCompilerException a &lt;- fromException x
°5u    cast a
°5u
°5u---------------------------------------------------------------------
°5u-- Make a subhierarchy for exceptions in the frontend of the compiler
°5u
°5udata SomeFrontendException = forall e . Exception e =&gt; SomeFrontendException e
°5u
°5uinstance Show SomeFrontendException where
°5u    show (SomeFrontendException e) = show e
°5u
°5uinstance Exception SomeFrontendException where
°5u    toException = compilerExceptionToException
°5u    fromException = compilerExceptionFromException
°5u
°5ufrontendExceptionToException :: Exception e =&gt; e -&gt; SomeException
°5ufrontendExceptionToException = toException . SomeFrontendException
°5u
°5ufrontendExceptionFromException :: Exception e =&gt; SomeException -&gt; Maybe e
°5ufrontendExceptionFromException x = do
°5u    SomeFrontendException a &lt;- fromException x
°5u    cast a
°5u
°5u---------------------------------------------------------------------
°5u-- Make an exception type for a particular frontend compiler exception
°5u
°5udata MismatchedParentheses = MismatchedParentheses
°5u    deriving Show
°5u
°5uinstance Exception MismatchedParentheses where
°5u    toException   = frontendExceptionToException
°5u    fromException = frontendExceptionFromException
°5u</pre>
°5u
°5uWe can now catch a <tt>MismatchedParentheses</tt> exception as
°5u<tt>MismatchedParentheses</tt>, <tt>SomeFrontendException</tt> or
°5u<tt>SomeCompilerException</tt>, but not other types, e.g.
°5u<tt>IOException</tt>:
°5u
°5u<pre>
°5u*Main&gt; throw MismatchedParentheses `catch` \e -&gt; putStrLn ("Caught " ++ show (e :: MismatchedParentheses))
°5uCaught MismatchedParentheses
°5u*Main&gt; throw MismatchedParentheses `catch` \e -&gt; putStrLn ("Caught " ++ show (e :: SomeFrontendException))
°5uCaught MismatchedParentheses
°5u*Main&gt; throw MismatchedParentheses `catch` \e -&gt; putStrLn ("Caught " ++ show (e :: SomeCompilerException))
°5uCaught MismatchedParentheses
°5u*Main&gt; throw MismatchedParentheses `catch` \e -&gt; putStrLn ("Caught " ++ show (e :: IOException))
°5u*** Exception: MismatchedParentheses
°5u</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.
°5u
°5uDefault implementation: <tt><a>show</a></tt>.
displayException :: Exception e => e -> String

-- | Exceptions that occur in the <tt>IO</tt> monad. An
°5u<tt>IOException</tt> records a more specific error type, a descriptive
°5ustring 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
°5ubeen 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
°5ubeen raised, the thread's stack will certainly be below its limit
°5uagain, but the programmer should take remedial action immediately.
StackOverflow :: AsyncException

-- | The program's heap is reaching its limit, and the program should take
°5uaction to reduce the amount of live data it has. Notes:
°5u
°5u<ul>
°5u<li>It is undefined which thread receives this exception. GHC
°5ucurrently throws this to the same thread that receives
°5u<a>UserInterrupt</a>, but this may change in the future.</li>
°5u<li>The GHC RTS currently can only recover from heap overflow if it
°5udetects that an explicit memory limit (set via RTS flags). has been
°5uexceeded. Currently, failure to allocate memory from the operating
°5usystem results in immediate termination of the program.</li>
°5u</ul>
HeapOverflow :: AsyncException

-- | This exception is raised by another thread calling <a>killThread</a>,
°5uor 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
°5uwhen the user requests to terminate the program via the usual
°5umechanism(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
°5uguaranteed not to terminate. Note that there is no guarantee that the
°5uruntime system will notice whether any given computation is guaranteed
°5uto terminate or not.
data NonTermination
NonTermination :: NonTermination

-- | Thrown when the program attempts to call <tt>atomically</tt>, from the
°5u<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
°5ureferences 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
°5uother references to any <tt>TVar</tt>s involved, so it can't ever
°5ucontinue.
data BlockedIndefinitelyOnSTM
BlockedIndefinitelyOnSTM :: BlockedIndefinitelyOnSTM

-- | This thread has exceeded its allocation limit. See
°5u<a>setAllocationCounter</a> and <a>enableAllocationLimit</a>.
data AllocationLimitExceeded
AllocationLimitExceeded :: AllocationLimitExceeded

-- | Compaction found an object that cannot be compacted. Functions cannot
°5ube compacted, nor can mutable objects or pinned objects. See
°5u<a>compact</a>.
newtype CompactionFailed
CompactionFailed :: String -> CompactionFailed

-- | There are no runnable threads, so the program is deadlocked. The
°5u<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
°5ua definition in the appropriate instance) was called. The
°5u<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
°5uthe source location of the pattern.
newtype PatternMatchFail
PatternMatchFail :: String -> PatternMatchFail

-- | An uninitialised record field was used. The <tt>String</tt> gives
°5uinformation about the source location where the record was
°5uconstructed.
newtype RecConError
RecConError :: String -> RecConError

-- | A record selector was applied to a constructor without the appropriate
°5ufield. This can only happen with a datatype with multiple
°5uconstructors, where some fields are in one constructor but not
°5uanother. The <tt>String</tt> gives information about the source
°5ulocation of the record selector.
newtype RecSelError
RecSelError :: String -> RecSelError

-- | A record update was performed on a constructor without the appropriate
°5ufield. This can only happen with a datatype with multiple
°5uconstructors, where some fields are in one constructor but not
°5uanother. The <tt>String</tt> gives information about the source
°5ulocation of the record update.
newtype RecUpdError
RecUpdError :: String -> RecUpdError

-- | This is thrown when the user calls <a>error</a>. The first
°5u<tt>String</tt> is the argument given to <a>error</a>, second
°5u<tt>String</tt> is the location.
data ErrorCall
ErrorCallWithLocation :: String -> String -> ErrorCall

-- | An expression that didn't typecheck during compile time was called.
°5uThis is only possible with -fdefer-type-errors. The <tt>String</tt>
°5ugives 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>
°5umonad.
°5u
°5uAlthough <a>throwIO</a> has a type that is an instance of the type of
°5u<a>throw</a>, the two functions are subtly different:
°5u
°5u<pre>
°5uthrow e   `seq` x  ===&gt; throw e
°5uthrowIO e `seq` x  ===&gt; x
°5u</pre>
°5u
°5uThe first example will cause the exception <tt>e</tt> to be raised,
°5uwhereas the second one won't. In fact, <a>throwIO</a> will only cause
°5uan exception to be raised when it is used within the <a>IO</a> monad.
°5uThe <a>throwIO</a> variant should be used in preference to
°5u<a>throw</a> to raise an exception within the <a>IO</a> monad because
°5uit guarantees ordering with respect to other <a>IO</a> operations,
°5uwhereas <a>throw</a> does not.
throwIO :: Exception e => e -> IO a

-- | Throw an exception. Exceptions may be thrown from purely functional
°5ucode, 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
°5uonly).
°5u
°5uException delivery synchronizes between the source and target thread:
°5u<a>throwTo</a> does not return until the exception has been raised in
°5uthe target thread. The calling thread can thus be certain that the
°5utarget thread has received the exception. Exception delivery is also
°5uatomic with respect to other exceptions. Atomicity is a useful
°5uproperty to have when dealing with race conditions: e.g. if there are
°5utwo threads that can kill each other, it is guaranteed that only one
°5uof the threads will get to kill the other.
°5u
°5uWhatever work the target thread was doing when the exception was
°5uraised is not lost: the computation is suspended until required by
°5uanother thread.
°5u
°5uIf the target thread is currently making a foreign call, then the
°5uexception will not be raised (and hence <a>throwTo</a> will not
°5ureturn) until the call has completed. This is the case regardless of
°5uwhether the call is inside a <a>mask</a> or not. However, in GHC a
°5uforeign call can be annotated as <tt>interruptible</tt>, in which case
°5ua <a>throwTo</a> will cause the RTS to attempt to cause the call to
°5ureturn; see the GHC documentation for more details.
°5u
°5uImportant note: the behaviour of <a>throwTo</a> differs from that
°5udescribed in the paper "Asynchronous exceptions in Haskell"
°5u(<a>http://research.microsoft.com/~simonpj/Papers/asynch-exns.htm</a>).
°5uIn the paper, <a>throwTo</a> is non-blocking; but the library
°5uimplementation adopts a more synchronous design in which
°5u<a>throwTo</a> does not return until the exception is received by the
°5utarget thread. The trade-off is discussed in Section 9 of the paper.
°5uLike any blocking operation, <a>throwTo</a> is therefore interruptible
°5u(see Section 5.3 of the paper). Unlike other interruptible operations,
°5uhowever, <a>throwTo</a> is <i>always</i> interruptible, even if it
°5udoes not actually block.
°5u
°5uThere is no guarantee that the exception will be delivered promptly,
°5ualthough the runtime will endeavour to ensure that arbitrary delays
°5udon't occur. In GHC, an exception can only be raised when a thread
°5ureaches a <i>safe point</i>, where a safe point is where memory
°5uallocation occurs. Some loops do not perform any memory allocation
°5uinside the loop and therefore cannot be interrupted by a
°5u<a>throwTo</a>.
°5u
°5uIf the target of <a>throwTo</a> is the calling thread, then the
°5ubehaviour is the same as <a>throwIO</a>, except that the exception is
°5uthrown as an asynchronous exception. This means that if there is an
°5uenclosing pure computation, which would be the case if the current IO
°5uoperation is inside <a>unsafePerformIO</a> or
°5u<a>unsafeInterleaveIO</a>, that computation is not permanently
°5ureplaced by the exception, but is suspended as if it had received an
°5uasynchronous exception.
°5u
°5uNote that if <a>throwTo</a> is called with the current thread as the
°5utarget, the exception will be thrown even if the thread is currently
°5uinside <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
°5usingle argument, runs it, and if an exception is raised the "handler"
°5uis executed, with the value of the exception passed as an argument.
°5uOtherwise, the result is returned as normal. For example:
°5u
°5u<pre>
°5ucatch (readFile f)
°5u      (\e -&gt; do let err = show (e :: IOException)
°5u                hPutStr stderr ("Warning: Couldn't open " ++ f ++ ": " ++ err)
°5u                return "")
°5u</pre>
°5u
°5uNote that we have to give a type signature to <tt>e</tt>, or the
°5uprogram will not typecheck as the type is ambiguous. While it is
°5upossible to catch exceptions of any type, see the section "Catching
°5uall exceptions" (in <a>Control.Exception</a>) for an explanation of
°5uthe problems with doing so.
°5u
°5uFor catching exceptions in pure (non-<a>IO</a>) expressions, see the
°5ufunction <a>evaluate</a>.
°5u
°5uNote that due to Haskell's unspecified evaluation order, an expression
°5umay throw one of several possible exceptions: consider the expression
°5u<tt>(error "urk") + (1 `div` 0)</tt>. Does the expression throw
°5u<tt>ErrorCall "urk"</tt>, or <tt>DivideByZero</tt>?
°5u
°5uThe answer is "it might throw either"; the choice is
°5unon-deterministic. If you are catching any type of exception then you
°5umight catch either. If you are calling <tt>catch</tt> with type <tt>IO
°5uInt -&gt; (ArithException -&gt; IO Int) -&gt; IO Int</tt> then the
°5uhandler may get run with <tt>DivideByZero</tt> as an argument, or an
°5u<tt>ErrorCall "urk"</tt> exception may be propogated further up. If
°5uyou call it again, you might get a the opposite behaviour. This is ok,
°5ubecause <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
°5uextra argument which is an <i>exception predicate</i>, a function
°5uwhich selects which type of exceptions we're interested in.
°5u
°5u<pre>
°5ucatchJust (\e -&gt; if isDoesNotExistErrorType (ioeGetErrorType e) then Just () else Nothing)
°5u          (readFile f)
°5u          (\_ -&gt; do hPutStrLn stderr ("No such file: " ++ show f)
°5u                    return "")
°5u</pre>
°5u
°5uAny other exceptions which are not matched by the predicate are
°5ure-raised, and may be caught by an enclosing <a>catch</a>,
°5u<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
°5usituations where the code for the handler is shorter. For example:
°5u
°5u<pre>
°5udo handle (\NonTermination -&gt; exitWith (ExitFailure 1)) $
°5u   ...
°5u</pre>
handle :: Exception e => (e -> IO a) -> IO a -> IO a

-- | A version of <a>catchJust</a> with the arguments swapped around (see
°5u<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
°5u<tt>(<a>Right</a> a)</tt> if no exception of type <tt>e</tt> was
°5uraised, or <tt>(<a>Left</a> ex)</tt> if an exception of type
°5u<tt>e</tt> was raised and its value is <tt>ex</tt>. If any other type
°5uof exception is raised than it will be propogated up to the next
°5uenclosing exception handler.
°5u
°5u<pre>
°5utry a = catch (Right `liftM` a) (return . Left)
°5u</pre>
try :: Exception e => IO a -> IO (Either e a)

-- | A variant of <a>try</a> that takes an exception predicate to select
°5uwhich exceptions are caught (c.f. <a>catchJust</a>). If the exception
°5udoes 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
°5uan exception raised by the computation.
onException :: IO a -> IO b -> IO a

-- | Evaluate the argument to weak head normal form.
°5u
°5u<a>evaluate</a> is typically used to uncover any exceptions that a
°5ulazy value may contain, and possibly handle them.
°5u
°5u<a>evaluate</a> only evaluates to <i>weak head normal form</i>. If
°5udeeper evaluation is needed, the <tt>force</tt> function from
°5u<tt>Control.DeepSeq</tt> may be handy:
°5u
°5u<pre>
°5uevaluate $ force x
°5u</pre>
°5u
°5uThere is a subtle difference between <tt><a>evaluate</a> x</tt> and
°5u<tt><a>return</a> <a>$!</a> x</tt>, analogous to the difference
°5ubetween <a>throwIO</a> and <a>throw</a>. If the lazy value <tt>x</tt>
°5uthrows an exception, <tt><a>return</a> <a>$!</a> x</tt> will fail to
°5ureturn an <a>IO</a> action and will throw an exception instead.
°5u<tt><a>evaluate</a> x</tt>, on the other hand, always produces an
°5u<a>IO</a> action; that action will throw an exception upon
°5u<i>execution</i> iff <tt>x</tt> throws an exception upon
°5u<i>evaluation</i>.
°5u
°5uThe practical implication of this difference is that due to the
°5u<i>imprecise exceptions</i> semantics,
°5u
°5u<pre>
°5u(return $! error "foo") &gt;&gt; error "bar"
°5u</pre>
°5u
°5umay throw either <tt>"foo"</tt> or <tt>"bar"</tt>, depending on the
°5uoptimizations performed by the compiler. On the other hand,
°5u
°5u<pre>
°5uevaluate (error "foo") &gt;&gt; error "bar"
°5u</pre>
°5u
°5uis guaranteed to throw <tt>"foo"</tt>.
°5u
°5uThe rule of thumb is to use <a>evaluate</a> to force or handle
°5uexceptions in lazy values. If, on the other hand, you are forcing a
°5ulazy value for efficiency reasons only and do not care about
°5uexceptions, 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
°5u"A semantics for imprecise exceptions".
mapException :: (Exception e1, Exception e2) => (e1 -> e2) -> a -> a

-- | Executes an IO computation with asynchronous exceptions <i>masked</i>.
°5uThat is, any thread which attempts to raise an exception in the
°5ucurrent thread with <a>throwTo</a> will be blocked until asynchronous
°5uexceptions are unmasked again.
°5u
°5uThe argument passed to <a>mask</a> is a function that takes as its
°5uargument another function, which can be used to restore the prevailing
°5umasking state within the context of the masked computation. For
°5uexample, a common way to use <a>mask</a> is to protect the acquisition
°5uof a resource:
°5u
°5u<pre>
°5umask $ \restore -&gt; do
°5u    x &lt;- acquire
°5u    restore (do_something_with x) `onException` release
°5u    release
°5u</pre>
°5u
°5uThis code guarantees that <tt>acquire</tt> is paired with
°5u<tt>release</tt>, by masking asynchronous exceptions for the critical
°5uparts. (Rather than write this code yourself, it would be better to
°5uuse <a>bracket</a> which abstracts the general pattern).
°5u
°5uNote that the <tt>restore</tt> action passed to the argument to
°5u<a>mask</a> does not necessarily unmask asynchronous exceptions, it
°5ujust restores the masking state to that of the enclosing context. Thus
°5uif asynchronous exceptions are already masked, <a>mask</a> cannot be
°5uused to unmask exceptions again. This is so that if you call a library
°5ufunction with exceptions masked, you can be sure that the library call
°5uwill not be able to unmask exceptions again. If you are writing
°5ulibrary code and need to use asynchronous exceptions, the only way is
°5uto create a new thread; see <a>forkIOWithUnmask</a>.
°5u
°5uAsynchronous exceptions may still be received while in the masked
°5ustate if the masked thread <i>blocks</i> in certain ways; see
°5u<a>Control.Exception#interruptible</a>.
°5u
°5uThreads created by <a>forkIO</a> inherit the <a>MaskingState</a> from
°5uthe parent; that is, to start a thread in the
°5u<a>MaskedInterruptible</a> state, use <tt>mask_ $ forkIO ...</tt>.
°5uThis is particularly useful if you need to establish an exception
°5uhandler in the forked thread before any asynchronous exceptions are
°5ureceived. To create a a new thread in an unmasked state use
°5u<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
°5uargument.
mask_ :: IO a -> IO a

-- | Like <a>mask</a>, but the masked computation is not interruptible (see
°5u<a>Control.Exception#interruptible</a>). THIS SHOULD BE USED WITH
°5uGREAT CARE, because if a thread executing in
°5u<a>uninterruptibleMask</a> blocks for any reason, then the thread (and
°5upossibly the program, if this is the main thread) will be unresponsive
°5uand unkillable. This function should only be necessary if you need to
°5umask exceptions around an interruptible operation, and you can
°5uguarantee that the interruptible operation will only block for a short
°5uperiod 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>
°5uaction to the argument.
uninterruptibleMask_ :: IO a -> IO a

-- | Describes the behaviour of a thread when an asynchronous exception is
°5ureceived.
data MaskingState

-- | asynchronous exceptions are unmasked (the normal state)
Unmasked :: MaskingState

-- | the state during <a>mask</a>: asynchronous exceptions are masked, but
°5ublocking operations may still be interrupted
MaskedInterruptible :: MaskingState

-- | the state during <a>uninterruptibleMask</a>: asynchronous exceptions
°5uare 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
°5usecond argument. Otherwise an <tt>AssertionFailed</tt> exception is
°5uraised, containing a <a>String</a> with the source file and line
°5unumber of the call to <a>assert</a>.
°5u
°5uAssertions can normally be turned on or off with a compiler flag (for
°5uGHC, assertions are normally on unless optimisation is turned on with
°5u<tt>-O</tt> or the <tt>-fignore-asserts</tt> option is given). When
°5uassertions are turned off, the first argument to <a>assert</a> is
°5uignored, 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
°5urelease the resource, it is a good idea to use <a>bracket</a>, because
°5u<a>bracket</a> will install the necessary exception handler to release
°5uthe resource in the event that an exception is raised during the
°5ucomputation. If an exception is raised, then <a>bracket</a> will
°5ure-raise the exception (after performing the release).
°5u
°5uA common example is opening a file:
°5u
°5u<pre>
°5ubracket
°5u  (openFile "filename" ReadMode)
°5u  (hClose)
°5u  (\fileHandle -&gt; do { ... })
°5u</pre>
°5u
°5uThe arguments to <a>bracket</a> are in this order so that we can
°5upartially apply it, e.g.:
°5u
°5u<pre>
°5uwithFile name mode = bracket (openFile name mode) hClose
°5u</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
°5ucomputation 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
°5uan 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
°5uafterward.
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
°5uoperation may raise an <a>IOError</a> instead of returning a result.
°5uFor a more general type of exception, including also those that arise
°5uin pure code, see <a>Exception</a>.
°5u
°5uIn Haskell 2010, this is an opaque type.
type IOError = IOException

-- | Construct an <a>IOError</a> value with a string describing the error.
°5uThe <a>fail</a> method of the <a>IO</a> instance of the <a>Monad</a>
°5uclass raises a <a>userError</a>, thus:
°5u
°5u<pre>
°5uinstance Monad IO where
°5u  ...
°5u  fail s = ioError (userError s)
°5u</pre>
userError :: String -> IOError

-- | Construct an <a>IOError</a> of the given type where the second
°5uargument describes the error location and the third and fourth
°5uargument contain the file handle and file path of the file involved in
°5uthe error if applicable.
mkIOError :: IOErrorType -> String -> Maybe Handle -> Maybe FilePath -> IOError

-- | Adds a location description and maybe a file path and file handle to
°5uan <a>IOError</a>. If any of the file handle or file path is not given
°5uthe 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
°5uits arguments already exists.
isAlreadyExistsError :: IOError -> Bool

-- | An error indicating that an <a>IO</a> operation failed because one of
°5uits arguments does not exist.
isDoesNotExistError :: IOError -> Bool

-- | An error indicating that an <a>IO</a> operation failed because one of
°5uits arguments is a single-use resource, which is already being used
°5u(for example, opening the same file twice for writing might give this
°5uerror).
isAlreadyInUseError :: IOError -> Bool

-- | An error indicating that an <a>IO</a> operation failed because the
°5udevice is full.
isFullError :: IOError -> Bool

-- | An error indicating that an <a>IO</a> operation failed because the end
°5uof file has been reached.
isEOFError :: IOError -> Bool

-- | An error indicating that an <a>IO</a> operation failed because the
°5uoperation was not possible. Any computation which returns an <a>IO</a>
°5uresult may fail with <a>isIllegalOperation</a>. In some cases, an
°5uimplementation will not be able to distinguish between the possible
°5uerror causes. In this case it should fail with
°5u<a>isIllegalOperation</a>.
isIllegalOperation :: IOError -> Bool

-- | An error indicating that an <a>IO</a> operation failed because the
°5uuser does not have sufficient operating system privilege to perform
°5uthat 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
°5u<a>IOError</a>.
data IOErrorType

-- | I/O error where the operation failed because one of its arguments
°5ualready exists.
alreadyExistsErrorType :: IOErrorType

-- | I/O error where the operation failed because one of its arguments does
°5unot exist.
doesNotExistErrorType :: IOErrorType

-- | I/O error where the operation failed because one of its arguments is a
°5usingle-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
°5ureached.
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
°5usufficient 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
°5ualready exists.
isAlreadyExistsErrorType :: IOErrorType -> Bool

-- | I/O error where the operation failed because one of its arguments does
°5unot exist.
isDoesNotExistErrorType :: IOErrorType -> Bool

-- | I/O error where the operation failed because one of its arguments is a
°5usingle-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
°5ureached.
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
°5usufficient 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
°5uany <a>IOError</a> raised in the action protected by
°5u<a>catchIOError</a>. An <a>IOError</a> is caught by the most recent
°5uhandler established by one of the exception handling functions. These
°5uhandlers are not selective: all <a>IOError</a>s are caught. Exception
°5upropagation must be explicitly provided in a handler by re-raising any
°5uunwanted exceptions. For example, in
°5u
°5u<pre>
°5uf = catchIOError g (\e -&gt; if IO.isEOFError e then return [] else ioError e)
°5u</pre>
°5u
°5uthe function <tt>f</tt> returns <tt>[]</tt> when an end-of-file
°5uexception (cf. <a>isEOFError</a>) occurs in <tt>g</tt>; otherwise, the
°5uexception is propagated to the next outer handler.
°5u
°5uWhen an exception propagates outside the main program, the Haskell
°5usystem prints the associated <a>IOError</a> value and exits the
°5uprogram.
°5u
°5uNon-I/O exceptions are not caught by this variant; to catch all
°5uexceptions, 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
°5uoccur within a computation, and which are not fully handled.
°5u
°5uNon-I/O exceptions are not caught by this variant; to catch all
°5uexceptions, 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
°5umodified version.
modifyIOError :: (IOError -> IOError) -> IO a -> IO a


-- | This module provides support for raising and catching both built-in
°5uand user-defined exceptions.
°5u
°5uIn addition to exceptions thrown by <a>IO</a> operations, exceptions
°5umay be thrown by pure code (imprecise exceptions) or by external
°5uevents (asynchronous exceptions), but may only be caught in the
°5u<a>IO</a> monad. For more details, see:
°5u
°5u<ul>
°5u<li><i>A semantics for imprecise exceptions</i>, by Simon Peyton
°5uJones, Alastair Reid, Tony Hoare, Simon Marlow, Fergus Henderson, in
°5u<i>PLDI'99</i>.</li>
°5u<li><i>Asynchronous exceptions in Haskell</i>, by Simon Marlow, Simon
°5uPeyton Jones, Andy Moran and John Reppy, in <i>PLDI'01</i>.</li>
°5u<li><i>An Extensible Dynamically-Typed Hierarchy of Exceptions</i>, by
°5uSimon Marlow, in <i>Haskell '06</i>.</li>
°5u</ul>
module Control.Exception

-- | The <tt>SomeException</tt> type is the root of the exception type
°5uhierarchy. When an exception of type <tt>e</tt> is thrown, behind the
°5uscenes 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
°5uinstance of the <tt>Exception</tt> class. The simplest case is a new
°5uexception type directly below the root:
°5u
°5u<pre>
°5udata MyException = ThisException | ThatException
°5u    deriving Show
°5u
°5uinstance Exception MyException
°5u</pre>
°5u
°5uThe default method definitions in the <tt>Exception</tt> class do what
°5uwe need in this case. You can now throw and catch
°5u<tt>ThisException</tt> and <tt>ThatException</tt> as exceptions:
°5u
°5u<pre>
°5u*Main&gt; throw ThisException `catch` \e -&gt; putStrLn ("Caught " ++ show (e :: MyException))
°5uCaught ThisException
°5u</pre>
°5u
°5uIn more complicated examples, you may wish to define a whole hierarchy
°5uof exceptions:
°5u
°5u<pre>
°5u---------------------------------------------------------------------
°5u-- Make the root exception type for all the exceptions in a compiler
°5u
°5udata SomeCompilerException = forall e . Exception e =&gt; SomeCompilerException e
°5u
°5uinstance Show SomeCompilerException where
°5u    show (SomeCompilerException e) = show e
°5u
°5uinstance Exception SomeCompilerException
°5u
°5ucompilerExceptionToException :: Exception e =&gt; e -&gt; SomeException
°5ucompilerExceptionToException = toException . SomeCompilerException
°5u
°5ucompilerExceptionFromException :: Exception e =&gt; SomeException -&gt; Maybe e
°5ucompilerExceptionFromException x = do
°5u    SomeCompilerException a &lt;- fromException x
°5u    cast a
°5u
°5u---------------------------------------------------------------------
°5u-- Make a subhierarchy for exceptions in the frontend of the compiler
°5u
°5udata SomeFrontendException = forall e . Exception e =&gt; SomeFrontendException e
°5u
°5uinstance Show SomeFrontendException where
°5u    show (SomeFrontendException e) = show e
°5u
°5uinstance Exception SomeFrontendException where
°5u    toException = compilerExceptionToException
°5u    fromException = compilerExceptionFromException
°5u
°5ufrontendExceptionToException :: Exception e =&gt; e -&gt; SomeException
°5ufrontendExceptionToException = toException . SomeFrontendException
°5u
°5ufrontendExceptionFromException :: Exception e =&gt; SomeException -&gt; Maybe e
°5ufrontendExceptionFromException x = do
°5u    SomeFrontendException a &lt;- fromException x
°5u    cast a
°5u
°5u---------------------------------------------------------------------
°5u-- Make an exception type for a particular frontend compiler exception
°5u
°5udata MismatchedParentheses = MismatchedParentheses
°5u    deriving Show
°5u
°5uinstance Exception MismatchedParentheses where
°5u    toException   = frontendExceptionToException
°5u    fromException = frontendExceptionFromException
°5u</pre>
°5u
°5uWe can now catch a <tt>MismatchedParentheses</tt> exception as
°5u<tt>MismatchedParentheses</tt>, <tt>SomeFrontendException</tt> or
°5u<tt>SomeCompilerException</tt>, but not other types, e.g.
°5u<tt>IOException</tt>:
°5u
°5u<pre>
°5u*Main&gt; throw MismatchedParentheses `catch` \e -&gt; putStrLn ("Caught " ++ show (e :: MismatchedParentheses))
°5uCaught MismatchedParentheses
°5u*Main&gt; throw MismatchedParentheses `catch` \e -&gt; putStrLn ("Caught " ++ show (e :: SomeFrontendException))
°5uCaught MismatchedParentheses
°5u*Main&gt; throw MismatchedParentheses `catch` \e -&gt; putStrLn ("Caught " ++ show (e :: SomeCompilerException))
°5uCaught MismatchedParentheses
°5u*Main&gt; throw MismatchedParentheses `catch` \e -&gt; putStrLn ("Caught " ++ show (e :: IOException))
°5u*** Exception: MismatchedParentheses
°5u</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.
°5u
°5uDefault implementation: <tt><a>show</a></tt>.
displayException :: Exception e => e -> String

-- | Exceptions that occur in the <tt>IO</tt> monad. An
°5u<tt>IOException</tt> records a more specific error type, a descriptive
°5ustring 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
°5ubeen 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
°5ubeen raised, the thread's stack will certainly be below its limit
°5uagain, but the programmer should take remedial action immediately.
StackOverflow :: AsyncException

-- | The program's heap is reaching its limit, and the program should take
°5uaction to reduce the amount of live data it has. Notes:
°5u
°5u<ul>
°5u<li>It is undefined which thread receives this exception. GHC
°5ucurrently throws this to the same thread that receives
°5u<a>UserInterrupt</a>, but this may change in the future.</li>
°5u<li>The GHC RTS currently can only recover from heap overflow if it
°5udetects that an explicit memory limit (set via RTS flags). has been
°5uexceeded. Currently, failure to allocate memory from the operating
°5usystem results in immediate termination of the program.</li>
°5u</ul>
HeapOverflow :: AsyncException

-- | This exception is raised by another thread calling <a>killThread</a>,
°5uor 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
°5uwhen the user requests to terminate the program via the usual
°5umechanism(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
°5uguaranteed not to terminate. Note that there is no guarantee that the
°5uruntime system will notice whether any given computation is guaranteed
°5uto terminate or not.
data NonTermination
NonTermination :: NonTermination

-- | Thrown when the program attempts to call <tt>atomically</tt>, from the
°5u<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
°5ureferences 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
°5uother references to any <tt>TVar</tt>s involved, so it can't ever
°5ucontinue.
data BlockedIndefinitelyOnSTM
BlockedIndefinitelyOnSTM :: BlockedIndefinitelyOnSTM

-- | This thread has exceeded its allocation limit. See
°5u<a>setAllocationCounter</a> and <a>enableAllocationLimit</a>.
data AllocationLimitExceeded
AllocationLimitExceeded :: AllocationLimitExceeded

-- | Compaction found an object that cannot be compacted. Functions cannot
°5ube compacted, nor can mutable objects or pinned objects. See
°5u<a>compact</a>.
newtype CompactionFailed
CompactionFailed :: String -> CompactionFailed

-- | There are no runnable threads, so the program is deadlocked. The
°5u<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
°5ua definition in the appropriate instance) was called. The
°5u<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
°5uthe source location of the pattern.
newtype PatternMatchFail
PatternMatchFail :: String -> PatternMatchFail

-- | An uninitialised record field was used. The <tt>String</tt> gives
°5uinformation about the source location where the record was
°5uconstructed.
newtype RecConError
RecConError :: String -> RecConError

-- | A record selector was applied to a constructor without the appropriate
°5ufield. This can only happen with a datatype with multiple
°5uconstructors, where some fields are in one constructor but not
°5uanother. The <tt>String</tt> gives information about the source
°5ulocation of the record selector.
newtype RecSelError
RecSelError :: String -> RecSelError

-- | A record update was performed on a constructor without the appropriate
°5ufield. This can only happen with a datatype with multiple
°5uconstructors, where some fields are in one constructor but not
°5uanother. The <tt>String</tt> gives information about the source
°5ulocation of the record update.
newtype RecUpdError
RecUpdError :: String -> RecUpdError

-- | This is thrown when the user calls <a>error</a>. The first
°5u<tt>String</tt> is the argument given to <a>error</a>, second
°5u<tt>String</tt> is the location.
data ErrorCall
ErrorCallWithLocation :: String -> String -> ErrorCall

-- | An expression that didn't typecheck during compile time was called.
°5uThis is only possible with -fdefer-type-errors. The <tt>String</tt>
°5ugives details about the failed type check.
newtype TypeError
TypeError :: String -> TypeError

-- | Throw an exception. Exceptions may be thrown from purely functional
°5ucode, 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>
°5umonad.
°5u
°5uAlthough <a>throwIO</a> has a type that is an instance of the type of
°5u<a>throw</a>, the two functions are subtly different:
°5u
°5u<pre>
°5uthrow e   `seq` x  ===&gt; throw e
°5uthrowIO e `seq` x  ===&gt; x
°5u</pre>
°5u
°5uThe first example will cause the exception <tt>e</tt> to be raised,
°5uwhereas the second one won't. In fact, <a>throwIO</a> will only cause
°5uan exception to be raised when it is used within the <a>IO</a> monad.
°5uThe <a>throwIO</a> variant should be used in preference to
°5u<a>throw</a> to raise an exception within the <a>IO</a> monad because
°5uit guarantees ordering with respect to other <a>IO</a> operations,
°5uwhereas <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
°5uonly).
°5u
°5uException delivery synchronizes between the source and target thread:
°5u<a>throwTo</a> does not return until the exception has been raised in
°5uthe target thread. The calling thread can thus be certain that the
°5utarget thread has received the exception. Exception delivery is also
°5uatomic with respect to other exceptions. Atomicity is a useful
°5uproperty to have when dealing with race conditions: e.g. if there are
°5utwo threads that can kill each other, it is guaranteed that only one
°5uof the threads will get to kill the other.
°5u
°5uWhatever work the target thread was doing when the exception was
°5uraised is not lost: the computation is suspended until required by
°5uanother thread.
°5u
°5uIf the target thread is currently making a foreign call, then the
°5uexception will not be raised (and hence <a>throwTo</a> will not
°5ureturn) until the call has completed. This is the case regardless of
°5uwhether the call is inside a <a>mask</a> or not. However, in GHC a
°5uforeign call can be annotated as <tt>interruptible</tt>, in which case
°5ua <a>throwTo</a> will cause the RTS to attempt to cause the call to
°5ureturn; see the GHC documentation for more details.
°5u
°5uImportant note: the behaviour of <a>throwTo</a> differs from that
°5udescribed in the paper "Asynchronous exceptions in Haskell"
°5u(<a>http://research.microsoft.com/~simonpj/Papers/asynch-exns.htm</a>).
°5uIn the paper, <a>throwTo</a> is non-blocking; but the library
°5uimplementation adopts a more synchronous design in which
°5u<a>throwTo</a> does not return until the exception is received by the
°5utarget thread. The trade-off is discussed in Section 9 of the paper.
°5uLike any blocking operation, <a>throwTo</a> is therefore interruptible
°5u(see Section 5.3 of the paper). Unlike other interruptible operations,
°5uhowever, <a>throwTo</a> is <i>always</i> interruptible, even if it
°5udoes not actually block.
°5u
°5uThere is no guarantee that the exception will be delivered promptly,
°5ualthough the runtime will endeavour to ensure that arbitrary delays
°5udon't occur. In GHC, an exception can only be raised when a thread
°5ureaches a <i>safe point</i>, where a safe point is where memory
°5uallocation occurs. Some loops do not perform any memory allocation
°5uinside the loop and therefore cannot be interrupted by a
°5u<a>throwTo</a>.
°5u
°5uIf the target of <a>throwTo</a> is the calling thread, then the
°5ubehaviour is the same as <a>throwIO</a>, except that the exception is
°5uthrown as an asynchronous exception. This means that if there is an
°5uenclosing pure computation, which would be the case if the current IO
°5uoperation is inside <a>unsafePerformIO</a> or
°5u<a>unsafeInterleaveIO</a>, that computation is not permanently
°5ureplaced by the exception, but is suspended as if it had received an
°5uasynchronous exception.
°5u
°5uNote that if <a>throwTo</a> is called with the current thread as the
°5utarget, the exception will be thrown even if the thread is currently
°5uinside <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
°5usingle argument, runs it, and if an exception is raised the "handler"
°5uis executed, with the value of the exception passed as an argument.
°5uOtherwise, the result is returned as normal. For example:
°5u
°5u<pre>
°5ucatch (readFile f)
°5u      (\e -&gt; do let err = show (e :: IOException)
°5u                hPutStr stderr ("Warning: Couldn't open " ++ f ++ ": " ++ err)
°5u                return "")
°5u</pre>
°5u
°5uNote that we have to give a type signature to <tt>e</tt>, or the
°5uprogram will not typecheck as the type is ambiguous. While it is
°5upossible to catch exceptions of any type, see the section "Catching
°5uall exceptions" (in <a>Control.Exception</a>) for an explanation of
°5uthe problems with doing so.
°5u
°5uFor catching exceptions in pure (non-<a>IO</a>) expressions, see the
°5ufunction <a>evaluate</a>.
°5u
°5uNote that due to Haskell's unspecified evaluation order, an expression
°5umay throw one of several possible exceptions: consider the expression
°5u<tt>(error "urk") + (1 `div` 0)</tt>. Does the expression throw
°5u<tt>ErrorCall "urk"</tt>, or <tt>DivideByZero</tt>?
°5u
°5uThe answer is "it might throw either"; the choice is
°5unon-deterministic. If you are catching any type of exception then you
°5umight catch either. If you are calling <tt>catch</tt> with type <tt>IO
°5uInt -&gt; (ArithException -&gt; IO Int) -&gt; IO Int</tt> then the
°5uhandler may get run with <tt>DivideByZero</tt> as an argument, or an
°5u<tt>ErrorCall "urk"</tt> exception may be propogated further up. If
°5uyou call it again, you might get a the opposite behaviour. This is ok,
°5ubecause <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
°5ucould do something like
°5u
°5u<pre>
°5uf = expr `catch` \ (ex :: ArithException) -&gt; handleArith ex
°5u         `catch` \ (ex :: IOException)    -&gt; handleIO    ex
°5u</pre>
°5u
°5uHowever, there are a couple of problems with this approach. The first
°5uis that having two exception handlers is inefficient. However, the
°5umore serious issue is that the second exception handler will catch
°5uexceptions in the first, e.g. in the example above, if
°5u<tt>handleArith</tt> throws an <tt>IOException</tt> then the second
°5uexception handler will catch it.
°5u
°5uInstead, we provide a function <a>catches</a>, which would be used
°5uthus:
°5u
°5u<pre>
°5uf = expr `catches` [Handler (\ (ex :: ArithException) -&gt; handleArith ex),
°5u                    Handler (\ (ex :: IOException)    -&gt; handleIO    ex)]
°5u</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
°5uextra argument which is an <i>exception predicate</i>, a function
°5uwhich selects which type of exceptions we're interested in.
°5u
°5u<pre>
°5ucatchJust (\e -&gt; if isDoesNotExistErrorType (ioeGetErrorType e) then Just () else Nothing)
°5u          (readFile f)
°5u          (\_ -&gt; do hPutStrLn stderr ("No such file: " ++ show f)
°5u                    return "")
°5u</pre>
°5u
°5uAny other exceptions which are not matched by the predicate are
°5ure-raised, and may be caught by an enclosing <a>catch</a>,
°5u<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
°5usituations where the code for the handler is shorter. For example:
°5u
°5u<pre>
°5udo handle (\NonTermination -&gt; exitWith (ExitFailure 1)) $
°5u   ...
°5u</pre>
handle :: Exception e => (e -> IO a) -> IO a -> IO a

-- | A version of <a>catchJust</a> with the arguments swapped around (see
°5u<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
°5u<tt>(<a>Right</a> a)</tt> if no exception of type <tt>e</tt> was
°5uraised, or <tt>(<a>Left</a> ex)</tt> if an exception of type
°5u<tt>e</tt> was raised and its value is <tt>ex</tt>. If any other type
°5uof exception is raised than it will be propogated up to the next
°5uenclosing exception handler.
°5u
°5u<pre>
°5utry a = catch (Right `liftM` a) (return . Left)
°5u</pre>
try :: Exception e => IO a -> IO (Either e a)

-- | A variant of <a>try</a> that takes an exception predicate to select
°5uwhich exceptions are caught (c.f. <a>catchJust</a>). If the exception
°5udoes 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.
°5u
°5u<a>evaluate</a> is typically used to uncover any exceptions that a
°5ulazy value may contain, and possibly handle them.
°5u
°5u<a>evaluate</a> only evaluates to <i>weak head normal form</i>. If
°5udeeper evaluation is needed, the <tt>force</tt> function from
°5u<tt>Control.DeepSeq</tt> may be handy:
°5u
°5u<pre>
°5uevaluate $ force x
°5u</pre>
°5u
°5uThere is a subtle difference between <tt><a>evaluate</a> x</tt> and
°5u<tt><a>return</a> <a>$!</a> x</tt>, analogous to the difference
°5ubetween <a>throwIO</a> and <a>throw</a>. If the lazy value <tt>x</tt>
°5uthrows an exception, <tt><a>return</a> <a>$!</a> x</tt> will fail to
°5ureturn an <a>IO</a> action and will throw an exception instead.
°5u<tt><a>evaluate</a> x</tt>, on the other hand, always produces an
°5u<a>IO</a> action; that action will throw an exception upon
°5u<i>execution</i> iff <tt>x</tt> throws an exception upon
°5u<i>evaluation</i>.
°5u
°5uThe practical implication of this difference is that due to the
°5u<i>imprecise exceptions</i> semantics,
°5u
°5u<pre>
°5u(return $! error "foo") &gt;&gt; error "bar"
°5u</pre>
°5u
°5umay throw either <tt>"foo"</tt> or <tt>"bar"</tt>, depending on the
°5uoptimizations performed by the compiler. On the other hand,
°5u
°5u<pre>
°5uevaluate (error "foo") &gt;&gt; error "bar"
°5u</pre>
°5u
°5uis guaranteed to throw <tt>"foo"</tt>.
°5u
°5uThe rule of thumb is to use <a>evaluate</a> to force or handle
°5uexceptions in lazy values. If, on the other hand, you are forcing a
°5ulazy value for efficiency reasons only and do not care about
°5uexceptions, 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
°5u"A semantics for imprecise exceptions".
mapException :: (Exception e1, Exception e2) => (e1 -> e2) -> a -> a

-- | Executes an IO computation with asynchronous exceptions <i>masked</i>.
°5uThat is, any thread which attempts to raise an exception in the
°5ucurrent thread with <a>throwTo</a> will be blocked until asynchronous
°5uexceptions are unmasked again.
°5u
°5uThe argument passed to <a>mask</a> is a function that takes as its
°5uargument another function, which can be used to restore the prevailing
°5umasking state within the context of the masked computation. For
°5uexample, a common way to use <a>mask</a> is to protect the acquisition
°5uof a resource:
°5u
°5u<pre>
°5umask $ \restore -&gt; do
°5u    x &lt;- acquire
°5u    restore (do_something_with x) `onException` release
°5u    release
°5u</pre>
°5u
°5uThis code guarantees that <tt>acquire</tt> is paired with
°5u<tt>release</tt>, by masking asynchronous exceptions for the critical
°5uparts. (Rather than write this code yourself, it would be better to
°5uuse <a>bracket</a> which abstracts the general pattern).
°5u
°5uNote that the <tt>restore</tt> action passed to the argument to
°5u<a>mask</a> does not necessarily unmask asynchronous exceptions, it
°5ujust restores the masking state to that of the enclosing context. Thus
°5uif asynchronous exceptions are already masked, <a>mask</a> cannot be
°5uused to unmask exceptions again. This is so that if you call a library
°5ufunction with exceptions masked, you can be sure that the library call
°5uwill not be able to unmask exceptions again. If you are writing
°5ulibrary code and need to use asynchronous exceptions, the only way is
°5uto create a new thread; see <a>forkIOWithUnmask</a>.
°5u
°5uAsynchronous exceptions may still be received while in the masked
°5ustate if the masked thread <i>blocks</i> in certain ways; see
°5u<a>Control.Exception#interruptible</a>.
°5u
°5uThreads created by <a>forkIO</a> inherit the <a>MaskingState</a> from
°5uthe parent; that is, to start a thread in the
°5u<a>MaskedInterruptible</a> state, use <tt>mask_ $ forkIO ...</tt>.
°5uThis is particularly useful if you need to establish an exception
°5uhandler in the forked thread before any asynchronous exceptions are
°5ureceived. To create a a new thread in an unmasked state use
°5u<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
°5uargument.
mask_ :: IO a -> IO a

-- | Like <a>mask</a>, but the masked computation is not interruptible (see
°5u<a>Control.Exception#interruptible</a>). THIS SHOULD BE USED WITH
°5uGREAT CARE, because if a thread executing in
°5u<a>uninterruptibleMask</a> blocks for any reason, then the thread (and
°5upossibly the program, if this is the main thread) will be unresponsive
°5uand unkillable. This function should only be necessary if you need to
°5umask exceptions around an interruptible operation, and you can
°5uguarantee that the interruptible operation will only block for a short
°5uperiod 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>
°5uaction to the argument.
uninterruptibleMask_ :: IO a -> IO a

-- | Describes the behaviour of a thread when an asynchronous exception is
°5ureceived.
data MaskingState

-- | asynchronous exceptions are unmasked (the normal state)
Unmasked :: MaskingState

-- | the state during <a>mask</a>: asynchronous exceptions are masked, but
°5ublocking operations may still be interrupted
MaskedInterruptible :: MaskingState

-- | the state during <a>uninterruptibleMask</a>: asynchronous exceptions
°5uare 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>,
°5umaking the operation interruptible (see the discussion of
°5u"Interruptible operations" in <a>Exception</a>).
°5u
°5uWhen called outside <a>mask</a>, or inside <a>uninterruptibleMask</a>,
°5uthis function has no effect.
interruptible :: IO a -> IO a

-- | When invoked inside <a>mask</a>, this function allows a masked
°5uasynchronous exception to be raised, if one exists. It is equivalent
°5uto performing an interruptible operation (see #interruptible), but
°5udoes not involve any actual blocking.
°5u
°5uWhen called outside <a>mask</a>, or inside <a>uninterruptibleMask</a>,
°5uthis function has no effect.
allowInterrupt :: IO ()

-- | If the first argument evaluates to <a>True</a>, then the result is the
°5usecond argument. Otherwise an <tt>AssertionFailed</tt> exception is
°5uraised, containing a <a>String</a> with the source file and line
°5unumber of the call to <a>assert</a>.
°5u
°5uAssertions can normally be turned on or off with a compiler flag (for
°5uGHC, assertions are normally on unless optimisation is turned on with
°5u<tt>-O</tt> or the <tt>-fignore-asserts</tt> option is given). When
°5uassertions are turned off, the first argument to <a>assert</a> is
°5uignored, 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
°5urelease the resource, it is a good idea to use <a>bracket</a>, because
°5u<a>bracket</a> will install the necessary exception handler to release
°5uthe resource in the event that an exception is raised during the
°5ucomputation. If an exception is raised, then <a>bracket</a> will
°5ure-raise the exception (after performing the release).
°5u
°5uA common example is opening a file:
°5u
°5u<pre>
°5ubracket
°5u  (openFile "filename" ReadMode)
°5u  (hClose)
°5u  (\fileHandle -&gt; do { ... })
°5u</pre>
°5u
°5uThe arguments to <a>bracket</a> are in this order so that we can
°5upartially apply it, e.g.:
°5u
°5u<pre>
°5uwithFile name mode = bracket (openFile name mode) hClose
°5u</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
°5ucomputation 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
°5uan 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
°5uafterward.
finally :: IO a -> IO b -> IO a

-- | Like <a>finally</a>, but only performs the final action if there was
°5uan 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>
°5ucomputation to be performed at any time. For this to be safe, the
°5u<a>IO</a> computation should be free of side effects and independent
°5uof its environment.
°5u
°5uIf the I/O computation wrapped in <a>unsafePerformIO</a> performs side
°5ueffects, then the relative order in which those side effects take
°5uplace (relative to the main I/O trunk, or other calls to
°5u<a>unsafePerformIO</a>) is indeterminate. Furthermore, when using
°5u<a>unsafePerformIO</a> to cause side-effects, you should take the
°5ufollowing precautions to ensure the side effects are performed as many
°5utimes as you expect them to be. Note that these precautions are
°5unecessary for GHC, but may not be sufficient, and other compilers may
°5urequire different precautions:
°5u
°5u<ul>
°5u<li>Use <tt>{-# NOINLINE foo #-}</tt> as a pragma on any function
°5u<tt>foo</tt> that calls <a>unsafePerformIO</a>. If the call is
°5uinlined, the I/O may be performed more than once.</li>
°5u<li>Use the compiler flag <tt>-fno-cse</tt> to prevent common
°5usub-expression elimination being performed on the module, which might
°5ucombine two side effects that were meant to be separate. A good
°5uexample is using multiple global variables (like <tt>test</tt> in the
°5uexample below).</li>
°5u<li>Make sure that the either you switch off let-floating
°5u(<tt>-fno-full-laziness</tt>), or that the call to
°5u<a>unsafePerformIO</a> cannot float outside a lambda. For example, if
°5uyou say: <tt> f x = unsafePerformIO (newIORef []) </tt> you may get
°5uonly one reference cell shared between all calls to <tt>f</tt>. Better
°5uwould be <tt> f x = unsafePerformIO (newIORef [x]) </tt> because now
°5uit can't float outside the lambda.</li>
°5u</ul>
°5u
°5uIt is less well known that <a>unsafePerformIO</a> is not type safe.
°5uFor example:
°5u
°5u<pre>
°5utest :: IORef [a]
°5utest = unsafePerformIO $ newIORef []
°5u
°5umain = do
°5u        writeIORef test [42]
°5u        bang &lt;- readIORef test
°5u        print (bang :: [Char])
°5u</pre>
°5u
°5uThis program will core dump. This problem with polymorphic references
°5uis well known in the ML community, and does not arise with normal
°5umonadic use of references. There is no easy way to make it impossible
°5uonce you use <a>unsafePerformIO</a>. Indeed, it is possible to write
°5u<tt>coerce :: a -&gt; b</tt> with the help of <a>unsafePerformIO</a>.
°5uSo be careful!
unsafePerformIO :: IO a -> a

-- | This version of <a>unsafePerformIO</a> is more efficient because it
°5uomits the check that the IO is only being performed by a single
°5uthread. Hence, when you use <a>unsafeDupablePerformIO</a>, there is a
°5upossibility that the IO action may be performed multiple times (on a
°5umultiprocessor), and you should therefore ensure that it gives the
°5usame results each time. It may even happen that one of the duplicated
°5uIO actions is only run partially, and then interrupted in the middle
°5uwithout an exception being raised. Therefore, functions like
°5u<tt>bracket</tt> cannot be used safely within
°5u<a>unsafeDupablePerformIO</a>.
unsafeDupablePerformIO :: IO a -> a

-- | <a>unsafeInterleaveIO</a> allows an <a>IO</a> computation to be
°5udeferred lazily. When passed a value of type <tt>IO a</tt>, the
°5u<a>IO</a> will only be performed when the value of the <tt>a</tt> is
°5udemanded. This is used to implement lazy file reading, see
°5u<a>hGetContents</a>.
unsafeInterleaveIO :: IO a -> IO a

-- | A slightly faster version of <a>fixIO</a> that may not be safe to use
°5uwith multiple threads. The unsafety arises when used like this:
°5u
°5u<pre>
°5uunsafeFixIO $ \r -&gt; do
°5u   forkIO (print r)
°5u   return (...)
°5u</pre>
°5u
°5uIn this case, the child thread will receive a <tt>NonTermination</tt>
°5uexception instead of waiting for the value of <tt>r</tt> to be
°5ucomputed.
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
°5u<tt>from</tt> to the buffer <tt>to</tt>. It should translate as many
°5uelements as possible given the sizes of the buffers, including
°5utranslating zero elements if there is either not enough room in
°5u<tt>to</tt>, or <tt>from</tt> does not contain a complete multibyte
°5usequence.
°5u
°5uIf multiple CodingProgress returns are possible, OutputUnderflow must
°5ube preferred to InvalidSequence. This allows GHC's IO library to
°5uassume that if we observe InvalidSequence there is at least a single
°5uelement available in the output buffer.
°5u
°5uThe fact that as many elements as possible are translated is used by
°5uthe IO library in order to report translation errors at the point they
°5uactually 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
°5upresence of invalid or unrepresentable sequences. This includes both
°5uthose detected by <tt>encode</tt> returning <tt>InvalidSequence</tt>
°5uand those that occur because the input byte sequence appears to be
°5utruncated.
°5u
°5uProgress will usually be made by skipping the first element of the
°5u<tt>from</tt> buffer. This function should only be called if you are
°5ucertain that you wish to do this skipping and if the <tt>to</tt>
°5ubuffer has at least one element of free space. Because this function
°5udeals with decoding failure, it assumes that the from buffer has at
°5uleast one element.
°5u
°5u<tt>recover</tt> may raise an exception rather than skipping anything.
°5u
°5uCurrently, some implementations of <tt>recover</tt> may mutate the
°5uinput buffer. In particular, this feature is used to implement
°5utransliteration.
[recover] :: BufferCodec from to state -> Buffer from -> Buffer to -> IO (Buffer from, Buffer to)

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

-- | Return the current state of the codec.
°5u
°5uMany codecs are not stateful, and in these case the state can be
°5urepresented as '()'. Other codecs maintain a state. For example,
°5uUTF-16 recognises a BOM (byte-order-mark) character at the beginning
°5uof the input, and remembers thereafter whether to use big-endian or
°5ulittle-endian mode. In this case, the state of the codec would include
°5utwo pieces of information: whether we are at the beginning of the
°5ustream (the BOM only occurs at the beginning), and if not, whether to
°5uuse 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
°5ubetween sequences of bytes and sequences of Unicode characters.
°5u
°5uFor example, UTF-8 is an encoding of Unicode characters into a
°5usequence 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
°5uequivalent <a>TextEncoding</a>.
[textEncodingName] :: TextEncoding -> String

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

-- | Creates a means of encode characters into bytes: the result must not
°5ube shared between several character sequences or simultaneously across
°5uthreads
[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
°5uall 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
°5uoutput at least one encoded ASCII character, but the input contains an
°5uinvalid or unrepresentable sequence
InvalidSequence :: CodingProgress

-- | The Latin1 (ISO8859-1) encoding. This encoding maps bytes directly to
°5uthe first 256 Unicode code points, and is thus not a complete Unicode
°5uencoding. An attempt to write a character greater than '\255' to a
°5u<tt>Handle</tt> using the <a>latin1</a> encoding will result in an
°5uerror.
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
°5usequence 0xEF 0xBB 0xBF). This encoding behaves like <a>utf8</a>,
°5uexcept that on input, the BOM sequence is ignored at the beginning of
°5uthe stream, and on output, the BOM sequence is prepended.
°5u
°5uThe byte-order-mark is strictly unnecessary in UTF-8, but is sometimes
°5uused to identify the encoding of a file.
utf8_bom :: TextEncoding

-- | The UTF-16 Unicode encoding (a byte-order-mark should be used to
°5uindicate 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
°5uindicate 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
°5uundecodable bytes to be round-tripped through it.
°5u
°5uThis <a>TextEncoding</a> is used to decode and encode command line
°5uarguments and environment variables on non-Windows platforms.
°5u
°5uOn Windows, this encoding *should not* be used if possible because the
°5uuse of code pages is deprecated: Strings should be retrieved via the
°5u"wide" W-family of UTF-16 APIs instead
getFileSystemEncoding :: IO TextEncoding

-- | The Unicode encoding of the current locale, but where undecodable
°5ubytes are replaced with their closest visual match. Used for the
°5u<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
°5utaking the code point modulo 256. When decoding, bytes are translated
°5udirectly into the equivalent code point.
°5u
°5uThis encoding never fails in either direction. However, encoding
°5udiscards information, so encode followed by decode is not the
°5uidentity.
char8 :: TextEncoding

-- | Look up the named Unicode encoding. May fail with
°5u
°5u<ul>
°5u<li><tt>isDoesNotExistError</tt> if the encoding is unknown</li>
°5u</ul>
°5u
°5uThe set of known encodings is system-dependent, but includes at least:
°5u
°5u<ul>
°5u<li><pre>UTF-8</pre></li>
°5u<li><tt>UTF-16</tt>, <tt>UTF-16BE</tt>, <tt>UTF-16LE</tt></li>
°5u<li><tt>UTF-32</tt>, <tt>UTF-32BE</tt>, <tt>UTF-32LE</tt></li>
°5u</ul>
°5u
°5uThere is additional notation (borrowed from GNU iconv) for specifying
°5uhow illegal characters are handled:
°5u
°5u<ul>
°5u<li>a suffix of <tt>//IGNORE</tt>, e.g. <tt>UTF-8//IGNORE</tt>, will
°5ucause all illegal sequences on input to be ignored, and on output will
°5udrop all code points that have no representation in the target
°5uencoding.</li>
°5u<li>a suffix of <tt>//TRANSLIT</tt> will choose a replacement
°5ucharacter for illegal sequences or code points.</li>
°5u<li>a suffix of <tt>//ROUNDTRIP</tt> will use a PEP383-style escape
°5umechanism to represent any invalid bytes in the input as Unicode
°5ucodepoints (specifically, as lone surrogates, which are normally
°5uinvalid in UTF-32). Upon output, these special codepoints are detected
°5uand turned back into the corresponding original byte.</li>
°5u</ul>
°5u
°5uIn theory, this mechanism allows arbitrary data to be roundtripped via
°5ua <a>String</a> with no loss of data. In practice, there are two
°5ulimitations to be aware of:
°5u
°5u<ol>
°5u<li>This only stands a chance of working for an encoding which is an
°5uASCII superset, as for security reasons we refuse to escape any bytes
°5usmaller than 128. Many encodings of interest are ASCII supersets (in
°5uparticular, you can assume that the locale encoding is an ASCII
°5usuperset) but many (such as UTF-16) are not.</li>
°5u<li>If the underlying encoding is not itself roundtrippable, this
°5umechanism can fail. Roundtrippable encodings are those which have an
°5uinjective mapping into Unicode. Almost all encodings meet this
°5ucriteria, but some do not. Notably, Shift-JIS (CP932) and Big5 contain
°5useveral different encodings of the same Unicode codepoint.</li>
°5u</ol>
°5u
°5uOn Windows, you can access supported code pages with the prefix
°5u<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
°5ucan be useful for debugging.
°5u
°5uThe implementation uses the call-stack simulation maintained by the
°5uprofiler, so it only works if the program was compiled with
°5u<tt>-prof</tt> and contains suitable SCC annotations (e.g. by using
°5u<tt>-fprof-auto</tt>). Otherwise, the list returned is likely to be
°5uempty 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>
°5uif the current program was not compiled with profiling support). Takes
°5ua dummy argument which can be used to avoid the call to
°5u<tt>getCurrentCCS</tt> being floated out by the simplifier, which
°5uwould 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
°5uis used by the interpreter to run an interpreted computation without
°5uthe 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
°5umessage 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
°5ucan be useful for debugging.
°5u
°5uThe implementation uses the call-stack simulation maintained by the
°5uprofiler, so it only works if the program was compiled with
°5u<tt>-prof</tt> and contains suitable SCC annotations (e.g. by using
°5u<tt>-fprof-auto</tt>). Otherwise, the list returned is likely to be
°5uempty 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
°5ucall-stack at any point in the program.
°5u
°5uA function can request its call-site with the <a>HasCallStack</a>
°5uconstraint. For example, we can define
°5u
°5u<pre>
°5uputStrLnWithCallStack :: HasCallStack =&gt; String -&gt; IO ()
°5u</pre>
°5u
°5uas a variant of <tt>putStrLn</tt> that will get its call-site and
°5uprint it, along with the string given as argument. We can access the
°5ucall-stack inside <tt>putStrLnWithCallStack</tt> with
°5u<a>callStack</a>.
°5u
°5u<pre>
°5uputStrLnWithCallStack :: HasCallStack =&gt; String -&gt; IO ()
°5uputStrLnWithCallStack msg = do
°5u  putStrLn msg
°5u  putStrLn (prettyCallStack callStack)
°5u</pre>
°5u
°5uThus, if we call <tt>putStrLnWithCallStack</tt> we will get a
°5uformatted call-stack alongside our string.
°5u
°5u<pre>
°5u&gt;&gt;&gt; putStrLnWithCallStack "hello"
°5uhello
°5uCallStack (from HasCallStack):
°5u  putStrLnWithCallStack, called at &lt;interactive&gt;:2:1 in interactive:Ghci1
°5u</pre>
°5u
°5uGHC solves <a>HasCallStack</a> constraints in three steps:
°5u
°5u<ol>
°5u<li>If there is a <a>CallStack</a> in scope -- i.e. the enclosing
°5ufunction has a <a>HasCallStack</a> constraint -- GHC will append the
°5unew call-site to the existing <a>CallStack</a>.</li>
°5u<li>If there is no <a>CallStack</a> in scope -- e.g. in the GHCi
°5usession above -- and the enclosing definition does not have an
°5uexplicit type signature, GHC will infer a <a>HasCallStack</a>
°5uconstraint for the enclosing definition (subject to the monomorphism
°5urestriction).</li>
°5u<li>If there is no <a>CallStack</a> in scope and the enclosing
°5udefinition has an explicit type signature, GHC will solve the
°5u<a>HasCallStack</a> constraint for the singleton <a>CallStack</a>
°5ucontaining just the current call-site.</li>
°5u</ol>
°5u
°5u<a>CallStack</a>s do not interact with the RTS and do not require
°5ucompilation with <tt>-prof</tt>. On the other hand, as they are built
°5uup explicitly via the <a>HasCallStack</a> constraints, they will
°5ugenerally not contain as much information as the simulated call-stacks
°5umaintained by the RTS.
°5u
°5uA <a>CallStack</a> is a <tt>[(String, SrcLoc)]</tt>. The
°5u<tt>String</tt> is the name of function that was called, the
°5u<a>SrcLoc</a> is the call-site. The list is ordered with the most
°5urecently called function at the head.
°5u
°5uNOTE: The intrepid user may notice that <a>HasCallStack</a> is just an
°5ualias for an implicit parameter <tt>?callStack :: CallStack</tt>. This
°5uis an implementation detail and <b>should not</b> be considered part
°5uof the <a>CallStack</a> API, we may decide to change the
°5uimplementation in the future.
data CallStack

-- | Request a CallStack.
°5u
°5uNOTE: The implicit parameter <tt>?callStack :: CallStack</tt> is an
°5uimplementation detail and <b>should not</b> be considered part of the
°5u<a>CallStack</a> API, we may decide to change the implementation in
°5uthe future.
type HasCallStack = (?callStack :: CallStack)

-- | Return the current <a>CallStack</a>.
°5u
°5uDoes *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
°5uappended.
°5u
°5u<pre>
°5upushCallStack callSite (freezeCallStack callStack) = freezeCallStack callStack
°5u</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>.
°5u
°5uThe list is ordered by most recent call.
getCallStack :: CallStack -> [([Char], SrcLoc)]

-- | Pop the most recent call-site off the <a>CallStack</a>.
°5u
°5uThis function, like <a>pushCallStack</a>, has no effect on a frozen
°5u<a>CallStack</a>.
popCallStack :: CallStack -> CallStack

-- | Pretty print a <a>CallStack</a>.
prettyCallStack :: CallStack -> String

-- | Push a call-site onto the stack.
°5u
°5uThis function has no effect on a frozen <a>CallStack</a>.
pushCallStack :: ([Char], SrcLoc) -> CallStack -> CallStack

-- | Perform some computation without adding new entries to the
°5u<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>
°5uif the current program was not compiled with profiling support). Takes
°5ua dummy argument which can be used to avoid the call to
°5u<tt>getCurrentCCS</tt> being floated out by the simplifier, which
°5uwould 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
°5uis used by the interpreter to run an interpreted computation without
°5uthe 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
°5u<tt>getArgs</tt>, similar to <tt>argv</tt> in other languages. It
°5ureturns a list of the program's command line arguments, starting with
°5uthe program name, and including those normally eaten by the RTS (+RTS
°5u... -RTS).
getFullArgs :: IO [String]


-- | An <tt><a>MVar</a> t</tt> is mutable location that is either empty or
°5ucontains a value of type <tt>t</tt>. It has two fundamental
°5uoperations: <a>putMVar</a> which fills an <a>MVar</a> if it is empty
°5uand blocks otherwise, and <a>takeMVar</a> which empties an <a>MVar</a>
°5uif it is full and blocks otherwise. They can be used in multiple
°5udifferent ways:
°5u
°5u<ol>
°5u<li>As synchronized mutable variables,</li>
°5u<li>As channels, with <a>takeMVar</a> and <a>putMVar</a> as receive
°5uand send, and</li>
°5u<li>As a binary semaphore <tt><a>MVar</a> ()</tt>, with
°5u<a>takeMVar</a> and <a>putMVar</a> as wait and signal.</li>
°5u</ol>
°5u
°5uThey were introduced in the paper <a>"Concurrent Haskell"</a> by Simon
°5uPeyton Jones, Andrew Gordon and Sigbjorn Finne, though some details of
°5utheir implementation have since then changed (in particular, a put on
°5ua full <a>MVar</a> used to error, but now merely blocks.)
°5u
°5u<h3>Applicability</h3>
°5u
°5u<a>MVar</a>s offer more flexibility than <tt>IORef</tt>s, but less
°5uflexibility than <tt>STM</tt>. They are appropriate for building
°5usynchronization primitives and performing simple interthread
°5ucommunication; however they are very simple and susceptible to race
°5uconditions, deadlocks or uncaught exceptions. Do not use them if you
°5uneed perform larger atomic operations such as reading from multiple
°5uvariables: use <tt>STM</tt> instead.
°5u
°5uIn particular, the "bigger" functions in this module (<a>readMVar</a>,
°5u<a>swapMVar</a>, <a>withMVar</a>, <a>modifyMVar_</a> and
°5u<a>modifyMVar</a>) are simply the composition of a <a>takeMVar</a>
°5ufollowed by a <a>putMVar</a> with exception safety. These only have
°5uatomicity guarantees if all other threads perform a <a>takeMVar</a>
°5ubefore a <a>putMVar</a> as well; otherwise, they may block.
°5u
°5u<h3>Fairness</h3>
°5u
°5uNo thread can be blocked indefinitely on an <a>MVar</a> unless another
°5uthread holds that <a>MVar</a> indefinitely. One usual implementation
°5uof this fairness guarantee is that threads blocked on an <a>MVar</a>
°5uare served in a first-in-first-out fashion, but this is not guaranteed
°5uin the semantics.
°5u
°5u<h3>Gotchas</h3>
°5u
°5uLike many other Haskell data structures, <a>MVar</a>s are lazy. This
°5umeans that if you place an expensive unevaluated thunk inside an
°5u<a>MVar</a>, it will be evaluated by the thread that consumes it, not
°5uthe thread that produced it. Be sure to <a>evaluate</a> values to be
°5uplaced in an <a>MVar</a> to the appropriate normal form, or utilize a
°5ustrict MVar provided by the strict-concurrency package.
°5u
°5u<h3>Ordering</h3>
°5u
°5u<a>MVar</a> operations are always observed to take place in the order
°5uthey are written in the program, regardless of the memory model of the
°5uunderlying machine. This is in contrast to <tt>IORef</tt> operations
°5uwhich may appear out-of-order to another thread in some cases.
°5u
°5u<h3>Example</h3>
°5u
°5uConsider the following concurrent data structure, a skip channel. This
°5uis a channel for an intermittent source of high bandwidth information
°5u(for example, mouse movement events.) Writing to the channel never
°5ublocks, and reading from the channel only returns the most recent
°5uvalue, or blocks if there are no new values. Multiple readers are
°5usupported with a <tt>dupSkipChan</tt> operation.
°5u
°5uA skip channel is a pair of <a>MVar</a>s. The first <a>MVar</a>
°5ucontains the current value, and a list of semaphores that need to be
°5unotified when it changes. The second <a>MVar</a> is a semaphore for
°5uthis particular reader: it is full if there is a value in the channel
°5uthat this reader has not read yet, and empty otherwise.
°5u
°5u<pre>
°5udata SkipChan a = SkipChan (MVar (a, [MVar ()])) (MVar ())
°5u
°5unewSkipChan :: IO (SkipChan a)
°5unewSkipChan = do
°5u    sem &lt;- newEmptyMVar
°5u    main &lt;- newMVar (undefined, [sem])
°5u    return (SkipChan main sem)
°5u
°5uputSkipChan :: SkipChan a -&gt; a -&gt; IO ()
°5uputSkipChan (SkipChan main _) v = do
°5u    (_, sems) &lt;- takeMVar main
°5u    putMVar main (v, [])
°5u    mapM_ (sem -&gt; putMVar sem ()) sems
°5u
°5ugetSkipChan :: SkipChan a -&gt; IO a
°5ugetSkipChan (SkipChan main sem) = do
°5u    takeMVar sem
°5u    (v, sems) &lt;- takeMVar main
°5u    putMVar main (v, sem:sems)
°5u    return v
°5u
°5udupSkipChan :: SkipChan a -&gt; IO (SkipChan a)
°5udupSkipChan (SkipChan main _) = do
°5u    sem &lt;- newEmptyMVar
°5u    (v, sems) &lt;- takeMVar main
°5u    putMVar main (v, sem:sems)
°5u    return (SkipChan main sem)
°5u</pre>
°5u
°5uThis example was adapted from the original Concurrent Haskell paper.
°5uFor more examples of <a>MVar</a>s being used to build higher-level
°5usynchronization 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
°5ufor communication between concurrent threads. It can be thought of as
°5ua 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
°5ucurrently empty, <a>takeMVar</a> will wait until it is full. After a
°5u<a>takeMVar</a>, the <a>MVar</a> is left empty.
°5u
°5uThere are two further important properties of <a>takeMVar</a>:
°5u
°5u<ul>
°5u<li><a>takeMVar</a> is single-wakeup. That is, if there are multiple
°5uthreads blocked in <a>takeMVar</a>, and the <a>MVar</a> becomes full,
°5uonly one thread will be woken up. The runtime guarantees that the
°5uwoken thread completes its <a>takeMVar</a> operation.</li>
°5u<li>When multiple threads are blocked on an <a>MVar</a>, they are
°5uwoken up in FIFO order. This is useful for providing fairness
°5uproperties of abstractions built using <a>MVar</a>s.</li>
°5u</ul>
takeMVar :: MVar a -> IO a

-- | Put a value into an <a>MVar</a>. If the <a>MVar</a> is currently full,
°5u<a>putMVar</a> will wait until it becomes empty.
°5u
°5uThere are two further important properties of <a>putMVar</a>:
°5u
°5u<ul>
°5u<li><a>putMVar</a> is single-wakeup. That is, if there are multiple
°5uthreads blocked in <a>putMVar</a>, and the <a>MVar</a> becomes empty,
°5uonly one thread will be woken up. The runtime guarantees that the
°5uwoken thread completes its <a>putMVar</a> operation.</li>
°5u<li>When multiple threads are blocked on an <a>MVar</a>, they are
°5uwoken up in FIFO order. This is useful for providing fairness
°5uproperties of abstractions built using <a>MVar</a>s.</li>
°5u</ul>
putMVar :: MVar a -> a -> IO ()

-- | Atomically read the contents of an <a>MVar</a>. If the <a>MVar</a> is
°5ucurrently empty, <a>readMVar</a> will wait until its full.
°5u<a>readMVar</a> is guaranteed to receive the next <a>putMVar</a>.
°5u
°5u<a>readMVar</a> is multiple-wakeup, so when multiple readers are
°5ublocked on an <a>MVar</a>, all of them are woken up at the same time.
°5u
°5u<i>Compatibility note:</i> Prior to base 4.7, <a>readMVar</a> was a
°5ucombination of <a>takeMVar</a> and <a>putMVar</a>. This mean that in
°5uthe presence of other threads attempting to <a>putMVar</a>,
°5u<a>readMVar</a> could block. Furthermore, <a>readMVar</a> would not
°5ureceive the next <a>putMVar</a> if there was already a pending thread
°5ublocked on <a>takeMVar</a>. The old behavior can be recovered by
°5uimplementing 'readMVar as follows:
°5u
°5u<pre>
°5ureadMVar :: MVar a -&gt; IO a
°5ureadMVar m =
°5u  mask_ $ do
°5u    a &lt;- takeMVar m
°5u    putMVar m a
°5u    return a
°5u</pre>
readMVar :: MVar a -> IO a

-- | Take a value from an <a>MVar</a>, put a new value into the <a>MVar</a>
°5uand return the value taken. This function is atomic only if there are
°5uno 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>
°5ufunction returns immediately, with <a>Nothing</a> if the <a>MVar</a>
°5uwas empty, or <tt><a>Just</a> a</tt> if the <a>MVar</a> was full with
°5ucontents <tt>a</tt>. After <a>tryTakeMVar</a>, the <a>MVar</a> is left
°5uempty.
tryTakeMVar :: MVar a -> IO (Maybe a)

-- | A non-blocking version of <a>putMVar</a>. The <a>tryPutMVar</a>
°5ufunction attempts to put the value <tt>a</tt> into the <a>MVar</a>,
°5ureturning <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.
°5u
°5uNotice that the boolean value returned is just a snapshot of the state
°5uof the MVar. By the time you get to react on its result, the MVar may
°5uhave been filled (or emptied) - so be extremely careful when using
°5uthis 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
°5ucontents of an <a>MVar</a>. This operation is exception-safe: it will
°5ureplace the original contents of the <a>MVar</a> if an exception is
°5uraised (see <a>Control.Exception</a>). However, it is only atomic if
°5uthere 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
°5uargument is executed with asynchronous exceptions masked.
withMVarMasked :: MVar a -> (a -> IO b) -> IO b

-- | An exception-safe wrapper for modifying the contents of an
°5u<a>MVar</a>. Like <a>withMVar</a>, <a>modifyMVar</a> will replace the
°5uoriginal contents of the <a>MVar</a> if an exception is raised during
°5uthe operation. This function is only atomic if there are no other
°5uproducers 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
°5ureturned (<tt>b</tt>) in addition to the modified value of the
°5u<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
°5uargument 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
°5uargument 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>
°5ufunction returns immediately, with <a>Nothing</a> if the <a>MVar</a>
°5uwas empty, or <tt><a>Just</a> a</tt> if the <a>MVar</a> was full with
°5ucontents <tt>a</tt>.
tryReadMVar :: MVar a -> IO (Maybe a)

-- | Make a <a>Weak</a> pointer to an <a>MVar</a>, using the second
°5uargument 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
°5uonly).
°5u
°5uThere is no guarantee that the thread will be rescheduled promptly
°5uwhen the delay has expired, but the thread will never continue to run
°5u<i>earlier</i> than specified.
threadDelay :: Int -> IO ()

-- | Set the value of returned TVar to True after a given number of
°5umicroseconds. 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
°5ufile descriptor (GHC only).
°5u
°5uThis will throw an <tt>IOError</tt> if the file descriptor was closed
°5uwhile this thread was blocked. To safely close a file descriptor that
°5uhas 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
°5udescriptor (GHC only).
°5u
°5uThis will throw an <tt>IOError</tt> if the file descriptor was closed
°5uwhile this thread was blocked. To safely close a file descriptor that
°5uhas 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
°5ufile descriptor. The second returned value is an IO action that can be
°5uused 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
°5uwritten to a file descriptor. The second returned value is an IO
°5uaction 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
°5uare using <a>threadWaitRead</a> or <a>threadWaitWrite</a> to perform
°5ublocking I/O, you <i>must</i> use this function to close file
°5udescriptors, or blocked threads may not be woken.
°5u
°5uAny threads that are blocked on the file descriptor via
°5u<a>threadWaitRead</a> or <a>threadWaitWrite</a> will be unblocked by
°5uhaving 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
°5uchannel.
stdin :: Handle

-- | A handle managing output to the Haskell program's standard output
°5uchannel.
stdout :: Handle

-- | A handle managing output to the Haskell program's standard error
°5uchannel.
stderr :: Handle

-- | Computation <a>openFile</a> <tt>file mode</tt> allocates and returns a
°5unew, open handle to manage the file <tt>file</tt>. It manages input if
°5u<tt>mode</tt> is <a>ReadMode</a>, output if <tt>mode</tt> is
°5u<a>WriteMode</a> or <a>AppendMode</a>, and both input and output if
°5umode is <a>ReadWriteMode</a>.
°5u
°5uIf the file does not exist and it is opened for output, it should be
°5ucreated as a new file. If <tt>mode</tt> is <a>WriteMode</a> and the
°5ufile already exists, then it should be truncated to zero length. Some
°5uoperating systems delete empty files, so there is no guarantee that
°5uthe file will exist following an <a>openFile</a> with <tt>mode</tt>
°5u<a>WriteMode</a> unless it is subsequently written to successfully.
°5uThe handle is positioned at the end of the file if <tt>mode</tt> is
°5u<a>AppendMode</a>, and otherwise at the beginning (in which case its
°5uinternal position is 0). The initial buffer mode is
°5uimplementation-dependent.
°5u
°5uThis operation may fail with:
°5u
°5u<ul>
°5u<li><tt>isAlreadyInUseError</tt> if the file is already open and
°5ucannot be reopened;</li>
°5u<li><tt>isDoesNotExistError</tt> if the file does not exist; or</li>
°5u<li><tt>isPermissionError</tt> if the user does not have permission to
°5uopen the file.</li>
°5u</ul>
°5u
°5uNote: if you will be working with files containing binary data, you'll
°5uwant to be using <a>openBinaryFile</a>.
openFile :: FilePath -> IOMode -> IO Handle

-- | Like <a>openFile</a>, but open the file in binary mode. On Windows,
°5ureading a file in text mode (which is the default) will translate CRLF
°5uto LF, and writing will translate LF to CRLF. This is usually what you
°5uwant with text files. With binary files this is undesirable; also, as
°5uusual under Microsoft operating systems, text mode treats control-Z as
°5uEOF. Binary mode turns off all special treatment of end-of-line and
°5uend-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.
°5uThis can be useful for opening a FIFO for writing: if we open in
°5unon-blocking mode then the open will fail if there are no readers,
°5uwhereas 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
°5uvarious external libraries to make Handles.
°5u
°5uMakes a binary Handle. This is for historical reasons; it should
°5uprobably be a text Handle with the default encoding and newline
°5utranslation 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
°5uan 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
°5usupport <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
°5ucontents of the underlying file in appropriate mode. If the file is
°5ualready locked in incompatible mode, this function blocks until the
°5ulock is established. The lock is automatically released upon closing a
°5u<a>Handle</a>.
°5u
°5uThings to be aware of:
°5u
°5u1) This function may block inside a C call. If it does, in order to be
°5uable to interrupt it with asynchronous exceptions and/or for other
°5uthreads to continue working, you MUST use threaded version of the
°5uruntime system.
°5u
°5u2) The implementation uses <tt>LockFileEx</tt> on Windows and
°5u<tt>flock</tt> otherwise, hence all of their caveats also apply here.
°5u
°5u3) On non-Windows plaftorms that don't support <tt>flock</tt> (e.g.
°5uSolaris) this function throws <tt>FileLockingNotImplemented</tt>. We
°5udeliberately choose to not provide fcntl based locking instead because
°5uof 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
°5ufiles, represented by values of type <tt>Handle</tt>. Each value of
°5uthis type is a <i>handle</i>: a record used by the Haskell run-time
°5usystem to <i>manage</i> I/O with file system objects. A handle has at
°5uleast the following properties:
°5u
°5u<ul>
°5u<li>whether it manages input or output or both;</li>
°5u<li>whether it is <i>open</i>, <i>closed</i> or
°5u<i>semi-closed</i>;</li>
°5u<li>whether the object is seekable;</li>
°5u<li>whether buffering is disabled, or enabled on a line or block
°5ubasis;</li>
°5u<li>a buffer (whose length may be zero).</li>
°5u</ul>
°5u
°5uMost handles will also have a current I/O position indicating where
°5uthe next input or output operation will occur. A handle is
°5u<i>readable</i> if it manages only input or both input and output;
°5ulikewise, it is <i>writable</i> if it manages only output or both
°5uinput and output. A handle is <i>open</i> when first allocated. Once
°5uit is closed it can no longer be used for either input or output,
°5uthough an implementation cannot re-use its storage while references
°5uremain to it. Handles are in the <a>Show</a> and <a>Eq</a> classes.
°5uThe string produced by showing a handle is system dependent; it should
°5uinclude enough information to identify the handle for debugging. A
°5uhandle is equal according to <a>==</a> only to itself; no attempt is
°5umade to compare the internal state of different handles for equality.
data Handle

-- | Three kinds of buffering are supported: line-buffering,
°5ublock-buffering or no-buffering. These modes have the following
°5ueffects. For output, items are written out, or <i>flushed</i>, from
°5uthe internal buffer according to the buffer mode:
°5u
°5u<ul>
°5u<li><i>line-buffering</i>: the entire output buffer is flushed
°5uwhenever a newline is output, the buffer overflows, a <a>hFlush</a> is
°5uissued, or the handle is closed.</li>
°5u<li><i>block-buffering</i>: the entire buffer is written out whenever
°5uit overflows, a <a>hFlush</a> is issued, or the handle is closed.</li>
°5u<li><i>no-buffering</i>: output is written immediately, and never
°5ustored in the buffer.</li>
°5u</ul>
°5u
°5uAn implementation is free to flush the buffer more frequently, but not
°5uless frequently, than specified above. The output buffer is emptied as
°5usoon as it has been written out.
°5u
°5uSimilarly, input occurs according to the buffer mode for the handle:
°5u
°5u<ul>
°5u<li><i>line-buffering</i>: when the buffer for the handle is not
°5uempty, the next item is obtained from the buffer; otherwise, when the
°5ubuffer is empty, characters up to and including the next newline
°5ucharacter are read into the buffer. No characters are available until
°5uthe newline character is available or the buffer is full.</li>
°5u<li><i>block-buffering</i>: when the buffer for the handle becomes
°5uempty, the next block of data is read into the buffer.</li>
°5u<li><i>no-buffering</i>: the next input item is read and returned. The
°5u<a>hLookAhead</a> operation implies that even a no-buffered handle may
°5urequire a one-character buffer.</li>
°5u</ul>
°5u
°5uThe default buffering mode when a handle is opened is
°5uimplementation-dependent and may depend on the file system object
°5uwhich is attached to that handle. For most implementations, physical
°5ufiles will normally be block-buffered and terminals will normally be
°5uline-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
°5uis <tt>n</tt> items if the argument is <a>Just</a> <tt>n</tt> and is
°5uotherwise 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
°5utwo independent buffers, one for reading and one for writing. Used for
°5ufull-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,
°5u<a>hFileSize</a> <tt>hdl</tt> returns the size of that file in 8-bit
°5ubytes.
hFileSize :: Handle -> IO Integer

-- | <a>hSetFileSize</a> <tt>hdl</tt> <tt>size</tt> truncates the physical
°5ufile 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
°5u<a>True</a> if no further input can be taken from <tt>hdl</tt> or for
°5ua physical file, if the current I/O position is equal to the length of
°5uthe file. Otherwise, it returns <a>False</a>.
°5u
°5uNOTE: <a>hIsEOF</a> may block, because it has to attempt to read from
°5uthe 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
°5uthat it works only on <a>stdin</a>.
isEOF :: IO Bool

-- | Computation <a>hLookAhead</a> returns the next character from the
°5uhandle without removing it from the input buffer, blocking until a
°5ucharacter is available.
°5u
°5uThis operation may fail with:
°5u
°5u<ul>
°5u<li><tt>isEOFError</tt> if the end of file has been reached.</li>
°5u</ul>
hLookAhead :: Handle -> IO Char

-- | Computation <a>hSetBuffering</a> <tt>hdl mode</tt> sets the mode of
°5ubuffering for handle <tt>hdl</tt> on subsequent reads and writes.
°5u
°5uIf the buffer mode is changed from <a>BlockBuffering</a> or
°5u<a>LineBuffering</a> to <a>NoBuffering</a>, then
°5u
°5u<ul>
°5u<li>if <tt>hdl</tt> is writable, the buffer is flushed as for
°5u<a>hFlush</a>;</li>
°5u<li>if <tt>hdl</tt> is not writable, the contents of the buffer is
°5udiscarded.</li>
°5u</ul>
°5u
°5uThis operation may fail with:
°5u
°5u<ul>
°5u<li><tt>isPermissionError</tt> if the handle has already been used for
°5ureading or writing and the implementation does not allow the buffering
°5umode to be changed.</li>
°5u</ul>
hSetBuffering :: Handle -> BufferMode -> IO ()

-- | Select binary mode (<a>True</a>) or text mode (<a>False</a>) on a open
°5uhandle. (See also <a>openBinaryFile</a>.)
°5u
°5uThis has the same effect as calling <a>hSetEncoding</a> with
°5u<a>char8</a>, together with <a>hSetNewlineMode</a> with
°5u<a>noNewlineTranslation</a>.
hSetBinaryMode :: Handle -> Bool -> IO ()

-- | The action <a>hSetEncoding</a> <tt>hdl</tt> <tt>encoding</tt> changes
°5uthe text encoding for the handle <tt>hdl</tt> to <tt>encoding</tt>.
°5uThe default encoding when a <a>Handle</a> is created is
°5u<tt>localeEncoding</tt>, namely the default encoding for the current
°5ulocale.
°5u
°5uTo create a <a>Handle</a> with no encoding at all, use
°5u<a>openBinaryFile</a>. To stop further encoding or decoding on an
°5uexisting <a>Handle</a>, use <a>hSetBinaryMode</a>.
°5u
°5u<a>hSetEncoding</a> may need to flush buffered data in order to change
°5uthe encoding.
hSetEncoding :: Handle -> TextEncoding -> IO ()

-- | Return the current <a>TextEncoding</a> for the specified
°5u<a>Handle</a>, or <a>Nothing</a> if the <a>Handle</a> is in binary
°5umode.
°5u
°5uNote that the <a>TextEncoding</a> remembers nothing about the state of
°5uthe encoder/decoder in use on this <a>Handle</a>. For example, if the
°5uencoding in use is UTF-16, then using <a>hGetEncoding</a> and
°5u<a>hSetEncoding</a> to save and restore the encoding may result in an
°5uextra 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
°5uoutput in handle <tt>hdl</tt> to be sent immediately to the operating
°5usystem.
°5u
°5uThis operation may fail with:
°5u
°5u<ul>
°5u<li><tt>isFullError</tt> if the device is full;</li>
°5u<li><tt>isPermissionError</tt> if a system resource limit would be
°5uexceeded. It is unspecified whether the characters in the buffer are
°5udiscarded or retained under these circumstances.</li>
°5u</ul>
hFlush :: Handle -> IO ()

-- | The action <a>hFlushAll</a> <tt>hdl</tt> flushes all buffered data in
°5u<tt>hdl</tt>, including any buffered read data. Buffered read data is
°5uflushed by seeking the file position back to the point before the
°5ubufferred data was read, and hence only works if <tt>hdl</tt> is
°5useekable (see <a>hIsSeekable</a>).
°5u
°5uThis operation may fail with:
°5u
°5u<ul>
°5u<li><tt>isFullError</tt> if the device is full;</li>
°5u<li><tt>isPermissionError</tt> if a system resource limit would be
°5uexceeded. It is unspecified whether the characters in the buffer are
°5udiscarded or retained under these circumstances;</li>
°5u<li><tt>isIllegalOperation</tt> if <tt>hdl</tt> has buffered read
°5udata, and is not seekable.</li>
°5u</ul>
hFlushAll :: Handle -> IO ()

-- | Returns a duplicate of the original handle, with its own buffer. The
°5utwo Handles will share a file pointer, however. The original handle's
°5ubuffer is flushed, including discarding any input data, before the
°5uhandle is duplicated.
hDuplicate :: Handle -> IO Handle

-- | Makes the second handle a duplicate of the first handle. The second
°5uhandle will be closed first, if it is not already.
°5u
°5uThis can be used to retarget the standard Handles, for example:
°5u
°5u<pre>
°5udo h &lt;- openFile "mystdout" WriteMode
°5u   hDuplicateTo h stdout
°5u</pre>
hDuplicateTo :: Handle -> Handle -> IO ()

-- | Computation <a>hClose</a> <tt>hdl</tt> makes handle <tt>hdl</tt>
°5uclosed. Before the computation finishes, if <tt>hdl</tt> is writable
°5uits buffer is flushed as for <a>hFlush</a>. Performing <a>hClose</a>
°5uon a handle that has already been closed has no effect; doing so is
°5unot an error. All other operations on a closed handle will fail. If
°5u<a>hClose</a> fails for any reason, any further operations (apart from
°5u<a>hClose</a>) on the handle will still fail as if <tt>hdl</tt> had
°5ubeen 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
°5ucontents of the underlying file in appropriate mode. If the file is
°5ualready locked in incompatible mode, this function blocks until the
°5ulock is established. The lock is automatically released upon closing a
°5u<a>Handle</a>.
°5u
°5uThings to be aware of:
°5u
°5u1) This function may block inside a C call. If it does, in order to be
°5uable to interrupt it with asynchronous exceptions and/or for other
°5uthreads to continue working, you MUST use threaded version of the
°5uruntime system.
°5u
°5u2) The implementation uses <tt>LockFileEx</tt> on Windows and
°5u<tt>flock</tt> otherwise, hence all of their caveats also apply here.
°5u
°5u3) On non-Windows plaftorms that don't support <tt>flock</tt> (e.g.
°5uSolaris) this function throws <tt>FileLockingNotImplemented</tt>. We
°5udeliberately choose to not provide fcntl based locking instead because
°5uof 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
°5uposition of <tt>hdl</tt> as a value of the abstract type
°5u<a>HandlePosn</a>.
hGetPosn :: Handle -> IO HandlePosn

-- | If a call to <a>hGetPosn</a> <tt>hdl</tt> returns a position
°5u<tt>p</tt>, then computation <a>hSetPosn</a> <tt>p</tt> sets the
°5uposition of <tt>hdl</tt> to the position it held at the time of the
°5ucall to <a>hGetPosn</a>.
°5u
°5uThis operation may fail with:
°5u
°5u<ul>
°5u<li><tt>isPermissionError</tt> if a system resource limit would be
°5uexceeded.</li>
°5u</ul>
hSetPosn :: HandlePosn -> IO ()

-- | A mode that determines the effect of <tt>hSeek</tt> <tt>hdl mode
°5ui</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
°5ucurrent position.
RelativeSeek :: SeekMode

-- | the position of <tt>hdl</tt> is set to offset <tt>i</tt> from the end
°5uof the file.
SeekFromEnd :: SeekMode

-- | Computation <a>hSeek</a> <tt>hdl mode i</tt> sets the position of
°5uhandle <tt>hdl</tt> depending on <tt>mode</tt>. The offset <tt>i</tt>
°5uis given in terms of 8-bit bytes.
°5u
°5uIf <tt>hdl</tt> is block- or line-buffered, then seeking to a position
°5uwhich is not in the current buffer will first cause any items in the
°5uoutput buffer to be written to the device, and then cause the input
°5ubuffer to be discarded. Some handles may not be seekable (see
°5u<a>hIsSeekable</a>), or only support a subset of the possible
°5upositioning operations (for instance, it may only be possible to seek
°5uto the end of a tape, or to a positive offset from the beginning or
°5ucurrent position). It is not possible to set a negative I/O position,
°5uor for a physical file, an I/O position beyond the current
°5uend-of-file.
°5u
°5uThis operation may fail with:
°5u
°5u<ul>
°5u<li><tt>isIllegalOperationError</tt> if the Handle is not seekable, or
°5udoes not support the requested seek mode.</li>
°5u<li><tt>isPermissionError</tt> if a system resource limit would be
°5uexceeded.</li>
°5u</ul>
hSeek :: Handle -> SeekMode -> Integer -> IO ()

-- | Computation <a>hTell</a> <tt>hdl</tt> returns the current position of
°5uthe handle <tt>hdl</tt>, as the number of bytes from the beginning of
°5uthe file. The value returned may be subsequently passed to
°5u<a>hSeek</a> to reposition the handle to the current position.
°5u
°5uThis operation may fail with:
°5u
°5u<ul>
°5u<li><tt>isIllegalOperationError</tt> if the Handle is not
°5useekable.</li>
°5u</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
°5ubuffering 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
°5ubuffered 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
°5uinternal Strings and the external file or stream. Haskell Strings are
°5uassumed to represent newlines with the '\n' character; the newline
°5umode specifies how to translate '\n' on output, and what to translate
°5uinto '\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>
°5uon Unix systems, <a>CRLF</a> on Windows.
nativeNewline :: Newline

-- | Do no newline translation at all.
°5u
°5u<pre>
°5unoNewlineTranslation  = NewlineMode { inputNL  = LF, outputNL = LF }
°5u</pre>
noNewlineTranslation :: NewlineMode

-- | Map '\r\n' into '\n' on input, and '\n' to the native newline
°5urepresetnation on output. This mode can be used on any platform, and
°5uworks with text files using any newline convention. The downside is
°5uthat <tt>readFile &gt;&gt;= writeFile</tt> might yield a different
°5ufile.
°5u
°5u<pre>
°5uuniversalNewlineMode  = NewlineMode { inputNL  = CRLF,
°5u                                      outputNL = nativeNewline }
°5u</pre>
universalNewlineMode :: NewlineMode

-- | Use the native newline representation on both input and output
°5u
°5u<pre>
°5unativeNewlineMode  = NewlineMode { inputNL  = nativeNewline
°5u                                   outputNL = nativeNewline }
°5u</pre>
nativeNewlineMode :: NewlineMode

-- | <a>hShow</a> is in the <a>IO</a> monad, and gives more comprehensive
°5uoutput 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
°5uavailable on handle <tt>hdl</tt>. It returns <a>True</a> as soon as
°5uinput is available on <tt>hdl</tt>, or <a>False</a> if no input is
°5uavailable within <tt>t</tt> milliseconds. Note that
°5u<a>hWaitForInput</a> waits until one or more full <i>characters</i>
°5uare available, which means that it needs to do decoding, and hence may
°5ufail with a decoding error.
°5u
°5uIf <tt>t</tt> is less than zero, then <tt>hWaitForInput</tt> waits
°5uindefinitely.
°5u
°5uThis operation may fail with:
°5u
°5u<ul>
°5u<li><a>isEOFError</a> if the end of file has been reached.</li>
°5u<li>a decoding error, if the input begins with an invalid byte
°5usequence in this Handle's encoding.</li>
°5u</ul>
°5u
°5uNOTE for GHC users: unless you use the <tt>-threaded</tt> flag,
°5u<tt>hWaitForInput hdl t</tt> where <tt>t &gt;= 0</tt> will block all
°5uother Haskell threads for the duration of the call. It behaves like a
°5u<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
°5ufile or channel managed by <tt>hdl</tt>, blocking until a character is
°5uavailable.
°5u
°5uThis operation may fail with:
°5u
°5u<ul>
°5u<li><a>isEOFError</a> if the end of file has been reached.</li>
°5u</ul>
hGetChar :: Handle -> IO Char

-- | Computation <a>hGetLine</a> <tt>hdl</tt> reads a line from the file or
°5uchannel managed by <tt>hdl</tt>.
°5u
°5uThis operation may fail with:
°5u
°5u<ul>
°5u<li><a>isEOFError</a> if the end of file is encountered when reading
°5uthe <i>first</i> character of the line.</li>
°5u</ul>
°5u
°5uIf <a>hGetLine</a> encounters end-of-file at any other point while
°5ureading in a line, it is treated as a line terminator and the
°5u(partial) line is returned.
hGetLine :: Handle -> IO String

-- | Computation <a>hGetContents</a> <tt>hdl</tt> returns the list of
°5ucharacters corresponding to the unread portion of the channel or file
°5umanaged by <tt>hdl</tt>, which is put into an intermediate state,
°5u<i>semi-closed</i>. In this state, <tt>hdl</tt> is effectively closed,
°5ubut items are read from <tt>hdl</tt> on demand and accumulated in a
°5uspecial list returned by <a>hGetContents</a> <tt>hdl</tt>.
°5u
°5uAny operation that fails because a handle is closed, also fails if a
°5uhandle is semi-closed. The only exception is <tt>hClose</tt>. A
°5usemi-closed handle becomes closed:
°5u
°5u<ul>
°5u<li>if <tt>hClose</tt> is applied to it;</li>
°5u<li>if an I/O error occurs when reading an item from the handle;</li>
°5u<li>or once the entire contents of the handle has been read.</li>
°5u</ul>
°5u
°5uOnce a semi-closed handle becomes closed, the contents of the
°5uassociated list becomes fixed. The contents of this final list is only
°5upartially specified: it will contain at least all the items of the
°5ustream that were evaluated prior to the handle becoming closed.
°5u
°5uAny I/O errors encountered while a handle is semi-closed are simply
°5udiscarded.
°5u
°5uThis operation may fail with:
°5u
°5u<ul>
°5u<li><a>isEOFError</a> if the end of file has been reached.</li>
°5u</ul>
hGetContents :: Handle -> IO String

-- | Computation <a>hPutChar</a> <tt>hdl ch</tt> writes the character
°5u<tt>ch</tt> to the file or channel managed by <tt>hdl</tt>. Characters
°5umay be buffered if buffering is enabled for <tt>hdl</tt>.
°5u
°5uThis operation may fail with:
°5u
°5u<ul>
°5u<li><a>isFullError</a> if the device is full; or</li>
°5u<li><a>isPermissionError</a> if another system resource limit would be
°5uexceeded.</li>
°5u</ul>
hPutChar :: Handle -> Char -> IO ()

-- | Computation <a>hPutStr</a> <tt>hdl s</tt> writes the string <tt>s</tt>
°5uto the file or channel managed by <tt>hdl</tt>.
°5u
°5uThis operation may fail with:
°5u
°5u<ul>
°5u<li><a>isFullError</a> if the device is full; or</li>
°5u<li><a>isPermissionError</a> if another system resource limit would be
°5uexceeded.</li>
°5u</ul>
hPutStr :: Handle -> String -> IO ()

-- | <a>hGetBuf</a> <tt>hdl buf count</tt> reads data from the handle
°5u<tt>hdl</tt> into the buffer <tt>buf</tt> until either EOF is reached
°5uor <tt>count</tt> 8-bit bytes have been read. It returns the number of
°5ubytes actually read. This may be zero if EOF was reached before any
°5udata was read (or if <tt>count</tt> is zero).
°5u
°5u<a>hGetBuf</a> never raises an EOF exception, instead it returns a
°5uvalue smaller than <tt>count</tt>.
°5u
°5uIf the handle is a pipe or socket, and the writing end is closed,
°5u<a>hGetBuf</a> will behave as if EOF was reached.
°5u
°5u<a>hGetBuf</a> ignores the prevailing <tt>TextEncoding</tt> and
°5u<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
°5uhandle <tt>hdl</tt> into the buffer <tt>buf</tt> until either EOF is
°5ureached, or <tt>count</tt> 8-bit bytes have been read, or there is no
°5umore data available to read immediately.
°5u
°5u<a>hGetBufNonBlocking</a> is identical to <a>hGetBuf</a>, except that
°5uit will never block waiting for data to become available, instead it
°5ureturns only whatever data is available. To wait for data to arrive
°5ubefore calling <a>hGetBufNonBlocking</a>, use <a>hWaitForInput</a>.
°5u
°5uIf the handle is a pipe or socket, and the writing end is closed,
°5u<a>hGetBufNonBlocking</a> will behave as if EOF was reached.
°5u
°5u<a>hGetBufNonBlocking</a> ignores the prevailing <tt>TextEncoding</tt>
°5uand <a>NewlineMode</a> on the <a>Handle</a>, and reads bytes directly.
°5u
°5uNOTE: on Windows, this function does not work correctly; it behaves
°5uidentically 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
°5ubytes from the buffer <tt>buf</tt> to the handle <tt>hdl</tt>. It
°5ureturns ().
°5u
°5u<a>hPutBuf</a> ignores any text encoding that applies to the
°5u<a>Handle</a>, writing the bytes directly to the underlying file or
°5udevice.
°5u
°5u<a>hPutBuf</a> ignores the prevailing <tt>TextEncoding</tt> and
°5u<a>NewlineMode</a> on the <a>Handle</a>, and writes bytes directly.
°5u
°5uThis operation may fail with:
°5u
°5u<ul>
°5u<li><a>ResourceVanished</a> if the handle is a pipe or socket, and the
°5ureading end is closed. (If this is a POSIX system, and the program has
°5unot asked to ignore SIGPIPE, then a SIGPIPE may be delivered instead,
°5uwhose default action is to terminate the program).</li>
°5u</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
°5uperformed, does some I/O before returning a value of type <tt>a</tt>.
°5u
°5uThere is really only one way to "perform" an I/O action: bind it to
°5u<tt>Main.main</tt> in your program. When your program is run, the I/O
°5uwill be performed. It isn't possible to perform I/O from an arbitrary
°5ufunction, unless that function is itself in the <a>IO</a> monad and
°5ucalled at some point, directly or indirectly, from <tt>Main.main</tt>.
°5u
°5u<a>IO</a> is a monad, so <a>IO</a> actions can be combined using
°5ueither the do-notation or the <tt>&gt;&gt;</tt> and <tt>&gt;&gt;=</tt>
°5uoperations from the <tt>Monad</tt> class.
data IO a

-- | The implementation of <tt>mfix</tt> for <a>IO</a>. If the function
°5upassed to <a>fixIO</a> inspects its argument, the resulting action
°5uwill throw <a>FixIOException</a>.
fixIO :: (a -> IO a) -> IO a

-- | File and directory names are values of type <a>String</a>, whose
°5uprecise meaning is operating system dependent. Files can be opened,
°5uyielding a handle which can then be used to operate on the contents of
°5uthat file.
type FilePath = String

-- | Haskell defines operations to read and write characters from and to
°5ufiles, represented by values of type <tt>Handle</tt>. Each value of
°5uthis type is a <i>handle</i>: a record used by the Haskell run-time
°5usystem to <i>manage</i> I/O with file system objects. A handle has at
°5uleast the following properties:
°5u
°5u<ul>
°5u<li>whether it manages input or output or both;</li>
°5u<li>whether it is <i>open</i>, <i>closed</i> or
°5u<i>semi-closed</i>;</li>
°5u<li>whether the object is seekable;</li>
°5u<li>whether buffering is disabled, or enabled on a line or block
°5ubasis;</li>
°5u<li>a buffer (whose length may be zero).</li>
°5u</ul>
°5u
°5uMost handles will also have a current I/O position indicating where
°5uthe next input or output operation will occur. A handle is
°5u<i>readable</i> if it manages only input or both input and output;
°5ulikewise, it is <i>writable</i> if it manages only output or both
°5uinput and output. A handle is <i>open</i> when first allocated. Once
°5uit is closed it can no longer be used for either input or output,
°5uthough an implementation cannot re-use its storage while references
°5uremain to it. Handles are in the <a>Show</a> and <a>Eq</a> classes.
°5uThe string produced by showing a handle is system dependent; it should
°5uinclude enough information to identify the handle for debugging. A
°5uhandle is equal according to <a>==</a> only to itself; no attempt is
°5umade to compare the internal state of different handles for equality.
data Handle

-- | A handle managing input from the Haskell program's standard input
°5uchannel.
stdin :: Handle

-- | A handle managing output to the Haskell program's standard output
°5uchannel.
stdout :: Handle

-- | A handle managing output to the Haskell program's standard error
°5uchannel.
stderr :: Handle

-- | <tt><a>withFile</a> name mode act</tt> opens a file using
°5u<a>openFile</a> and passes the resulting handle to the computation
°5u<tt>act</tt>. The handle will be closed on exit from <a>withFile</a>,
°5uwhether by normal termination or by raising an exception. If closing
°5uthe handle raises an exception, then this exception will be raised by
°5u<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
°5unew, open handle to manage the file <tt>file</tt>. It manages input if
°5u<tt>mode</tt> is <a>ReadMode</a>, output if <tt>mode</tt> is
°5u<a>WriteMode</a> or <a>AppendMode</a>, and both input and output if
°5umode is <a>ReadWriteMode</a>.
°5u
°5uIf the file does not exist and it is opened for output, it should be
°5ucreated as a new file. If <tt>mode</tt> is <a>WriteMode</a> and the
°5ufile already exists, then it should be truncated to zero length. Some
°5uoperating systems delete empty files, so there is no guarantee that
°5uthe file will exist following an <a>openFile</a> with <tt>mode</tt>
°5u<a>WriteMode</a> unless it is subsequently written to successfully.
°5uThe handle is positioned at the end of the file if <tt>mode</tt> is
°5u<a>AppendMode</a>, and otherwise at the beginning (in which case its
°5uinternal position is 0). The initial buffer mode is
°5uimplementation-dependent.
°5u
°5uThis operation may fail with:
°5u
°5u<ul>
°5u<li><tt>isAlreadyInUseError</tt> if the file is already open and
°5ucannot be reopened;</li>
°5u<li><tt>isDoesNotExistError</tt> if the file does not exist; or</li>
°5u<li><tt>isPermissionError</tt> if the user does not have permission to
°5uopen the file.</li>
°5u</ul>
°5u
°5uNote: if you will be working with files containing binary data, you'll
°5uwant 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>
°5uclosed. Before the computation finishes, if <tt>hdl</tt> is writable
°5uits buffer is flushed as for <a>hFlush</a>. Performing <a>hClose</a>
°5uon a handle that has already been closed has no effect; doing so is
°5unot an error. All other operations on a closed handle will fail. If
°5u<a>hClose</a> fails for any reason, any further operations (apart from
°5u<a>hClose</a>) on the handle will still fail as if <tt>hdl</tt> had
°5ubeen successfully closed.
hClose :: Handle -> IO ()

-- | The <a>readFile</a> function reads a file and returns the contents of
°5uthe file as a string. The file is read lazily, on demand, as with
°5u<a>getContents</a>.
readFile :: FilePath -> IO String

-- | The computation <a>writeFile</a> <tt>file str</tt> function writes the
°5ustring <tt>str</tt>, to the file <tt>file</tt>.
writeFile :: FilePath -> String -> IO ()

-- | The computation <a>appendFile</a> <tt>file str</tt> function appends
°5uthe string <tt>str</tt>, to the file <tt>file</tt>.
°5u
°5uNote that <a>writeFile</a> and <a>appendFile</a> write a literal
°5ustring to a file. To write a value of any printable type, as with
°5u<a>print</a>, use the <a>show</a> function to convert the value to a
°5ustring first.
°5u
°5u<pre>
°5umain = appendFile "squares" (show [(x,x*x) | x &lt;- [0,0.1..2]])
°5u</pre>
appendFile :: FilePath -> String -> IO ()

-- | For a handle <tt>hdl</tt> which attached to a physical file,
°5u<a>hFileSize</a> <tt>hdl</tt> returns the size of that file in 8-bit
°5ubytes.
hFileSize :: Handle -> IO Integer

-- | <a>hSetFileSize</a> <tt>hdl</tt> <tt>size</tt> truncates the physical
°5ufile 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
°5u<a>True</a> if no further input can be taken from <tt>hdl</tt> or for
°5ua physical file, if the current I/O position is equal to the length of
°5uthe file. Otherwise, it returns <a>False</a>.
°5u
°5uNOTE: <a>hIsEOF</a> may block, because it has to attempt to read from
°5uthe 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
°5uthat it works only on <a>stdin</a>.
isEOF :: IO Bool

-- | Three kinds of buffering are supported: line-buffering,
°5ublock-buffering or no-buffering. These modes have the following
°5ueffects. For output, items are written out, or <i>flushed</i>, from
°5uthe internal buffer according to the buffer mode:
°5u
°5u<ul>
°5u<li><i>line-buffering</i>: the entire output buffer is flushed
°5uwhenever a newline is output, the buffer overflows, a <a>hFlush</a> is
°5uissued, or the handle is closed.</li>
°5u<li><i>block-buffering</i>: the entire buffer is written out whenever
°5uit overflows, a <a>hFlush</a> is issued, or the handle is closed.</li>
°5u<li><i>no-buffering</i>: output is written immediately, and never
°5ustored in the buffer.</li>
°5u</ul>
°5u
°5uAn implementation is free to flush the buffer more frequently, but not
°5uless frequently, than specified above. The output buffer is emptied as
°5usoon as it has been written out.
°5u
°5uSimilarly, input occurs according to the buffer mode for the handle:
°5u
°5u<ul>
°5u<li><i>line-buffering</i>: when the buffer for the handle is not
°5uempty, the next item is obtained from the buffer; otherwise, when the
°5ubuffer is empty, characters up to and including the next newline
°5ucharacter are read into the buffer. No characters are available until
°5uthe newline character is available or the buffer is full.</li>
°5u<li><i>block-buffering</i>: when the buffer for the handle becomes
°5uempty, the next block of data is read into the buffer.</li>
°5u<li><i>no-buffering</i>: the next input item is read and returned. The
°5u<a>hLookAhead</a> operation implies that even a no-buffered handle may
°5urequire a one-character buffer.</li>
°5u</ul>
°5u
°5uThe default buffering mode when a handle is opened is
°5uimplementation-dependent and may depend on the file system object
°5uwhich is attached to that handle. For most implementations, physical
°5ufiles will normally be block-buffered and terminals will normally be
°5uline-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
°5uis <tt>n</tt> items if the argument is <a>Just</a> <tt>n</tt> and is
°5uotherwise implementation-dependent.
BlockBuffering :: (Maybe Int) -> BufferMode

-- | Computation <a>hSetBuffering</a> <tt>hdl mode</tt> sets the mode of
°5ubuffering for handle <tt>hdl</tt> on subsequent reads and writes.
°5u
°5uIf the buffer mode is changed from <a>BlockBuffering</a> or
°5u<a>LineBuffering</a> to <a>NoBuffering</a>, then
°5u
°5u<ul>
°5u<li>if <tt>hdl</tt> is writable, the buffer is flushed as for
°5u<a>hFlush</a>;</li>
°5u<li>if <tt>hdl</tt> is not writable, the contents of the buffer is
°5udiscarded.</li>
°5u</ul>
°5u
°5uThis operation may fail with:
°5u
°5u<ul>
°5u<li><tt>isPermissionError</tt> if the handle has already been used for
°5ureading or writing and the implementation does not allow the buffering
°5umode to be changed.</li>
°5u</ul>
hSetBuffering :: Handle -> BufferMode -> IO ()

-- | Computation <a>hGetBuffering</a> <tt>hdl</tt> returns the current
°5ubuffering mode for <tt>hdl</tt>.
hGetBuffering :: Handle -> IO BufferMode

-- | The action <a>hFlush</a> <tt>hdl</tt> causes any items buffered for
°5uoutput in handle <tt>hdl</tt> to be sent immediately to the operating
°5usystem.
°5u
°5uThis operation may fail with:
°5u
°5u<ul>
°5u<li><tt>isFullError</tt> if the device is full;</li>
°5u<li><tt>isPermissionError</tt> if a system resource limit would be
°5uexceeded. It is unspecified whether the characters in the buffer are
°5udiscarded or retained under these circumstances.</li>
°5u</ul>
hFlush :: Handle -> IO ()

-- | Computation <a>hGetPosn</a> <tt>hdl</tt> returns the current I/O
°5uposition of <tt>hdl</tt> as a value of the abstract type
°5u<a>HandlePosn</a>.
hGetPosn :: Handle -> IO HandlePosn

-- | If a call to <a>hGetPosn</a> <tt>hdl</tt> returns a position
°5u<tt>p</tt>, then computation <a>hSetPosn</a> <tt>p</tt> sets the
°5uposition of <tt>hdl</tt> to the position it held at the time of the
°5ucall to <a>hGetPosn</a>.
°5u
°5uThis operation may fail with:
°5u
°5u<ul>
°5u<li><tt>isPermissionError</tt> if a system resource limit would be
°5uexceeded.</li>
°5u</ul>
hSetPosn :: HandlePosn -> IO ()
data HandlePosn

-- | Computation <a>hSeek</a> <tt>hdl mode i</tt> sets the position of
°5uhandle <tt>hdl</tt> depending on <tt>mode</tt>. The offset <tt>i</tt>
°5uis given in terms of 8-bit bytes.
°5u
°5uIf <tt>hdl</tt> is block- or line-buffered, then seeking to a position
°5uwhich is not in the current buffer will first cause any items in the
°5uoutput buffer to be written to the device, and then cause the input
°5ubuffer to be discarded. Some handles may not be seekable (see
°5u<a>hIsSeekable</a>), or only support a subset of the possible
°5upositioning operations (for instance, it may only be possible to seek
°5uto the end of a tape, or to a positive offset from the beginning or
°5ucurrent position). It is not possible to set a negative I/O position,
°5uor for a physical file, an I/O position beyond the current
°5uend-of-file.
°5u
°5uThis operation may fail with:
°5u
°5u<ul>
°5u<li><tt>isIllegalOperationError</tt> if the Handle is not seekable, or
°5udoes not support the requested seek mode.</li>
°5u<li><tt>isPermissionError</tt> if a system resource limit would be
°5uexceeded.</li>
°5u</ul>
hSeek :: Handle -> SeekMode -> Integer -> IO ()

-- | A mode that determines the effect of <tt>hSeek</tt> <tt>hdl mode
°5ui</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
°5ucurrent position.
RelativeSeek :: SeekMode

-- | the position of <tt>hdl</tt> is set to offset <tt>i</tt> from the end
°5uof the file.
SeekFromEnd :: SeekMode

-- | Computation <a>hTell</a> <tt>hdl</tt> returns the current position of
°5uthe handle <tt>hdl</tt>, as the number of bytes from the beginning of
°5uthe file. The value returned may be subsequently passed to
°5u<a>hSeek</a> to reposition the handle to the current position.
°5u
°5uThis operation may fail with:
°5u
°5u<ul>
°5u<li><tt>isIllegalOperationError</tt> if the Handle is not
°5useekable.</li>
°5u</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
°5uoutput 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
°5uavailable on handle <tt>hdl</tt>. It returns <a>True</a> as soon as
°5uinput is available on <tt>hdl</tt>, or <a>False</a> if no input is
°5uavailable within <tt>t</tt> milliseconds. Note that
°5u<a>hWaitForInput</a> waits until one or more full <i>characters</i>
°5uare available, which means that it needs to do decoding, and hence may
°5ufail with a decoding error.
°5u
°5uIf <tt>t</tt> is less than zero, then <tt>hWaitForInput</tt> waits
°5uindefinitely.
°5u
°5uThis operation may fail with:
°5u
°5u<ul>
°5u<li><a>isEOFError</a> if the end of file has been reached.</li>
°5u<li>a decoding error, if the input begins with an invalid byte
°5usequence in this Handle's encoding.</li>
°5u</ul>
°5u
°5uNOTE for GHC users: unless you use the <tt>-threaded</tt> flag,
°5u<tt>hWaitForInput hdl t</tt> where <tt>t &gt;= 0</tt> will block all
°5uother Haskell threads for the duration of the call. It behaves like a
°5u<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
°5uitem is available for input from handle <tt>hdl</tt>.
°5u
°5uThis operation may fail with:
°5u
°5u<ul>
°5u<li><a>isEOFError</a> if the end of file has been reached.</li>
°5u</ul>
hReady :: Handle -> IO Bool

-- | Computation <a>hGetChar</a> <tt>hdl</tt> reads a character from the
°5ufile or channel managed by <tt>hdl</tt>, blocking until a character is
°5uavailable.
°5u
°5uThis operation may fail with:
°5u
°5u<ul>
°5u<li><a>isEOFError</a> if the end of file has been reached.</li>
°5u</ul>
hGetChar :: Handle -> IO Char

-- | Computation <a>hGetLine</a> <tt>hdl</tt> reads a line from the file or
°5uchannel managed by <tt>hdl</tt>.
°5u
°5uThis operation may fail with:
°5u
°5u<ul>
°5u<li><a>isEOFError</a> if the end of file is encountered when reading
°5uthe <i>first</i> character of the line.</li>
°5u</ul>
°5u
°5uIf <a>hGetLine</a> encounters end-of-file at any other point while
°5ureading in a line, it is treated as a line terminator and the
°5u(partial) line is returned.
hGetLine :: Handle -> IO String

-- | Computation <a>hLookAhead</a> returns the next character from the
°5uhandle without removing it from the input buffer, blocking until a
°5ucharacter is available.
°5u
°5uThis operation may fail with:
°5u
°5u<ul>
°5u<li><tt>isEOFError</tt> if the end of file has been reached.</li>
°5u</ul>
hLookAhead :: Handle -> IO Char

-- | Computation <a>hGetContents</a> <tt>hdl</tt> returns the list of
°5ucharacters corresponding to the unread portion of the channel or file
°5umanaged by <tt>hdl</tt>, which is put into an intermediate state,
°5u<i>semi-closed</i>. In this state, <tt>hdl</tt> is effectively closed,
°5ubut items are read from <tt>hdl</tt> on demand and accumulated in a
°5uspecial list returned by <a>hGetContents</a> <tt>hdl</tt>.
°5u
°5uAny operation that fails because a handle is closed, also fails if a
°5uhandle is semi-closed. The only exception is <tt>hClose</tt>. A
°5usemi-closed handle becomes closed:
°5u
°5u<ul>
°5u<li>if <tt>hClose</tt> is applied to it;</li>
°5u<li>if an I/O error occurs when reading an item from the handle;</li>
°5u<li>or once the entire contents of the handle has been read.</li>
°5u</ul>
°5u
°5uOnce a semi-closed handle becomes closed, the contents of the
°5uassociated list becomes fixed. The contents of this final list is only
°5upartially specified: it will contain at least all the items of the
°5ustream that were evaluated prior to the handle becoming closed.
°5u
°5uAny I/O errors encountered while a handle is semi-closed are simply
°5udiscarded.
°5u
°5uThis operation may fail with:
°5u
°5u<ul>
°5u<li><a>isEOFError</a> if the end of file has been reached.</li>
°5u</ul>
hGetContents :: Handle -> IO String

-- | Computation <a>hPutChar</a> <tt>hdl ch</tt> writes the character
°5u<tt>ch</tt> to the file or channel managed by <tt>hdl</tt>. Characters
°5umay be buffered if buffering is enabled for <tt>hdl</tt>.
°5u
°5uThis operation may fail with:
°5u
°5u<ul>
°5u<li><a>isFullError</a> if the device is full; or</li>
°5u<li><a>isPermissionError</a> if another system resource limit would be
°5uexceeded.</li>
°5u</ul>
hPutChar :: Handle -> Char -> IO ()

-- | Computation <a>hPutStr</a> <tt>hdl s</tt> writes the string <tt>s</tt>
°5uto the file or channel managed by <tt>hdl</tt>.
°5u
°5uThis operation may fail with:
°5u
°5u<ul>
°5u<li><a>isFullError</a> if the device is full; or</li>
°5u<li><a>isPermissionError</a> if another system resource limit would be
°5uexceeded.</li>
°5u</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
°5urepresentation of <tt>t</tt> given by the <a>shows</a> function to the
°5ufile or channel managed by <tt>hdl</tt> and appends a newline.
°5u
°5uThis operation may fail with:
°5u
°5u<ul>
°5u<li><a>isFullError</a> if the device is full; or</li>
°5u<li><a>isPermissionError</a> if another system resource limit would be
°5uexceeded.</li>
°5u</ul>
hPrint :: Show a => Handle -> a -> IO ()

-- | The <a>interact</a> function takes a function of type
°5u<tt>String-&gt;String</tt> as its argument. The entire input from the
°5ustandard input device is passed to this function as its argument, and
°5uthe resulting string is output on the standard output device.
interact :: (String -> String) -> IO ()

-- | Write a character to the standard output device (same as
°5u<a>hPutChar</a> <a>stdout</a>).
putChar :: Char -> IO ()

-- | Write a string to the standard output device (same as <a>hPutStr</a>
°5u<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
°5ustandard output device. Printable types are those that are instances
°5uof class <a>Show</a>; <a>print</a> converts values to strings for
°5uoutput using the <a>show</a> operation and adds a newline.
°5u
°5uFor example, a program to print the first 20 integers and their powers
°5uof 2 could be written as:
°5u
°5u<pre>
°5umain = print ([(n, 2^n) | n &lt;- [0..19]])
°5u</pre>
print :: Show a => a -> IO ()

-- | Read a character from the standard input device (same as
°5u<a>hGetChar</a> <a>stdin</a>).
getChar :: IO Char

-- | Read a line from the standard input device (same as <a>hGetLine</a>
°5u<a>stdin</a>).
getLine :: IO String

-- | The <a>getContents</a> operation returns all user input as a single
°5ustring, which is read lazily as it is needed (same as
°5u<a>hGetContents</a> <a>stdin</a>).
getContents :: IO String

-- | The <a>readIO</a> function is similar to <a>read</a> except that it
°5usignals parse failure to the <a>IO</a> monad instead of terminating
°5uthe 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
°5u<a>openBinaryFile</a> and passes the resulting handle to the
°5ucomputation <tt>act</tt>. The handle will be closed on exit from
°5u<a>withBinaryFile</a>, whether by normal termination or by raising an
°5uexception.
withBinaryFile :: FilePath -> IOMode -> (Handle -> IO r) -> IO r

-- | Like <a>openFile</a>, but open the file in binary mode. On Windows,
°5ureading a file in text mode (which is the default) will translate CRLF
°5uto LF, and writing will translate LF to CRLF. This is usually what you
°5uwant with text files. With binary files this is undesirable; also, as
°5uusual under Microsoft operating systems, text mode treats control-Z as
°5uEOF. Binary mode turns off all special treatment of end-of-line and
°5uend-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
°5uhandle. (See also <a>openBinaryFile</a>.)
°5u
°5uThis has the same effect as calling <a>hSetEncoding</a> with
°5u<a>char8</a>, together with <a>hSetNewlineMode</a> with
°5u<a>noNewlineTranslation</a>.
hSetBinaryMode :: Handle -> Bool -> IO ()

-- | <a>hPutBuf</a> <tt>hdl buf count</tt> writes <tt>count</tt> 8-bit
°5ubytes from the buffer <tt>buf</tt> to the handle <tt>hdl</tt>. It
°5ureturns ().
°5u
°5u<a>hPutBuf</a> ignores any text encoding that applies to the
°5u<a>Handle</a>, writing the bytes directly to the underlying file or
°5udevice.
°5u
°5u<a>hPutBuf</a> ignores the prevailing <tt>TextEncoding</tt> and
°5u<a>NewlineMode</a> on the <a>Handle</a>, and writes bytes directly.
°5u
°5uThis operation may fail with:
°5u
°5u<ul>
°5u<li><a>ResourceVanished</a> if the handle is a pipe or socket, and the
°5ureading end is closed. (If this is a POSIX system, and the program has
°5unot asked to ignore SIGPIPE, then a SIGPIPE may be delivered instead,
°5uwhose default action is to terminate the program).</li>
°5u</ul>
hPutBuf :: Handle -> Ptr a -> Int -> IO ()

-- | <a>hGetBuf</a> <tt>hdl buf count</tt> reads data from the handle
°5u<tt>hdl</tt> into the buffer <tt>buf</tt> until either EOF is reached
°5uor <tt>count</tt> 8-bit bytes have been read. It returns the number of
°5ubytes actually read. This may be zero if EOF was reached before any
°5udata was read (or if <tt>count</tt> is zero).
°5u
°5u<a>hGetBuf</a> never raises an EOF exception, instead it returns a
°5uvalue smaller than <tt>count</tt>.
°5u
°5uIf the handle is a pipe or socket, and the writing end is closed,
°5u<a>hGetBuf</a> will behave as if EOF was reached.
°5u
°5u<a>hGetBuf</a> ignores the prevailing <tt>TextEncoding</tt> and
°5u<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
°5u<tt>hdl</tt> into the buffer <tt>buf</tt>. If there is any data
°5uavailable to read, then <a>hGetBufSome</a> returns it immediately; it
°5uonly blocks if there is no data to be read.
°5u
°5uIt returns the number of bytes actually read. This may be zero if EOF
°5uwas reached before any data was read (or if <tt>count</tt> is zero).
°5u
°5u<a>hGetBufSome</a> never raises an EOF exception, instead it returns a
°5uvalue smaller than <tt>count</tt>.
°5u
°5uIf the handle is a pipe or socket, and the writing end is closed,
°5u<a>hGetBufSome</a> will behave as if EOF was reached.
°5u
°5u<a>hGetBufSome</a> ignores the prevailing <tt>TextEncoding</tt> and
°5u<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
°5uhandle <tt>hdl</tt> into the buffer <tt>buf</tt> until either EOF is
°5ureached, or <tt>count</tt> 8-bit bytes have been read, or there is no
°5umore data available to read immediately.
°5u
°5u<a>hGetBufNonBlocking</a> is identical to <a>hGetBuf</a>, except that
°5uit will never block waiting for data to become available, instead it
°5ureturns only whatever data is available. To wait for data to arrive
°5ubefore calling <a>hGetBufNonBlocking</a>, use <a>hWaitForInput</a>.
°5u
°5uIf the handle is a pipe or socket, and the writing end is closed,
°5u<a>hGetBufNonBlocking</a> will behave as if EOF was reached.
°5u
°5u<a>hGetBufNonBlocking</a> ignores the prevailing <tt>TextEncoding</tt>
°5uand <a>NewlineMode</a> on the <a>Handle</a>, and reads bytes directly.
°5u
°5uNOTE: on Windows, this function does not work correctly; it behaves
°5uidentically to <a>hGetBuf</a>.
hGetBufNonBlocking :: Handle -> Ptr a -> Int -> IO Int

-- | The function creates a temporary file in ReadWrite mode. The created
°5ufile isn't deleted automatically, so you need to delete it manually.
°5u
°5uThe file is created with permissions such that only the current user
°5ucan read/write it.
°5u
°5uWith some exceptions (see below), the file will be created securely in
°5uthe sense that an attacker should not be able to cause openTempFile to
°5uoverwrite another file on the filesystem using your credentials, by
°5uputting symbolic links (on Unix) in the place where the temporary file
°5uis to be created. On Unix the <tt>O_CREAT</tt> and <tt>O_EXCL</tt>
°5uflags are used to prevent this attack, but note that <tt>O_EXCL</tt>
°5uis sometimes not supported on NFS filesystems, so if you rely on this
°5ubehaviour 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
°5u<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
°5uthe text encoding for the handle <tt>hdl</tt> to <tt>encoding</tt>.
°5uThe default encoding when a <a>Handle</a> is created is
°5u<tt>localeEncoding</tt>, namely the default encoding for the current
°5ulocale.
°5u
°5uTo create a <a>Handle</a> with no encoding at all, use
°5u<a>openBinaryFile</a>. To stop further encoding or decoding on an
°5uexisting <a>Handle</a>, use <a>hSetBinaryMode</a>.
°5u
°5u<a>hSetEncoding</a> may need to flush buffered data in order to change
°5uthe encoding.
hSetEncoding :: Handle -> TextEncoding -> IO ()

-- | Return the current <a>TextEncoding</a> for the specified
°5u<a>Handle</a>, or <a>Nothing</a> if the <a>Handle</a> is in binary
°5umode.
°5u
°5uNote that the <a>TextEncoding</a> remembers nothing about the state of
°5uthe encoder/decoder in use on this <a>Handle</a>. For example, if the
°5uencoding in use is UTF-16, then using <a>hGetEncoding</a> and
°5u<a>hSetEncoding</a> to save and restore the encoding may result in an
°5uextra byte-order-mark being written to the file.
hGetEncoding :: Handle -> IO (Maybe TextEncoding)

-- | A <a>TextEncoding</a> is a specification of a conversion scheme
°5ubetween sequences of bytes and sequences of Unicode characters.
°5u
°5uFor example, UTF-8 is an encoding of Unicode characters into a
°5usequence 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
°5uthe first 256 Unicode code points, and is thus not a complete Unicode
°5uencoding. An attempt to write a character greater than '\255' to a
°5u<tt>Handle</tt> using the <a>latin1</a> encoding will result in an
°5uerror.
latin1 :: TextEncoding

-- | The UTF-8 Unicode encoding
utf8 :: TextEncoding

-- | The UTF-8 Unicode encoding, with a byte-order-mark (BOM; the byte
°5usequence 0xEF 0xBB 0xBF). This encoding behaves like <a>utf8</a>,
°5uexcept that on input, the BOM sequence is ignored at the beginning of
°5uthe stream, and on output, the BOM sequence is prepended.
°5u
°5uThe byte-order-mark is strictly unnecessary in UTF-8, but is sometimes
°5uused to identify the encoding of a file.
utf8_bom :: TextEncoding

-- | The UTF-16 Unicode encoding (a byte-order-mark should be used to
°5uindicate 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
°5uindicate 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
°5u
°5uThis is the initial locale encoding: if it has been subsequently
°5uchanged by <a>setLocaleEncoding</a> this value will not reflect that
°5uchange.
localeEncoding :: TextEncoding

-- | An encoding in which Unicode code points are translated to bytes by
°5utaking the code point modulo 256. When decoding, bytes are translated
°5udirectly into the equivalent code point.
°5u
°5uThis encoding never fails in either direction. However, encoding
°5udiscards information, so encode followed by decode is not the
°5uidentity.
char8 :: TextEncoding

-- | Look up the named Unicode encoding. May fail with
°5u
°5u<ul>
°5u<li><tt>isDoesNotExistError</tt> if the encoding is unknown</li>
°5u</ul>
°5u
°5uThe set of known encodings is system-dependent, but includes at least:
°5u
°5u<ul>
°5u<li><pre>UTF-8</pre></li>
°5u<li><tt>UTF-16</tt>, <tt>UTF-16BE</tt>, <tt>UTF-16LE</tt></li>
°5u<li><tt>UTF-32</tt>, <tt>UTF-32BE</tt>, <tt>UTF-32LE</tt></li>
°5u</ul>
°5u
°5uThere is additional notation (borrowed from GNU iconv) for specifying
°5uhow illegal characters are handled:
°5u
°5u<ul>
°5u<li>a suffix of <tt>//IGNORE</tt>, e.g. <tt>UTF-8//IGNORE</tt>, will
°5ucause all illegal sequences on input to be ignored, and on output will
°5udrop all code points that have no representation in the target
°5uencoding.</li>
°5u<li>a suffix of <tt>//TRANSLIT</tt> will choose a replacement
°5ucharacter for illegal sequences or code points.</li>
°5u<li>a suffix of <tt>//ROUNDTRIP</tt> will use a PEP383-style escape
°5umechanism to represent any invalid bytes in the input as Unicode
°5ucodepoints (specifically, as lone surrogates, which are normally
°5uinvalid in UTF-32). Upon output, these special codepoints are detected
°5uand turned back into the corresponding original byte.</li>
°5u</ul>
°5u
°5uIn theory, this mechanism allows arbitrary data to be roundtripped via
°5ua <a>String</a> with no loss of data. In practice, there are two
°5ulimitations to be aware of:
°5u
°5u<ol>
°5u<li>This only stands a chance of working for an encoding which is an
°5uASCII superset, as for security reasons we refuse to escape any bytes
°5usmaller than 128. Many encodings of interest are ASCII supersets (in
°5uparticular, you can assume that the locale encoding is an ASCII
°5usuperset) but many (such as UTF-16) are not.</li>
°5u<li>If the underlying encoding is not itself roundtrippable, this
°5umechanism can fail. Roundtrippable encodings are those which have an
°5uinjective mapping into Unicode. Almost all encodings meet this
°5ucriteria, but some do not. Notably, Shift-JIS (CP932) and Big5 contain
°5useveral different encodings of the same Unicode codepoint.</li>
°5u</ol>
°5u
°5uOn Windows, you can access supported code pages with the prefix
°5u<tt>CP</tt>; for example, <tt>"CP1250"</tt>.
mkTextEncoding :: String -> IO TextEncoding

-- | Set the <a>NewlineMode</a> on the specified <a>Handle</a>. All
°5ubuffered 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>
°5uon Unix systems, <a>CRLF</a> on Windows.
nativeNewline :: Newline

-- | Specifies the translation, if any, of newline characters between
°5uinternal Strings and the external file or stream. Haskell Strings are
°5uassumed to represent newlines with the '\n' character; the newline
°5umode specifies how to translate '\n' on output, and what to translate
°5uinto '\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.
°5u
°5u<pre>
°5unoNewlineTranslation  = NewlineMode { inputNL  = LF, outputNL = LF }
°5u</pre>
noNewlineTranslation :: NewlineMode

-- | Map '\r\n' into '\n' on input, and '\n' to the native newline
°5urepresetnation on output. This mode can be used on any platform, and
°5uworks with text files using any newline convention. The downside is
°5uthat <tt>readFile &gt;&gt;= writeFile</tt> might yield a different
°5ufile.
°5u
°5u<pre>
°5uuniversalNewlineMode  = NewlineMode { inputNL  = CRLF,
°5u                                      outputNL = nativeNewline }
°5u</pre>
universalNewlineMode :: NewlineMode

-- | Use the native newline representation on both input and output
°5u
°5u<pre>
°5unativeNewlineMode  = NewlineMode { inputNL  = nativeNewline
°5u                                   outputNL = nativeNewline }
°5u</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
°5uhandle, running in constant memory.
getFileHash :: FilePath -> IO Fingerprint


-- | Monadic fixpoints.
°5u
°5uFor a detailed discussion, see Levent Erkok's thesis, <i>Value
°5uRecursion in Monadic Computations</i>, Oregon Graduate Institute,
°5u2002.
module Control.Monad.Fix

-- | Monads having fixed points with a 'knot-tying' semantics. Instances of
°5u<a>MonadFix</a> should satisfy the following laws:
°5u
°5u<ul>
°5u<li><i><i>purity</i></i> <tt><a>mfix</a> (<tt>return</tt> . h) =
°5u<tt>return</tt> (<a>fix</a> h)</tt></li>
°5u<li><i><i>left shrinking</i> (or <i>tightening</i>)</i>
°5u<tt><a>mfix</a> (\x -&gt; a &gt;&gt;= \y -&gt; f x y) = a &gt;&gt;= \y
°5u-&gt; <a>mfix</a> (\x -&gt; f x y)</tt></li>
°5u<li><i><i>sliding</i></i> <tt><a>mfix</a> (<a>liftM</a> h . f) =
°5u<a>liftM</a> h (<a>mfix</a> (f . h))</tt>, for strict <tt>h</tt>.</li>
°5u<li><i><i>nesting</i></i> <tt><a>mfix</a> (\x -&gt; <a>mfix</a> (\y
°5u-&gt; f x y)) = <a>mfix</a> (\x -&gt; f x x)</tt></li>
°5u</ul>
°5u
°5uThis class is used in the translation of the recursive <tt>do</tt>
°5unotation supported by GHC and Hugs.
class (Monad m) => MonadFix m

-- | The fixed point of a monadic computation. <tt><a>mfix</a> f</tt>
°5uexecutes the action <tt>f</tt> only once, with the eventual output fed
°5uback as the input. Hence <tt>f</tt> should not be strict, for then
°5u<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
°5u<tt>f</tt>, i.e. the least defined <tt>x</tt> such that <tt>f x =
°5ux</tt>.
°5u
°5uFor example, we can write the factorial function using direct
°5urecursion as
°5u
°5u<pre>
°5u&gt;&gt;&gt; let fac n = if n &lt;= 1 then 1 else n * fac (n-1) in fac 5
°5u120
°5u</pre>
°5u
°5uThis uses the fact that Haskell’s <tt>let</tt> introduces recursive
°5ubindings. We can rewrite this definition using <a>fix</a>,
°5u
°5u<pre>
°5u&gt;&gt;&gt; fix (\rec n -&gt; if n &lt;= 1 then 1 else n * rec (n-1)) 5
°5u120
°5u</pre>
°5u
°5uInstead of making a recursive call, we introduce a dummy parameter
°5u<tt>rec</tt>; when used within <a>fix</a>, this parameter then refers
°5uto <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.
°5u
°5uThis trivial type constructor serves two purposes:
°5u
°5u<ul>
°5u<li>It can be used with functions parameterized by functor or monad
°5uclasses.</li>
°5u<li>It can be used as a base monad to which a series of monad
°5utransformers may be applied to construct a composite monad. Most monad
°5utransformer modules include the special case of applying the
°5utransformer to <a>Identity</a>. For example, <tt>State s</tt> is an
°5uabbreviation for <tt>StateT s <a>Identity</a></tt>.</li>
°5u</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
°5u
°5u<ul>
°5u<li><i>Generalising Monads to Arrows</i>, by John Hughes, <i>Science
°5uof Computer Programming</i> 37, pp67-111, May 2000.</li>
°5u</ul>
°5u
°5uplus a couple of definitions (<a>returnA</a> and <a>loop</a>) from
°5u
°5u<ul>
°5u<li><i>A New Notation for Arrows</i>, by Ross Paterson, in <i>ICFP
°5u2001</i>, Firenze, Italy, pp229-240.</li>
°5u</ul>
°5u
°5uThese papers and more information on arrows can be found at
°5u<a>http://www.haskell.org/arrows/</a>.
module Control.Arrow

-- | The basic arrow class.
°5u
°5uInstances should satisfy the following laws:
°5u
°5u<ul>
°5u<li><pre><a>arr</a> id = <a>id</a></pre></li>
°5u<li><pre><a>arr</a> (f &gt;&gt;&gt; g) = <a>arr</a> f &gt;&gt;&gt;
°5u<a>arr</a> g</pre></li>
°5u<li><pre><a>first</a> (<a>arr</a> f) = <a>arr</a> (<a>first</a>
°5uf)</pre></li>
°5u<li><pre><a>first</a> (f &gt;&gt;&gt; g) = <a>first</a> f &gt;&gt;&gt;
°5u<a>first</a> g</pre></li>
°5u<li><pre><a>first</a> f &gt;&gt;&gt; <a>arr</a> <a>fst</a> =
°5u<a>arr</a> <a>fst</a> &gt;&gt;&gt; f</pre></li>
°5u<li><pre><a>first</a> f &gt;&gt;&gt; <a>arr</a> (<a>id</a> *** g) =
°5u<a>arr</a> (<a>id</a> *** g) &gt;&gt;&gt; <a>first</a> f</pre></li>
°5u<li><pre><a>first</a> (<a>first</a> f) &gt;&gt;&gt; <a>arr</a>
°5u<tt>assoc</tt> = <a>arr</a> <tt>assoc</tt> &gt;&gt;&gt; <a>first</a>
°5uf</pre></li>
°5u</ul>
°5u
°5uwhere
°5u
°5u<pre>
°5uassoc ((a,b),c) = (a,(b,c))
°5u</pre>
°5u
°5uThe other combinators have sensible default definitions, which may be
°5uoverridden 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
°5ucopy the rest unchanged to the output.
first :: Arrow a => a b c -> a (b, d) (c, d)

-- | A mirror image of <a>first</a>.
°5u
°5uThe default definition may be overridden with a more efficient version
°5uif desired.
second :: Arrow a => a b c -> a (d, b) (d, c)

-- | Split the input between the two argument arrows and combine their
°5uoutput. Note that this is in general not a functor.
°5u
°5uThe default definition may be overridden with a more efficient version
°5uif 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
°5uoutput.
°5u
°5uThe default definition may be overridden with a more efficient version
°5uif 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
°5unotation.
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
°5u<tt>if</tt> and <tt>case</tt> constructs in arrow notation.
°5u
°5uInstances should satisfy the following laws:
°5u
°5u<ul>
°5u<li><pre><a>left</a> (<a>arr</a> f) = <a>arr</a> (<a>left</a>
°5uf)</pre></li>
°5u<li><pre><a>left</a> (f &gt;&gt;&gt; g) = <a>left</a> f &gt;&gt;&gt;
°5u<a>left</a> g</pre></li>
°5u<li><pre>f &gt;&gt;&gt; <a>arr</a> <a>Left</a> = <a>arr</a>
°5u<a>Left</a> &gt;&gt;&gt; <a>left</a> f</pre></li>
°5u<li><pre><a>left</a> f &gt;&gt;&gt; <a>arr</a> (<a>id</a> +++ g) =
°5u<a>arr</a> (<a>id</a> +++ g) &gt;&gt;&gt; <a>left</a> f</pre></li>
°5u<li><pre><a>left</a> (<a>left</a> f) &gt;&gt;&gt; <a>arr</a>
°5u<tt>assocsum</tt> = <a>arr</a> <tt>assocsum</tt> &gt;&gt;&gt;
°5u<a>left</a> f</pre></li>
°5u</ul>
°5u
°5uwhere
°5u
°5u<pre>
°5uassocsum (Left (Left x)) = Left x
°5uassocsum (Left (Right y)) = Right (Left y)
°5uassocsum (Right z) = Right (Right z)
°5u</pre>
°5u
°5uThe other combinators have sensible default definitions, which may be
°5uoverridden for efficiency.
class Arrow a => ArrowChoice a

-- | Feed marked inputs through the argument arrow, passing the rest
°5uthrough unchanged to the output.
left :: ArrowChoice a => a b c -> a (Either b d) (Either c d)

-- | A mirror image of <a>left</a>.
°5u
°5uThe default definition may be overridden with a more efficient version
°5uif 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
°5utheir outputs. Note that this is in general not a functor.
°5u
°5uThe default definition may be overridden with a more efficient version
°5uif 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
°5uoutputs.
°5u
°5uThe default definition may be overridden with a more efficient version
°5uif desired.
(|||) :: ArrowChoice a => a b d -> a c d -> a (Either b c) d

-- | Some arrows allow application of arrow inputs to other inputs.
°5uInstances should satisfy the following laws:
°5u
°5u<ul>
°5u<li><pre><a>first</a> (<a>arr</a> (\x -&gt; <a>arr</a> (\y -&gt;
°5u(x,y)))) &gt;&gt;&gt; <a>app</a> = <a>id</a></pre></li>
°5u<li><pre><a>first</a> (<a>arr</a> (g &gt;&gt;&gt;)) &gt;&gt;&gt;
°5u<a>app</a> = <a>second</a> g &gt;&gt;&gt; <a>app</a></pre></li>
°5u<li><pre><a>first</a> (<a>arr</a> (&gt;&gt;&gt; h)) &gt;&gt;&gt;
°5u<a>app</a> = <a>app</a> &gt;&gt;&gt; h</pre></li>
°5u</ul>
°5u
°5uSuch 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
°5ugives rise to a <a>Kleisli</a> arrow, and any instance of
°5u<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
°5u<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
°5uvalue is fed back as input, although the computation occurs only once.
°5uIt underlies the <tt>rec</tt> value recursion construct in arrow
°5unotation. <a>loop</a> should satisfy the following laws:
°5u
°5u<ul>
°5u<li><i><i>extension</i></i> <tt><a>loop</a> (<a>arr</a> f) =
°5u<a>arr</a> (\ b -&gt; <a>fst</a> (<a>fix</a> (\ (c,d) -&gt; f
°5u(b,d))))</tt></li>
°5u<li><i><i>left tightening</i></i> <tt><a>loop</a> (<a>first</a> h
°5u&gt;&gt;&gt; f) = h &gt;&gt;&gt; <a>loop</a> f</tt></li>
°5u<li><i><i>right tightening</i></i> <tt><a>loop</a> (f &gt;&gt;&gt;
°5u<a>first</a> h) = <a>loop</a> f &gt;&gt;&gt; h</tt></li>
°5u<li><i><i>sliding</i></i> <tt><a>loop</a> (f &gt;&gt;&gt; <a>arr</a>
°5u(<a>id</a> *** k)) = <a>loop</a> (<a>arr</a> (<a>id</a> *** k)
°5u&gt;&gt;&gt; f)</tt></li>
°5u<li><i><i>vanishing</i></i> <tt><a>loop</a> (<a>loop</a> f) =
°5u<a>loop</a> (<a>arr</a> unassoc &gt;&gt;&gt; f &gt;&gt;&gt; <a>arr</a>
°5uassoc)</tt></li>
°5u<li><i><i>superposing</i></i> <tt><a>second</a> (<a>loop</a> f) =
°5u<a>loop</a> (<a>arr</a> assoc &gt;&gt;&gt; <a>second</a> f
°5u&gt;&gt;&gt; <a>arr</a> unassoc)</tt></li>
°5u</ul>
°5u
°5uwhere
°5u
°5u<pre>
°5uassoc ((a,b),c) = (a,(b,c))
°5uunassoc (a,(b,c)) = ((a,b),c)
°5u</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
°5umonad (technically, a strong lax monoidal functor). Compared with
°5umonads, this interface lacks the full power of the binding operation
°5u<a>&gt;&gt;=</a>, but
°5u
°5u<ul>
°5u<li>it has more instances.</li>
°5u<li>it is sufficient for many uses, e.g. context-free parsing, or the
°5u<a>Traversable</a> class.</li>
°5u<li>instances can perform analysis of computations before they are
°5uexecuted, and thus produce shared optimizations.</li>
°5u</ul>
°5u
°5uThis interface was introduced for parsers by Niklas Röjemo, because it
°5uadmits more sharing than the monadic interface. The names here are
°5umostly based on parsing work by Doaitse Swierstra.
°5u
°5uFor more details, see <a>Applicative Programming with Effects</a>, by
°5uConor McBride and Ross Paterson.
module Control.Applicative

-- | A functor with application, providing operations to
°5u
°5u<ul>
°5u<li>embed pure expressions (<a>pure</a>), and</li>
°5u<li>sequence computations and combine their results (<a>&lt;*&gt;</a>
°5uand <a>liftA2</a>).</li>
°5u</ul>
°5u
°5uA minimal complete definition must include implementations of
°5u<a>pure</a> and of either <a>&lt;*&gt;</a> or <a>liftA2</a>. If it
°5udefines both, then they must behave the same as their default
°5udefinitions:
°5u
°5u<pre>
°5u(<a>&lt;*&gt;</a>) = <a>liftA2</a> <a>id</a>
°5u</pre>
°5u
°5u<pre>
°5u<a>liftA2</a> f x y = f <tt>&lt;$&gt;</tt> x <a>&lt;*&gt;</a> y
°5u</pre>
°5u
°5uFurther, any definition must satisfy the following:
°5u
°5u<ul>
°5u<li><i><i>identity</i></i> <pre><a>pure</a> <a>id</a> <a>&lt;*&gt;</a>
°5uv = v</pre></li>
°5u<li><i><i>composition</i></i> <pre><a>pure</a> (.) <a>&lt;*&gt;</a> u
°5u<a>&lt;*&gt;</a> v <a>&lt;*&gt;</a> w = u <a>&lt;*&gt;</a> (v
°5u<a>&lt;*&gt;</a> w)</pre></li>
°5u<li><i><i>homomorphism</i></i> <pre><a>pure</a> f <a>&lt;*&gt;</a>
°5u<a>pure</a> x = <a>pure</a> (f x)</pre></li>
°5u<li><i><i>interchange</i></i> <pre>u <a>&lt;*&gt;</a> <a>pure</a> y =
°5u<a>pure</a> (<a>$</a> y) <a>&lt;*&gt;</a> u</pre></li>
°5u</ul>
°5u
°5uThe other methods have the following default definitions, which may be
°5uoverridden with equivalent specialized implementations:
°5u
°5u<ul>
°5u<li><pre>u <a>*&gt;</a> v = (<a>id</a> <a>&lt;$</a> u)
°5u<a>&lt;*&gt;</a> v</pre></li>
°5u<li><pre>u <a>&lt;*</a> v = <a>liftA2</a> <a>const</a> u v</pre></li>
°5u</ul>
°5u
°5uAs a consequence of these laws, the <a>Functor</a> instance for
°5u<tt>f</tt> will satisfy
°5u
°5u<ul>
°5u<li><pre><a>fmap</a> f x = <a>pure</a> f <a>&lt;*&gt;</a> x</pre></li>
°5u</ul>
°5u
°5uIt may be useful to note that supposing
°5u
°5u<pre>
°5uforall x y. p (q x y) = f x . g y
°5u</pre>
°5u
°5uit follows from the above that
°5u
°5u<pre>
°5u<a>liftA2</a> p (<a>liftA2</a> q u v) = <a>liftA2</a> f u . <a>liftA2</a> g v
°5u</pre>
°5u
°5uIf <tt>f</tt> is also a <a>Monad</a>, it should satisfy
°5u
°5u<ul>
°5u<li><pre><a>pure</a> = <a>return</a></pre></li>
°5u<li><pre>(<a>&lt;*&gt;</a>) = <a>ap</a></pre></li>
°5u<li><pre>(<a>*&gt;</a>) = (<a>&gt;&gt;</a>)</pre></li>
°5u</ul>
°5u
°5u(which implies that <a>pure</a> and <a>&lt;*&gt;</a> satisfy the
°5uapplicative functor laws).
class Functor f => Applicative f

-- | Lift a value.
pure :: Applicative f => a -> f a

-- | Sequential application.
°5u
°5uA few functors support an implementation of <a>&lt;*&gt;</a> that is
°5umore efficient than the default one.
(<*>) :: Applicative f => f (a -> b) -> f a -> f b

-- | Lift a binary function to actions.
°5u
°5uSome functors support an implementation of <a>liftA2</a> that is more
°5uefficient than the default one. In particular, if <a>fmap</a> is an
°5uexpensive operation, it is likely better to use <a>liftA2</a> than to
°5u<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.
°5u
°5uIf defined, <a>some</a> and <a>many</a> should be the least solutions
°5uof the equations:
°5u
°5u<ul>
°5u<li><pre><a>some</a> v = (:) <tt>&lt;$&gt;</tt> v <a>&lt;*&gt;</a>
°5u<a>many</a> v</pre></li>
°5u<li><pre><a>many</a> v = <a>some</a> v <a>&lt;|&gt;</a> <a>pure</a>
°5u[]</pre></li>
°5u</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>.
°5u
°5uThe name of this operator is an allusion to <tt>$</tt>. Note the
°5usimilarities between their types:
°5u
°5u<pre>
°5u ($)  ::              (a -&gt; b) -&gt;   a -&gt;   b
°5u(&lt;$&gt;) :: Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
°5u</pre>
°5u
°5uWhereas <tt>$</tt> is function application, <a>&lt;$&gt;</a> is
°5ufunction application lifted over a <a>Functor</a>.
°5u
°5u<h4><b>Examples</b></h4>
°5u
°5uConvert from a <tt><tt>Maybe</tt> <tt>Int</tt></tt> to a
°5u<tt><tt>Maybe</tt> <tt>String</tt></tt> using <tt>show</tt>:
°5u
°5u<pre>
°5u&gt;&gt;&gt; show &lt;$&gt; Nothing
°5uNothing
°5u
°5u&gt;&gt;&gt; show &lt;$&gt; Just 3
°5uJust "3"
°5u</pre>
°5u
°5uConvert from an <tt><tt>Either</tt> <tt>Int</tt> <tt>Int</tt></tt> to
°5uan <tt><tt>Either</tt> <tt>Int</tt></tt> <tt>String</tt> using
°5u<tt>show</tt>:
°5u
°5u<pre>
°5u&gt;&gt;&gt; show &lt;$&gt; Left 17
°5uLeft 17
°5u
°5u&gt;&gt;&gt; show &lt;$&gt; Right 17
°5uRight "17"
°5u</pre>
°5u
°5uDouble each element of a list:
°5u
°5u<pre>
°5u&gt;&gt;&gt; (*2) &lt;$&gt; [1,2,3]
°5u[2,4,6]
°5u</pre>
°5u
°5uApply <tt>even</tt> to the second element of a pair:
°5u
°5u<pre>
°5u&gt;&gt;&gt; even &lt;$&gt; (2,2)
°5u(2,True)
°5u</pre>
(<$>) :: Functor f => (a -> b) -> f a -> f b
infixl 4 <$>

-- | Replace all locations in the input with the same value. The default
°5udefinition is <tt><a>fmap</a> . <a>const</a></tt>, but this may be
°5uoverridden 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
°5u<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,
°5uperforming an action on each element.
°5u
°5uSee also
°5u
°5u<ul>
°5u<li>"Applicative Programming with Effects", by Conor McBride and Ross
°5uPaterson, <i>Journal of Functional Programming</i> 18:1 (2008) 1-13,
°5uonline at
°5u<a>http://www.soi.city.ac.uk/~ross/papers/Applicative.html</a>.</li>
°5u<li>"The Essence of the Iterator Pattern", by Jeremy Gibbons and Bruno
°5uOliveira, in <i>Mathematically-Structured Functional Programming</i>,
°5u2006, online at
°5u<a>http://web.comlab.ox.ac.uk/oucl/work/jeremy.gibbons/publications/#iterator</a>.</li>
°5u<li>"An Investigation of the Laws of Traversals", by Mauro Jaskelioff
°5uand Ondrej Rypacek, in <i>Mathematically-Structured Functional
°5uProgramming</i>, 2012, online at
°5u<a>http://arxiv.org/pdf/1202.2919</a>.</li>
°5u</ul>
module Data.Traversable

-- | Functors representing data structures that can be traversed from left
°5uto right.
°5u
°5uA definition of <a>traverse</a> must satisfy the following laws:
°5u
°5u<ul>
°5u<li><i><i>naturality</i></i> <tt>t . <a>traverse</a> f =
°5u<a>traverse</a> (t . f)</tt> for every applicative transformation
°5u<tt>t</tt></li>
°5u<li><i><i>identity</i></i> <tt><a>traverse</a> Identity =
°5uIdentity</tt></li>
°5u<li><i><i>composition</i></i> <tt><a>traverse</a> (Compose .
°5u<a>fmap</a> g . f) = Compose . <a>fmap</a> (<a>traverse</a> g) .
°5u<a>traverse</a> f</tt></li>
°5u</ul>
°5u
°5uA definition of <a>sequenceA</a> must satisfy the following laws:
°5u
°5u<ul>
°5u<li><i><i>naturality</i></i> <tt>t . <a>sequenceA</a> =
°5u<a>sequenceA</a> . <a>fmap</a> t</tt> for every applicative
°5utransformation <tt>t</tt></li>
°5u<li><i><i>identity</i></i> <tt><a>sequenceA</a> . <a>fmap</a> Identity
°5u= Identity</tt></li>
°5u<li><i><i>composition</i></i> <tt><a>sequenceA</a> . <a>fmap</a>
°5uCompose = Compose . <a>fmap</a> <a>sequenceA</a> .
°5u<a>sequenceA</a></tt></li>
°5u</ul>
°5u
°5uwhere an <i>applicative transformation</i> is a function
°5u
°5u<pre>
°5ut :: (Applicative f, Applicative g) =&gt; f a -&gt; g a
°5u</pre>
°5u
°5upreserving the <a>Applicative</a> operations, i.e.
°5u
°5u<ul>
°5u<li><pre>t (<a>pure</a> x) = <a>pure</a> x</pre></li>
°5u<li><pre>t (x <a>&lt;*&gt;</a> y) = t x <a>&lt;*&gt;</a> t
°5uy</pre></li>
°5u</ul>
°5u
°5uand the identity functor <tt>Identity</tt> and composition of functors
°5u<tt>Compose</tt> are defined as
°5u
°5u<pre>
°5unewtype Identity a = Identity a
°5u
°5uinstance Functor Identity where
°5u  fmap f (Identity x) = Identity (f x)
°5u
°5uinstance Applicative Identity where
°5u  pure x = Identity x
°5u  Identity f &lt;*&gt; Identity x = Identity (f x)
°5u
°5unewtype Compose f g a = Compose (f (g a))
°5u
°5uinstance (Functor f, Functor g) =&gt; Functor (Compose f g) where
°5u  fmap f (Compose x) = Compose (fmap (fmap f) x)
°5u
°5uinstance (Applicative f, Applicative g) =&gt; Applicative (Compose f g) where
°5u  pure x = Compose (pure (pure x))
°5u  Compose f &lt;*&gt; Compose x = Compose ((&lt;*&gt;) &lt;$&gt; f &lt;*&gt; x)
°5u</pre>
°5u
°5u(The naturality law is implied by parametricity.)
°5u
°5uInstances are similar to <a>Functor</a>, e.g. given a data type
°5u
°5u<pre>
°5udata Tree a = Empty | Leaf a | Node (Tree a) a (Tree a)
°5u</pre>
°5u
°5ua suitable instance would be
°5u
°5u<pre>
°5uinstance Traversable Tree where
°5u   traverse f Empty = pure Empty
°5u   traverse f (Leaf x) = Leaf &lt;$&gt; f x
°5u   traverse f (Node l k r) = Node &lt;$&gt; traverse f l &lt;*&gt; f k &lt;*&gt; traverse f r
°5u</pre>
°5u
°5uThis is suitable even for abstract types, as the laws for
°5u<a>&lt;*&gt;</a> imply a form of associativity.
°5u
°5uThe superclass instances should satisfy the following:
°5u
°5u<ul>
°5u<li>In the <a>Functor</a> instance, <a>fmap</a> should be equivalent
°5uto traversal with the identity applicative functor
°5u(<a>fmapDefault</a>).</li>
°5u<li>In the <a>Foldable</a> instance, <a>foldMap</a> should be
°5uequivalent to traversal with a constant applicative functor
°5u(<a>foldMapDefault</a>).</li>
°5u</ul>
class (Functor t, Foldable t) => Traversable t

-- | Map each element of a structure to an action, evaluate these actions
°5ufrom left to right, and collect the results. For a version that
°5uignores 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
°5ucollect the results. For a version that ignores the results see
°5u<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
°5uactions from left to right, and collect the results. For a version
°5uthat 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
°5ucollect the results. For a version that ignores the results see
°5u<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
°5uversion 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
°5uthat 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
°5u<a>fmap</a> and <tt>foldl</tt>; it applies a function to each element
°5uof a structure, passing an accumulating parameter from left to right,
°5uand returning a final value of this accumulator together with the new
°5ustructure.
mapAccumL :: Traversable t => (a -> b -> (a, c)) -> a -> t b -> (a, t c)

-- | The <a>mapAccumR</a> function behaves like a combination of
°5u<a>fmap</a> and <tt>foldr</tt>; it applies a function to each element
°5uof a structure, passing an accumulating parameter from right to left,
°5uand returning a final value of this accumulator together with the new
°5ustructure.
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
°5u<a>Functor</a> instance, provided that <a>traverse</a> is defined.
°5u(Using <a>fmapDefault</a> with a <a>Traversable</a> instance defined
°5uonly by <a>sequenceA</a> will result in infinite recursion.)
°5u
°5u<pre>
°5u<a>fmapDefault</a> f ≡ <a>runIdentity</a> . <a>traverse</a> (<a>Identity</a> . f)
°5u</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
°5u<a>Foldable</a> instance.
°5u
°5u<pre>
°5u<a>foldMapDefault</a> f ≡ <a>getConst</a> . <a>traverse</a> (<a>Const</a> . f)
°5u</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.,
°5u
°5u<pre>
°5u[x1, ..., xm] ++ [y1, ..., yn] == [x1, ..., xm, y1, ..., yn]
°5u[x1, ..., xm] ++ [y1, ...] == [x1, ..., xm, y1, ...]
°5u</pre>
°5u
°5uIf 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
°5unon-empty.
last :: [a] -> a

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

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

-- | Decompose a list into its head and tail. If the list is empty, returns
°5u<a>Nothing</a>. If the list is non-empty, returns <tt><a>Just</a> (x,
°5uxs)</tt>, where <tt>x</tt> is the head of the list and <tt>xs</tt> its
°5utail.
uncons :: [a] -> Maybe (a, [a])

-- | Test whether the structure is empty. The default implementation is
°5uoptimized for structures that are similar to cons-lists, because there
°5uis 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
°5udefault implementation is optimized for structures that are similar to
°5ucons-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>
°5uto each element of <tt>xs</tt>, i.e.,
°5u
°5u<pre>
°5umap f [x1, x2, ..., xn] == [f x1, f x2, ..., f xn]
°5umap f [x1, x2, ...] == [f x1, f x2, ...]
°5u</pre>
map :: (a -> b) -> [a] -> [b]

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

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

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

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

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

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

-- | Left-associative fold of a structure.
°5u
°5uIn the case of lists, <a>foldl</a>, when applied to a binary operator,
°5ua starting value (typically the left-identity of the operator), and a
°5ulist, reduces the list using the binary operator, from left to right:
°5u
°5u<pre>
°5ufoldl f z [x1, x2, ..., xn] == (...((z `f` x1) `f` x2) `f`...) `f` xn
°5u</pre>
°5u
°5uNote that to produce the outermost application of the operator the
°5uentire input list must be traversed. This means that <a>foldl'</a>
°5uwill diverge if given an infinite list.
°5u
°5uAlso note that if you want an efficient left-fold, you probably want
°5uto use <a>foldl'</a> instead of <a>foldl</a>. The reason for this is
°5uthat latter does not force the "inner" results (e.g. <tt>z <tt>f</tt>
°5ux1</tt> in the above example) before applying them to the operator
°5u(e.g. to <tt>(<tt>f</tt> x2)</tt>). This results in a thunk chain
°5u<tt>O(n)</tt> elements long, which then must be evaluated from the
°5uoutside-in.
°5u
°5uFor a general <a>Foldable</a> structure this should be semantically
°5uidentical to,
°5u
°5u<pre>
°5ufoldl f z = <a>foldl</a> f z . <a>toList</a>
°5u</pre>
foldl :: Foldable t => (b -> a -> b) -> b -> t a -> b

-- | Left-associative fold of a structure but with strict application of
°5uthe operator.
°5u
°5uThis ensures that each step of the fold is forced to weak head normal
°5uform before being applied, avoiding the collection of thunks that
°5uwould otherwise occur. This is often what you want to strictly reduce
°5ua finite list to a single, monolithic result (e.g. <a>length</a>).
°5u
°5uFor a general <a>Foldable</a> structure this should be semantically
°5uidentical to,
°5u
°5u<pre>
°5ufoldl f z = <a>foldl'</a> f z . <a>toList</a>
°5u</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
°5uapplied to non-empty structures.
°5u
°5u<pre>
°5u<a>foldl1</a> f = <a>foldl1</a> f . <a>toList</a>
°5u</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.
°5u
°5uIn the case of lists, <a>foldr</a>, when applied to a binary operator,
°5ua starting value (typically the right-identity of the operator), and a
°5ulist, reduces the list using the binary operator, from right to left:
°5u
°5u<pre>
°5ufoldr f z [x1, x2, ..., xn] == x1 `f` (x2 `f` ... (xn `f` z)...)
°5u</pre>
°5u
°5uNote that, since the head of the resulting expression is produced by
°5uan application of the operator to the first element of the list,
°5u<a>foldr</a> can produce a terminating expression from an infinite
°5ulist.
°5u
°5uFor a general <a>Foldable</a> structure this should be semantically
°5uidentical to,
°5u
°5u<pre>
°5ufoldr f z = <a>foldr</a> f z . <a>toList</a>
°5u</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
°5uapplied to non-empty structures.
°5u
°5u<pre>
°5u<a>foldr1</a> f = <a>foldr1</a> f . <a>toList</a>
°5u</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
°5uthe resulting lists.
concatMap :: Foldable t => (a -> [b]) -> t a -> [b]

-- | <a>and</a> returns the conjunction of a container of Bools. For the
°5uresult to be <a>True</a>, the container must be finite; <a>False</a>,
°5uhowever, results from a <a>False</a> value finitely far from the left
°5uend.
and :: Foldable t => t Bool -> Bool

-- | <a>or</a> returns the disjunction of a container of Bools. For the
°5uresult to be <a>False</a>, the container must be finite; <a>True</a>,
°5uhowever, results from a <a>True</a> value finitely far from the left
°5uend.
or :: Foldable t => t Bool -> Bool

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

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

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

-- | The <a>product</a> function computes the product of the numbers of a
°5ustructure.
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
°5usuccessive reduced values from the left:
°5u
°5u<pre>
°5uscanl f z [x1, x2, ...] == [z, z `f` x1, (z `f` x1) `f` x2, ...]
°5u</pre>
°5u
°5uNote that
°5u
°5u<pre>
°5ulast (scanl f z xs) == foldl f z xs.
°5u</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
°5uargument:
°5u
°5u<pre>
°5uscanl1 f [x1, x2, ...] == [x1, x1 `f` x2, ...]
°5u</pre>
scanl1 :: (a -> a -> a) -> [a] -> [a]

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

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

-- | The <a>mapAccumL</a> function behaves like a combination of
°5u<a>fmap</a> and <tt>foldl</tt>; it applies a function to each element
°5uof a structure, passing an accumulating parameter from left to right,
°5uand returning a final value of this accumulator together with the new
°5ustructure.
mapAccumL :: Traversable t => (a -> b -> (a, c)) -> a -> t b -> (a, t c)

-- | The <a>mapAccumR</a> function behaves like a combination of
°5u<a>fmap</a> and <tt>foldr</tt>; it applies a function to each element
°5uof a structure, passing an accumulating parameter from right to left,
°5uand returning a final value of this accumulator together with the new
°5ustructure.
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
°5uapplications of <tt>f</tt> to <tt>x</tt>:
°5u
°5u<pre>
°5uiterate f x == [x, f x, f (f x), ...]
°5u</pre>
°5u
°5uNote that <a>iterate</a> is lazy, potentially leading to thunk
°5ubuild-up if the consumer doesn't force each iterate. See 'iterate\''
°5ufor a strict variant of this function.
iterate :: (a -> a) -> a -> [a]

-- | 'iterate\'' is the strict version of <a>iterate</a>.
°5u
°5uIt ensures that the result of each application of force to weak head
°5unormal form before proceeding.
iterate' :: (a -> a) -> a -> [a]

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

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

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

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

-- | <a>take</a> <tt>n</tt>, applied to a list <tt>xs</tt>, returns the
°5uprefix of <tt>xs</tt> of length <tt>n</tt>, or <tt>xs</tt> itself if
°5u<tt>n &gt; <a>length</a> xs</tt>:
°5u
°5u<pre>
°5utake 5 "Hello World!" == "Hello"
°5utake 3 [1,2,3,4,5] == [1,2,3]
°5utake 3 [1,2] == [1,2]
°5utake 3 [] == []
°5utake (-1) [1,2] == []
°5utake 0 [1,2] == []
°5u</pre>
°5u
°5uIt is an instance of the more general <a>genericTake</a>, in which
°5u<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
°5ufirst <tt>n</tt> elements, or <tt>[]</tt> if <tt>n &gt; <a>length</a>
°5uxs</tt>:
°5u
°5u<pre>
°5udrop 6 "Hello World!" == "World!"
°5udrop 3 [1,2,3,4,5] == [4,5]
°5udrop 3 [1,2] == []
°5udrop 3 [] == []
°5udrop (-1) [1,2] == [1,2]
°5udrop 0 [1,2] == [1,2]
°5u</pre>
°5u
°5uIt is an instance of the more general <a>genericDrop</a>, in which
°5u<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
°5u<tt>xs</tt> prefix of length <tt>n</tt> and second element is the
°5uremainder of the list:
°5u
°5u<pre>
°5usplitAt 6 "Hello World!" == ("Hello ","World!")
°5usplitAt 3 [1,2,3,4,5] == ([1,2,3],[4,5])
°5usplitAt 1 [1,2,3] == ([1],[2,3])
°5usplitAt 3 [1,2,3] == ([1,2,3],[])
°5usplitAt 4 [1,2,3] == ([1,2,3],[])
°5usplitAt 0 [1,2,3] == ([],[1,2,3])
°5usplitAt (-1) [1,2,3] == ([],[1,2,3])
°5u</pre>
°5u
°5uIt is equivalent to <tt>(<a>take</a> n xs, <a>drop</a> n xs)</tt> when
°5u<tt>n</tt> is not <tt>_|_</tt> (<tt>splitAt _|_ xs = _|_</tt>).
°5u<a>splitAt</a> is an instance of the more general
°5u<a>genericSplitAt</a>, in which <tt>n</tt> may be of any integral
°5utype.
splitAt :: Int -> [a] -> ([a], [a])

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

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

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

-- | <a>span</a>, applied to a predicate <tt>p</tt> and a list <tt>xs</tt>,
°5ureturns a tuple where first element is longest prefix (possibly empty)
°5uof <tt>xs</tt> of elements that satisfy <tt>p</tt> and second element
°5uis the remainder of the list:
°5u
°5u<pre>
°5uspan (&lt; 3) [1,2,3,4,1,2,3,4] == ([1,2],[3,4,1,2,3,4])
°5uspan (&lt; 9) [1,2,3] == ([1,2,3],[])
°5uspan (&lt; 0) [1,2,3] == ([],[1,2,3])
°5u</pre>
°5u
°5u<a>span</a> <tt>p xs</tt> is equivalent to <tt>(<a>takeWhile</a> p xs,
°5u<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
°5u<tt>xs</tt>, returns a tuple where first element is longest prefix
°5u(possibly empty) of <tt>xs</tt> of elements that <i>do not satisfy</i>
°5u<tt>p</tt> and second element is the remainder of the list:
°5u
°5u<pre>
°5ubreak (&gt; 3) [1,2,3,4,1,2,3,4] == ([1,2,3],[4,1,2,3,4])
°5ubreak (&lt; 9) [1,2,3] == ([],[1,2,3])
°5ubreak (&gt; 9) [1,2,3] == ([1,2,3],[])
°5u</pre>
°5u
°5u<a>break</a> <tt>p</tt> is equivalent to <tt><a>span</a> (<a>not</a> .
°5up)</tt>.
break :: (a -> Bool) -> [a] -> ([a], [a])

-- | The <a>stripPrefix</a> function drops the given prefix from a list. It
°5ureturns <a>Nothing</a> if the list did not start with the prefix
°5ugiven, or <a>Just</a> the list after the prefix, if it does.
°5u
°5u<pre>
°5u&gt;&gt;&gt; stripPrefix "foo" "foobar"
°5uJust "bar"
°5u</pre>
°5u
°5u<pre>
°5u&gt;&gt;&gt; stripPrefix "foo" "foo"
°5uJust ""
°5u</pre>
°5u
°5u<pre>
°5u&gt;&gt;&gt; stripPrefix "foo" "barfoo"
°5uNothing
°5u</pre>
°5u
°5u<pre>
°5u&gt;&gt;&gt; stripPrefix "foo" "barfoobaz"
°5uNothing
°5u</pre>
stripPrefix :: Eq a => [a] -> [a] -> Maybe [a]

-- | The <a>group</a> function takes a list and returns a list of lists
°5usuch that the concatenation of the result is equal to the argument.
°5uMoreover, each sublist in the result contains only equal elements. For
°5uexample,
°5u
°5u<pre>
°5u&gt;&gt;&gt; group "Mississippi"
°5u["M","i","ss","i","ss","i","pp","i"]
°5u</pre>
°5u
°5uIt is a special case of <a>groupBy</a>, which allows the programmer to
°5usupply their own equality test.
group :: Eq a => [a] -> [[a]]

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

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

-- | The <a>isPrefixOf</a> function takes two lists and returns <a>True</a>
°5uiff the first list is a prefix of the second.
°5u
°5u<pre>
°5u&gt;&gt;&gt; "Hello" `isPrefixOf` "Hello World!"
°5uTrue
°5u</pre>
°5u
°5u<pre>
°5u&gt;&gt;&gt; "Hello" `isPrefixOf` "Wello Horld!"
°5uFalse
°5u</pre>
isPrefixOf :: (Eq a) => [a] -> [a] -> Bool

-- | The <a>isSuffixOf</a> function takes two lists and returns <a>True</a>
°5uiff the first list is a suffix of the second. The second list must be
°5ufinite.
°5u
°5u<pre>
°5u&gt;&gt;&gt; "ld!" `isSuffixOf` "Hello World!"
°5uTrue
°5u</pre>
°5u
°5u<pre>
°5u&gt;&gt;&gt; "World" `isSuffixOf` "Hello World!"
°5uFalse
°5u</pre>
isSuffixOf :: (Eq a) => [a] -> [a] -> Bool

-- | The <a>isInfixOf</a> function takes two lists and returns <a>True</a>
°5uiff the first list is contained, wholly and intact, anywhere within
°5uthe second.
°5u
°5u<pre>
°5u&gt;&gt;&gt; isInfixOf "Haskell" "I really like Haskell."
°5uTrue
°5u</pre>
°5u
°5u<pre>
°5u&gt;&gt;&gt; isInfixOf "Ial" "I really like Haskell."
°5uFalse
°5u</pre>
isInfixOf :: (Eq a) => [a] -> [a] -> Bool

-- | The <a>isSubsequenceOf</a> function takes two lists and returns
°5u<a>True</a> if all the elements of the first list occur, in order, in
°5uthe second. The elements do not have to occur consecutively.
°5u
°5u<tt><a>isSubsequenceOf</a> x y</tt> is equivalent to <tt><a>elem</a> x
°5u(<a>subsequences</a> y)</tt>.
°5u
°5u<h4><b>Examples</b></h4>
°5u
°5u<pre>
°5u&gt;&gt;&gt; isSubsequenceOf "GHC" "The Glorious Haskell Compiler"
°5uTrue
°5u
°5u&gt;&gt;&gt; isSubsequenceOf ['a','d'..'z'] ['a'..'z']
°5uTrue
°5u
°5u&gt;&gt;&gt; isSubsequenceOf [1..10] [10,9..0]
°5uFalse
°5u</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
°5ulist.
lookup :: (Eq a) => a -> [(a, b)] -> Maybe b

-- | The <a>find</a> function takes a predicate and a structure and returns
°5uthe leftmost element of the structure matching the predicate, or
°5u<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
°5uthose elements that satisfy the predicate; i.e.,
°5u
°5u<pre>
°5ufilter p xs = [ x | x &lt;- xs, p x]
°5u</pre>
filter :: (a -> Bool) -> [a] -> [a]

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

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

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

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

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

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

-- | <a>zip</a> takes two lists and returns a list of corresponding pairs.
°5uIf one input list is short, excess elements of the longer list are
°5udiscarded.
°5u
°5u<a>zip</a> is right-lazy:
°5u
°5u<pre>
°5uzip [] _|_ = []
°5u</pre>
zip :: [a] -> [b] -> [(a, b)]

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

-- | The <a>zip4</a> function takes four lists and returns a list of
°5uquadruples, 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
°5ufive-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
°5usix-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
°5useven-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
°5ugiven as the first argument, instead of a tupling function. For
°5uexample, <tt><a>zipWith</a> (+)</tt> is applied to two lists to
°5uproduce the list of corresponding sums.
°5u
°5u<a>zipWith</a> is right-lazy:
°5u
°5u<pre>
°5uzipWith f [] _|_ = []
°5u</pre>
zipWith :: (a -> b -> c) -> [a] -> [b] -> [c]

-- | The <a>zipWith3</a> function takes a function which combines three
°5uelements, as well as three lists and returns a list of their
°5upoint-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
°5uelements, as well as four lists and returns a list of their point-wise
°5ucombination, 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
°5uelements, as well as five lists and returns a list of their point-wise
°5ucombination, 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
°5uelements, as well as six lists and returns a list of their point-wise
°5ucombination, 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
°5uelements, as well as seven lists and returns a list of their
°5upoint-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
°5ucomponents and a list of second components.
unzip :: [(a, b)] -> ([a], [b])

-- | The <a>unzip3</a> function takes a list of triples and returns three
°5ulists, 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
°5ulists, 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
°5ufive 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
°5ulists, 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
°5useven 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
°5ucharacters. The resulting strings do not contain newlines.
°5u
°5uNote that after splitting the string at newline characters, the last
°5upart of the string is considered a line even if it doesn't end with a
°5unewline. For example,
°5u
°5u<pre>
°5u&gt;&gt;&gt; lines ""
°5u[]
°5u</pre>
°5u
°5u<pre>
°5u&gt;&gt;&gt; lines "\n"
°5u[""]
°5u</pre>
°5u
°5u<pre>
°5u&gt;&gt;&gt; lines "one"
°5u["one"]
°5u</pre>
°5u
°5u<pre>
°5u&gt;&gt;&gt; lines "one\n"
°5u["one"]
°5u</pre>
°5u
°5u<pre>
°5u&gt;&gt;&gt; lines "one\n\n"
°5u["one",""]
°5u</pre>
°5u
°5u<pre>
°5u&gt;&gt;&gt; lines "one\ntwo"
°5u["one","two"]
°5u</pre>
°5u
°5u<pre>
°5u&gt;&gt;&gt; lines "one\ntwo\n"
°5u["one","two"]
°5u</pre>
°5u
°5uThus <tt><a>lines</a> s</tt> contains at least as many elements as
°5unewlines in <tt>s</tt>.
lines :: String -> [String]

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

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

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

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

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

-- | The <a>\\</a> function is list difference (non-associative). In the
°5uresult of <tt>xs</tt> <a>\\</a> <tt>ys</tt>, the first occurrence of
°5ueach element of <tt>ys</tt> in turn (if any) has been removed from
°5u<tt>xs</tt>. Thus
°5u
°5u<pre>
°5u(xs ++ ys) \\ xs == ys.
°5u</pre>
°5u
°5u<pre>
°5u&gt;&gt;&gt; "Hello World!" \\ "ell W"
°5u"Hoorld!"
°5u</pre>
°5u
°5uIt is a special case of <a>deleteFirstsBy</a>, which allows the
°5uprogrammer 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
°5uexample,
°5u
°5u<pre>
°5u&gt;&gt;&gt; "dog" `union` "cow"
°5u"dogcw"
°5u</pre>
°5u
°5uDuplicates, and elements of the first list, are removed from the the
°5usecond list, but if the first list contains duplicates, so will the
°5uresult. It is a special case of <a>unionBy</a>, which allows the
°5uprogrammer to supply their own equality test.
union :: (Eq a) => [a] -> [a] -> [a]

-- | The <a>intersect</a> function takes the list intersection of two
°5ulists. For example,
°5u
°5u<pre>
°5u&gt;&gt;&gt; [1,2,3,4] `intersect` [2,4,6,8]
°5u[2,4]
°5u</pre>
°5u
°5uIf the first list contains duplicates, so will the result.
°5u
°5u<pre>
°5u&gt;&gt;&gt; [1,2,2,3,4] `intersect` [6,4,4,2]
°5u[2,2,4]
°5u</pre>
°5u
°5uIt is a special case of <a>intersectBy</a>, which allows the
°5uprogrammer to supply their own equality test. If the element is found
°5uin both the first and the second list, the element from the first list
°5uwill be used.
intersect :: (Eq a) => [a] -> [a] -> [a]

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

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

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

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

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

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

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

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

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

-- | The <a>sortBy</a> function is the non-overloaded version of
°5u<a>sort</a>.
°5u
°5u<pre>
°5u&gt;&gt;&gt; sortBy (\(a,_) (b,_) -&gt; compare a b) [(2, "world"), (4, "!"), (1, "Hello")]
°5u[(1,"Hello"),(2,"world"),(4,"!")]
°5u</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
°5ucomparison function.
maximumBy :: Foldable t => (a -> a -> Ordering) -> t a -> a

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

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

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

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

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

-- | The <a>genericIndex</a> function is an overloaded version of
°5u<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
°5u<a>replicate</a>, which accepts any <a>Integral</a> value as the
°5unumber of repetitions to make.
genericReplicate :: (Integral i) => i -> a -> [a]


-- | Functions for tracing and monitoring execution.
°5u
°5uThese can be useful for investigating bugs or performance problems.
°5uThey 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
°5uargument, before returning the second argument as its result.
°5u
°5uFor example, this returns the value of <tt>f x</tt> but first outputs
°5uthe message.
°5u
°5u<pre>
°5u&gt;&gt;&gt; let x = 123; f = show
°5u
°5u&gt;&gt;&gt; trace ("calling f with x = " ++ show x) (f x)
°5u"calling f with x = 123
°5u123"
°5u</pre>
°5u
°5uThe <a>trace</a> function should <i>only</i> be used for debugging, or
°5ufor monitoring execution. The function is not referentially
°5utransparent: its type indicates that it is a pure function but it has
°5uthe side effect of outputting the trace message.
trace :: String -> a -> a

-- | Like <a>trace</a> but returns the message instead of a third value.
°5u
°5u<pre>
°5u&gt;&gt;&gt; traceId "hello"
°5u"hello
°5uhello"
°5u</pre>
traceId :: String -> String

-- | Like <a>trace</a>, but uses <a>show</a> on the argument to convert it
°5uto a <a>String</a>.
°5u
°5uThis makes it convenient for printing the values of interesting
°5uvariables or expressions inside a function. For example here we print
°5uthe value of the variables <tt>x</tt> and <tt>y</tt>:
°5u
°5u<pre>
°5u&gt;&gt;&gt; let f x y = traceShow (x,y) (x + y) in f (1+2) 5
°5u(3,5)
°5u8
°5u</pre>
traceShow :: Show a => a -> b -> b

-- | Like <a>traceShow</a> but returns the shown value instead of a third
°5uvalue.
°5u
°5u<pre>
°5u&gt;&gt;&gt; traceShowId (1+2+3, "hello" ++ "world")
°5u(6,"helloworld")
°5u(6,"helloworld")
°5u</pre>
traceShowId :: Show a => a -> a

-- | like <a>trace</a>, but additionally prints a call stack if one is
°5uavailable.
°5u
°5uIn the current GHC implementation, the call stack is only available if
°5uthe program was compiled with <tt>-prof</tt>; otherwise
°5u<a>traceStack</a> behaves exactly like <a>trace</a>. Entries in the
°5ucall stack correspond to <tt>SCC</tt> annotations, so it is a good
°5uidea to use <tt>-fprof-auto</tt> or <tt>-fprof-auto-calls</tt> to add
°5uSCC annotations automatically.
traceStack :: String -> a -> a

-- | The <a>traceIO</a> function outputs the trace message from the IO
°5umonad. This sequences the output with respect to other IO actions.
traceIO :: String -> IO ()

-- | Like <a>trace</a> but returning unit in an arbitrary
°5u<a>Applicative</a> context. Allows for convenient use in do-notation.
°5u
°5uNote that the application of <a>traceM</a> is not an action in the
°5u<a>Applicative</a> context, as <a>traceIO</a> is in the <a>IO</a>
°5utype. While the fresh bindings in the following example will force the
°5u<a>traceM</a> expressions to be reduced every time the
°5u<tt>do</tt>-block is executed, <tt>traceM "not crashed"</tt> would
°5uonly be reduced once, and the message would only be printed once. If
°5uyour monad is in <tt>MonadIO</tt>, <tt>liftIO . traceIO</tt> may be a
°5ubetter option.
°5u
°5u<pre>
°5u&gt;&gt;&gt; :{
°5udo
°5u    x &lt;- Just 3
°5u    traceM ("x: " ++ show x)
°5u    y &lt;- pure 12
°5u    traceM ("y: " ++ show y)
°5u    pure (x*2 + y)
°5u:}
°5ux: 3
°5uy: 12
°5uJust 18
°5u</pre>
traceM :: Applicative f => String -> f ()

-- | Like <a>traceM</a>, but uses <a>show</a> on the argument to convert it
°5uto a <a>String</a>.
°5u
°5u<pre>
°5u&gt;&gt;&gt; :{
°5udo
°5u    x &lt;- Just 3
°5u    traceShowM x
°5u    y &lt;- pure 12
°5u    traceShowM y
°5u    pure (x*2 + y)
°5u:}
°5u3
°5u12
°5uJust 18
°5u</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
°5udifference that the message is emitted to the eventlog, if eventlog
°5uprofiling is available and enabled at runtime.
°5u
°5uIt is suitable for use in pure code. In an IO context use
°5u<a>traceEventIO</a> instead.
°5u
°5uNote that when using GHC's SMP runtime, it is possible (but rare) to
°5uget duplicate events emitted if two CPUs simultaneously evaluate the
°5usame thunk that uses <a>traceEvent</a>.
traceEvent :: String -> a -> a

-- | The <a>traceEventIO</a> function emits a message to the eventlog, if
°5ueventlog profiling is available and enabled at runtime.
°5u
°5uCompared to <a>traceEvent</a>, <a>traceEventIO</a> sequences the event
°5uwith respect to other IO actions.
traceEventIO :: String -> IO ()

-- | The <a>traceMarker</a> function emits a marker to the eventlog, if
°5ueventlog profiling is available and enabled at runtime. The
°5u<tt>String</tt> is the name of the marker. The name is just used in
°5uthe profiling tools to help you keep clear which marker is which.
°5u
°5uThis function is suitable for use in pure code. In an IO context use
°5u<a>traceMarkerIO</a> instead.
°5u
°5uNote that when using GHC's SMP runtime, it is possible (but rare) to
°5uget duplicate events emitted if two CPUs simultaneously evaluate the
°5usame thunk that uses <a>traceMarker</a>.
traceMarker :: String -> a -> a

-- | The <a>traceMarkerIO</a> function emits a marker to the eventlog, if
°5ueventlog profiling is available and enabled at runtime.
°5u
°5uCompared to <a>traceMarker</a>, <a>traceMarkerIO</a> sequences the
°5uevent 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
°5uare values of type <a>String</a>.
type String = [Char]

-- | Class for string-like datastructures; used by the overloaded string
°5uextension (-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
°5ucharacters. The resulting strings do not contain newlines.
°5u
°5uNote that after splitting the string at newline characters, the last
°5upart of the string is considered a line even if it doesn't end with a
°5unewline. For example,
°5u
°5u<pre>
°5u&gt;&gt;&gt; lines ""
°5u[]
°5u</pre>
°5u
°5u<pre>
°5u&gt;&gt;&gt; lines "\n"
°5u[""]
°5u</pre>
°5u
°5u<pre>
°5u&gt;&gt;&gt; lines "one"
°5u["one"]
°5u</pre>
°5u
°5u<pre>
°5u&gt;&gt;&gt; lines "one\n"
°5u["one"]
°5u</pre>
°5u
°5u<pre>
°5u&gt;&gt;&gt; lines "one\n\n"
°5u["one",""]
°5u</pre>
°5u
°5u<pre>
°5u&gt;&gt;&gt; lines "one\ntwo"
°5u["one","two"]
°5u</pre>
°5u
°5u<pre>
°5u&gt;&gt;&gt; lines "one\ntwo\n"
°5u["one","two"]
°5u</pre>
°5u
°5uThus <tt><a>lines</a> s</tt> contains at least as many elements as
°5unewlines in <tt>s</tt>.
lines :: String -> [String]

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

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

-- | <a>unwords</a> is an inverse operation to <a>words</a>. It joins words
°5uwith separating spaces.
°5u
°5u<pre>
°5u&gt;&gt;&gt; unwords ["Lorem", "ipsum", "dolor"]
°5u"Lorem ipsum dolor"
°5u</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.
°5u
°5uVersioning schemes are many and varied, so the version representation
°5uprovided by this library is intended to be a compromise between
°5ucomplete generality, where almost no common functionality could
°5ureasonably be provided, and fixing a particular versioning scheme,
°5uwhich would probably be too restrictive.
°5u
°5uSo the approach taken here is to provide a representation which
°5usubsumes many of the versioning schemes commonly in use, and we
°5uprovide implementations of <a>Eq</a>, <a>Ord</a> and conversion
°5uto/from <a>String</a> which will be appropriate for some applications,
°5ubut not all.
module Data.Version

-- | A <a>Version</a> represents the version of a software entity.
°5u
°5uAn instance of <a>Eq</a> is provided, which implements exact equality
°5umodulo reordering of the tags in the <a>versionTags</a> field.
°5u
°5uAn instance of <a>Ord</a> is also provided, which gives lexicographic
°5uordering on the <a>versionBranch</a> fields (i.e. 2.1 &gt; 2.0, 1.2.3
°5u&gt; 1.2.2, etc.). This is expected to be sufficient for many uses,
°5ubut note that you may need to use a more specific ordering for your
°5uversioning scheme. For example, some versioning schemes may include
°5upre-releases which have tags <tt>"pre1"</tt>, <tt>"pre2"</tt>, and so
°5uon, and these would need to be taken into account when determining
°5uordering. In some cases, date ordering may be more appropriate, so the
°5uapplication would have to look for <tt>date</tt> tags in the
°5u<a>versionTags</a> field and compare those. The bottom line is, don't
°5ualways assume that <a>compare</a> and other <a>Ord</a> operations are
°5uthe right thing for every <a>Version</a>.
°5u
°5uSimilarly, concrete representations of versions may differ. One
°5upossible concrete representation is provided (see <a>showVersion</a>
°5uand <a>parseVersion</a>), but depending on the application a different
°5uconcrete representation may be more appropriate.
data Version
Version :: [Int] -> [String] -> Version

-- | The numeric branch for this version. This reflects the fact that most
°5usoftware versions are tree-structured; there is a main trunk which is
°5utagged with versions at various points (1,2,3...), and the first
°5ubranch off the trunk after version 3 is 3.1, the second branch off the
°5utrunk after version 3 is 3.2, and so on. The tree can be branched
°5uarbitrarily, just by adding more digits.
°5u
°5uWe represent the branch as a list of <a>Int</a>, so version 3.2.1
°5ubecomes [3,2,1]. Lexicographic ordering (i.e. the default instance of
°5u<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
°5uinterpretation of the list of tags is entirely dependent on the entity
°5uthat this version applies to.

-- | <i>Deprecated: See GHC ticket #2496</i>
[versionTags] :: Version -> [String]

-- | Provides one possible concrete representation for <a>Version</a>. For
°5ua version with <a>versionBranch</a> <tt>= [1,2,3]</tt> and
°5u<a>versionTags</a> <tt>= ["tag1","tag2"]</tt>, the output will be
°5u<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
°5usome useful operations on monads.
module Control.Monad

-- | The <a>Functor</a> class is used for types that can be mapped over.
°5uInstances of <a>Functor</a> should satisfy the following laws:
°5u
°5u<pre>
°5ufmap id  ==  id
°5ufmap (f . g)  ==  fmap f . fmap g
°5u</pre>
°5u
°5uThe instances of <a>Functor</a> for lists, <a>Maybe</a> and <a>IO</a>
°5usatisfy 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
°5u<i>monad</i>, a concept from a branch of mathematics known as
°5u<i>category theory</i>. From the perspective of a Haskell programmer,
°5uhowever, it is best to think of a monad as an <i>abstract datatype</i>
°5uof actions. Haskell's <tt>do</tt> expressions provide a convenient
°5usyntax for writing monadic expressions.
°5u
°5uInstances of <a>Monad</a> should satisfy the following laws:
°5u
°5u<ul>
°5u<li><pre><a>return</a> a <a>&gt;&gt;=</a> k = k a</pre></li>
°5u<li><pre>m <a>&gt;&gt;=</a> <a>return</a> = m</pre></li>
°5u<li><pre>m <a>&gt;&gt;=</a> (\x -&gt; k x <a>&gt;&gt;=</a> h) = (m
°5u<a>&gt;&gt;=</a> k) <a>&gt;&gt;=</a> h</pre></li>
°5u</ul>
°5u
°5uFurthermore, the <a>Monad</a> and <a>Applicative</a> operations should
°5urelate as follows:
°5u
°5u<ul>
°5u<li><pre><a>pure</a> = <a>return</a></pre></li>
°5u<li><pre>(<a>&lt;*&gt;</a>) = <a>ap</a></pre></li>
°5u</ul>
°5u
°5uThe above laws imply:
°5u
°5u<ul>
°5u<li><pre><a>fmap</a> f xs = xs <a>&gt;&gt;=</a> <a>return</a> .
°5uf</pre></li>
°5u<li><pre>(<a>&gt;&gt;</a>) = (<a>*&gt;</a>)</pre></li>
°5u</ul>
°5u
°5uand that <a>pure</a> and (<a>&lt;*&gt;</a>) satisfy the applicative
°5ufunctor laws.
°5u
°5uThe instances of <a>Monad</a> for lists, <a>Maybe</a> and <a>IO</a>
°5udefined in the <a>Prelude</a> satisfy these laws.
class Applicative m => Monad m

-- | Sequentially compose two actions, passing any value produced by the
°5ufirst 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
°5ufirst, like sequencing operators (such as the semicolon) in imperative
°5ulanguages.
(>>) :: 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
°5udefinition of a monad, but is invoked on pattern-match failure in a
°5u<tt>do</tt> expression.
°5u
°5uAs part of the MonadFail proposal (MFP), this function is moved to its
°5uown class <tt>MonadFail</tt> (see <a>Control.Monad.Fail</a> for more
°5udetails). 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
°5u
°5u<pre>
°5umzero &gt;&gt;= f  =  mzero
°5uv &gt;&gt; mzero   =  mzero
°5u</pre>
°5u
°5uThe default definition is
°5u
°5u<pre>
°5umzero = <a>empty</a>
°5u</pre>
mzero :: MonadPlus m => m a

-- | An associative operation. The default definition is
°5u
°5u<pre>
°5umplus = (<a>&lt;|&gt;</a>)
°5u</pre>
mplus :: MonadPlus m => m a -> m a -> m a

-- | Map each element of a structure to a monadic action, evaluate these
°5uactions from left to right, and collect the results. For a version
°5uthat 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
°5uactions from left to right, and ignore the results. For a version that
°5udoesn't ignore the results see <a>mapM</a>.
°5u
°5uAs of base 4.8.0.0, <a>mapM_</a> is just <a>traverse_</a>, specialized
°5uto <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
°5uthat 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
°5uthat doesn't ignore the results see <a>forM</a>.
°5u
°5uAs of base 4.8.0.0, <a>forM_</a> is just <a>for_</a>, specialized to
°5u<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
°5ucollect the results. For a version that ignores the results see
°5u<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
°5uignore the results. For a version that doesn't ignore the results see
°5u<a>sequence</a>.
°5u
°5uAs of base 4.8.0.0, <a>sequence_</a> is just <a>sequenceA_</a>,
°5uspecialized 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.
°5u<tt>(<a>&gt;=&gt;</a>)</tt>, with the arguments flipped.
°5u
°5uNote how this operator resembles function composition
°5u<tt>(<a>.</a>)</tt>:
°5u
°5u<pre>
°5u(.)   ::            (b -&gt;   c) -&gt; (a -&gt;   b) -&gt; a -&gt;   c
°5u(&lt;=&lt;) :: Monad m =&gt; (b -&gt; m c) -&gt; (a -&gt; m b) -&gt; a -&gt; m c
°5u</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
°5uevaluation, such as the return value of an <a>IO</a> action.
°5u
°5u<h4><b>Examples</b></h4>
°5u
°5uReplace the contents of a <tt><tt>Maybe</tt> <tt>Int</tt></tt> with
°5uunit:
°5u
°5u<pre>
°5u&gt;&gt;&gt; void Nothing
°5uNothing
°5u
°5u&gt;&gt;&gt; void (Just 3)
°5uJust ()
°5u</pre>
°5u
°5uReplace the contents of an <tt><tt>Either</tt> <tt>Int</tt>
°5u<tt>Int</tt></tt> with unit, resulting in an <tt><tt>Either</tt>
°5u<tt>Int</tt> '()'</tt>:
°5u
°5u<pre>
°5u&gt;&gt;&gt; void (Left 8675309)
°5uLeft 8675309
°5u
°5u&gt;&gt;&gt; void (Right 8675309)
°5uRight ()
°5u</pre>
°5u
°5uReplace every element of a list with unit:
°5u
°5u<pre>
°5u&gt;&gt;&gt; void [1,2,3]
°5u[(),(),()]
°5u</pre>
°5u
°5uReplace the second element of a pair with unit:
°5u
°5u<pre>
°5u&gt;&gt;&gt; void (1,2)
°5u(1,())
°5u</pre>
°5u
°5uDiscard the result of an <a>IO</a> action:
°5u
°5u<pre>
°5u&gt;&gt;&gt; mapM print [1,2]
°5u1
°5u2
°5u[(),()]
°5u
°5u&gt;&gt;&gt; void $ mapM print [1,2]
°5u1
°5u2
°5u</pre>
void :: Functor f => f a -> f ()

-- | The <a>join</a> function is the conventional monad join operator. It
°5uis used to remove one level of monadic structure, projecting its bound
°5uargument 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
°5ubase 4.8.0.0, <a>msum</a> is just <a>asum</a>, specialized to
°5u<a>MonadPlus</a>.
msum :: (Foldable t, MonadPlus m) => t (m a) -> m a

-- | Direct <a>MonadPlus</a> equivalent of <tt>filter</tt>
°5u<tt><tt>filter</tt></tt> = <tt>(mfilter:: (a -&gt; Bool) -&gt; [a]
°5u-&gt; [a]</tt> applicable to any <a>MonadPlus</a>, for example
°5u<tt>mfilter odd (Just 1) == Just 1</tt> <tt>mfilter odd (Just 2) ==
°5uNothing</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,
°5ureturning the result as a pair of lists. This function is mainly used
°5uwith 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
°5uapplicative 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
°5ufinal result.
zipWithM_ :: (Applicative m) => (a -> b -> m c) -> [a] -> [b] -> m ()

-- | The <a>foldM</a> function is analogous to <tt>foldl</tt>, except that
°5uits result is encapsulated in a monad. Note that <a>foldM</a> works
°5ufrom left-to-right over the list arguments. This could be an issue
°5uwhere <tt>(<a>&gt;&gt;</a>)</tt> and the `folded function' are not
°5ucommutative.
°5u
°5u<pre>
°5ufoldM f a1 [x1, x2, ..., xm]
°5u
°5u==
°5u
°5udo
°5u  a2 &lt;- f a1 x1
°5u  a3 &lt;- f a2 x2
°5u  ...
°5u  f am xm
°5u</pre>
°5u
°5uIf right-to-left evaluation is required, the input list should be
°5ureversed.
°5u
°5uNote: <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,
°5ugathering 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
°5u
°5u<pre>
°5uguard True  = <a>pure</a> ()
°5uguard False = <a>empty</a>
°5u</pre>
°5u
°5u<h4><b>Examples</b></h4>
°5u
°5uCommon uses of <a>guard</a> include conditionally signaling an error
°5uin an error monad and conditionally rejecting the current choice in an
°5u<a>Alternative</a>-based parser.
°5u
°5uAs an example of signaling an error in the error monad <a>Maybe</a>,
°5uconsider a safe division function <tt>safeDiv x y</tt> that returns
°5u<a>Nothing</a> when the denominator <tt>y</tt> is zero and
°5u<tt><a>Just</a> (x `div` y)</tt> otherwise. For example:
°5u
°5u<pre>
°5u&gt;&gt;&gt; safeDiv 4 0
°5uNothing
°5u&gt;&gt;&gt; safeDiv 4 2
°5uJust 2
°5u</pre>
°5u
°5uA definition of <tt>safeDiv</tt> using guards, but not <a>guard</a>:
°5u
°5u<pre>
°5usafeDiv :: Int -&gt; Int -&gt; Maybe Int
°5usafeDiv x y | y /= 0    = Just (x `div` y)
°5u            | otherwise = Nothing
°5u</pre>
°5u
°5uA definition of <tt>safeDiv</tt> using <a>guard</a> and <a>Monad</a>
°5u<tt>do</tt>-notation:
°5u
°5u<pre>
°5usafeDiv :: Int -&gt; Int -&gt; Maybe Int
°5usafeDiv x y = do
°5u  guard (y /= 0)
°5u  return (x `div` y)
°5u</pre>
guard :: (Alternative f) => Bool -> f ()

-- | Conditional execution of <a>Applicative</a> expressions. For example,
°5u
°5u<pre>
°5uwhen debug (putStrLn "Debugging")
°5u</pre>
°5u
°5uwill output the string <tt>Debugging</tt> if the Boolean value
°5u<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
°5uleft to right. For example,
°5u
°5u<pre>
°5uliftM2 (+) [0,1] [0,2] = [0,2,1,3]
°5uliftM2 (+) (Just 1) Nothing = Nothing
°5u</pre>
liftM2 :: (Monad m) => (a1 -> a2 -> r) -> m a1 -> m a2 -> m r

-- | Promote a function to a monad, scanning the monadic arguments from
°5uleft 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
°5uleft 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
°5uleft 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
°5uuses of <a>ap</a>, which promotes function application.
°5u
°5u<pre>
°5ureturn f `ap` x1 `ap` ... `ap` xn
°5u</pre>
°5u
°5uis equivalent to
°5u
°5u<pre>
°5uliftMn f x1 x2 ... xn
°5u</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
°5uinto all Haskell modules unless either there is an explicit import
°5ustatement 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
°5uguards more readable. eg.
°5u
°5u<pre>
°5uf x | x &lt; 0     = ...
°5u    | otherwise = ...
°5u</pre>
otherwise :: Bool

-- | The <a>Maybe</a> type encapsulates an optional value. A value of type
°5u<tt><a>Maybe</a> a</tt> either contains a value of type <tt>a</tt>
°5u(represented as <tt><a>Just</a> a</tt>), or it is empty (represented
°5uas <a>Nothing</a>). Using <a>Maybe</a> is a good way to deal with
°5uerrors or exceptional cases without resorting to drastic measures such
°5uas <a>error</a>.
°5u
°5uThe <a>Maybe</a> type is also a monad. It is a simple kind of error
°5umonad, where all errors are represented by <a>Nothing</a>. A richer
°5uerror 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
°5u<a>Maybe</a> value. If the <a>Maybe</a> value is <a>Nothing</a>, the
°5ufunction returns the default value. Otherwise, it applies the function
°5uto the value inside the <a>Just</a> and returns the result.
°5u
°5u<h4><b>Examples</b></h4>
°5u
°5uBasic usage:
°5u
°5u<pre>
°5u&gt;&gt;&gt; maybe False odd (Just 3)
°5uTrue
°5u</pre>
°5u
°5u<pre>
°5u&gt;&gt;&gt; maybe False odd Nothing
°5uFalse
°5u</pre>
°5u
°5uRead an integer from a string using <tt>readMaybe</tt>. If we succeed,
°5ureturn twice the integer; that is, apply <tt>(*2)</tt> to it. If
°5uinstead we fail to parse an integer, return <tt>0</tt> by default:
°5u
°5u<pre>
°5u&gt;&gt;&gt; import Text.Read ( readMaybe )
°5u
°5u&gt;&gt;&gt; maybe 0 (*2) (readMaybe "5")
°5u10
°5u
°5u&gt;&gt;&gt; maybe 0 (*2) (readMaybe "")
°5u0
°5u</pre>
°5u
°5uApply <tt>show</tt> to a <tt>Maybe Int</tt>. If we have <tt>Just
°5un</tt>, we want to show the underlying <a>Int</a> <tt>n</tt>. But if
°5uwe have <a>Nothing</a>, we return the empty string instead of (for
°5uexample) "Nothing":
°5u
°5u<pre>
°5u&gt;&gt;&gt; maybe "" show (Just 5)
°5u"5"
°5u
°5u&gt;&gt;&gt; maybe "" show Nothing
°5u""
°5u</pre>
maybe :: b -> (a -> b) -> Maybe a -> b

-- | The <a>Either</a> type represents values with two possibilities: a
°5uvalue of type <tt><a>Either</a> a b</tt> is either <tt><a>Left</a>
°5ua</tt> or <tt><a>Right</a> b</tt>.
°5u
°5uThe <a>Either</a> type is sometimes used to represent a value which is
°5ueither correct or an error; by convention, the <a>Left</a> constructor
°5uis used to hold an error value and the <a>Right</a> constructor is
°5uused to hold a correct value (mnemonic: "right" also means "correct").
°5u
°5u<h4><b>Examples</b></h4>
°5u
°5uThe type <tt><a>Either</a> <a>String</a> <a>Int</a></tt> is the type
°5uof values which can be either a <a>String</a> or an <a>Int</a>. The
°5u<a>Left</a> constructor can be used only on <a>String</a>s, and the
°5u<a>Right</a> constructor can be used only on <a>Int</a>s:
°5u
°5u<pre>
°5u&gt;&gt;&gt; let s = Left "foo" :: Either String Int
°5u
°5u&gt;&gt;&gt; s
°5uLeft "foo"
°5u
°5u&gt;&gt;&gt; let n = Right 3 :: Either String Int
°5u
°5u&gt;&gt;&gt; n
°5uRight 3
°5u
°5u&gt;&gt;&gt; :type s
°5us :: Either String Int
°5u
°5u&gt;&gt;&gt; :type n
°5un :: Either String Int
°5u</pre>
°5u
°5uThe <a>fmap</a> from our <a>Functor</a> instance will ignore
°5u<a>Left</a> values, but will apply the supplied function to values
°5ucontained in a <a>Right</a>:
°5u
°5u<pre>
°5u&gt;&gt;&gt; let s = Left "foo" :: Either String Int
°5u
°5u&gt;&gt;&gt; let n = Right 3 :: Either String Int
°5u
°5u&gt;&gt;&gt; fmap (*2) s
°5uLeft "foo"
°5u
°5u&gt;&gt;&gt; fmap (*2) n
°5uRight 6
°5u</pre>
°5u
°5uThe <a>Monad</a> instance for <a>Either</a> allows us to chain
°5utogether multiple actions which may fail, and fail overall if any of
°5uthe individual steps failed. First we'll write a function that can
°5ueither parse an <a>Int</a> from a <a>Char</a>, or fail.
°5u
°5u<pre>
°5u&gt;&gt;&gt; import Data.Char ( digitToInt, isDigit )
°5u
°5u&gt;&gt;&gt; :{
°5u    let parseEither :: Char -&gt; Either String Int
°5u        parseEither c
°5u          | isDigit c = Right (digitToInt c)
°5u          | otherwise = Left "parse error"
°5u
°5u&gt;&gt;&gt; :}
°5u</pre>
°5u
°5uThe following should work, since both <tt>'1'</tt> and <tt>'2'</tt>
°5ucan be parsed as <a>Int</a>s.
°5u
°5u<pre>
°5u&gt;&gt;&gt; :{
°5u    let parseMultiple :: Either String Int
°5u        parseMultiple = do
°5u          x &lt;- parseEither '1'
°5u          y &lt;- parseEither '2'
°5u          return (x + y)
°5u
°5u&gt;&gt;&gt; :}
°5u</pre>
°5u
°5u<pre>
°5u&gt;&gt;&gt; parseMultiple
°5uRight 3
°5u</pre>
°5u
°5uBut the following should fail overall, since the first operation where
°5uwe attempt to parse <tt>'m'</tt> as an <a>Int</a> will fail:
°5u
°5u<pre>
°5u&gt;&gt;&gt; :{
°5u    let parseMultiple :: Either String Int
°5u        parseMultiple = do
°5u          x &lt;- parseEither 'm'
°5u          y &lt;- parseEither '2'
°5u          return (x + y)
°5u
°5u&gt;&gt;&gt; :}
°5u</pre>
°5u
°5u<pre>
°5u&gt;&gt;&gt; parseMultiple
°5uLeft "parse error"
°5u</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
°5u<tt><a>Left</a> a</tt>, apply the first function to <tt>a</tt>; if it
°5uis <tt><a>Right</a> b</tt>, apply the second function to <tt>b</tt>.
°5u
°5u<h4><b>Examples</b></h4>
°5u
°5uWe create two values of type <tt><a>Either</a> <a>String</a>
°5u<a>Int</a></tt>, one using the <a>Left</a> constructor and another
°5uusing the <a>Right</a> constructor. Then we apply "either" the
°5u<tt>length</tt> function (if we have a <a>String</a>) or the
°5u"times-two" function (if we have an <a>Int</a>):
°5u
°5u<pre>
°5u&gt;&gt;&gt; let s = Left "foo" :: Either String Int
°5u
°5u&gt;&gt;&gt; let n = Right 3 :: Either String Int
°5u
°5u&gt;&gt;&gt; either length (*2) s
°5u3
°5u
°5u&gt;&gt;&gt; either length (*2) n
°5u6
°5u</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
°5urepresent Unicode (or equivalently ISO/IEC 10646) code points (i.e.
°5ucharacters, see <a>http://www.unicode.org/</a> for details). This set
°5uextends the ISO 8859-1 (Latin-1) character set (the first 256
°5ucharacters), which is itself an extension of the ASCII character set
°5u(the first 128 characters). A character literal in Haskell has type
°5u<a>Char</a>.
°5u
°5uTo convert a <a>Char</a> to or from the corresponding <a>Int</a> value
°5udefined by Unicode, use <a>toEnum</a> and <a>fromEnum</a> from the
°5u<a>Enum</a> class respectively (or equivalently <tt>ord</tt> and
°5u<tt>chr</tt>).
data Char

-- | A <a>String</a> is a list of characters. String constants in Haskell
°5uare 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.
°5u
°5u<h4><b>Examples</b></h4>
°5u
°5u<pre>
°5u&gt;&gt;&gt; curry fst 1 2
°5u1
°5u</pre>
curry :: ((a, b) -> c) -> a -> b -> c

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

-- | The <a>Eq</a> class defines equality (<a>==</a>) and inequality
°5u(<a>/=</a>). All the basic datatypes exported by the <a>Prelude</a>
°5uare instances of <a>Eq</a>, and <a>Eq</a> may be derived for any
°5udatatype whose constituents are also instances of <a>Eq</a>.
°5u
°5uMinimal 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.
°5u
°5uInstances of <a>Ord</a> can be derived for any user-defined datatype
°5uwhose constituent types are in <a>Ord</a>. The declared order of the
°5uconstructors in the data declaration determines the ordering in
°5uderived <a>Ord</a> instances. The <a>Ordering</a> datatype allows a
°5usingle comparison to determine the precise ordering of two objects.
°5u
°5uMinimal complete definition: either <a>compare</a> or <a>&lt;=</a>.
°5uUsing <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.
°5u
°5uThe <tt>enumFrom</tt>... methods are used in Haskell's translation of
°5uarithmetic sequences.
°5u
°5uInstances of <a>Enum</a> may be derived for any enumeration type
°5u(types whose constructors have no fields). The nullary constructors
°5uare assumed to be numbered left-to-right by <a>fromEnum</a> from
°5u<tt>0</tt> through <tt>n-1</tt>. See Chapter 10 of the <i>Haskell
°5uReport</i> for more details.
°5u
°5uFor any type that is an instance of class <a>Bounded</a> as well as
°5u<a>Enum</a>, the following should hold:
°5u
°5u<ul>
°5u<li>The calls <tt><a>succ</a> <a>maxBound</a></tt> and <tt><a>pred</a>
°5u<a>minBound</a></tt> should result in a runtime error.</li>
°5u<li><a>fromEnum</a> and <a>toEnum</a> should give a runtime error if
°5uthe result value is not representable in the result type. For example,
°5u<tt><a>toEnum</a> 7 :: <a>Bool</a></tt> is an error.</li>
°5u<li><a>enumFrom</a> and <a>enumFromThen</a> should be defined with an
°5uimplicit bound, thus:</li>
°5u</ul>
°5u
°5u<pre>
°5uenumFrom     x   = enumFromTo     x maxBound
°5uenumFromThen x y = enumFromThenTo x y bound
°5u  where
°5u    bound | fromEnum y &gt;= fromEnum x = maxBound
°5u          | otherwise                = minBound
°5u</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
°5u1.
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
°5u<a>fromEnum</a> returns when applied to a value that is too large to
°5ufit 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
°5ua type. <a>Ord</a> is not a superclass of <a>Bounded</a> since types
°5uthat are not totally ordered may also have upper and lower bounds.
°5u
°5uThe <a>Bounded</a> class may be derived for any enumeration type;
°5u<a>minBound</a> is the first constructor listed in the <tt>data</tt>
°5udeclaration and <a>maxBound</a> is the last. <a>Bounded</a> may also
°5ube derived for single-constructor datatypes whose constituent types
°5uare in <a>Bounded</a>.
class Bounded a
minBound, maxBound :: Bounded a => a
minBound, maxBound :: Bounded a => a

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

-- | Invariant: <a>Jn#</a> and <a>Jp#</a> are used iff value doesn't fit in
°5u<a>S#</a>
°5u
°5uUseful properties resulting from the invariants:
°5u
°5u<ul>
°5u<li><pre>abs (<a>S#</a> _) &lt;= abs (<a>Jp#</a> _)</pre></li>
°5u<li><pre>abs (<a>S#</a> _) &lt; abs (<a>Jn#</a> _)</pre></li>
°5u</ul>
data Integer

-- | Single-precision floating point numbers. It is desirable that this
°5utype be at least equal in range and precision to the IEEE
°5usingle-precision type.
data Float

-- | Double-precision floating point numbers. It is desirable that this
°5utype be at least equal in range and precision to the IEEE
°5udouble-precision type.
data Double

-- | Arbitrary-precision rational numbers, represented as a ratio of two
°5u<a>Integer</a> values. A rational number may be constructed using the
°5u<a>%</a> operator.
type Rational = Ratio Integer

-- | A <a>Word</a> is an unsigned integral type, with the same size as
°5u<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
°5usatisfy the law:
°5u
°5u<pre>
°5uabs x * signum x == x
°5u</pre>
°5u
°5uFor real numbers, the <a>signum</a> is either <tt>-1</tt> (negative),
°5u<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
°5uapplication of the function <a>fromInteger</a> to the appropriate
°5uvalue of type <a>Integer</a>, so such literals have type
°5u<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
°5u
°5u<pre>
°5u(x `quot` y)*y + (x `rem` y) == x
°5u</pre>
rem :: Integral a => a -> a -> a

-- | integer division truncated toward negative infinity
div :: Integral a => a -> a -> a

-- | integer modulus, satisfying
°5u
°5u<pre>
°5u(x `div` y)*y + (x `mod` y) == x
°5u</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>
°5u<a>Integer</a></tt>). A floating literal stands for an application of
°5u<a>fromRational</a> to a value of type <a>Rational</a>, so such
°5uliterals 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, log, sqrt :: Floating a => a -> a
exp, log, sqrt :: Floating a => a -> a
exp, log, sqrt :: Floating a => a -> a
(**, logBase) :: Floating a => a -> a -> a
(**, logBase) :: Floating a => a -> a -> a
sin, cos, tan :: Floating a => a -> a
sin, cos, tan :: Floating a => a -> a
sin, cos, tan :: Floating a => a -> a
asin, acos, atan :: Floating a => a -> a
asin, acos, atan :: Floating a => a -> a
asin, acos, atan :: Floating a => a -> a
sinh, cosh, tanh :: Floating a => a -> a
sinh, cosh, tanh :: Floating a => a -> a
sinh, cosh, tanh :: Floating a => a -> a
asinh, acosh, atanh :: Floating a => a -> a
asinh, acosh, atanh :: Floating a => a -> a
asinh, acosh, 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
°5u<tt>x</tt> and returns a pair <tt>(n,f)</tt> such that <tt>x =
°5un+f</tt>, and:
°5u
°5u<ul>
°5u<li><tt>n</tt> is an integral number with the same sign as <tt>x</tt>;
°5uand</li>
°5u<li><tt>f</tt> is a fraction with the same type and sign as
°5u<tt>x</tt>, and with absolute value less than <tt>1</tt>.</li>
°5u</ul>
°5u
°5uThe default definitions of the <a>ceiling</a>, <a>floor</a>,
°5u<a>truncate</a> and <a>round</a> functions are in terms of
°5u<a>properFraction</a>.
properFraction :: (RealFrac a, (Integral b)) => a -> (b, a)

-- | <tt><a>truncate</a> x</tt> returns the integer nearest <tt>x</tt>
°5ubetween 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
°5ueven 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
°5u<tt>x</tt>
ceiling :: (RealFrac a, (Integral b)) => a -> b

-- | <tt><a>floor</a> x</tt> returns the greatest integer not greater than
°5u<tt>x</tt>
floor :: (RealFrac a, (Integral b)) => a -> b

-- | Efficient, machine-independent access to the components of a
°5ufloating-point number.
class (RealFrac a, Floating a) => RealFloat a

-- | a constant function, returning the radix of the representation (often
°5u<tt>2</tt>)
floatRadix :: RealFloat a => a -> Integer

-- | a constant function, returning the number of digits of
°5u<a>floatRadix</a> in the significand
floatDigits :: RealFloat a => a -> Int

-- | a constant function, returning the lowest and highest values the
°5uexponent may assume
floatRange :: RealFloat a => a -> (Int, Int)

-- | The function <a>decodeFloat</a> applied to a real floating-point
°5unumber returns the significand expressed as an <a>Integer</a> and an
°5uappropriately scaled exponent (an <a>Int</a>). If
°5u<tt><a>decodeFloat</a> x</tt> yields <tt>(m,n)</tt>, then <tt>x</tt>
°5uis equal in value to <tt>m*b^^n</tt>, where <tt>b</tt> is the
°5ufloating-point radix, and furthermore, either <tt>m</tt> and
°5u<tt>n</tt> are both zero or else <tt>b^(d-1) &lt;= <a>abs</a> m &lt;
°5ub^d</tt>, where <tt>d</tt> is the value of <tt><a>floatDigits</a>
°5ux</tt>. In particular, <tt><a>decodeFloat</a> 0 = (0,0)</tt>. If the
°5utype contains a negative zero, also <tt><a>decodeFloat</a> (-0.0) =
°5u(0,0)</tt>. <i>The result of</i> <tt><a>decodeFloat</a> x</tt> <i>is
°5uunspecified if either of</i> <tt><a>isNaN</a> x</tt> <i>or</i>
°5u<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
°5usense that for finite <tt>x</tt> with the exception of <tt>-0.0</tt>,
°5u<tt><tt>uncurry</tt> <a>encodeFloat</a> (<a>decodeFloat</a> x) =
°5ux</tt>. <tt><a>encodeFloat</a> m n</tt> is one of the two closest
°5urepresentable floating-point numbers to <tt>m*b^^n</tt> (or
°5u<tt>±Infinity</tt> if overflow occurs); usually the closer, but if
°5u<tt>m</tt> contains too many bits, the result may be rounded in the
°5uwrong direction.
encodeFloat :: RealFloat a => Integer -> Int -> a

-- | <a>exponent</a> corresponds to the second component of
°5u<a>decodeFloat</a>. <tt><a>exponent</a> 0 = 0</tt> and for finite
°5unonzero <tt>x</tt>, <tt><a>exponent</a> x = snd (<a>decodeFloat</a> x)
°5u+ <a>floatDigits</a> x</tt>. If <tt>x</tt> is a finite floating-point
°5unumber, it is equal in value to <tt><a>significand</a> x * b ^^
°5u<a>exponent</a> x</tt>, where <tt>b</tt> is the floating-point radix.
°5uThe 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
°5uinterval (<tt>-1</tt>,<tt>1</tt>), either <tt>0.0</tt> or of absolute
°5uvalue <tt>&gt;= 1/b</tt>, where <tt>b</tt> is the floating-point
°5uradix. The behaviour is unspecified on infinite or <tt>NaN</tt>
°5uvalues.
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
°5unormalized 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
°5ureal floating <tt>x</tt> and <tt>y</tt>, <tt><a>atan2</a> y x</tt>
°5ucomputes the angle (from the positive x-axis) of the vector from the
°5uorigin to the point <tt>(x,y)</tt>. <tt><a>atan2</a> y x</tt> returns
°5ua value in the range [<tt>-pi</tt>, <tt>pi</tt>]. It follows the
°5uCommon Lisp semantics for the origin when signed zeroes are supported.
°5u<tt><a>atan2</a> y 1</tt>, with <tt>y</tt> in a type that is
°5u<a>RealFloat</a>, should return the same value as <tt><a>atan</a>
°5uy</tt>. A default definition of <a>atan2</a> is provided, but
°5uimplementors can provide a more accurate implementation.
atan2 :: RealFloat a => a -> a -> a

-- | the same as <tt><a>flip</a> (<a>-</a>)</tt>.
°5u
°5uBecause <tt>-</tt> is treated specially in the Haskell grammar,
°5u<tt>(-</tt> <i>e</i><tt>)</tt> is not a section, but an application of
°5uprefix negation. However, <tt>(<a>subtract</a></tt>
°5u<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>
°5uand <tt>y</tt> of which every common factor of <tt>x</tt> and
°5u<tt>y</tt> is also a factor; for example <tt><a>gcd</a> 4 2 = 2</tt>,
°5u<tt><a>gcd</a> (-4) 6 = 2</tt>, <tt><a>gcd</a> 0 4</tt> = <tt>4</tt>.
°5u<tt><a>gcd</a> 0 0</tt> = <tt>0</tt>. (That is, the common divisor
°5uthat is "greatest" in the divisibility preordering.)
°5u
°5uNote: Since for signed fixed-width integer types, <tt><a>abs</a>
°5u<a>minBound</a> &lt; 0</tt>, the result may be negative if one of the
°5uarguments is <tt><a>minBound</a></tt> (and necessarily is if the other
°5uis <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
°5u<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).
°5u
°5uInstances should satisfy the associativity law:
°5u
°5u<ul>
°5u<li><pre>x <a>&lt;&gt;</a> (y <a>&lt;&gt;</a> z) = (x <a>&lt;&gt;</a>
°5uy) <a>&lt;&gt;</a> z</pre></li>
°5u</ul>
class Semigroup a

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

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

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

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

-- | Fold a list using the monoid.
°5u
°5uFor most types, the default definition for <a>mconcat</a> will be
°5uused, but the function is included in the class definition so that an
°5uoptimized 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.
°5uInstances of <a>Functor</a> should satisfy the following laws:
°5u
°5u<pre>
°5ufmap id  ==  id
°5ufmap (f . g)  ==  fmap f . fmap g
°5u</pre>
°5u
°5uThe instances of <a>Functor</a> for lists, <a>Maybe</a> and <a>IO</a>
°5usatisfy 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
°5udefinition is <tt><a>fmap</a> . <a>const</a></tt>, but this may be
°5uoverridden with a more efficient version.
(<$) :: Functor f => a -> f b -> f a

-- | An infix synonym for <a>fmap</a>.
°5u
°5uThe name of this operator is an allusion to <tt>$</tt>. Note the
°5usimilarities between their types:
°5u
°5u<pre>
°5u ($)  ::              (a -&gt; b) -&gt;   a -&gt;   b
°5u(&lt;$&gt;) :: Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
°5u</pre>
°5u
°5uWhereas <tt>$</tt> is function application, <a>&lt;$&gt;</a> is
°5ufunction application lifted over a <a>Functor</a>.
°5u
°5u<h4><b>Examples</b></h4>
°5u
°5uConvert from a <tt><tt>Maybe</tt> <tt>Int</tt></tt> to a
°5u<tt><tt>Maybe</tt> <tt>String</tt></tt> using <tt>show</tt>:
°5u
°5u<pre>
°5u&gt;&gt;&gt; show &lt;$&gt; Nothing
°5uNothing
°5u
°5u&gt;&gt;&gt; show &lt;$&gt; Just 3
°5uJust "3"
°5u</pre>
°5u
°5uConvert from an <tt><tt>Either</tt> <tt>Int</tt> <tt>Int</tt></tt> to
°5uan <tt><tt>Either</tt> <tt>Int</tt></tt> <tt>String</tt> using
°5u<tt>show</tt>:
°5u
°5u<pre>
°5u&gt;&gt;&gt; show &lt;$&gt; Left 17
°5uLeft 17
°5u
°5u&gt;&gt;&gt; show &lt;$&gt; Right 17
°5uRight "17"
°5u</pre>
°5u
°5uDouble each element of a list:
°5u
°5u<pre>
°5u&gt;&gt;&gt; (*2) &lt;$&gt; [1,2,3]
°5u[2,4,6]
°5u</pre>
°5u
°5uApply <tt>even</tt> to the second element of a pair:
°5u
°5u<pre>
°5u&gt;&gt;&gt; even &lt;$&gt; (2,2)
°5u(2,True)
°5u</pre>
(<$>) :: Functor f => (a -> b) -> f a -> f b
infixl 4 <$>

-- | A functor with application, providing operations to
°5u
°5u<ul>
°5u<li>embed pure expressions (<a>pure</a>), and</li>
°5u<li>sequence computations and combine their results (<a>&lt;*&gt;</a>
°5uand <a>liftA2</a>).</li>
°5u</ul>
°5u
°5uA minimal complete definition must include implementations of
°5u<a>pure</a> and of either <a>&lt;*&gt;</a> or <a>liftA2</a>. If it
°5udefines both, then they must behave the same as their default
°5udefinitions:
°5u
°5u<pre>
°5u(<a>&lt;*&gt;</a>) = <a>liftA2</a> <a>id</a>
°5u</pre>
°5u
°5u<pre>
°5u<a>liftA2</a> f x y = f <tt>&lt;$&gt;</tt> x <a>&lt;*&gt;</a> y
°5u</pre>
°5u
°5uFurther, any definition must satisfy the following:
°5u
°5u<ul>
°5u<li><i><i>identity</i></i> <pre><a>pure</a> <a>id</a> <a>&lt;*&gt;</a>
°5uv = v</pre></li>
°5u<li><i><i>composition</i></i> <pre><a>pure</a> (.) <a>&lt;*&gt;</a> u
°5u<a>&lt;*&gt;</a> v <a>&lt;*&gt;</a> w = u <a>&lt;*&gt;</a> (v
°5u<a>&lt;*&gt;</a> w)</pre></li>
°5u<li><i><i>homomorphism</i></i> <pre><a>pure</a> f <a>&lt;*&gt;</a>
°5u<a>pure</a> x = <a>pure</a> (f x)</pre></li>
°5u<li><i><i>interchange</i></i> <pre>u <a>&lt;*&gt;</a> <a>pure</a> y =
°5u<a>pure</a> (<a>$</a> y) <a>&lt;*&gt;</a> u</pre></li>
°5u</ul>
°5u
°5uThe other methods have the following default definitions, which may be
°5uoverridden with equivalent specialized implementations:
°5u
°5u<ul>
°5u<li><pre>u <a>*&gt;</a> v = (<a>id</a> <a>&lt;$</a> u)
°5u<a>&lt;*&gt;</a> v</pre></li>
°5u<li><pre>u <a>&lt;*</a> v = <a>liftA2</a> <a>const</a> u v</pre></li>
°5u</ul>
°5u
°5uAs a consequence of these laws, the <a>Functor</a> instance for
°5u<tt>f</tt> will satisfy
°5u
°5u<ul>
°5u<li><pre><a>fmap</a> f x = <a>pure</a> f <a>&lt;*&gt;</a> x</pre></li>
°5u</ul>
°5u
°5uIt may be useful to note that supposing
°5u
°5u<pre>
°5uforall x y. p (q x y) = f x . g y
°5u</pre>
°5u
°5uit follows from the above that
°5u
°5u<pre>
°5u<a>liftA2</a> p (<a>liftA2</a> q u v) = <a>liftA2</a> f u . <a>liftA2</a> g v
°5u</pre>
°5u
°5uIf <tt>f</tt> is also a <a>Monad</a>, it should satisfy
°5u
°5u<ul>
°5u<li><pre><a>pure</a> = <a>return</a></pre></li>
°5u<li><pre>(<a>&lt;*&gt;</a>) = <a>ap</a></pre></li>
°5u<li><pre>(<a>*&gt;</a>) = (<a>&gt;&gt;</a>)</pre></li>
°5u</ul>
°5u
°5u(which implies that <a>pure</a> and <a>&lt;*&gt;</a> satisfy the
°5uapplicative functor laws).
class Functor f => Applicative f

-- | Lift a value.
pure :: Applicative f => a -> f a

-- | Sequential application.
°5u
°5uA few functors support an implementation of <a>&lt;*&gt;</a> that is
°5umore 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
°5u<i>monad</i>, a concept from a branch of mathematics known as
°5u<i>category theory</i>. From the perspective of a Haskell programmer,
°5uhowever, it is best to think of a monad as an <i>abstract datatype</i>
°5uof actions. Haskell's <tt>do</tt> expressions provide a convenient
°5usyntax for writing monadic expressions.
°5u
°5uInstances of <a>Monad</a> should satisfy the following laws:
°5u
°5u<ul>
°5u<li><pre><a>return</a> a <a>&gt;&gt;=</a> k = k a</pre></li>
°5u<li><pre>m <a>&gt;&gt;=</a> <a>return</a> = m</pre></li>
°5u<li><pre>m <a>&gt;&gt;=</a> (\x -&gt; k x <a>&gt;&gt;=</a> h) = (m
°5u<a>&gt;&gt;=</a> k) <a>&gt;&gt;=</a> h</pre></li>
°5u</ul>
°5u
°5uFurthermore, the <a>Monad</a> and <a>Applicative</a> operations should
°5urelate as follows:
°5u
°5u<ul>
°5u<li><pre><a>pure</a> = <a>return</a></pre></li>
°5u<li><pre>(<a>&lt;*&gt;</a>) = <a>ap</a></pre></li>
°5u</ul>
°5u
°5uThe above laws imply:
°5u
°5u<ul>
°5u<li><pre><a>fmap</a> f xs = xs <a>&gt;&gt;=</a> <a>return</a> .
°5uf</pre></li>
°5u<li><pre>(<a>&gt;&gt;</a>) = (<a>*&gt;</a>)</pre></li>
°5u</ul>
°5u
°5uand that <a>pure</a> and (<a>&lt;*&gt;</a>) satisfy the applicative
°5ufunctor laws.
°5u
°5uThe instances of <a>Monad</a> for lists, <a>Maybe</a> and <a>IO</a>
°5udefined in the <a>Prelude</a> satisfy these laws.
class Applicative m => Monad m

-- | Sequentially compose two actions, passing any value produced by the
°5ufirst 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
°5ufirst, like sequencing operators (such as the semicolon) in imperative
°5ulanguages.
(>>) :: 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
°5udefinition of a monad, but is invoked on pattern-match failure in a
°5u<tt>do</tt> expression.
°5u
°5uAs part of the MonadFail proposal (MFP), this function is moved to its
°5uown class <tt>MonadFail</tt> (see <a>Control.Monad.Fail</a> for more
°5udetails). 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
°5uactions from left to right, and ignore the results. For a version that
°5udoesn't ignore the results see <a>mapM</a>.
°5u
°5uAs of base 4.8.0.0, <a>mapM_</a> is just <a>traverse_</a>, specialized
°5uto <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
°5uignore the results. For a version that doesn't ignore the results see
°5u<a>sequence</a>.
°5u
°5uAs of base 4.8.0.0, <a>sequence_</a> is just <a>sequenceA_</a>,
°5uspecialized 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.
°5u
°5uFor example, given a data type
°5u
°5u<pre>
°5udata Tree a = Empty | Leaf a | Node (Tree a) a (Tree a)
°5u</pre>
°5u
°5ua suitable instance would be
°5u
°5u<pre>
°5uinstance Foldable Tree where
°5u   foldMap f Empty = mempty
°5u   foldMap f (Leaf x) = f x
°5u   foldMap f (Node l k r) = foldMap f l `mappend` f k `mappend` foldMap f r
°5u</pre>
°5u
°5uThis is suitable even for abstract types, as the monoid is assumed to
°5usatisfy the monoid laws. Alternatively, one could define
°5u<tt>foldr</tt>:
°5u
°5u<pre>
°5uinstance Foldable Tree where
°5u   foldr f z Empty = z
°5u   foldr f z (Leaf x) = f x z
°5u   foldr f z (Node l k r) = foldr f (f k (foldr f z r)) l
°5u</pre>
°5u
°5u<tt>Foldable</tt> instances are expected to satisfy the following
°5ulaws:
°5u
°5u<pre>
°5ufoldr f z t = appEndo (foldMap (Endo . f) t ) z
°5u</pre>
°5u
°5u<pre>
°5ufoldl f z t = appEndo (getDual (foldMap (Dual . Endo . flip f) t)) z
°5u</pre>
°5u
°5u<pre>
°5ufold = foldMap id
°5u</pre>
°5u
°5u<pre>
°5ulength = getSum . foldMap (Sum . const  1)
°5u</pre>
°5u
°5u<tt>sum</tt>, <tt>product</tt>, <tt>maximum</tt>, and <tt>minimum</tt>
°5ushould all be essentially equivalent to <tt>foldMap</tt> forms, such
°5uas
°5u
°5u<pre>
°5usum = getSum . foldMap Sum
°5u</pre>
°5u
°5ubut may be less defined.
°5u
°5uIf the type is also a <a>Functor</a> instance, it should satisfy
°5u
°5u<pre>
°5ufoldMap f = fold . fmap f
°5u</pre>
°5u
°5uwhich implies that
°5u
°5u<pre>
°5ufoldMap f . fmap g = foldMap (f . g)
°5u</pre>
class Foldable t

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

-- | Right-associative fold of a structure.
°5u
°5uIn the case of lists, <a>foldr</a>, when applied to a binary operator,
°5ua starting value (typically the right-identity of the operator), and a
°5ulist, reduces the list using the binary operator, from right to left:
°5u
°5u<pre>
°5ufoldr f z [x1, x2, ..., xn] == x1 `f` (x2 `f` ... (xn `f` z)...)
°5u</pre>
°5u
°5uNote that, since the head of the resulting expression is produced by
°5uan application of the operator to the first element of the list,
°5u<a>foldr</a> can produce a terminating expression from an infinite
°5ulist.
°5u
°5uFor a general <a>Foldable</a> structure this should be semantically
°5uidentical to,
°5u
°5u<pre>
°5ufoldr f z = <a>foldr</a> f z . <a>toList</a>
°5u</pre>
foldr :: Foldable t => (a -> b -> b) -> b -> t a -> b

-- | Left-associative fold of a structure.
°5u
°5uIn the case of lists, <a>foldl</a>, when applied to a binary operator,
°5ua starting value (typically the left-identity of the operator), and a
°5ulist, reduces the list using the binary operator, from left to right:
°5u
°5u<pre>
°5ufoldl f z [x1, x2, ..., xn] == (...((z `f` x1) `f` x2) `f`...) `f` xn
°5u</pre>
°5u
°5uNote that to produce the outermost application of the operator the
°5uentire input list must be traversed. This means that <a>foldl'</a>
°5uwill diverge if given an infinite list.
°5u
°5uAlso note that if you want an efficient left-fold, you probably want
°5uto use <a>foldl'</a> instead of <a>foldl</a>. The reason for this is
°5uthat latter does not force the "inner" results (e.g. <tt>z <tt>f</tt>
°5ux1</tt> in the above example) before applying them to the operator
°5u(e.g. to <tt>(<tt>f</tt> x2)</tt>). This results in a thunk chain
°5u<tt>O(n)</tt> elements long, which then must be evaluated from the
°5uoutside-in.
°5u
°5uFor a general <a>Foldable</a> structure this should be semantically
°5uidentical to,
°5u
°5u<pre>
°5ufoldl f z = <a>foldl</a> f z . <a>toList</a>
°5u</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
°5uapplied to non-empty structures.
°5u
°5u<pre>
°5u<a>foldr1</a> f = <a>foldr1</a> f . <a>toList</a>
°5u</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
°5uapplied to non-empty structures.
°5u
°5u<pre>
°5u<a>foldl1</a> f = <a>foldl1</a> f . <a>toList</a>
°5u</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
°5ustructure.
sum :: (Foldable t, Num a) => t a -> a

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

-- | Functors representing data structures that can be traversed from left
°5uto right.
°5u
°5uA definition of <a>traverse</a> must satisfy the following laws:
°5u
°5u<ul>
°5u<li><i><i>naturality</i></i> <tt>t . <a>traverse</a> f =
°5u<a>traverse</a> (t . f)</tt> for every applicative transformation
°5u<tt>t</tt></li>
°5u<li><i><i>identity</i></i> <tt><a>traverse</a> Identity =
°5uIdentity</tt></li>
°5u<li><i><i>composition</i></i> <tt><a>traverse</a> (Compose .
°5u<a>fmap</a> g . f) = Compose . <a>fmap</a> (<a>traverse</a> g) .
°5u<a>traverse</a> f</tt></li>
°5u</ul>
°5u
°5uA definition of <a>sequenceA</a> must satisfy the following laws:
°5u
°5u<ul>
°5u<li><i><i>naturality</i></i> <tt>t . <a>sequenceA</a> =
°5u<a>sequenceA</a> . <a>fmap</a> t</tt> for every applicative
°5utransformation <tt>t</tt></li>
°5u<li><i><i>identity</i></i> <tt><a>sequenceA</a> . <a>fmap</a> Identity
°5u= Identity</tt></li>
°5u<li><i><i>composition</i></i> <tt><a>sequenceA</a> . <a>fmap</a>
°5uCompose = Compose . <a>fmap</a> <a>sequenceA</a> .
°5u<a>sequenceA</a></tt></li>
°5u</ul>
°5u
°5uwhere an <i>applicative transformation</i> is a function
°5u
°5u<pre>
°5ut :: (Applicative f, Applicative g) =&gt; f a -&gt; g a
°5u</pre>
°5u
°5upreserving the <a>Applicative</a> operations, i.e.
°5u
°5u<ul>
°5u<li><pre>t (<a>pure</a> x) = <a>pure</a> x</pre></li>
°5u<li><pre>t (x <a>&lt;*&gt;</a> y) = t x <a>&lt;*&gt;</a> t
°5uy</pre></li>
°5u</ul>
°5u
°5uand the identity functor <tt>Identity</tt> and composition of functors
°5u<tt>Compose</tt> are defined as
°5u
°5u<pre>
°5unewtype Identity a = Identity a
°5u
°5uinstance Functor Identity where
°5u  fmap f (Identity x) = Identity (f x)
°5u
°5uinstance Applicative Identity where
°5u  pure x = Identity x
°5u  Identity f &lt;*&gt; Identity x = Identity (f x)
°5u
°5unewtype Compose f g a = Compose (f (g a))
°5u
°5uinstance (Functor f, Functor g) =&gt; Functor (Compose f g) where
°5u  fmap f (Compose x) = Compose (fmap (fmap f) x)
°5u
°5uinstance (Applicative f, Applicative g) =&gt; Applicative (Compose f g) where
°5u  pure x = Compose (pure (pure x))
°5u  Compose f &lt;*&gt; Compose x = Compose ((&lt;*&gt;) &lt;$&gt; f &lt;*&gt; x)
°5u</pre>
°5u
°5u(The naturality law is implied by parametricity.)
°5u
°5uInstances are similar to <a>Functor</a>, e.g. given a data type
°5u
°5u<pre>
°5udata Tree a = Empty | Leaf a | Node (Tree a) a (Tree a)
°5u</pre>
°5u
°5ua suitable instance would be
°5u
°5u<pre>
°5uinstance Traversable Tree where
°5u   traverse f Empty = pure Empty
°5u   traverse f (Leaf x) = Leaf &lt;$&gt; f x
°5u   traverse f (Node l k r) = Node &lt;$&gt; traverse f l &lt;*&gt; f k &lt;*&gt; traverse f r
°5u</pre>
°5u
°5uThis is suitable even for abstract types, as the laws for
°5u<a>&lt;*&gt;</a> imply a form of associativity.
°5u
°5uThe superclass instances should satisfy the following:
°5u
°5u<ul>
°5u<li>In the <a>Functor</a> instance, <a>fmap</a> should be equivalent
°5uto traversal with the identity applicative functor
°5u(<a>fmapDefault</a>).</li>
°5u<li>In the <a>Foldable</a> instance, <a>foldMap</a> should be
°5uequivalent to traversal with a constant applicative functor
°5u(<a>foldMapDefault</a>).</li>
°5u</ul>
class (Functor t, Foldable t) => Traversable t

-- | Map each element of a structure to an action, evaluate these actions
°5ufrom left to right, and collect the results. For a version that
°5uignores 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
°5ucollect the results. For a version that ignores the results see
°5u<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
°5uactions from left to right, and collect the results. For a version
°5uthat 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
°5ucollect the results. For a version that ignores the results see
°5u<a>sequence_</a>.
sequence :: (Traversable t, Monad m) => t (m a) -> m (t a)

-- | Identity function.
°5u
°5u<pre>
°5uid x = x
°5u</pre>
id :: a -> a

-- | <tt>const x</tt> is a unary function which evaluates to <tt>x</tt> for
°5uall inputs.
°5u
°5u<pre>
°5u&gt;&gt;&gt; const 42 "hello"
°5u42
°5u</pre>
°5u
°5u<pre>
°5u&gt;&gt;&gt; map (const 42) [0..3]
°5u[42,42,42,42]
°5u</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
°5uorder of <tt>f</tt>.
°5u
°5u<pre>
°5u&gt;&gt;&gt; flip (++) "hello" "world"
°5u"worldhello"
°5u</pre>
flip :: (a -> b -> c) -> b -> a -> c

-- | Application operator. This operator is redundant, since ordinary
°5uapplication <tt>(f x)</tt> means the same as <tt>(f <a>$</a> x)</tt>.
°5uHowever, <a>$</a> has low, right-associative binding precedence, so it
°5usometimes allows parentheses to be omitted; for example:
°5u
°5u<pre>
°5uf $ g $ h x  =  f (g (h x))
°5u</pre>
°5u
°5uIt is also useful in higher-order situations, such as <tt><a>map</a>
°5u(<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>
°5uuntil <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
°5uusually used as an infix operator, and its typing forces its first
°5uargument (which is usually overloaded) to have the same type as the
°5usecond.
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
°5urecognize this and insert error messages which are more appropriate to
°5uthe 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
°5uotherwise equal to <tt>b</tt>. In other words, it evaluates the first
°5uargument <tt>a</tt> to weak head normal form (WHNF). <tt>seq</tt> is
°5uusually introduced to improve performance by avoiding unneeded
°5ulaziness.
°5u
°5uA note on evaluation order: the expression <tt>seq a b</tt> does
°5u<i>not</i> guarantee that <tt>a</tt> will be evaluated before
°5u<tt>b</tt>. The only guarantee given by <tt>seq</tt> is that the both
°5u<tt>a</tt> and <tt>b</tt> will be evaluated before <tt>seq</tt>
°5ureturns a value. In particular, this means that <tt>b</tt> may be
°5uevaluated before <tt>a</tt>. If you need to guarantee a specific order
°5uof evaluation, you must use the function <tt>pseq</tt> from the
°5u"parallel" package.
seq :: () => a -> b -> b

-- | Strict (call-by-value) application operator. It takes a function and
°5uan argument, evaluates the argument to weak head normal form (WHNF),
°5uthen 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>
°5uto each element of <tt>xs</tt>, i.e.,
°5u
°5u<pre>
°5umap f [x1, x2, ..., xn] == [f x1, f x2, ..., f xn]
°5umap f [x1, x2, ...] == [f x1, f x2, ...]
°5u</pre>
map :: (a -> b) -> [a] -> [b]

-- | Append two lists, i.e.,
°5u
°5u<pre>
°5u[x1, ..., xm] ++ [y1, ..., yn] == [x1, ..., xm, y1, ..., yn]
°5u[x1, ..., xm] ++ [y1, ...] == [x1, ..., xm, y1, ...]
°5u</pre>
°5u
°5uIf 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
°5uthose elements that satisfy the predicate; i.e.,
°5u
°5u<pre>
°5ufilter p xs = [ x | x &lt;- xs, p x]
°5u</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
°5unon-empty.
last :: [a] -> a

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

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

-- | Test whether the structure is empty. The default implementation is
°5uoptimized for structures that are similar to cons-lists, because there
°5uis 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
°5udefault implementation is optimized for structures that are similar to
°5ucons-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
°5uthe more general <a>genericIndex</a>, which takes an index of any
°5uintegral type.
(!!) :: [a] -> Int -> a
infixl 9 !!

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

-- | <a>and</a> returns the conjunction of a container of Bools. For the
°5uresult to be <a>True</a>, the container must be finite; <a>False</a>,
°5uhowever, results from a <a>False</a> value finitely far from the left
°5uend.
and :: Foldable t => t Bool -> Bool

-- | <a>or</a> returns the disjunction of a container of Bools. For the
°5uresult to be <a>False</a>, the container must be finite; <a>True</a>,
°5uhowever, results from a <a>True</a> value finitely far from the left
°5uend.
or :: Foldable t => t Bool -> Bool

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

-- | Determines whether all elements of the structure satisfy the
°5upredicate.
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
°5uthe resulting lists.
concatMap :: Foldable t => (a -> [b]) -> t a -> [b]

-- | <a>scanl</a> is similar to <a>foldl</a>, but returns a list of
°5usuccessive reduced values from the left:
°5u
°5u<pre>
°5uscanl f z [x1, x2, ...] == [z, z `f` x1, (z `f` x1) `f` x2, ...]
°5u</pre>
°5u
°5uNote that
°5u
°5u<pre>
°5ulast (scanl f z xs) == foldl f z xs.
°5u</pre>
scanl :: (b -> a -> b) -> b -> [a] -> [b]

-- | <a>scanl1</a> is a variant of <a>scanl</a> that has no starting value
°5uargument:
°5u
°5u<pre>
°5uscanl1 f [x1, x2, ...] == [x1, x1 `f` x2, ...]
°5u</pre>
scanl1 :: (a -> a -> a) -> [a] -> [a]

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

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

-- | <a>iterate</a> <tt>f x</tt> returns an infinite list of repeated
°5uapplications of <tt>f</tt> to <tt>x</tt>:
°5u
°5u<pre>
°5uiterate f x == [x, f x, f (f x), ...]
°5u</pre>
°5u
°5uNote that <a>iterate</a> is lazy, potentially leading to thunk
°5ubuild-up if the consumer doesn't force each iterate. See 'iterate\''
°5ufor 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
°5uvalue of every element.
repeat :: a -> [a]

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

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

-- | <a>take</a> <tt>n</tt>, applied to a list <tt>xs</tt>, returns the
°5uprefix of <tt>xs</tt> of length <tt>n</tt>, or <tt>xs</tt> itself if
°5u<tt>n &gt; <a>length</a> xs</tt>:
°5u
°5u<pre>
°5utake 5 "Hello World!" == "Hello"
°5utake 3 [1,2,3,4,5] == [1,2,3]
°5utake 3 [1,2] == [1,2]
°5utake 3 [] == []
°5utake (-1) [1,2] == []
°5utake 0 [1,2] == []
°5u</pre>
°5u
°5uIt is an instance of the more general <a>genericTake</a>, in which
°5u<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
°5ufirst <tt>n</tt> elements, or <tt>[]</tt> if <tt>n &gt; <a>length</a>
°5uxs</tt>:
°5u
°5u<pre>
°5udrop 6 "Hello World!" == "World!"
°5udrop 3 [1,2,3,4,5] == [4,5]
°5udrop 3 [1,2] == []
°5udrop 3 [] == []
°5udrop (-1) [1,2] == [1,2]
°5udrop 0 [1,2] == [1,2]
°5u</pre>
°5u
°5uIt is an instance of the more general <a>genericDrop</a>, in which
°5u<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
°5u<tt>xs</tt> prefix of length <tt>n</tt> and second element is the
°5uremainder of the list:
°5u
°5u<pre>
°5usplitAt 6 "Hello World!" == ("Hello ","World!")
°5usplitAt 3 [1,2,3,4,5] == ([1,2,3],[4,5])
°5usplitAt 1 [1,2,3] == ([1],[2,3])
°5usplitAt 3 [1,2,3] == ([1,2,3],[])
°5usplitAt 4 [1,2,3] == ([1,2,3],[])
°5usplitAt 0 [1,2,3] == ([],[1,2,3])
°5usplitAt (-1) [1,2,3] == ([],[1,2,3])
°5u</pre>
°5u
°5uIt is equivalent to <tt>(<a>take</a> n xs, <a>drop</a> n xs)</tt> when
°5u<tt>n</tt> is not <tt>_|_</tt> (<tt>splitAt _|_ xs = _|_</tt>).
°5u<a>splitAt</a> is an instance of the more general
°5u<a>genericSplitAt</a>, in which <tt>n</tt> may be of any integral
°5utype.
splitAt :: Int -> [a] -> ([a], [a])

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

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

-- | <a>span</a>, applied to a predicate <tt>p</tt> and a list <tt>xs</tt>,
°5ureturns a tuple where first element is longest prefix (possibly empty)
°5uof <tt>xs</tt> of elements that satisfy <tt>p</tt> and second element
°5uis the remainder of the list:
°5u
°5u<pre>
°5uspan (&lt; 3) [1,2,3,4,1,2,3,4] == ([1,2],[3,4,1,2,3,4])
°5uspan (&lt; 9) [1,2,3] == ([1,2,3],[])
°5uspan (&lt; 0) [1,2,3] == ([],[1,2,3])
°5u</pre>
°5u
°5u<a>span</a> <tt>p xs</tt> is equivalent to <tt>(<a>takeWhile</a> p xs,
°5u<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
°5u<tt>xs</tt>, returns a tuple where first element is longest prefix
°5u(possibly empty) of <tt>xs</tt> of elements that <i>do not satisfy</i>
°5u<tt>p</tt> and second element is the remainder of the list:
°5u
°5u<pre>
°5ubreak (&gt; 3) [1,2,3,4,1,2,3,4] == ([1,2,3],[4,1,2,3,4])
°5ubreak (&lt; 9) [1,2,3] == ([],[1,2,3])
°5ubreak (&gt; 9) [1,2,3] == ([1,2,3],[])
°5u</pre>
°5u
°5u<a>break</a> <tt>p</tt> is equivalent to <tt><a>span</a> (<a>not</a> .
°5up)</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
°5ulist.
lookup :: (Eq a) => a -> [(a, b)] -> Maybe b

-- | <a>zip</a> takes two lists and returns a list of corresponding pairs.
°5uIf one input list is short, excess elements of the longer list are
°5udiscarded.
°5u
°5u<a>zip</a> is right-lazy:
°5u
°5u<pre>
°5uzip [] _|_ = []
°5u</pre>
zip :: [a] -> [b] -> [(a, b)]

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

-- | <a>zipWith</a> generalises <a>zip</a> by zipping with the function
°5ugiven as the first argument, instead of a tupling function. For
°5uexample, <tt><a>zipWith</a> (+)</tt> is applied to two lists to
°5uproduce the list of corresponding sums.
°5u
°5u<a>zipWith</a> is right-lazy:
°5u
°5u<pre>
°5uzipWith f [] _|_ = []
°5u</pre>
zipWith :: (a -> b -> c) -> [a] -> [b] -> [c]

-- | The <a>zipWith3</a> function takes a function which combines three
°5uelements, as well as three lists and returns a list of their
°5upoint-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
°5ucomponents and a list of second components.
unzip :: [(a, b)] -> ([a], [b])

-- | The <a>unzip3</a> function takes a list of triples and returns three
°5ulists, 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
°5ucharacters. The resulting strings do not contain newlines.
°5u
°5uNote that after splitting the string at newline characters, the last
°5upart of the string is considered a line even if it doesn't end with a
°5unewline. For example,
°5u
°5u<pre>
°5u&gt;&gt;&gt; lines ""
°5u[]
°5u</pre>
°5u
°5u<pre>
°5u&gt;&gt;&gt; lines "\n"
°5u[""]
°5u</pre>
°5u
°5u<pre>
°5u&gt;&gt;&gt; lines "one"
°5u["one"]
°5u</pre>
°5u
°5u<pre>
°5u&gt;&gt;&gt; lines "one\n"
°5u["one"]
°5u</pre>
°5u
°5u<pre>
°5u&gt;&gt;&gt; lines "one\n\n"
°5u["one",""]
°5u</pre>
°5u
°5u<pre>
°5u&gt;&gt;&gt; lines "one\ntwo"
°5u["one","two"]
°5u</pre>
°5u
°5u<pre>
°5u&gt;&gt;&gt; lines "one\ntwo\n"
°5u["one","two"]
°5u</pre>
°5u
°5uThus <tt><a>lines</a> s</tt> contains at least as many elements as
°5unewlines in <tt>s</tt>.
lines :: String -> [String]

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

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

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

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

-- | Conversion of values to readable <a>String</a>s.
°5u
°5uDerived instances of <a>Show</a> have the following properties, which
°5uare compatible with derived instances of <a>Read</a>:
°5u
°5u<ul>
°5u<li>The result of <a>show</a> is a syntactically correct Haskell
°5uexpression containing only constants, given the fixity declarations in
°5uforce at the point where the type is declared. It contains only the
°5uconstructor names defined in the data type, parentheses, and spaces.
°5uWhen labelled constructor fields are used, braces, commas, field
°5unames, and equal signs are also used.</li>
°5u<li>If the constructor is defined to be an infix operator, then
°5u<a>showsPrec</a> will produce infix applications of the
°5uconstructor.</li>
°5u<li>the representation will be enclosed in parentheses if the
°5uprecedence of the top-level constructor in <tt>x</tt> is less than
°5u<tt>d</tt> (associativity is ignored). Thus, if <tt>d</tt> is
°5u<tt>0</tt> then the result is never surrounded in parentheses; if
°5u<tt>d</tt> is <tt>11</tt> it is always surrounded in parentheses,
°5uunless it is an atomic expression.</li>
°5u<li>If the constructor is defined using record syntax, then
°5u<a>show</a> will produce the record-syntax form, with the fields given
°5uin the same order as the original declaration.</li>
°5u</ul>
°5u
°5uFor example, given the declarations
°5u
°5u<pre>
°5uinfixr 5 :^:
°5udata Tree a =  Leaf a  |  Tree a :^: Tree a
°5u</pre>
°5u
°5uthe derived instance of <a>Show</a> is equivalent to
°5u
°5u<pre>
°5uinstance (Show a) =&gt; Show (Tree a) where
°5u
°5u       showsPrec d (Leaf m) = showParen (d &gt; app_prec) $
°5u            showString "Leaf " . showsPrec (app_prec+1) m
°5u         where app_prec = 10
°5u
°5u       showsPrec d (u :^: v) = showParen (d &gt; up_prec) $
°5u            showsPrec (up_prec+1) u .
°5u            showString " :^: "      .
°5u            showsPrec (up_prec+1) v
°5u         where up_prec = 5
°5u</pre>
°5u
°5uNote that right-associativity of <tt>:^:</tt> is ignored. For example,
°5u
°5u<ul>
°5u<li><tt><a>show</a> (Leaf 1 :^: Leaf 2 :^: Leaf 3)</tt> produces the
°5ustring <tt>"Leaf 1 :^: (Leaf 2 :^: Leaf 3)"</tt>.</li>
°5u</ul>
class Show a

-- | Convert a value to a readable <a>String</a>.
°5u
°5u<a>showsPrec</a> should satisfy the law
°5u
°5u<pre>
°5ushowsPrec d x r ++ s  ==  showsPrec d x (r ++ s)
°5u</pre>
°5u
°5uDerived instances of <a>Read</a> and <a>Show</a> satisfy the
°5ufollowing:
°5u
°5u<ul>
°5u<li><tt>(x,"")</tt> is an element of <tt>(<a>readsPrec</a> d
°5u(<a>showsPrec</a> d x ""))</tt>.</li>
°5u</ul>
°5u
°5uThat is, <a>readsPrec</a> parses the string produced by
°5u<a>showsPrec</a>, and delivers the value that <a>showsPrec</a> started
°5uwith.
showsPrec :: Show a => Int -> a -> ShowS

-- | A specialised variant of <a>showsPrec</a>, using precedence context
°5uzero, 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
°5ua specialised way of showing lists of values. For example, this is
°5uused by the predefined <a>Show</a> instance of the <a>Char</a> type,
°5uwhere values of type <a>String</a> should be shown in double quotes,
°5urather 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
°5usimply prepends the character unchanged.
showChar :: Char -> ShowS

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

-- | utility function that surrounds the inner show function with
°5uparentheses 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
°5u<a>String</a> and returns a list of possible parses as
°5u<tt>(a,<a>String</a>)</tt> pairs.
°5u
°5uNote that this kind of backtracking parser is very inefficient;
°5ureading 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.
°5u
°5uDerived instances of <a>Read</a> make the following assumptions, which
°5uderived instances of <a>Show</a> obey:
°5u
°5u<ul>
°5u<li>If the constructor is defined to be an infix operator, then the
°5uderived <a>Read</a> instance will parse only infix applications of the
°5uconstructor (not the prefix form).</li>
°5u<li>Associativity is not used to reduce the occurrence of parentheses,
°5ualthough precedence may be.</li>
°5u<li>If the constructor is defined using record syntax, the derived
°5u<a>Read</a> will parse only the record-syntax form, and furthermore,
°5uthe fields must be given in the same order as the original
°5udeclaration.</li>
°5u<li>The derived <a>Read</a> instance allows arbitrary Haskell
°5uwhitespace between tokens of the input string. Extra parentheses are
°5ualso allowed.</li>
°5u</ul>
°5u
°5uFor example, given the declarations
°5u
°5u<pre>
°5uinfixr 5 :^:
°5udata Tree a =  Leaf a  |  Tree a :^: Tree a
°5u</pre>
°5u
°5uthe derived instance of <a>Read</a> in Haskell 2010 is equivalent to
°5u
°5u<pre>
°5uinstance (Read a) =&gt; Read (Tree a) where
°5u
°5u        readsPrec d r =  readParen (d &gt; app_prec)
°5u                         (\r -&gt; [(Leaf m,t) |
°5u                                 ("Leaf",s) &lt;- lex r,
°5u                                 (m,t) &lt;- readsPrec (app_prec+1) s]) r
°5u
°5u                      ++ readParen (d &gt; up_prec)
°5u                         (\r -&gt; [(u:^:v,w) |
°5u                                 (u,s) &lt;- readsPrec (up_prec+1) r,
°5u                                 (":^:",t) &lt;- lex s,
°5u                                 (v,w) &lt;- readsPrec (up_prec+1) t]) r
°5u
°5u          where app_prec = 10
°5u                up_prec = 5
°5u</pre>
°5u
°5uNote that right-associativity of <tt>:^:</tt> is unused.
°5u
°5uThe derived instance in GHC is equivalent to
°5u
°5u<pre>
°5uinstance (Read a) =&gt; Read (Tree a) where
°5u
°5u        readPrec = parens $ (prec app_prec $ do
°5u                                 Ident "Leaf" &lt;- lexP
°5u                                 m &lt;- step readPrec
°5u                                 return (Leaf m))
°5u
°5u                     +++ (prec up_prec $ do
°5u                                 u &lt;- step readPrec
°5u                                 Symbol ":^:" &lt;- lexP
°5u                                 v &lt;- step readPrec
°5u                                 return (u :^: v))
°5u
°5u          where app_prec = 10
°5u                up_prec = 5
°5u
°5u        readListPrec = readListPrecDefault
°5u</pre>
°5u
°5uWhy do both <a>readsPrec</a> and <a>readPrec</a> exist, and why does
°5uGHC opt to implement <a>readPrec</a> in derived <a>Read</a> instances
°5uinstead of <a>readsPrec</a>? The reason is that <a>readsPrec</a> is
°5ubased on the <a>ReadS</a> type, and although <a>ReadS</a> is mentioned
°5uin the Haskell 2010 Report, it is not a very efficient parser data
°5ustructure.
°5u
°5u<a>readPrec</a>, on the other hand, is based on a much more efficient
°5u<a>ReadPrec</a> datatype (a.k.a "new-style parsers"), but its
°5udefinition relies on the use of the <tt>RankNTypes</tt> language
°5uextension. Therefore, <a>readPrec</a> (and its cousin,
°5u<a>readListPrec</a>) are marked as GHC-only. Nevertheless, it is
°5urecommended to use <a>readPrec</a> instead of <a>readsPrec</a>
°5uwhenever possible for the efficiency improvements it brings.
°5u
°5uAs mentioned above, derived <a>Read</a> instances in GHC will
°5uimplement <a>readPrec</a> instead of <a>readsPrec</a>. The default
°5uimplementations of <a>readsPrec</a> (and its cousin, <a>readList</a>)
°5uwill simply use <a>readPrec</a> under the hood. If you are writing a
°5u<a>Read</a> instance by hand, it is recommended to write it like so:
°5u
°5u<pre>
°5uinstance <a>Read</a> T where
°5u  <a>readPrec</a>     = ...
°5u  <a>readListPrec</a> = <a>readListPrecDefault</a>
°5u</pre>
class Read a

-- | attempts to parse a value from the front of the string, returning a
°5ulist of (parsed value, remaining string) pairs. If there is no
°5usuccessful parse, the returned list is empty.
°5u
°5uDerived instances of <a>Read</a> and <a>Show</a> satisfy the
°5ufollowing:
°5u
°5u<ul>
°5u<li><tt>(x,"")</tt> is an element of <tt>(<a>readsPrec</a> d
°5u(<a>showsPrec</a> d x ""))</tt>.</li>
°5u</ul>
°5u
°5uThat is, <a>readsPrec</a> parses the string produced by
°5u<a>showsPrec</a>, and delivers the value that <a>showsPrec</a> started
°5uwith.
readsPrec :: Read a => Int -> ReadS a

-- | The method <a>readList</a> is provided to allow the programmer to give
°5ua specialised way of parsing lists of values. For example, this is
°5uused by the predefined <a>Read</a> instance of the <a>Char</a> type,
°5uwhere values of type <a>String</a> should be are expected to use
°5udouble 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,
°5ubut surrounded with parentheses.
°5u
°5u<tt><a>readParen</a> <a>False</a> p</tt> parses what <tt>p</tt>
°5uparses, but optionally surrounded with parentheses.
readParen :: Bool -> ReadS a -> ReadS a

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

-- | The <a>lex</a> function reads a single lexeme from the input,
°5udiscarding initial white space, and returning the characters that
°5uconstitute the lexeme. If the input string contains only white space,
°5u<a>lex</a> returns a single successful `lexeme' consisting of the
°5uempty string. (Thus <tt><a>lex</a> "" = [("","")]</tt>.) If there is
°5uno legal lexeme at the beginning of the input string, <a>lex</a> fails
°5u(i.e. returns <tt>[]</tt>).
°5u
°5uThis lexer is not completely faithful to the Haskell lexical syntax in
°5uthe following respects:
°5u
°5u<ul>
°5u<li>Qualified names are not handled properly</li>
°5u<li>Octal and hexadecimal numerics are not recognized as a single
°5utoken</li>
°5u<li>Comments are not treated properly</li>
°5u</ul>
lex :: ReadS String

-- | A value of type <tt><a>IO</a> a</tt> is a computation which, when
°5uperformed, does some I/O before returning a value of type <tt>a</tt>.
°5u
°5uThere is really only one way to "perform" an I/O action: bind it to
°5u<tt>Main.main</tt> in your program. When your program is run, the I/O
°5uwill be performed. It isn't possible to perform I/O from an arbitrary
°5ufunction, unless that function is itself in the <a>IO</a> monad and
°5ucalled at some point, directly or indirectly, from <tt>Main.main</tt>.
°5u
°5u<a>IO</a> is a monad, so <a>IO</a> actions can be combined using
°5ueither the do-notation or the <tt>&gt;&gt;</tt> and <tt>&gt;&gt;=</tt>
°5uoperations from the <tt>Monad</tt> class.
data IO a

-- | Write a character to the standard output device (same as
°5u<a>hPutChar</a> <a>stdout</a>).
putChar :: Char -> IO ()

-- | Write a string to the standard output device (same as <a>hPutStr</a>
°5u<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
°5ustandard output device. Printable types are those that are instances
°5uof class <a>Show</a>; <a>print</a> converts values to strings for
°5uoutput using the <a>show</a> operation and adds a newline.
°5u
°5uFor example, a program to print the first 20 integers and their powers
°5uof 2 could be written as:
°5u
°5u<pre>
°5umain = print ([(n, 2^n) | n &lt;- [0..19]])
°5u</pre>
print :: Show a => a -> IO ()

-- | Read a character from the standard input device (same as
°5u<a>hGetChar</a> <a>stdin</a>).
getChar :: IO Char

-- | Read a line from the standard input device (same as <a>hGetLine</a>
°5u<a>stdin</a>).
getLine :: IO String

-- | The <a>getContents</a> operation returns all user input as a single
°5ustring, which is read lazily as it is needed (same as
°5u<a>hGetContents</a> <a>stdin</a>).
getContents :: IO String

-- | The <a>interact</a> function takes a function of type
°5u<tt>String-&gt;String</tt> as its argument. The entire input from the
°5ustandard input device is passed to this function as its argument, and
°5uthe 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
°5uprecise meaning is operating system dependent. Files can be opened,
°5uyielding a handle which can then be used to operate on the contents of
°5uthat file.
type FilePath = String

-- | The <a>readFile</a> function reads a file and returns the contents of
°5uthe file as a string. The file is read lazily, on demand, as with
°5u<a>getContents</a>.
readFile :: FilePath -> IO String

-- | The computation <a>writeFile</a> <tt>file str</tt> function writes the
°5ustring <tt>str</tt>, to the file <tt>file</tt>.
writeFile :: FilePath -> String -> IO ()

-- | The computation <a>appendFile</a> <tt>file str</tt> function appends
°5uthe string <tt>str</tt>, to the file <tt>file</tt>.
°5u
°5uNote that <a>writeFile</a> and <a>appendFile</a> write a literal
°5ustring to a file. To write a value of any printable type, as with
°5u<a>print</a>, use the <a>show</a> function to convert the value to a
°5ustring first.
°5u
°5u<pre>
°5umain = appendFile "squares" (show [(x,x*x) | x &lt;- [0,0.1..2]])
°5u</pre>
appendFile :: FilePath -> String -> IO ()

-- | The <a>readIO</a> function is similar to <a>read</a> except that it
°5usignals parse failure to the <a>IO</a> monad instead of terminating
°5uthe 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
°5uoperation may raise an <a>IOError</a> instead of returning a result.
°5uFor a more general type of exception, including also those that arise
°5uin pure code, see <a>Exception</a>.
°5u
°5uIn 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.
°5uThe <a>fail</a> method of the <a>IO</a> instance of the <a>Monad</a>
°5uclass raises a <a>userError</a>, thus:
°5u
°5u<pre>
°5uinstance Monad IO where
°5u  ...
°5u  fail s = ioError (userError s)
°5u</pre>
userError :: String -> IOError


-- | The representations of the types <a>TyCon</a> and <a>TypeRep</a>, and
°5uthe function <a>mkTyCon</a> which is used by derived instances of
°5u<a>Typeable</a> to construct <a>TyCon</a>s.
°5u
°5uBe warned, these functions can be used to construct ill-kinded type
°5urepresentations.
module Type.Reflection.Unsafe

-- | A concrete representation of a (monomorphic) type. <a>TypeRep</a>
°5usupports 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
°5u<tt>TypeRep</tt>. See Note [Representing TyCon kinds: KindRep] in
°5uTcTypeable.
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
°5umonomorphic kind.
°5u
°5uNote that this is unsafe as it allows you to construct ill-kinded
°5utypes.
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:
°5u
°5u<pre>
°5uinstance Show (a -&gt; b) where
°5u   showsPrec _ _ = showString \"\&lt;function\&gt;\"
°5u</pre>
module Text.Show.Functions
instance GHC.Show.Show (a -> b)


-- | A C <tt>printf(3)</tt>-like formatter. This version has been extended
°5uby Bart Massey as per the recommendations of John Meacham and Simon
°5uMarlow
°5u&lt;<a>http://comments.gmane.org/gmane.comp.lang.haskell.libraries/4726</a>&gt;
°5uto support extensible formatting for new datatypes. It has also been
°5uextended to support almost all C <tt>printf(3)</tt> syntax.
module Text.Printf

-- | Format a variable number of arguments with the C-style formatting
°5ustring.
°5u
°5u<pre>
°5u&gt;&gt;&gt; printf "%s, %d, %.4f" "hello" 123 pi
°5uhello, 123, 3.1416
°5u</pre>
°5u
°5uThe return value is either <a>String</a> or <tt>(<a>IO</a> a)</tt>
°5u(which should be <tt>(<a>IO</a> '()')</tt>, but Haskell's type system
°5umakes this hard).
°5u
°5uThe format string consists of ordinary characters and <i>conversion
°5uspecifications</i>, which specify how to format one of the arguments
°5uto <a>printf</a> in the output string. A format specification is
°5uintroduced by the <tt>%</tt> character; this character can be
°5uself-escaped into the format string using <tt>%%</tt>. A format
°5uspecification ends with a /format character/ that provides the primary
°5uinformation about how to format the value. The rest of the conversion
°5uspecification is optional. In order, one may have flag characters, a
°5uwidth specifier, a precision specifier, and type-specific modifier
°5ucharacters.
°5u
°5uUnlike C <tt>printf(3)</tt>, the formatting of this <a>printf</a> is
°5udriven by the argument type; formatting is type specific. The types
°5uformatted by <a>printf</a> "out of the box" are:
°5u
°5u<ul>
°5u<li><a>Integral</a> types, including <a>Char</a></li>
°5u<li><a>String</a></li>
°5u<li><a>RealFloat</a> types</li>
°5u</ul>
°5u
°5u<a>printf</a> is also extensible to support other types: see below.
°5u
°5uA conversion specification begins with the character <tt>%</tt>,
°5ufollowed by zero or more of the following flags:
°5u
°5u<pre>
°5u-      left adjust (default is right adjust)
°5u+      always use a sign (+ or -) for signed conversions
°5uspace  leading space for positive numbers in signed conversions
°5u0      pad with zeros rather than spaces
°5u#      use an \"alternate form\": see below
°5u</pre>
°5u
°5uWhen both flags are given, <tt>-</tt> overrides <tt>0</tt> and
°5u<tt>+</tt> overrides space. A negative width specifier in a <tt>*</tt>
°5uconversion is treated as positive but implies the left adjust flag.
°5u
°5uThe "alternate form" for unsigned radix conversions is as in C
°5u<tt>printf(3)</tt>:
°5u
°5u<pre>
°5u%o           prefix with a leading 0 if needed
°5u%x           prefix with a leading 0x if nonzero
°5u%X           prefix with a leading 0X if nonzero
°5u%b           prefix with a leading 0b if nonzero
°5u%[eEfFgG]    ensure that the number contains a decimal point
°5u</pre>
°5u
°5uAny flags are followed optionally by a field width:
°5u
°5u<pre>
°5unum    field width
°5u*      as num, but taken from argument list
°5u</pre>
°5u
°5uThe field width is a minimum, not a maximum: it will be expanded as
°5uneeded to avoid mutilating a value.
°5u
°5uAny field width is followed optionally by a precision:
°5u
°5u<pre>
°5u.num   precision
°5u.      same as .0
°5u.*     as num, but taken from argument list
°5u</pre>
°5u
°5uNegative precision is taken as 0. The meaning of the precision depends
°5uon the conversion type.
°5u
°5u<pre>
°5uIntegral    minimum number of digits to show
°5uRealFloat   number of digits after the decimal point
°5uString      maximum number of characters
°5u</pre>
°5u
°5uThe precision for Integral types is accomplished by zero-padding. If
°5uboth precision and zero-pad are given for an Integral field, the
°5uzero-pad is ignored.
°5u
°5uAny precision is followed optionally for Integral types by a width
°5umodifier; the only use of this modifier being to set the implicit size
°5uof the operand for conversion of a negative operand to unsigned:
°5u
°5u<pre>
°5uhh     Int8
°5uh      Int16
°5ul      Int32
°5ull     Int64
°5uL      Int64
°5u</pre>
°5u
°5uThe specification ends with a format character:
°5u
°5u<pre>
°5uc      character               Integral
°5ud      decimal                 Integral
°5uo      octal                   Integral
°5ux      hexadecimal             Integral
°5uX      hexadecimal             Integral
°5ub      binary                  Integral
°5uu      unsigned decimal        Integral
°5uf      floating point          RealFloat
°5uF      floating point          RealFloat
°5ug      general format float    RealFloat
°5uG      general format float    RealFloat
°5ue      exponent format float   RealFloat
°5uE      exponent format float   RealFloat
°5us      string                  String
°5uv      default format          any type
°5u</pre>
°5u
°5uThe "%v" specifier is provided for all built-in types, and should be
°5uprovided for user-defined type formatters as well. It picks a "best"
°5urepresentation for the given type. For the built-in types the "%v"
°5uspecifier is converted as follows:
°5u
°5u<pre>
°5uc      Char
°5uu      other unsigned Integral
°5ud      other signed Integral
°5ug      RealFloat
°5us      String
°5u</pre>
°5u
°5uMismatch between the argument types and the format string, as well as
°5uany other syntactic or semantic errors in the format string, will
°5ucause an exception to be thrown at runtime.
°5u
°5uNote that the formatting for <a>RealFloat</a> types is currently a bit
°5udifferent from that of C <tt>printf(3)</tt>, conforming instead to
°5u<a>showEFloat</a>, <a>showFFloat</a> and <a>showGFloat</a> (and their
°5ualternate versions <a>showFFloatAlt</a> and <a>showGFloatAlt</a>).
°5uThis is hard to fix: the fixed versions would format in a
°5ubackward-incompatible way. In any case the Haskell behavior is
°5ugenerally more sensible than the C behavior. A brief summary of some
°5ukey differences:
°5u
°5u<ul>
°5u<li>Haskell <a>printf</a> never uses the default "6-digit" precision
°5uused by C printf.</li>
°5u<li>Haskell <a>printf</a> treats the "precision" specifier as
°5uindicating the number of digits after the decimal point.</li>
°5u<li>Haskell <a>printf</a> prints the exponent of e-format numbers
°5uwithout a gratuitous plus sign, and with the minimum possible number
°5uof digits.</li>
°5u<li>Haskell <a>printf</a> will place a zero after a decimal point when
°5upossible.</li>
°5u</ul>
printf :: (PrintfType r) => String -> r

-- | Similar to <a>printf</a>, except that output is via the specified
°5u<a>Handle</a>. The return type is restricted to <tt>(<a>IO</a>
°5ua)</tt>.
hPrintf :: (HPrintfType r) => Handle -> String -> r

-- | Typeclass of <a>printf</a>-formattable values. The <a>formatArg</a>
°5umethod takes a value and a field format descriptor and either fails
°5udue to a bad descriptor or produces a <a>ShowS</a> as the result. The
°5udefault <a>parseFormat</a> expects no modifiers: this is the normal
°5ucase. 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
°5u<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
°5uvary by argument spec.
[fmtAlternate] :: FieldFormat -> Bool

-- | Characters that appeared immediately to the left of <a>fmtChar</a> in
°5uthe format and were accepted by the type's <a>parseFormat</a>.
°5uNormally the empty string.
[fmtModifiers] :: FieldFormat -> String

-- | The format character <a>printf</a> was invoked with. <a>formatArg</a>
°5ushould fail unless this character matches the type. It is normal to
°5uhandle many different format characters for a single type.
[fmtChar] :: FieldFormat -> Char

-- | Whether to left-adjust or zero-pad a field. These are mutually
°5uexclusive, with <a>LeftAdjust</a> taking precedence.
data FormatAdjustment
LeftAdjust :: FormatAdjustment
ZeroPad :: FormatAdjustment

-- | How to handle the sign of a numeric field. These are mutually
°5uexclusive, with <a>SignPlus</a> taking precedence.
data FormatSign
SignPlus :: FormatSign
SignSpace :: FormatSign

-- | Substitute a 'v' format character with the given default format
°5ucharacter in the <a>FieldFormat</a>. A convenience for
°5uuser-implemented types, which should support "%v".
vFmt :: Char -> FieldFormat -> FieldFormat

-- | Type of a function that will parse modifier characters from the format
°5ustring.
type ModifierParser = String -> FormatParse

-- | The "format parser" walks over argument-type-specific modifier
°5ucharacters to find the primary format character. This is the type of
°5uits 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
°5utype.
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
°5uthe argument list.
errorMissingArgument :: a

-- | Calls <a>perror</a> to indicate that there is a type error or similar
°5uin the given argument.
errorBadArgument :: a

-- | Raises an <a>error</a> with a printf-specific prefix on the message
°5ustring.
perror :: String -> a

-- | The <a>PrintfType</a> class provides the variable argument magic for
°5u<a>printf</a>. Its implementation is intentionally not visible from
°5uthis module. If you attempt to pass an argument of a type which is not
°5uan instance of this class to <a>printf</a> or <a>hPrintf</a>, then the
°5ucompiler 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
°5u<a>hPrintf</a>. Its implementation is intentionally not visible from
°5uthis module.
class HPrintfType t

-- | This class, with only the one instance, is used as a workaround for
°5uthe fact that <a>String</a>, as a concrete type, is not allowable as a
°5utypeclass instance. <a>IsChar</a> is exported for
°5ubackward-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
°5unot followed by the garbage collector - that is, the existence of a
°5uweak pointer to an object has no effect on the lifetime of that
°5uobject. A weak pointer can be de-referenced to find out whether the
°5uobject it refers to is still alive or not, and if so to return the
°5uobject itself.
°5u
°5uWeak pointers are particularly useful for caches and memo tables. To
°5ubuild a memo table, you build a data structure mapping from the
°5ufunction argument (the key) to its result (the value). When you apply
°5uthe function to a new argument you first check whether the key/value
°5upair is already in the memo table. The key point is that the memo
°5utable itself should not keep the key and value alive. So the table
°5ushould contain a weak pointer to the key, not an ordinary pointer. The
°5upointer to the value must not be weak, because the only reference to
°5uthe value might indeed be from the memo table.
°5u
°5uSo it looks as if the memo table will keep all its values alive for
°5uever. One way to solve this is to purge the table occasionally, by
°5udeleting entries whose keys have died.
°5u
°5uThe weak pointers in this library support another approach, called
°5u<i>finalization</i>. When the key referred to by a weak pointer dies,
°5uthe storage manager arranges to run a programmer-specified finalizer.
°5uIn the case of memo tables, for example, the finalizer could remove
°5uthe key/value pair from the memo table.
°5u
°5uAnother difficulty with the memo table is that the value of a
°5ukey/value pair might itself contain a pointer to the key. So the memo
°5utable keeps the value alive, which keeps the key alive, even though
°5uthere may be no other references to the key so both should die. The
°5uweak pointers in this library provide a slight generalisation of the
°5ubasic weak-pointer idea, in which each weak pointer actually contains
°5uboth a key and a value.
module System.Mem.Weak

-- | A weak pointer object with a key and a value. The value has type
°5u<tt>v</tt>.
°5u
°5uA weak pointer expresses a relationship between two objects, the
°5u<i>key</i> and the <i>value</i>: if the key is considered to be alive
°5uby the garbage collector, then the value is also alive. A reference
°5ufrom the value to the key does <i>not</i> keep the key alive.
°5u
°5uA weak pointer may also have a finalizer of type <tt>IO ()</tt>; if it
°5udoes, then the finalizer will be run at most once, at a time after the
°5ukey has become unreachable by the program ("dead"). The storage
°5umanager attempts to run the finalizer(s) for an object soon after the
°5uobject dies, but promptness is not guaranteed.
°5u
°5uIt is not guaranteed that a finalizer will eventually run, and no
°5uattempt is made to run outstanding finalizers when the program exits.
°5uTherefore finalizers should not be relied on to clean up resources -
°5uother methods (eg. exception handlers) should be employed, possibly in
°5uaddition to finalizers.
°5u
°5uReferences from the finalizer to the key are treated in the same way
°5uas references from the value to the key: they do not keep the key
°5ualive. A finalizer may therefore ressurrect the key, perhaps by
°5ustoring it in the same data structure.
°5u
°5uThe finalizer, and the relationship between the key and the value,
°5uexist regardless of whether the program keeps a reference to the
°5u<a>Weak</a> object or not.
°5u
°5uThere may be multiple weak pointers with the same key. In this case,
°5uthe finalizers for each of these weak pointers will all be run in some
°5uarbitrary order, or perhaps concurrently, when the key dies. If the
°5uprogrammer specifies a finalizer that assumes it has the only
°5ureference to an object (for example, a file that it wishes to close),
°5uthen the programmer must ensure that there is only one such finalizer.
°5u
°5uIf there are no other threads to run, the runtime system will check
°5ufor runnable finalizers before declaring the system to be deadlocked.
°5u
°5uWARNING: weak pointers to ordinary non-primitive Haskell types are
°5uparticularly fragile, because the compiler is free to optimise away or
°5uduplicate the underlying data structure. Therefore attempting to place
°5ua finalizer on an ordinary Haskell type may well result in the
°5ufinalizer running earlier than you expected. This is not a problem for
°5ucaches and memo tables where early finalization is benign.
°5u
°5uFinalizers <i>can</i> be used reliably for types that are created
°5uexplicitly and have identity, such as <tt>IORef</tt> and
°5u<tt>MVar</tt>. However, to place a finalizer on one of these types,
°5uyou should use the specific operation provided for that type, e.g.
°5u<tt>mkWeakIORef</tt> and <tt>addMVarFinalizer</tt> respectively (the
°5unon-uniformity is accidental). These operations attach the finalizer
°5uto the primitive object inside the box (e.g. <tt>MutVar#</tt> in the
°5ucase of <tt>IORef</tt>), because attaching the finalizer to the box
°5uitself 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
°5ufinalizer.
°5u
°5uThis 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
°5u<tt><a>Just</a> v</tt> is returned (where <tt>v</tt> is the
°5u<i>value</i> in the weak pointer), otherwise <a>Nothing</a> is
°5ureturned.
°5u
°5uThe return value of <a>deRefWeak</a> depends on when the garbage
°5ucollector 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
°5uimmediately.
finalize :: Weak v -> IO ()

-- | A specialised version of <a>mkWeak</a>, where the key and the value
°5uare the same object:
°5u
°5u<pre>
°5umkWeakPtr key finalizer = mkWeak key key finalizer
°5u</pre>
mkWeakPtr :: k -> Maybe (IO ()) -> IO (Weak k)

-- | A specialised version of <a>mkWeakPtr</a>, where the <a>Weak</a>
°5uobject returned is simply thrown away (however the finalizer will be
°5uremembered by the garbage collector, and will still be run when the
°5ukey becomes unreachable).
°5u
°5uNote: adding a finalizer to a <a>ForeignPtr</a> using
°5u<a>addFinalizer</a> won't work; use the specialised version
°5u<a>addForeignPtrFinalizer</a> instead. For discussion see the
°5u<a>Weak</a> type. .
addFinalizer :: key -> IO () -> IO ()

-- | A specialised version of <a>mkWeak</a> where the value is actually a
°5upair of the key and value passed to <a>mkWeakPair</a>:
°5u
°5u<pre>
°5umkWeakPair key val finalizer = mkWeak key (key,val) finalizer
°5u</pre>
°5u
°5uThe advantage of this is that the key can be retrieved by
°5u<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
°5ucomparison between objects.
°5u
°5uStable names solve the following problem: suppose you want to build a
°5uhash table with Haskell objects as keys, but you want to use pointer
°5uequality for comparison; maybe because the keys are large and hashing
°5uwould be slow, or perhaps because the keys are infinite in size. We
°5ucan't build a hash table using the address of the object as the key,
°5ubecause objects get moved around by the garbage collector, meaning a
°5ure-hash would be necessary after every garbage collection.
module System.Mem.StableName

-- | An abstract name for an object, that supports equality and hashing.
°5u
°5uStable names have the following property:
°5u
°5u<ul>
°5u<li>If <tt>sn1 :: StableName</tt> and <tt>sn2 :: StableName</tt> and
°5u<tt>sn1 == sn2</tt> then <tt>sn1</tt> and <tt>sn2</tt> were created by
°5ucalls to <tt>makeStableName</tt> on the same object.</li>
°5u</ul>
°5u
°5uThe reverse is not necessarily true: if two stable names are not
°5uequal, then the objects they name may still be equal. Note in
°5uparticular that <a>makeStableName</a> may return a different
°5u<a>StableName</a> after an object is evaluated.
°5u
°5uStable Names are similar to Stable Pointers
°5u(<a>Foreign.StablePtr</a>), but differ in the following ways:
°5u
°5u<ul>
°5u<li>There is no <tt>freeStableName</tt> operation, unlike
°5u<a>Foreign.StablePtr</a>s. Stable names are reclaimed by the runtime
°5usystem when they are no longer needed.</li>
°5u<li>There is no <tt>deRefStableName</tt> operation. You can't get back
°5ufrom a stable name to the original Haskell object. The reason for this
°5uis that the existence of a stable name for an object does not
°5uguarantee the existence of the object itself; it can still be garbage
°5ucollected.</li>
°5u</ul>
data StableName a

-- | Makes a <a>StableName</a> for an arbitrary object. The object passed
°5uas 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
°5uis not necessarily unique; several <a>StableName</a>s may map to the
°5usame <a>Int</a> (in practice however, the chances of this are small,
°5uso 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
°5uthe 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
°5ubeen allocated by the thread. The counter is initialized to zero, and
°5u<a>setAllocationCounter</a> sets the current value. The allocation
°5ucounter counts *down*, so in the absence of a call to
°5u<a>setAllocationCounter</a> its value is the negation of the number of
°5ubytes of memory allocated by the thread.
°5u
°5uThere are two things that you can do with this counter:
°5u
°5u<ul>
°5u<li>Use it as a simple profiling mechanism, with
°5u<a>getAllocationCounter</a>.</li>
°5u<li>Use it as a resource limit. See <a>enableAllocationLimit</a>.</li>
°5u</ul>
°5u
°5uAllocation accounting is accurate only to about 4Kbytes.
setAllocationCounter :: Int64 -> IO ()

-- | Return the current value of the allocation counter for the current
°5uthread.
getAllocationCounter :: IO Int64

-- | Enables the allocation counter to be treated as a limit for the
°5ucurrent thread. When the allocation limit is enabled, if the
°5uallocation counter counts down below zero, the thread will be sent the
°5u<a>AllocationLimitExceeded</a> asynchronous exception. When this
°5uhappens, the counter is reinitialised (by default to 100K, but tunable
°5uwith the <tt>+RTS -xq</tt> option) so that it can handle the exception
°5uand perform any necessary clean up. If it exhausts this additional
°5uallowance, another <a>AllocationLimitExceeded</a> exception is sent,
°5uand so forth. Like other asynchronous exceptions, the
°5u<a>AllocationLimitExceeded</a> exception is deferred while the thread
°5uis inside <a>mask</a> or an exception handler in <a>catch</a>.
°5u
°5uNote that memory allocation is unrelated to <i>live memory</i>, also
°5uknown as <i>heap residency</i>. A thread can allocate a large amount
°5uof memory and retain anything between none and all of it. It is better
°5uto think of the allocation limit as a limit on <i>CPU time</i>, rather
°5uthan a limit on memory.
°5u
°5uCompared to using timeouts, allocation limits don't count time spent
°5ublocked 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
°5uto 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
°5ubeing interpreted.
compilerName :: String

-- | The version of <a>compilerName</a> with which the program was compiled
°5uor 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
°5uof the code is operating-system dependent. In particular, some values
°5umay be prohibited (e.g. 0 on a POSIX-compliant system).
ExitFailure :: Int -> ExitCode

-- | Computation <a>exitWith</a> <tt>code</tt> throws <a>ExitCode</a>
°5u<tt>code</tt>. Normally this terminates the program, returning
°5u<tt>code</tt> to the program's caller.
°5u
°5uOn program termination, the standard <a>Handle</a>s <a>stdout</a> and
°5u<a>stderr</a> are flushed automatically; any other buffered
°5u<a>Handle</a>s need to be flushed manually, otherwise the buffered
°5udata will be discarded.
°5u
°5uA program that fails in any other way is treated as if it had called
°5u<a>exitFailure</a>. A program that terminates successfully without
°5ucalling <a>exitWith</a> explicitly is treated as if it had called
°5u<a>exitWith</a> <a>ExitSuccess</a>.
°5u
°5uAs an <a>ExitCode</a> is not an <a>IOError</a>, <a>exitWith</a>
°5ubypasses the error handling in the <a>IO</a> monad and cannot be
°5uintercepted by <a>catch</a> from the <a>Prelude</a>. However it is a
°5u<tt>SomeException</tt>, and can be caught using the functions of
°5u<a>Control.Exception</a>. This means that cleanup computations added
°5uwith <a>bracket</a> (from <a>Control.Exception</a>) are also executed
°5uproperly on <a>exitWith</a>.
°5u
°5uNote: in GHC, <a>exitWith</a> should be called from the main program
°5uthread in order to exit the process. When called from another thread,
°5u<a>exitWith</a> will throw an <tt>ExitException</tt> as normal, but
°5uthe exception will not cause the process itself to exit.
exitWith :: ExitCode -> IO a

-- | The computation <a>exitFailure</a> is equivalent to <a>exitWith</a>
°5u<tt>(</tt><a>ExitFailure</a> <i>exitfail</i><tt>)</tt>, where
°5u<i>exitfail</i> is implementation-dependent.
exitFailure :: IO a

-- | The computation <a>exitSuccess</a> is equivalent to <a>exitWith</a>
°5u<a>ExitSuccess</a>, It terminates the program successfully.
exitSuccess :: IO a

-- | Write given error message to <a>stderr</a> and terminate with
°5u<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
°5uline arguments (not including the program name).
getArgs :: IO [String]

-- | Computation <a>getProgName</a> returns the name of the program as it
°5uwas invoked.
°5u
°5uHowever, this is hard-to-impossible to implement on some non-Unix
°5uOSes, so instead, for maximum portability, we just return the leafname
°5uof the program as invoked. Even then there are some differences
°5ubetween platforms: on Windows, for example, a program invoked as foo
°5uis probably really <tt>FOO.EXE</tt>, and that is what
°5u<a>getProgName</a> will return.
getProgName :: IO String

-- | Returns the absolute pathname of the current executable.
°5u
°5uNote that for scripts and interactive sessions, this is the path to
°5uthe interpreter (e.g. ghci.)
°5u
°5uSince base 4.11.0.0, <a>getExecutablePath</a> resolves symlinks on
°5uWindows. If an executable is launched through a symlink,
°5u<a>getExecutablePath</a> returns the absolute path of the original
°5uexecutable.
getExecutablePath :: IO FilePath

-- | Computation <a>getEnv</a> <tt>var</tt> returns the value of the
°5uenvironment variable <tt>var</tt>. For the inverse, POSIX users can
°5uuse <a>putEnv</a>.
°5u
°5uThis computation may fail with:
°5u
°5u<ul>
°5u<li><a>isDoesNotExistError</a> if the environment variable does not
°5uexist.</li>
°5u</ul>
getEnv :: String -> IO String

-- | Return the value of the environment variable <tt>var</tt>, or
°5u<tt>Nothing</tt> if there is no such value.
°5u
°5uFor 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
°5u<tt>value</tt>.
°5u
°5uEarly versions of this function operated under the mistaken belief
°5uthat setting an environment variable to the <i>empty string</i> on
°5uWindows removes that environment variable from the environment. For
°5uthe sake of compatibility, it adopted that behavior on POSIX. In
°5uparticular
°5u
°5u<pre>
°5usetEnv name ""
°5u</pre>
°5u
°5uhas the same effect as
°5u
°5u<pre>
°5u<a>unsetEnv</a> name
°5u</pre>
°5u
°5uIf you'd like to be able to set environment variables to blank
°5ustrings, use <a>setEnv</a>.
°5u
°5uThrows <a>IOException</a> if <tt>name</tt> is the empty string or
°5ucontains an equals sign.
setEnv :: String -> String -> IO ()

-- | <tt>unsetEnv name</tt> removes the specified environment variable from
°5uthe environment of the current process.
°5u
°5uThrows <a>IOException</a> if <tt>name</tt> is the empty string or
°5ucontains an equals sign.
unsetEnv :: String -> IO ()

-- | <a>withArgs</a> <tt>args act</tt> - while executing action
°5u<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
°5u<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
°5u<tt>(key,value)</tt> pairs.
°5u
°5uIf an environment entry does not contain an <tt>'='</tt> character,
°5uthe <tt>key</tt> is the whole entry and the <tt>value</tt> is the
°5uempty string.
getEnvironment :: IO [(String, String)]


-- | A setEnv implementation that allows blank environment variables.
°5uMimics the <a>Env</a> module from the <tt>unix</tt> package, but with
°5usupport for Windows too.
°5u
°5uThe matrix of platforms that:
°5u
°5u<ul>
°5u<li>support putenv(<a>FOO</a>) to unset environment variables,</li>
°5u<li>support putenv("FOO=") to unset environment variables or set them
°5uto blank values,</li>
°5u<li>support unsetenv to unset environment variables,</li>
°5u<li>support setenv to set environment variables,</li>
°5u<li>etc.</li>
°5u</ul>
°5u
°5uis very complicated. I think AIX is screwed, but we don't support it.
°5uThe whole situation with setenv(3), unsetenv(3), and putenv(3) is not
°5ugood. Even mingw32 adds its own crap to the pile, but luckily, we can
°5ujust use Windows' native environment functions to sidestep the issue.
°5u
°5u#12494
module System.Environment.Blank

-- | Returns the absolute pathname of the current executable.
°5u
°5uNote that for scripts and interactive sessions, this is the path to
°5uthe interpreter (e.g. ghci.)
°5u
°5uSince base 4.11.0.0, <a>getExecutablePath</a> resolves symlinks on
°5uWindows. If an executable is launched through a symlink,
°5u<a>getExecutablePath</a> returns the absolute path of the original
°5uexecutable.
getExecutablePath :: IO FilePath

-- | Computation <a>getArgs</a> returns a list of the program's command
°5uline arguments (not including the program name).
getArgs :: IO [String]

-- | Computation <a>getProgName</a> returns the name of the program as it
°5uwas invoked.
°5u
°5uHowever, this is hard-to-impossible to implement on some non-Unix
°5uOSes, so instead, for maximum portability, we just return the leafname
°5uof the program as invoked. Even then there are some differences
°5ubetween platforms: on Windows, for example, a program invoked as foo
°5uis probably really <tt>FOO.EXE</tt>, and that is what
°5u<a>getProgName</a> will return.
getProgName :: IO String

-- | <a>withArgs</a> <tt>args act</tt> - while executing action
°5u<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
°5u<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
°5u<tt>(key,value)</tt> pairs.
°5u
°5uIf an environment entry does not contain an <tt>'='</tt> character,
°5uthe <tt>key</tt> is the whole entry and the <tt>value</tt> is the
°5uempty 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
°5ufunction 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
°5uvariables.
unsetEnv :: String -> IO ()


-- | This library provides facilities for parsing the command-line options
°5uin a standalone program. It is essentially a Haskell port of the GNU
°5u<tt>getopt</tt> library.
module System.Console.GetOpt

-- | Process the command-line, and return the list of values that matched
°5u(and those that didn't). The arguments are:
°5u
°5u<ul>
°5u<li>The order requirements (see <a>ArgOrder</a>)</li>
°5u<li>The option descriptions (see <a>OptDescr</a>)</li>
°5u<li>The actual command line arguments (presumably got from
°5u<a>getArgs</a>).</li>
°5u</ul>
°5u
°5u<a>getOpt</a> returns a triple consisting of the option arguments, a
°5ulist 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
°5uconsisting of the option arguments, a list of non-options, a list of
°5uunrecognized 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
°5uheader (first argument) and the options described by the second
°5uargument.
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.
°5u
°5uThe arguments to <a>Option</a> are:
°5u
°5u<ul>
°5u<li>list of short option characters</li>
°5u<li>list of long option strings (without "--")</li>
°5u<li>argument descriptor</li>
°5u<li>explanation of option for user</li>
°5u</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
°5uthe 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
°5utime used by the current program. The precision of this result is
°5uimplementation-dependent.
getCPUTime :: IO Integer

-- | The <a>cpuTimePrecision</a> constant is the smallest measurable
°5udifference in CPU time that the implementation can record, and is
°5ugiven as an integral number of picoseconds.
cpuTimePrecision :: Integer


-- | This module defines the <a>HasField</a> class used by the
°5u<tt>OverloadedRecordFields</tt> extension. See the
°5u&lt;<a>https://ghc.haskell.org/trac/ghc/wiki/Records/OverloadedRecordFields</a>
°5uwiki page&gt; for more details.
module GHC.Records

-- | Constraint representing the fact that the field <tt>x</tt> belongs to
°5uthe record type <tt>r</tt> and has field type <tt>a</tt>. This will be
°5usolved 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
°5u<tt>OverloadedLabels</tt> extension. See the <a>wiki page</a> for more
°5udetails.
°5u
°5uWhen <tt>OverloadedLabels</tt> is enabled, if GHC sees an occurrence
°5uof the overloaded label syntax <tt>#foo</tt>, it is replaced with
°5u
°5u<pre>
°5ufromLabel @"foo" :: alpha
°5u</pre>
°5u
°5uplus a wanted constraint <tt>IsLabel "foo" alpha</tt>.
°5u
°5uNote that if <tt>RebindableSyntax</tt> is enabled, the desugaring of
°5uoverloaded label syntax will make use of whatever <tt>fromLabel</tt>
°5uis 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
°5ucompared for equality and ordering and hashed into <a>Int</a>.
°5u
°5u<pre>
°5u&gt;&gt;&gt; :{
°5udo x &lt;- newUnique
°5u   print (x == x)
°5u   y &lt;- newUnique
°5u   print (x == y)
°5u:}
°5uTrue
°5uFalse
°5u</pre>
data Unique

-- | Creates a new object of type <a>Unique</a>. The value returned will
°5unot compare equal to any other value of type <a>Unique</a> returned by
°5uprevious calls to <a>newUnique</a>. There is no limit on the number of
°5utimes <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
°5uto the same value, although in practice this is unlikely. The
°5u<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
°5uthread <tt>s</tt>, containing a value of type <tt>a</tt>
°5u
°5u<pre>
°5u&gt;&gt;&gt; :{
°5urunST (do
°5u    ref &lt;- newSTRef "hello"
°5u    x &lt;- readSTRef ref
°5u    writeSTRef ref (x ++ "world")
°5u    readSTRef ref )
°5u:}
°5u"helloworld"
°5u</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>.
°5u
°5u<pre>
°5u&gt;&gt;&gt; :{
°5urunST (do
°5u    ref &lt;- newSTRef ""
°5u    modifySTRef ref (const "world")
°5u    modifySTRef ref (++ "!")
°5u    modifySTRef ref ("Hello, " ++)
°5u    readSTRef ref )
°5u:}
°5u"Hello, world!"
°5u</pre>
°5u
°5uBe warned that <a>modifySTRef</a> does not apply the function
°5ustrictly. This means if the program calls <a>modifySTRef</a> many
°5utimes, but seldomly uses the value, thunks will pile up in memory
°5uresulting in a space leak. This is a common mistake made when using an
°5uSTRef as a counter. For example, the following will leak memory and
°5umay produce a stack overflow:
°5u
°5u<pre>
°5u&gt;&gt;&gt; import Control.Monad (replicateM_)
°5u
°5u&gt;&gt;&gt; :{
°5uprint (runST (do
°5u    ref &lt;- newSTRef 0
°5u    replicateM_ 1000 $ modifySTRef ref (+1)
°5u    readSTRef ref ))
°5u:}
°5u1000
°5u</pre>
°5u
°5uTo 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
°5u<a>Data.STRef</a>)
module Data.STRef.Strict


-- | Standard functions on rational numbers
module Data.Ratio

-- | Rational numbers, with numerator and denominator of some
°5u<a>Integral</a> type.
data Ratio a

-- | Arbitrary-precision rational numbers, represented as a ratio of two
°5u<a>Integer</a> values. A rational number may be constructed using the
°5u<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
°5udenominator have no common factor and the denominator is positive.
numerator :: Ratio a -> a

-- | Extract the denominator of the ratio in reduced form: the numerator
°5uand denominator have no common factor and the denominator is positive.
denominator :: Ratio a -> a

-- | <a>approxRational</a>, applied to two real fractional numbers
°5u<tt>x</tt> and <tt>epsilon</tt>, returns the simplest rational number
°5uwithin <tt>epsilon</tt> of <tt>x</tt>. A rational number <tt>y</tt> is
°5usaid to be <i>simpler</i> than another <tt>y'</tt> if
°5u
°5u<ul>
°5u<li><tt><a>abs</a> (<a>numerator</a> y) &lt;= <a>abs</a>
°5u(<a>numerator</a> y')</tt>, and</li>
°5u<li><tt><a>denominator</a> y &lt;= <a>denominator</a> y'</tt>.</li>
°5u</ul>
°5u
°5uAny real interval contains a unique simplest rational; in particular,
°5unote 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
°5utype onto integers. It is used primarily for array indexing (see the
°5uarray 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
°5ua type onto integers. It is used primarily for array indexing (see the
°5uarray package).
°5u
°5uThe first argument <tt>(l,u)</tt> of each of these operations is a
°5upair specifying the lower and upper bounds of a contiguous subrange of
°5uvalues.
°5u
°5uAn implementation is entitled to assume the following laws about these
°5uoperations:
°5u
°5u<ul>
°5u<li><tt><a>inRange</a> (l,u) i == <a>elem</a> i (<a>range</a>
°5u(l,u))</tt> <tt> </tt></li>
°5u<li><tt><a>range</a> (l,u) <a>!!</a> <a>index</a> (l,u) i == i</tt>,
°5uwhen <tt><a>inRange</a> (l,u) i</tt></li>
°5u<li><tt><a>map</a> (<a>index</a> (l,u)) (<a>range</a> (l,u))) ==
°5u[0..<a>rangeSize</a> (l,u)-1]</tt> <tt> </tt></li>
°5u<li><tt><a>rangeSize</a> (l,u) == <a>length</a> (<a>range</a>
°5u(l,u))</tt> <tt> </tt></li>
°5u</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
°5ubounding 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
°5udescribed in the PLDI '94 paper by John Launchbury and Simon Peyton
°5uJones <i>Lazy Functional State Threads</i>.
°5u
°5uUnsafe API.
module Control.Monad.ST.Unsafe

-- | <a>unsafeInterleaveST</a> allows an <a>ST</a> computation to be
°5udeferred lazily. When passed a value of type <tt>ST a</tt>, the
°5u<a>ST</a> computation will only be performed when the value of the
°5u<tt>a</tt> is demanded.
unsafeInterleaveST :: ST s a -> ST s a

-- | <a>unsafeDupableInterleaveST</a> allows an <a>ST</a> computation to be
°5udeferred lazily. When passed a value of type <tt>ST a</tt>, the
°5u<a>ST</a> computation will only be performed when the value of the
°5u<tt>a</tt> is demanded.
°5u
°5uThe computation may be performed multiple times by different threads,
°5upossibly at the same time. To prevent this, use
°5u<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
°5u<a>IO</a> and <a>ST</a> having the same representation modulo the
°5uconstraint 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
°5u<a>IO</a> and <a>ST</a> having the same representation modulo the
°5uconstraint on the type of the state.
°5u
°5uFor an example demonstrating why this is unsafe, see
°5u<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
°5udescribed in the PLDI '94 paper by John Launchbury and Simon Peyton
°5uJones <i>Lazy Functional State Threads</i>.
°5u
°5uSafe API Only.

-- | <i>Deprecated: Safe is now the default, please use Control.Monad.ST
°5uinstead</i>
module Control.Monad.ST.Safe

-- | The strict state-transformer monad. A computation of type
°5u<tt><a>ST</a> s a</tt> transforms an internal state indexed by
°5u<tt>s</tt>, and returns a value of type <tt>a</tt>. The <tt>s</tt>
°5uparameter is either
°5u
°5u<ul>
°5u<li>an uninstantiated type variable (inside invocations of
°5u<a>runST</a>), or</li>
°5u<li><a>RealWorld</a> (inside invocations of <a>stToIO</a>).</li>
°5u</ul>
°5u
°5uIt serves to keep the internal states of different invocations of
°5u<a>runST</a> separate from each other and from invocations of
°5u<a>stToIO</a>.
°5u
°5uThe <a>&gt;&gt;=</a> and <a>&gt;&gt;</a> operations are strict in the
°5ustate (though not in values stored in the state). For example,
°5u
°5u<pre>
°5u<a>runST</a> (writeSTRef _|_ v &gt;&gt;= f) = _|_
°5u</pre>
data ST s a

-- | Return the value computed by a state transformer computation. The
°5u<tt>forall</tt> ensures that the internal state used by the <a>ST</a>
°5ucomputation 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
°5u(lazily) inside the computation. Note that if <tt>f</tt> is strict,
°5u<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
°5uis not <i>unlifted</i> (hence <tt>ptrArg</tt>). We never manipulate
°5uvalues of type <tt>RealWorld</tt>; it's only used in the type system,
°5uto parameterise <tt>State#</tt>.
data RealWorld

-- | Embed a strict state transformer in an <a>IO</a> action. The
°5u<a>RealWorld</a> parameter indicates that the internal state used by
°5uthe <a>ST</a> computation is a special one supplied by the <a>IO</a>
°5umonad, and thus distinct from those used by invocations of
°5u<a>runST</a>.
stToIO :: ST RealWorld a -> IO a


-- | This library provides support for <i>strict</i> state threads, as
°5udescribed in the PLDI '94 paper by John Launchbury and Simon Peyton
°5uJones <i>Lazy Functional State Threads</i>.
°5u
°5uReferences (variables) that can be used within the <tt>ST</tt> monad
°5uare provided by <a>Data.STRef</a>, and arrays are provided by
°5u<a>Data.Array.ST</a>.
module Control.Monad.ST

-- | The strict state-transformer monad. A computation of type
°5u<tt><a>ST</a> s a</tt> transforms an internal state indexed by
°5u<tt>s</tt>, and returns a value of type <tt>a</tt>. The <tt>s</tt>
°5uparameter is either
°5u
°5u<ul>
°5u<li>an uninstantiated type variable (inside invocations of
°5u<a>runST</a>), or</li>
°5u<li><a>RealWorld</a> (inside invocations of <a>stToIO</a>).</li>
°5u</ul>
°5u
°5uIt serves to keep the internal states of different invocations of
°5u<a>runST</a> separate from each other and from invocations of
°5u<a>stToIO</a>.
°5u
°5uThe <a>&gt;&gt;=</a> and <a>&gt;&gt;</a> operations are strict in the
°5ustate (though not in values stored in the state). For example,
°5u
°5u<pre>
°5u<a>runST</a> (writeSTRef _|_ v &gt;&gt;= f) = _|_
°5u</pre>
data ST s a

-- | Return the value computed by a state transformer computation. The
°5u<tt>forall</tt> ensures that the internal state used by the <a>ST</a>
°5ucomputation 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
°5u(lazily) inside the computation. Note that if <tt>f</tt> is strict,
°5u<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
°5uis not <i>unlifted</i> (hence <tt>ptrArg</tt>). We never manipulate
°5uvalues of type <tt>RealWorld</tt>; it's only used in the type system,
°5uto parameterise <tt>State#</tt>.
data RealWorld

-- | Embed a strict state transformer in an <a>IO</a> action. The
°5u<a>RealWorld</a> parameter indicates that the internal state used by
°5uthe <a>ST</a> computation is a special one supplied by the <a>IO</a>
°5umonad, and thus distinct from those used by invocations of
°5u<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
°5u<a>Control.Monad.ST</a>, except that the monad delays evaluation of
°5ustate operations until a value depending on them is required.
°5u
°5uUnsafe 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
°5u<a>Control.Monad.ST</a>, except that the monad delays evaluation of
°5ustate operations until a value depending on them is required.
°5u
°5uSafe API only.

-- | <i>Deprecated: Safe is now the default, please use
°5uControl.Monad.ST.Lazy instead</i>
module Control.Monad.ST.Lazy.Safe

-- | The lazy state-transformer monad. A computation of type <tt><a>ST</a>
°5us a</tt> transforms an internal state indexed by <tt>s</tt>, and
°5ureturns a value of type <tt>a</tt>. The <tt>s</tt> parameter is either
°5u
°5u<ul>
°5u<li>an uninstantiated type variable (inside invocations of
°5u<a>runST</a>), or</li>
°5u<li><a>RealWorld</a> (inside invocations of <a>stToIO</a>).</li>
°5u</ul>
°5u
°5uIt serves to keep the internal states of different invocations of
°5u<a>runST</a> separate from each other and from invocations of
°5u<a>stToIO</a>.
°5u
°5uThe <a>&gt;&gt;=</a> and <a>&gt;&gt;</a> operations are not strict in
°5uthe state. For example,
°5u
°5u<pre>
°5u<a>runST</a> (writeSTRef _|_ v &gt;&gt;= readSTRef _|_ &gt;&gt; return 2) = 2
°5u</pre>
data ST s a

-- | Return the value computed by a state transformer computation. The
°5u<tt>forall</tt> ensures that the internal state used by the <a>ST</a>
°5ucomputation 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
°5u(lazily) inside the computation. Note that if <tt>f</tt> is strict,
°5u<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
°5ustate thread passed to <a>strictToLazyST</a> is not performed until
°5uthe 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
°5uis not <i>unlifted</i> (hence <tt>ptrArg</tt>). We never manipulate
°5uvalues of type <tt>RealWorld</tt>; it's only used in the type system,
°5uto parameterise <tt>State#</tt>.
data RealWorld

-- | A monad transformer embedding lazy state transformers in the <a>IO</a>
°5umonad. The <a>RealWorld</a> parameter indicates that the internal
°5ustate used by the <a>ST</a> computation is a special one supplied by
°5uthe <a>IO</a> monad, and thus distinct from those used by invocations
°5uof <a>runST</a>.
stToIO :: ST RealWorld a -> IO a


-- | This module presents an identical interface to
°5u<a>Control.Monad.ST</a>, except that the monad delays evaluation of
°5ustate 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>
°5us a</tt> transforms an internal state indexed by <tt>s</tt>, and
°5ureturns a value of type <tt>a</tt>. The <tt>s</tt> parameter is either
°5u
°5u<ul>
°5u<li>an uninstantiated type variable (inside invocations of
°5u<a>runST</a>), or</li>
°5u<li><a>RealWorld</a> (inside invocations of <a>stToIO</a>).</li>
°5u</ul>
°5u
°5uIt serves to keep the internal states of different invocations of
°5u<a>runST</a> separate from each other and from invocations of
°5u<a>stToIO</a>.
°5u
°5uThe <a>&gt;&gt;=</a> and <a>&gt;&gt;</a> operations are not strict in
°5uthe state. For example,
°5u
°5u<pre>
°5u<a>runST</a> (writeSTRef _|_ v &gt;&gt;= readSTRef _|_ &gt;&gt; return 2) = 2
°5u</pre>
data ST s a

-- | Return the value computed by a state transformer computation. The
°5u<tt>forall</tt> ensures that the internal state used by the <a>ST</a>
°5ucomputation 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
°5u(lazily) inside the computation. Note that if <tt>f</tt> is strict,
°5u<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
°5ustate thread passed to <a>strictToLazyST</a> is not performed until
°5uthe 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
°5uis not <i>unlifted</i> (hence <tt>ptrArg</tt>). We never manipulate
°5uvalues of type <tt>RealWorld</tt>; it's only used in the type system,
°5uto parameterise <tt>State#</tt>.
data RealWorld

-- | A monad transformer embedding lazy state transformers in the <a>IO</a>
°5umonad. The <a>RealWorld</a> parameter indicates that the internal
°5ustate used by the <a>ST</a> computation is a special one supplied by
°5uthe <a>IO</a> monad, and thus distinct from those used by invocations
°5uof <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
°5uthread <tt>s</tt>, containing a value of type <tt>a</tt>
°5u
°5u<pre>
°5u&gt;&gt;&gt; :{
°5urunST (do
°5u    ref &lt;- newSTRef "hello"
°5u    x &lt;- readSTRef ref
°5u    writeSTRef ref (x ++ "world")
°5u    readSTRef ref )
°5u:}
°5u"helloworld"
°5u</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>
°5u
°5u<a>Functor</a> and <a>Monad</a> instances for <tt>(-&gt;) r</tt> and
°5u<a>Functor</a> instances for <tt>(,) a</tt> and <tt><a>Either</a>
°5ua</tt>.

-- | <i>Deprecated: This module now contains no instances and will be
°5uremoved in the future</i>
module Control.Monad.Instances

-- | The <a>Functor</a> class is used for types that can be mapped over.
°5uInstances of <a>Functor</a> should satisfy the following laws:
°5u
°5u<pre>
°5ufmap id  ==  id
°5ufmap (f . g)  ==  fmap f . fmap g
°5u</pre>
°5u
°5uThe instances of <a>Functor</a> for lists, <a>Maybe</a> and <a>IO</a>
°5usatisfy 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
°5udefinition is <tt><a>fmap</a> . <a>const</a></tt>, but this may be
°5uoverridden with a more efficient version.
(<$) :: Functor f => a -> f b -> f a

-- | The <a>Monad</a> class defines the basic operations over a
°5u<i>monad</i>, a concept from a branch of mathematics known as
°5u<i>category theory</i>. From the perspective of a Haskell programmer,
°5uhowever, it is best to think of a monad as an <i>abstract datatype</i>
°5uof actions. Haskell's <tt>do</tt> expressions provide a convenient
°5usyntax for writing monadic expressions.
°5u
°5uInstances of <a>Monad</a> should satisfy the following laws:
°5u
°5u<ul>
°5u<li><pre><a>return</a> a <a>&gt;&gt;=</a> k = k a</pre></li>
°5u<li><pre>m <a>&gt;&gt;=</a> <a>return</a> = m</pre></li>
°5u<li><pre>m <a>&gt;&gt;=</a> (\x -&gt; k x <a>&gt;&gt;=</a> h) = (m
°5u<a>&gt;&gt;=</a> k) <a>&gt;&gt;=</a> h</pre></li>
°5u</ul>
°5u
°5uFurthermore, the <a>Monad</a> and <a>Applicative</a> operations should
°5urelate as follows:
°5u
°5u<ul>
°5u<li><pre><a>pure</a> = <a>return</a></pre></li>
°5u<li><pre>(<a>&lt;*&gt;</a>) = <a>ap</a></pre></li>
°5u</ul>
°5u
°5uThe above laws imply:
°5u
°5u<ul>
°5u<li><pre><a>fmap</a> f xs = xs <a>&gt;&gt;=</a> <a>return</a> .
°5uf</pre></li>
°5u<li><pre>(<a>&gt;&gt;</a>) = (<a>*&gt;</a>)</pre></li>
°5u</ul>
°5u
°5uand that <a>pure</a> and (<a>&lt;*&gt;</a>) satisfy the applicative
°5ufunctor laws.
°5u
°5uThe instances of <a>Monad</a> for lists, <a>Maybe</a> and <a>IO</a>
°5udefined in the <a>Prelude</a> satisfy these laws.
class Applicative m => Monad m

-- | Sequentially compose two actions, passing any value produced by the
°5ufirst 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
°5ufirst, like sequencing operators (such as the semicolon) in imperative
°5ulanguages.
(>>) :: 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
°5udefinition of a monad, but is invoked on pattern-match failure in a
°5u<tt>do</tt> expression.
°5u
°5uAs part of the MonadFail proposal (MFP), this function is moved to its
°5uown class <tt>MonadFail</tt> (see <a>Control.Monad.Fail</a> for more
°5udetails). 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
°5ubuilt by applying a sequence of monad transformers to the <a>IO</a>
°5umonad will be an instance of this class.
°5u
°5uInstances should satisfy the following laws, which state that
°5u<a>liftIO</a> is a transformer of monads:
°5u
°5u<ul>
°5u<li><pre><a>liftIO</a> . <a>return</a> = <a>return</a></pre></li>
°5u<li><pre><a>liftIO</a> (m &gt;&gt;= f) = <a>liftIO</a> m &gt;&gt;=
°5u(<a>liftIO</a> . f)</pre></li>
°5u</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
°5uusage statistics. These statistics are not available unless a program
°5uis run with the <tt>-T</tt> RTS flag.
°5u
°5uThis module is GHC-only and should not be considered portable.
module GHC.Stats

-- | Statistics about runtime activity since the start of the program. This
°5uis 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
°5uaverage 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
°5uGCDetails</tt> in <tt>RtsAPI.h</tt>, with the field prefixed with
°5u<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.
°5uDeprecated.
[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
°5uexample).
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
°5u<a>GHC User's Guide</a>, or by running RTS help message using <tt>+RTS
°5u--help</tt>.
module GHC.RTS.Flags

-- | <tt><tt>Time</tt></tt> is defined as a <tt><tt>StgWord64</tt></tt> in
°5u<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
°5uthe 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
°5usubsystems.
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
°5uimplementation is considered low overhead. Basic usage looks like
°5uthis:
°5u
°5u<pre>
°5uimport GHC.ExecutionStack
°5u
°5umyFunction :: IO ()
°5umyFunction = do
°5u     putStrLn =&lt;&lt; showStackTrace
°5u</pre>
°5u
°5uYour GHC must have been built with <tt>libdw</tt> support for this to
°5uwork.
°5u
°5u<pre>
°5uuser@host:~$ ghc --info | grep libdw
°5u ,("RTS expects libdw",<a>YES</a>)
°5u</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.
°5u
°5uReturns <tt>Nothing</tt> if stack trace support isn't available on
°5uhost 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,
°5ubut is otherwise identical to the traditional list type in complexity
°5uand in terms of API. You will almost certainly want to import this
°5umodule <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
°5u<tt>x</tt>.
°5u
°5u<pre>
°5uintersperse 0 (1 :| [2,3]) == 1 :| [0,2,0,3]
°5u</pre>
intersperse :: a -> NonEmpty a -> NonEmpty a

-- | <a>scanl</a> is similar to <a>foldl</a>, but returns a stream of
°5usuccessive reduced values from the left:
°5u
°5u<pre>
°5uscanl f z [x1, x2, ...] == z :| [z `f` x1, (z `f` x1) `f` x2, ...]
°5u</pre>
°5u
°5uNote that
°5u
°5u<pre>
°5ulast (scanl f z xs) == foldl f z xs.
°5u</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
°5u
°5u<pre>
°5uhead (scanr f z xs) == foldr f z xs.
°5u</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
°5uargument:
°5u
°5u<pre>
°5uscanl1 f [x1, x2, ...] == x1 :| [x1 `f` x2, x1 `f` (x2 `f` x3), ...]
°5u</pre>
scanl1 :: (a -> a -> a) -> NonEmpty a -> NonEmpty a

-- | <a>scanr1</a> is a variant of <a>scanr</a> that has no starting value
°5uargument.
scanr1 :: (a -> a -> a) -> NonEmpty a -> NonEmpty a

-- | <a>transpose</a> for <a>NonEmpty</a>, behaves the same as
°5u<a>transpose</a> The rows/columns need not be the same length, in
°5uwhich 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:
°5u
°5u<pre>
°5usortBy . comparing
°5u</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
°5uof 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
°5u<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
°5uthe 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
°5uthe 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
°5uapplications of <tt>f</tt> to <tt>x</tt>.
°5u
°5u<pre>
°5uiterate f x = x :| [f x, f (f x), ..]
°5u</pre>
iterate :: (a -> a) -> a -> NonEmpty a

-- | <tt><a>repeat</a> x</tt> returns a constant stream, where all elements
°5uare equal to <tt>x</tt>.
repeat :: a -> NonEmpty a

-- | <tt><a>cycle</a> xs</tt> returns the infinite repetition of
°5u<tt>xs</tt>:
°5u
°5u<pre>
°5ucycle (1 :| [2,3]) = 1 :| [2,3,1,2,3,...]
°5u</pre>
cycle :: NonEmpty a -> NonEmpty a

-- | <a>unfold</a> produces a new stream by repeatedly applying the
°5uunfolding function to the seed value to produce an element of type
°5u<tt>b</tt> and a new seed value. When the unfolding function returns
°5u<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
°5uin <tt>xs</tt> where it is still less than or equal to the next
°5uelement. In particular, if the list is sorted beforehand, the result
°5uwill 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
°5u<tt>xs</tt>.
take :: Int -> NonEmpty a -> [a]

-- | <tt><a>drop</a> n xs</tt> drops the first <tt>n</tt> elements off the
°5ufront 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
°5uof <tt>xs</tt> of length <tt>n</tt> and the remaining stream
°5uimmediately following this prefix.
°5u
°5u<pre>
°5u'splitAt' n xs == ('take' n xs, 'drop' n xs)
°5uxs == ys ++ zs where (ys, zs) = 'splitAt' n xs
°5u</pre>
splitAt :: Int -> NonEmpty a -> ([a], [a])

-- | <tt><a>takeWhile</a> p xs</tt> returns the longest prefix of the
°5ustream <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
°5u<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>
°5uthat satisfies <tt>p</tt>, together with the remainder of the stream.
°5u
°5u<pre>
°5u'span' p xs == ('takeWhile' p xs, 'dropWhile' p xs)
°5uxs == ys ++ zs where (ys, zs) = 'span' p xs
°5u</pre>
span :: (a -> Bool) -> NonEmpty a -> ([a], [a])

-- | The <tt><a>break</a> p</tt> function is equivalent to <tt><a>span</a>
°5u(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
°5udo not satisfy <tt>p</tt>.
filter :: (a -> Bool) -> NonEmpty a -> [a]

-- | The <a>partition</a> function takes a predicate <tt>p</tt> and a
°5ustream <tt>xs</tt>, and returns a pair of lists. The first list
°5ucorresponds to the elements of <tt>xs</tt> for which <tt>p</tt> holds;
°5uthe second corresponds to the elements of <tt>xs</tt> for which
°5u<tt>p</tt> does not hold.
°5u
°5u<pre>
°5u'partition' p xs = ('filter' p xs, 'filter' (not . p) xs)
°5u</pre>
partition :: (a -> Bool) -> NonEmpty a -> ([a], [a])

-- | The <a>group</a> function takes a stream and returns a list of streams
°5usuch that flattening the resulting list is equal to the argument.
°5uMoreover, each stream in the resulting list contains only equal
°5uelements. For example, in list notation:
°5u
°5u<pre>
°5u'group' $ 'cycle' "Mississippi"
°5u  = "M" : "i" : "ss" : "i" : "ss" : "i" : "pp" : "i" : "M" : "i" : ...
°5u</pre>
group :: (Foldable f, Eq a) => f a -> [NonEmpty a]

-- | <a>groupBy</a> operates like <a>group</a>, but uses the provided
°5uequality 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
°5uprojection 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
°5ufirst so that each equivalence class has, at most, one list in the
°5uoutput
groupAllWith :: (Ord b) => (a -> b) -> [a] -> [NonEmpty a]

-- | <a>group1</a> operates like <a>group</a>, but uses the knowledge that
°5uits 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
°5u<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
°5u<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
°5uto <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
°5uargument 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
°5uparticular, it keeps only the first occurrence of each element. (The
°5uname <a>nub</a> means 'essence'.) It is a special case of
°5u<a>nubBy</a>, which allows the programmer to supply their own
°5uinequality test.
nub :: Eq a => NonEmpty a -> NonEmpty a

-- | The <a>nubBy</a> function behaves just like <a>nub</a>, except it uses
°5ua user-supplied equality predicate instead of the overloaded <a>==</a>
°5ufunction.
nubBy :: (a -> a -> Bool) -> NonEmpty a -> NonEmpty a

-- | <tt>xs !! n</tt> returns the element of the stream <tt>xs</tt> at
°5uindex <tt>n</tt>. Note that the head of the stream has index 0.
°5u
°5u<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
°5ucorresponding pairs.
zip :: NonEmpty a -> NonEmpty b -> NonEmpty (a, b)

-- | The <a>zipWith</a> function generalizes <a>zip</a>. Rather than
°5utupling the elements, the elements are combined using the function
°5upassed 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.
°5u
°5uRaises 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>
°5ustream, 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
°5u<a>mzipWith</a>
°5u
°5uInstances should satisfy the laws:
°5u
°5u<ul>
°5u<li>Naturality :</li>
°5u</ul>
°5u
°5u<pre>
°5uliftM (f *** g) (mzip ma mb) = mzip (liftM f ma) (liftM g mb)
°5u</pre>
°5u
°5u<ul>
°5u<li>Information Preservation:</li>
°5u</ul>
°5u
°5u<pre>
°5uliftM (const ()) ma = liftM (const ()) mb
°5u==&gt;
°5umunzip (mzip ma mb) = (ma, mb)
°5u</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
°5u<a>Show</a> to unary and binary type constructors.
°5u
°5uThese classes are needed to express the constraints on arguments of
°5utransformers in portable Haskell. Thus for a new transformer
°5u<tt>T</tt>, one might write instances like
°5u
°5u<pre>
°5uinstance (Eq1 f) =&gt; Eq1 (T f) where ...
°5uinstance (Ord1 f) =&gt; Ord1 (T f) where ...
°5uinstance (Read1 f) =&gt; Read1 (T f) where ...
°5uinstance (Show1 f) =&gt; Show1 (T f) where ...
°5u</pre>
°5u
°5uIf these instances can be defined, defining instances of the base
°5uclasses is mechanical:
°5u
°5u<pre>
°5uinstance (Eq1 f, Eq a) =&gt; Eq (T f a) where (==) = eq1
°5uinstance (Ord1 f, Ord a) =&gt; Ord (T f a) where compare = compare1
°5uinstance (Read1 f, Read a) =&gt; Read (T f a) where
°5u  readPrec     = readPrec1
°5u  readListPrec = readListPrecDefault
°5uinstance (Show1 f, Show a) =&gt; Show (T f a) where showsPrec = showsPrec1
°5u</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.
°5u
°5uThe function will usually be applied to an equality function, but the
°5umore general type ensures that the implementation uses it to compare
°5uelements 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
°5uconstructor.
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.
°5u
°5uThe function will usually be applied to a comparison function, but the
°5umore general type ensures that the implementation uses it to compare
°5uelements 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
°5uconstructor.
compare1 :: (Ord1 f, Ord a) => f a -> f a -> Ordering

-- | Lifting of the <a>Read</a> class to unary type constructors.
°5u
°5uBoth <a>liftReadsPrec</a> and <a>liftReadPrec</a> exist to match the
°5uinterface provided in the <a>Read</a> type class, but it is
°5urecommended to implement <a>Read1</a> instances using
°5u<a>liftReadPrec</a> as opposed to <a>liftReadsPrec</a>, since the
°5uformer is more efficient than the latter. For example:
°5u
°5u<pre>
°5uinstance <a>Read1</a> T where
°5u  <a>liftReadPrec</a>     = ...
°5u  <a>liftReadListPrec</a> = <a>liftReadListPrecDefault</a>
°5u</pre>
°5u
°5uFor more information, refer to the documentation for the <a>Read</a>
°5uclass.
class Read1 f

-- | <a>readsPrec</a> function for an application of the type constructor
°5ubased on <a>readsPrec</a> and <a>readList</a> functions for the
°5uargument type.
liftReadsPrec :: Read1 f => (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (f a)

-- | <a>readList</a> function for an application of the type constructor
°5ubased on <a>readsPrec</a> and <a>readList</a> functions for the
°5uargument type. The default implementation using standard list syntax
°5uis 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
°5ubased on <a>readPrec</a> and <a>readListPrec</a> functions for the
°5uargument type.
liftReadPrec :: Read1 f => ReadPrec a -> ReadPrec [a] -> ReadPrec (f a)

-- | <a>readListPrec</a> function for an application of the type
°5uconstructor based on <a>readPrec</a> and <a>readListPrec</a> functions
°5ufor the argument type.
°5u
°5uThe default definition uses <a>liftReadList</a>. Instances that define
°5u<a>liftReadPrec</a> should also define <a>liftReadListPrec</a> as
°5u<a>liftReadListPrecDefault</a>.
liftReadListPrec :: Read1 f => ReadPrec a -> ReadPrec [a] -> ReadPrec [f a]

-- | Lift the standard <a>readsPrec</a> and <a>readList</a> functions
°5uthrough the type constructor.
readsPrec1 :: (Read1 f, Read a) => Int -> ReadS (f a)

-- | Lift the standard <a>readPrec</a> and <a>readListPrec</a> functions
°5uthrough the type constructor.
readPrec1 :: (Read1 f, Read a) => ReadPrec (f a)

-- | A possible replacement definition for the <a>liftReadList</a> method.
°5uThis is only needed for <a>Read1</a> instances where
°5u<a>liftReadListPrec</a> isn't defined as
°5u<a>liftReadListPrecDefault</a>.
liftReadListDefault :: Read1 f => (Int -> ReadS a) -> ReadS [a] -> ReadS [f a]

-- | A possible replacement definition for the <a>liftReadListPrec</a>
°5umethod, 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
°5ubased on <a>showsPrec</a> and <a>showList</a> functions for the
°5uargument type.
liftShowsPrec :: Show1 f => (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> f a -> ShowS

-- | <a>showList</a> function for an application of the type constructor
°5ubased on <a>showsPrec</a> and <a>showList</a> functions for the
°5uargument type. The default implementation using standard list syntax
°5uis 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
°5uthrough 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.
°5u
°5uThe function will usually be applied to equality functions, but the
°5umore general type ensures that the implementation uses them to compare
°5uelements 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
°5uconstructor.
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.
°5u
°5uThe function will usually be applied to comparison functions, but the
°5umore general type ensures that the implementation uses them to compare
°5uelements 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
°5uconstructor.
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.
°5u
°5uBoth <a>liftReadsPrec2</a> and <a>liftReadPrec2</a> exist to match the
°5uinterface provided in the <a>Read</a> type class, but it is
°5urecommended to implement <a>Read2</a> instances using
°5u<a>liftReadPrec2</a> as opposed to <a>liftReadsPrec2</a>, since the
°5uformer is more efficient than the latter. For example:
°5u
°5u<pre>
°5uinstance <a>Read2</a> T where
°5u  <a>liftReadPrec2</a>     = ...
°5u  <a>liftReadListPrec2</a> = <a>liftReadListPrec2Default</a>
°5u</pre>
°5u
°5uFor more information, refer to the documentation for the <a>Read</a>
°5uclass. @since 4.9.0.0
class Read2 f

-- | <a>readsPrec</a> function for an application of the type constructor
°5ubased on <a>readsPrec</a> and <a>readList</a> functions for the
°5uargument 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
°5ubased on <a>readsPrec</a> and <a>readList</a> functions for the
°5uargument types. The default implementation using standard list syntax
°5uis 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
°5ubased on <a>readPrec</a> and <a>readListPrec</a> functions for the
°5uargument 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
°5uconstructor based on <a>readPrec</a> and <a>readListPrec</a> functions
°5ufor the argument types.
°5u
°5uThe default definition uses <a>liftReadList2</a>. Instances that
°5udefine <a>liftReadPrec2</a> should also define
°5u<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
°5uconstructor.
readsPrec2 :: (Read2 f, Read a, Read b) => Int -> ReadS (f a b)

-- | Lift the standard <a>readPrec</a> function through the type
°5uconstructor.
readPrec2 :: (Read2 f, Read a, Read b) => ReadPrec (f a b)

-- | A possible replacement definition for the <a>liftReadList2</a> method.
°5uThis is only needed for <a>Read2</a> instances where
°5u<a>liftReadListPrec2</a> isn't defined as
°5u<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>
°5umethod, 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
°5ubased on <a>showsPrec</a> and <a>showList</a> functions for the
°5uargument 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
°5ubased on <a>showsPrec</a> and <a>showList</a> functions for the
°5uargument types. The default implementation using standard list syntax
°5uis 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
°5uconstructor.
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
°5ualternative begins with a data constructor. It parses the constructor
°5uand passes it to <tt>p</tt>. Parsers for various constructors can be
°5uconstructed with <a>readsUnary</a>, <a>readsUnary1</a> and
°5u<a>readsBinary1</a>, and combined with <tt>mappend</tt> from the
°5u<tt>Monoid</tt> class.
readsData :: (String -> ReadS a) -> Int -> ReadS a

-- | <tt><a>readData</a> p</tt> is a parser for datatypes where each
°5ualternative begins with a data constructor. It parses the constructor
°5uand passes it to <tt>p</tt>. Parsers for various constructors can be
°5uconstructed with <a>readUnaryWith</a> and <a>readBinaryWith</a>, and
°5ucombined 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
°5udata 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
°5uconstructor 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
°5ubinary data constructor and then parses its arguments using
°5u<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
°5ubinary data constructor and then parses its arguments using
°5u<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
°5urepresentation of a unary data constructor with name <tt>n</tt> and
°5uargument <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
°5urepresentation of a binary data constructor with name <tt>n</tt> and
°5uarguments <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
°5uconstructor 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
°5uconstructor 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
°5uconstructor 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
°5ua unary data constructor with name <tt>n</tt> and argument <tt>x</tt>,
°5uin 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
°5uof a unary data constructor with name <tt>n</tt> and argument
°5u<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
°5urepresentation of a binary data constructor with name <tt>n</tt> and
°5uarguments <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
°5ua functor in <i>both</i> arguments. That is, unlike with
°5u<a>Functor</a>, a type constructor such as <a>Either</a> does not need
°5uto be partially applied for a <a>Bifunctor</a> instance, and the
°5umethods in this class permit mapping functions over the <a>Left</a>
°5uvalue or the <a>Right</a> value, or both at the same time.
°5u
°5uFormally, the class <a>Bifunctor</a> represents a bifunctor from
°5u<tt>Hask</tt> -&gt; <tt>Hask</tt>.
°5u
°5uIntuitively it is a bifunctor where both the first and second
°5uarguments are covariant.
°5u
°5uYou can define a <a>Bifunctor</a> by either defining <a>bimap</a> or
°5uby defining both <a>first</a> and <a>second</a>.
°5u
°5uIf you supply <a>bimap</a>, you should ensure that:
°5u
°5u<pre>
°5u<a>bimap</a> <a>id</a> <a>id</a> ≡ <a>id</a>
°5u</pre>
°5u
°5uIf you supply <a>first</a> and <a>second</a>, ensure:
°5u
°5u<pre>
°5u<a>first</a> <a>id</a> ≡ <a>id</a>
°5u<a>second</a> <a>id</a> ≡ <a>id</a>
°5u</pre>
°5u
°5uIf you supply both, you should also ensure:
°5u
°5u<pre>
°5u<a>bimap</a> f g ≡ <a>first</a> f <a>.</a> <a>second</a> g
°5u</pre>
°5u
°5uThese ensure by parametricity:
°5u
°5u<pre>
°5u<a>bimap</a>  (f <a>.</a> g) (h <a>.</a> i) ≡ <a>bimap</a> f h <a>.</a> <a>bimap</a> g i
°5u<a>first</a>  (f <a>.</a> g) ≡ <a>first</a>  f <a>.</a> <a>first</a>  g
°5u<a>second</a> (f <a>.</a> g) ≡ <a>second</a> f <a>.</a> <a>second</a> g
°5u</pre>
class Bifunctor p

-- | Map over both arguments at the same time.
°5u
°5u<pre>
°5u<a>bimap</a> f g ≡ <a>first</a> f <a>.</a> <a>second</a> g
°5u</pre>
°5u
°5u<h4><b>Examples</b></h4>
°5u
°5u<pre>
°5u&gt;&gt;&gt; bimap toUpper (+1) ('j', 3)
°5u('J',4)
°5u</pre>
°5u
°5u<pre>
°5u&gt;&gt;&gt; bimap toUpper (+1) (Left 'j')
°5uLeft 'J'
°5u</pre>
°5u
°5u<pre>
°5u&gt;&gt;&gt; bimap toUpper (+1) (Right 3)
°5uRight 4
°5u</pre>
bimap :: Bifunctor p => (a -> b) -> (c -> d) -> p a c -> p b d

-- | Map covariantly over the first argument.
°5u
°5u<pre>
°5u<a>first</a> f ≡ <a>bimap</a> f <a>id</a>
°5u</pre>
°5u
°5u<h4><b>Examples</b></h4>
°5u
°5u<pre>
°5u&gt;&gt;&gt; first toUpper ('j', 3)
°5u('J',3)
°5u</pre>
°5u
°5u<pre>
°5u&gt;&gt;&gt; first toUpper (Left 'j')
°5uLeft 'J'
°5u</pre>
first :: Bifunctor p => (a -> b) -> p a c -> p b c

-- | Map covariantly over the second argument.
°5u
°5u<pre>
°5u<a>second</a> ≡ <a>bimap</a> <a>id</a>
°5u</pre>
°5u
°5u<h4><b>Examples</b></h4>
°5u
°5u<pre>
°5u&gt;&gt;&gt; second (+1) ('j', 3)
°5u('j',4)
°5u</pre>
°5u
°5u<pre>
°5u&gt;&gt;&gt; second (+1) (Right 3)
°5uRight 4
°5u</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
°5uvarieties of elements (as opposed to <a>Foldable</a>, which has one
°5uvariety of element). Common examples are <a>Either</a> and '(,)':
°5u
°5u<pre>
°5uinstance Bifoldable Either where
°5u  bifoldMap f _ (Left  a) = f a
°5u  bifoldMap _ g (Right b) = g b
°5u
°5uinstance Bifoldable (,) where
°5u  bifoldr f g z (a, b) = f a (g b z)
°5u</pre>
°5u
°5uA minimal <a>Bifoldable</a> definition consists of either
°5u<a>bifoldMap</a> or <a>bifoldr</a>. When defining more than this
°5uminimal set, one should ensure that the following identities hold:
°5u
°5u<pre>
°5u<a>bifold</a> ≡ <a>bifoldMap</a> <a>id</a> <a>id</a>
°5u<a>bifoldMap</a> f g ≡ <a>bifoldr</a> (<a>mappend</a> . f) (<a>mappend</a> . g) <a>mempty</a>
°5u<a>bifoldr</a> f g z t ≡ <a>appEndo</a> (<a>bifoldMap</a> (Endo . f) (Endo . g) t) z
°5u</pre>
°5u
°5uIf the type is also a <tt>Bifunctor</tt> instance, it should satisfy:
°5u
°5u<pre>
°5u'bifoldMap' f g ≡ 'bifold' . 'bimap' f g
°5u</pre>
°5u
°5uwhich implies that
°5u
°5u<pre>
°5u'bifoldMap' f g . 'bimap' h i ≡ 'bifoldMap' (f . h) (g . i)
°5u</pre>
class Bifoldable p

-- | Combines the elements of a structure using a monoid.
°5u
°5u<pre>
°5u<a>bifold</a> ≡ <a>bifoldMap</a> <a>id</a> <a>id</a>
°5u</pre>
bifold :: (Bifoldable p, Monoid m) => p m m -> m

-- | Combines the elements of a structure, given ways of mapping them to a
°5ucommon monoid.
°5u
°5u<pre>
°5u<a>bifoldMap</a> f g
°5u     ≡ <a>bifoldr</a> (<a>mappend</a> . f) (<a>mappend</a> . g) <a>mempty</a>
°5u</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.
°5uGiven a hypothetical function <tt>toEitherList :: p a b -&gt; [Either
°5ua b]</tt> yielding a list of all elements of a structure in order, the
°5ufollowing would hold:
°5u
°5u<pre>
°5u<a>bifoldr</a> f g z ≡ <a>foldr</a> (<a>either</a> f g) z . toEitherList
°5u</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.
°5uGiven a hypothetical function <tt>toEitherList :: p a b -&gt; [Either
°5ua b]</tt> yielding a list of all elements of a structure in order, the
°5ufollowing would hold:
°5u
°5u<pre>
°5u<a>bifoldl</a> f g z
°5u     ≡ <a>foldl</a> (acc -&gt; <a>either</a> (f acc) (g acc)) z . toEitherList
°5u</pre>
°5u
°5uNote that if you want an efficient left-fold, you probably want to use
°5u<a>bifoldl'</a> instead of <a>bifoldl</a>. The reason is that the
°5ulatter does not force the "inner" results, resulting in a thunk chain
°5uwhich 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
°5uat 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
°5ube 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
°5uat each step.
°5u
°5uThis ensures that each step of the bifold is forced to weak head
°5unormal form before being applied, avoiding the collection of thunks
°5uthat would otherwise occur. This is often what you want to strictly
°5ureduce a finite structure to a single, monolithic result (e.g.,
°5u<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
°5ube 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
°5uthese actions from left to right, and ignore the results. For a
°5uversion 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.
°5uFor a version that doesn't ignore the results, see <a>bifor</a>.
°5u
°5u<pre>
°5u&gt;&gt;&gt; &gt; bifor_ ('a', "bc") print (print . reverse)
°5u'a'
°5u"cb"
°5u</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
°5uthe results. For a version that doesn't ignore the results, see
°5u<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
°5ustructure.
bisum :: (Bifoldable t, Num a) => t a a -> a

-- | The <a>biproduct</a> function computes the product of the numbers of a
°5ustructure.
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,
°5ucomputes 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
°5uresult to be <a>True</a>, the container must be finite; <a>False</a>,
°5uhowever, results from a <a>False</a> value finitely far from the left
°5uend.
biand :: Bifoldable t => t Bool Bool -> Bool

-- | <a>bior</a> returns the disjunction of a container of Bools. For the
°5uresult to be <a>False</a>, the container must be finite; <a>True</a>,
°5uhowever, results from a <a>True</a> value finitely far from the left
°5uend.
bior :: Bifoldable t => t Bool Bool -> Bool

-- | Determines whether any element of the structure satisfies its
°5uappropriate predicate argument.
biany :: Bifoldable t => (a -> Bool) -> (b -> Bool) -> t a b -> Bool

-- | Determines whether all elements of the structure satisfy their
°5uappropriate 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
°5ucomparison function.
bimaximumBy :: Bifoldable t => (a -> a -> Ordering) -> t a a -> a

-- | The least element of a non-empty structure with respect to the given
°5ucomparison 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
°5ureturns the leftmost element of the structure matching the predicate,
°5uor <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
°5uelements can be traversed in order, performing <a>Applicative</a> or
°5u<a>Monad</a> actions at each element, and collecting a result
°5ustructure with the same shape.
°5u
°5uAs opposed to <a>Traversable</a> data structures, which have one
°5uvariety of element on which an action can be performed,
°5u<a>Bitraversable</a> data structures have two such varieties of
°5uelements.
°5u
°5uA definition of <a>bitraverse</a> must satisfy the following laws:
°5u
°5u<ul>
°5u<li><i><i>naturality</i></i> <tt><a>bitraverse</a> (t . f) (t . g) ≡ t
°5u. <a>bitraverse</a> f g</tt> for every applicative transformation
°5u<tt>t</tt></li>
°5u<li><i><i>identity</i></i> <tt><a>bitraverse</a> <a>Identity</a>
°5u<a>Identity</a> ≡ <a>Identity</a></tt></li>
°5u<li><i><i>composition</i></i> <tt><tt>Compose</tt> . <a>fmap</a>
°5u(<a>bitraverse</a> g1 g2) . <a>bitraverse</a> f1 f2 ≡ <a>traverse</a>
°5u(<tt>Compose</tt> . <a>fmap</a> g1 . f1) (<tt>Compose</tt> .
°5u<a>fmap</a> g2 . f2)</tt></li>
°5u</ul>
°5u
°5uwhere an <i>applicative transformation</i> is a function
°5u
°5u<pre>
°5ut :: (<a>Applicative</a> f, <a>Applicative</a> g) =&gt; f a -&gt; g a
°5u</pre>
°5u
°5upreserving the <a>Applicative</a> operations:
°5u
°5u<pre>
°5ut (<a>pure</a> x) = <a>pure</a> x
°5ut (f <a>&lt;*&gt;</a> x) = t f <a>&lt;*&gt;</a> t x
°5u</pre>
°5u
°5uand the identity functor <a>Identity</a> and composition functors
°5u<tt>Compose</tt> are defined as
°5u
°5u<pre>
°5unewtype Identity a = Identity { runIdentity :: a }
°5u
°5uinstance Functor Identity where
°5u  fmap f (Identity x) = Identity (f x)
°5u
°5uinstance Applicative Identity where
°5u  pure = Identity
°5u  Identity f &lt;*&gt; Identity x = Identity (f x)
°5u
°5unewtype Compose f g a = Compose (f (g a))
°5u
°5uinstance (Functor f, Functor g) =&gt; Functor (Compose f g) where
°5u  fmap f (Compose x) = Compose (fmap (fmap f) x)
°5u
°5uinstance (Applicative f, Applicative g) =&gt; Applicative (Compose f g) where
°5u  pure = Compose . pure . pure
°5u  Compose f &lt;*&gt; Compose x = Compose ((&lt;*&gt;) &lt;$&gt; f &lt;*&gt; x)
°5u</pre>
°5u
°5uSome simple examples are <a>Either</a> and '(,)':
°5u
°5u<pre>
°5uinstance Bitraversable Either where
°5u  bitraverse f _ (Left x) = Left &lt;$&gt; f x
°5u  bitraverse _ g (Right y) = Right &lt;$&gt; g y
°5u
°5uinstance Bitraversable (,) where
°5u  bitraverse f g (x, y) = (,) &lt;$&gt; f x &lt;*&gt; g y
°5u</pre>
°5u
°5u<a>Bitraversable</a> relates to its superclasses in the following
°5uways:
°5u
°5u<pre>
°5u<a>bimap</a> f g ≡ <a>runIdentity</a> . <a>bitraverse</a> (<a>Identity</a> . f) (<a>Identity</a> . g)
°5u<a>bifoldMap</a> f g = <a>getConst</a> . <a>bitraverse</a> (<a>Const</a> . f) (<a>Const</a> . g)
°5u</pre>
°5u
°5uThese are available as <a>bimapDefault</a> and <a>bifoldMapDefault</a>
°5urespectively.
class (Bifunctor t, Bifoldable t) => Bitraversable t

-- | Evaluates the relevant functions at each element in the structure,
°5urunning the action, and builds a new structure with the same shape,
°5uusing the results produced from sequencing the actions.
°5u
°5u<pre>
°5u<a>bitraverse</a> f g ≡ <a>bisequenceA</a> . <a>bimap</a> f g
°5u</pre>
°5u
°5uFor 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
°5uwith the same shape using the results of the actions. For a version
°5uthat ignores the results, see <a>bisequence_</a>.
°5u
°5u<pre>
°5u<a>bisequence</a> ≡ <a>bitraverse</a> <a>id</a> <a>id</a>
°5u</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
°5uargument. 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
°5u<a>bimap</a> and <a>bifoldl</a>; it traverses a structure from left to
°5uright, threading a state of type <tt>a</tt> and using the given
°5uactions 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
°5u<a>bimap</a> and <a>bifoldl</a>; it traverses a structure from right
°5uto left, threading a state of type <tt>a</tt> and using the given
°5uactions 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
°5u<a>Bitraversable</a> operations.
°5u
°5u<pre>
°5u<a>bimapDefault</a> f g ≡
°5u     <a>runIdentity</a> . <a>bitraverse</a> (<a>Identity</a> . f) (<a>Identity</a> . g)
°5u</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
°5u<a>Bitraversable</a> operations.
°5u
°5u<pre>
°5u<a>bifoldMapDefault</a> f g ≡
°5u    <a>getConst</a> . <a>bitraverse</a> (<a>Const</a> . f) (<a>Const</a> . g)
°5u</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
°5uand timeouts.
°5u
°5uThis module should be considered GHC internal.
°5u
°5u<ul>
°5u
°5u<li>---------------------------------------------------------------------------</li>
°5u</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
°5ucalling thread is running.
°5u
°5uThis function always returns <a>Just</a> the current thread's event
°5umanager 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
°5u<tt>evs</tt> on the file descriptor <tt>fd</tt> for lifetime
°5u<tt>lt</tt>. <tt>cb</tt> is called for each event that occurs. Returns
°5ua 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
°5umanager thread. The return value indicates whether the event manager
°5uought 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
°5u<a>TimeoutKey</a> can be used to later unregister or update the
°5utimeout. The timeout is automatically unregistered after the given
°5utime 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
°5uthread. <a>ThreadId</a> is an instance of <a>Eq</a>, <a>Ord</a> and
°5u<a>Show</a>, where the <a>Ord</a> instance implements an arbitrary
°5utotal ordering over <a>ThreadId</a>s. The <a>Show</a> instance lets
°5uyou convert an arbitrary-valued <a>ThreadId</a> to string form;
°5ushowing a <a>ThreadId</a> value is occasionally useful when debugging
°5uor diagnosing the behaviour of a concurrent program.
°5u
°5u<i>Note</i>: in GHC, if you have a <a>ThreadId</a>, you essentially
°5uhave a pointer to the thread itself. This means the thread itself
°5ucan't be garbage collected until you drop the <a>ThreadId</a>. This
°5umisfeature 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
°5ufirst argument, and returns the <a>ThreadId</a> of the newly created
°5uthread.
°5u
°5uThe new thread will be a lightweight, <i>unbound</i> thread. Foreign
°5ucalls made by this thread are not guaranteed to be made by any
°5uparticular OS thread; if you need foreign calls to be made by a
°5uparticular OS thread, then use <a>forkOS</a> instead.
°5u
°5uThe new thread inherits the <i>masked</i> state of the parent (see
°5u<a>mask</a>).
°5u
°5uThe newly created thread has an exception handler that discards the
°5uexceptions <a>BlockedIndefinitelyOnMVar</a>,
°5u<a>BlockedIndefinitelyOnSTM</a>, and <a>ThreadKilled</a>, and passes
°5uall 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
°5ube used to unmask asynchronous exceptions. This function is typically
°5uused in the following way
°5u
°5u<pre>
°5u... mask_ $ forkIOWithUnmask $ \unmask -&gt;
°5u               catch (unmask ...) handler
°5u</pre>
°5u
°5uso that the exception handler in the child thread is established with
°5uasynchronous exceptions masked, meanwhile the main body of the child
°5uthread is executed in the unmasked state.
°5u
°5uNote that the unmask function passed to the child thread should only
°5ube used in that thread; the behaviour is undefined if it is invoked in
°5ua different thread.
forkIOWithUnmask :: ((forall a. IO a -> IO a) -> IO ()) -> IO ThreadId

-- | Like <a>forkIO</a>, but lets you specify on which capability the
°5uthread should run. Unlike a <a>forkIO</a> thread, a thread created by
°5u<a>forkOn</a> will stay on the same capability for its entire lifetime
°5u(<a>forkIO</a> threads can migrate between capabilities according to
°5uthe scheduling policy). <a>forkOn</a> is useful for overriding the
°5uscheduling policy when you know in advance how best to distribute the
°5uthreads.
°5u
°5uThe <a>Int</a> argument specifies a <i>capability number</i> (see
°5u<a>getNumCapabilities</a>). Typically capabilities correspond to
°5uphysical processors, but the exact behaviour is
°5uimplementation-dependent. The value passed to <a>forkOn</a> is
°5uinterpreted modulo the total number of capabilities as returned by
°5u<a>getNumCapabilities</a>.
°5u
°5uGHC note: the number of capabilities is specified by the <tt>+RTS
°5u-N</tt> option when the program is started. Capabilities can be fixed
°5uto actual processor cores with <tt>+RTS -qa</tt> if the underlying
°5uoperating system supports that, although in practice this is usually
°5uunnecessary (and may actually degrade performance in some cases -
°5uexperimentation is recommended).
forkOn :: Int -> IO () -> IO ThreadId

-- | Like <a>forkIOWithUnmask</a>, but the child thread is pinned to the
°5ugiven 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
°5uHaskell threads that can run truly simultaneously at any given time,
°5uand is typically set to the number of physical processor cores on the
°5umachine.
°5u
°5uStrictly speaking it is better to use <a>getNumCapabilities</a>,
°5ubecause the number of capabilities might vary at runtime.
numCapabilities :: Int

-- | Returns the number of Haskell threads that can run truly
°5usimultaneously (on separate physical processors) at any given time. To
°5uchange this value, use <a>setNumCapabilities</a>.
getNumCapabilities :: IO Int

-- | Set the number of Haskell threads that can run truly simultaneously
°5u(on separate physical processors) at any given time. The number passed
°5uto <a>forkOn</a> is interpreted modulo this value. The initial value
°5uis given by the <tt>+RTS -N</tt> runtime flag.
°5u
°5uThis is also the number of threads that will participate in parallel
°5ugarbage collection. It is strongly recommended that the number of
°5ucapabilities is not set larger than the number of physical processor
°5ucores, and it may often be beneficial to leave one or more cores free
°5uto 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
°5ugiven thread (GHC only).
°5u
°5u<pre>
°5ukillThread tid = throwTo tid ThreadKilled
°5u</pre>
killThread :: ThreadId -> IO ()

-- | <a>throwTo</a> raises an arbitrary exception in the target thread (GHC
°5uonly).
°5u
°5uException delivery synchronizes between the source and target thread:
°5u<a>throwTo</a> does not return until the exception has been raised in
°5uthe target thread. The calling thread can thus be certain that the
°5utarget thread has received the exception. Exception delivery is also
°5uatomic with respect to other exceptions. Atomicity is a useful
°5uproperty to have when dealing with race conditions: e.g. if there are
°5utwo threads that can kill each other, it is guaranteed that only one
°5uof the threads will get to kill the other.
°5u
°5uWhatever work the target thread was doing when the exception was
°5uraised is not lost: the computation is suspended until required by
°5uanother thread.
°5u
°5uIf the target thread is currently making a foreign call, then the
°5uexception will not be raised (and hence <a>throwTo</a> will not
°5ureturn) until the call has completed. This is the case regardless of
°5uwhether the call is inside a <a>mask</a> or not. However, in GHC a
°5uforeign call can be annotated as <tt>interruptible</tt>, in which case
°5ua <a>throwTo</a> will cause the RTS to attempt to cause the call to
°5ureturn; see the GHC documentation for more details.
°5u
°5uImportant note: the behaviour of <a>throwTo</a> differs from that
°5udescribed in the paper "Asynchronous exceptions in Haskell"
°5u(<a>http://research.microsoft.com/~simonpj/Papers/asynch-exns.htm</a>).
°5uIn the paper, <a>throwTo</a> is non-blocking; but the library
°5uimplementation adopts a more synchronous design in which
°5u<a>throwTo</a> does not return until the exception is received by the
°5utarget thread. The trade-off is discussed in Section 9 of the paper.
°5uLike any blocking operation, <a>throwTo</a> is therefore interruptible
°5u(see Section 5.3 of the paper). Unlike other interruptible operations,
°5uhowever, <a>throwTo</a> is <i>always</i> interruptible, even if it
°5udoes not actually block.
°5u
°5uThere is no guarantee that the exception will be delivered promptly,
°5ualthough the runtime will endeavour to ensure that arbitrary delays
°5udon't occur. In GHC, an exception can only be raised when a thread
°5ureaches a <i>safe point</i>, where a safe point is where memory
°5uallocation occurs. Some loops do not perform any memory allocation
°5uinside the loop and therefore cannot be interrupted by a
°5u<a>throwTo</a>.
°5u
°5uIf the target of <a>throwTo</a> is the calling thread, then the
°5ubehaviour is the same as <a>throwIO</a>, except that the exception is
°5uthrown as an asynchronous exception. This means that if there is an
°5uenclosing pure computation, which would be the case if the current IO
°5uoperation is inside <a>unsafePerformIO</a> or
°5u<a>unsafeInterleaveIO</a>, that computation is not permanently
°5ureplaced by the exception, but is suspended as if it had received an
°5uasynchronous exception.
°5u
°5uNote that if <a>throwTo</a> is called with the current thread as the
°5utarget, the exception will be thrown even if the thread is currently
°5uinside <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
°5uimplementation) a context-switch to any other currently runnable
°5uthreads (if any), and is occasionally useful when implementing
°5uconcurrency abstractions.
yield :: IO ()

-- | <a>labelThread</a> stores a string as identifier for this thread if
°5uyou built a RTS with debugging support. This identifier will be used
°5uin the debugging output to make distinction of different threads
°5ueasier (otherwise you only have the thread state object's address in
°5uthe heap).
°5u
°5uOther applications like the graphical Concurrent Haskell Debugger
°5u(<a>http://www.informatik.uni-kiel.de/~fhu/chd/</a>) may choose to
°5uoverload <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
°5uthis if you want to hold a reference to a <a>ThreadId</a> while still
°5uallowing the thread to receive the <tt>BlockedIndefinitely</tt> family
°5uof exceptions (e.g. <a>BlockedIndefinitelyOnMVar</a>). Holding a
°5unormal <a>ThreadId</a> reference will prevent the delivery of
°5u<tt>BlockedIndefinitely</tt> exceptions because the reference could be
°5uused as the target of <a>throwTo</a> at any time, which would unblock
°5uthe thread.
°5u
°5uHolding a <tt>Weak ThreadId</tt>, on the other hand, will not prevent
°5uthe thread from receiving <tt>BlockedIndefinitely</tt> exceptions. It
°5uis still possible to throw an exception to a <tt>Weak ThreadId</tt>,
°5ubut the caller must use <tt>deRefWeak</tt> first to determine whether
°5uthe 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
°5u<tt>threadDelay</tt> show up as <a>BlockedOnOther</a>, with
°5u<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
°5urunning, and a boolean indicating whether the thread is locked to that
°5ucapability or not. A thread is locked to a capability if it was
°5ucreated with <tt>forkOn</tt>.
threadCapability :: ThreadId -> IO (Int, Bool)

-- | Make a StablePtr that can be passed to the C function
°5u<tt>hs_try_putmvar()</tt>. The RTS wants a <a>StablePtr</a> to the
°5uunderlying <a>MVar#</a>, but a <a>StablePtr#</a> can only refer to
°5ulifted 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
°5uonly).
°5u
°5uThere is no guarantee that the thread will be rescheduled promptly
°5uwhen the delay has expired, but the thread will never continue to run
°5u<i>earlier</i> than specified.
threadDelay :: Int -> IO ()

-- | Set the value of returned TVar to True after a given number of
°5umicroseconds. 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
°5ufile descriptor (GHC only).
°5u
°5uThis will throw an <tt>IOError</tt> if the file descriptor was closed
°5uwhile this thread was blocked. To safely close a file descriptor that
°5uhas 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
°5udescriptor (GHC only).
°5u
°5uThis will throw an <tt>IOError</tt> if the file descriptor was closed
°5uwhile this thread was blocked. To safely close a file descriptor that
°5uhas 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
°5ufile descriptor. The second returned value is an IO action that can be
°5uused 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
°5uwritten to a file descriptor. The second returned value is an IO
°5uaction 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
°5uare using <a>threadWaitRead</a> or <a>threadWaitWrite</a> to perform
°5ublocking I/O, you <i>must</i> use this function to close file
°5udescriptors, or blocked threads may not be woken.
°5u
°5uAny threads that are blocked on the file descriptor via
°5u<a>threadWaitRead</a> or <a>threadWaitWrite</a> will be unblocked by
°5uhaving IO exceptions thrown.
closeFdWith :: (Fd -> IO ()) -> Fd -> IO ()

-- | Every thread has an allocation counter that tracks how much memory has
°5ubeen allocated by the thread. The counter is initialized to zero, and
°5u<a>setAllocationCounter</a> sets the current value. The allocation
°5ucounter counts *down*, so in the absence of a call to
°5u<a>setAllocationCounter</a> its value is the negation of the number of
°5ubytes of memory allocated by the thread.
°5u
°5uThere are two things that you can do with this counter:
°5u
°5u<ul>
°5u<li>Use it as a simple profiling mechanism, with
°5u<a>getAllocationCounter</a>.</li>
°5u<li>Use it as a resource limit. See <a>enableAllocationLimit</a>.</li>
°5u</ul>
°5u
°5uAllocation accounting is accurate only to about 4Kbytes.
setAllocationCounter :: Int64 -> IO ()

-- | Return the current value of the allocation counter for the current
°5uthread.
getAllocationCounter :: IO Int64

-- | Enables the allocation counter to be treated as a limit for the
°5ucurrent thread. When the allocation limit is enabled, if the
°5uallocation counter counts down below zero, the thread will be sent the
°5u<a>AllocationLimitExceeded</a> asynchronous exception. When this
°5uhappens, the counter is reinitialised (by default to 100K, but tunable
°5uwith the <tt>+RTS -xq</tt> option) so that it can handle the exception
°5uand perform any necessary clean up. If it exhausts this additional
°5uallowance, another <a>AllocationLimitExceeded</a> exception is sent,
°5uand so forth. Like other asynchronous exceptions, the
°5u<a>AllocationLimitExceeded</a> exception is deferred while the thread
°5uis inside <a>mask</a> or an exception handler in <a>catch</a>.
°5u
°5uNote that memory allocation is unrelated to <i>live memory</i>, also
°5uknown as <i>heap residency</i>. A thread can allocate a large amount
°5uof memory and retain anything between none and all of it. It is better
°5uto think of the allocation limit as a limit on <i>CPU time</i>, rather
°5uthan a limit on memory.
°5u
°5uCompared to using timeouts, allocation limits don't count time spent
°5ublocked 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.
°5u
°5uUsing <a>atomically</a> inside an <a>unsafePerformIO</a> or
°5u<a>unsafeInterleaveIO</a> subverts some of guarantees that STM
°5uprovides. It makes it possible to run a transaction inside of another
°5utransaction, depending on when the thunk is evaluated. If a nested
°5utransaction is attempted, an exception is thrown by the runtime. It is
°5upossible to safely use <a>atomically</a> inside <a>unsafePerformIO</a>
°5uor <a>unsafeInterleaveIO</a>, but the typechecker does not rule out
°5uprograms that may attempt nested transactions, meaning that the
°5uprogrammer must take special care to prevent these.
°5u
°5uHowever, there are functions for creating transactional variables that
°5ucan always be safely called in <a>unsafePerformIO</a>. See:
°5u<a>newTVarIO</a>, <tt>newTChanIO</tt>, <tt>newBroadcastTChanIO</tt>,
°5u<tt>newTQueueIO</tt>, <tt>newTBQueueIO</tt>, and <tt>newTMVarIO</tt>.
°5u
°5uUsing <a>unsafePerformIO</a> inside of <a>atomically</a> is also
°5udangerous but for different reasons. See <a>unsafeIOToSTM</a> for more
°5uon this.
atomically :: STM a -> IO a

-- | Retry execution of the current memory transaction because it has seen
°5uvalues in <a>TVar</a>s which mean that it should not continue (e.g.
°5uthe <a>TVar</a>s represent a shared buffer that is now empty). The
°5uimplementation may block the thread until one of the <a>TVar</a>s that
°5uit has read from has been updated. (GHC only)
retry :: STM a

-- | Compose two alternative STM actions (GHC only).
°5u
°5uIf the first action completes without retrying then it forms the
°5uresult of the <a>orElse</a>. Otherwise, if the first action retries,
°5uthen the second action is tried in its place. If both actions retry
°5uthen 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>
°5umonad.
°5u
°5uThrowing an exception in <tt>STM</tt> aborts the transaction and
°5upropagates the exception.
°5u
°5uAlthough <a>throwSTM</a> has a type that is an instance of the type of
°5u<a>throw</a>, the two functions are subtly different:
°5u
°5u<pre>
°5uthrow e    `seq` x  ===&gt; throw e
°5uthrowSTM e `seq` x  ===&gt; x
°5u</pre>
°5u
°5uThe first example will cause the exception <tt>e</tt> to be raised,
°5uwhereas the second one won't. In fact, <a>throwSTM</a> will only cause
°5uan exception to be raised when it is used within the <a>STM</a> monad.
°5uThe <a>throwSTM</a> variant should be used in preference to
°5u<a>throw</a> to raise an exception within the <a>STM</a> monad because
°5uit guarantees ordering with respect to other <a>STM</a> operations,
°5uwhereas <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
°5upassed to <a>alwaysSucceeds</a>, at the end of the current
°5utransaction, and at the end of every subsequent transaction. If it
°5ufails at any of those points then the transaction violating it is
°5uaborted 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
°5uinvariant is expressed as an <tt>STM Bool</tt> action that must return
°5u<tt>True</tt>. Returning <tt>False</tt> or raising an exception are
°5uboth 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
°5utop-level <a>TVar</a>s using <a>unsafePerformIO</a>, because using
°5u<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
°5uto
°5u
°5u<pre>
°5ureadTVarIO = atomically . readTVar
°5u</pre>
°5u
°5ubut works much faster, because it doesn't perform a complete
°5utransaction, 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
°5udangerous thing to do.
°5u
°5u<ul>
°5u<li>The STM implementation will often run transactions multiple times,
°5uso you need to be prepared for this if your IO has any side
°5ueffects.</li>
°5u<li>The STM implementation will abort transactions that are known to
°5ube invalid and need to be restarted. This may happen in the middle of
°5u<a>unsafeIOToSTM</a>, so make sure you don't acquire any resources
°5uthat need releasing (exception handlers are ignored when aborting the
°5utransaction). That includes doing any IO using Handles, for example.
°5uGetting this wrong will probably lead to random deadlocks.</li>
°5u<li>The transaction may have seen an inconsistent view of memory when
°5uthe IO runs. Invariants that you expect to be true throughout your
°5uprogram may not be true inside a transaction, due to the way
°5utransactions are implemented. Normally this wouldn't be visible to the
°5uprogrammer, but using <a>unsafeIOToSTM</a> can expose it.</li>
°5u</ul>
unsafeIOToSTM :: IO a -> STM a

-- | Provide an <a>IO</a> action with the current value of an <a>MVar</a>.
°5uThe <a>MVar</a> will be empty for the duration that the action is
°5urunning.
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
°5u"amount".
module Control.Concurrent.QSemN

-- | <a>QSemN</a> is a quantity semaphore in which the resource is aqcuired
°5uand released in units of one. It provides guaranteed FIFO ordering for
°5usatisfying blocked <a>waitQSemN</a> calls.
°5u
°5uThe pattern
°5u
°5u<pre>
°5ubracket_ (waitQSemN n) (signalQSemN n) (...)
°5u</pre>
°5u
°5uis safe; it never loses any of the resource.
data QSemN

-- | Build a new <a>QSemN</a> with a supplied initial quantity. The initial
°5uquantity 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
°5uand released in units of one. It provides guaranteed FIFO ordering for
°5usatisfying blocked <a>waitQSem</a> calls.
°5u
°5uThe pattern
°5u
°5u<pre>
°5ubracket_ waitQSem signalQSem (...)
°5u</pre>
°5u
°5uis safe; it never loses a unit of the resource.
data QSem

-- | Build a new <a>QSem</a> with a supplied initial quantity. The initial
°5uquantity 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.
°5u
°5uThe channels are implemented with <tt>MVar</tt>s and therefore inherit
°5uall the caveats that apply to <tt>MVar</tt>s (possibility of races,
°5udeadlocks etc). The stm (software transactional memory) library has a
°5umore robust implementation of channels called <tt>TChan</tt>s.
module Control.Concurrent.Chan

-- | <a>Chan</a> is an abstract type representing an unbounded FIFO
°5uchannel.
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
°5uempty. Since the read end of a channel is an <a>MVar</a>, this
°5uoperation inherits fairness guarantees of <a>MVar</a>s (e.g. threads
°5ublocked in this operation are woken up in FIFO order).
°5u
°5uThrows <tt>BlockedIndefinitelyOnMVar</tt> when the channel is empty
°5uand 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
°5uwritten to either channel from then on will be available from both.
°5uHence this creates a kind of broadcast channel, where data written by
°5uanyone is seen by everyone else.
°5u
°5u(Note that a duplicated channel is not equal to its original. So:
°5u<tt>fmap (c /=) $ dupChan c</tt> returns <tt>True</tt> for all
°5u<tt>c</tt>.)
dupChan :: Chan a -> IO (Chan a)

-- | Return a lazy list representing the contents of the supplied
°5u<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
°5uthread. <a>ThreadId</a> is an instance of <a>Eq</a>, <a>Ord</a> and
°5u<a>Show</a>, where the <a>Ord</a> instance implements an arbitrary
°5utotal ordering over <a>ThreadId</a>s. The <a>Show</a> instance lets
°5uyou convert an arbitrary-valued <a>ThreadId</a> to string form;
°5ushowing a <a>ThreadId</a> value is occasionally useful when debugging
°5uor diagnosing the behaviour of a concurrent program.
°5u
°5u<i>Note</i>: in GHC, if you have a <a>ThreadId</a>, you essentially
°5uhave a pointer to the thread itself. This means the thread itself
°5ucan't be garbage collected until you drop the <a>ThreadId</a>. This
°5umisfeature 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
°5ufirst argument, and returns the <a>ThreadId</a> of the newly created
°5uthread.
°5u
°5uThe new thread will be a lightweight, <i>unbound</i> thread. Foreign
°5ucalls made by this thread are not guaranteed to be made by any
°5uparticular OS thread; if you need foreign calls to be made by a
°5uparticular OS thread, then use <a>forkOS</a> instead.
°5u
°5uThe new thread inherits the <i>masked</i> state of the parent (see
°5u<a>mask</a>).
°5u
°5uThe newly created thread has an exception handler that discards the
°5uexceptions <a>BlockedIndefinitelyOnMVar</a>,
°5u<a>BlockedIndefinitelyOnSTM</a>, and <a>ThreadKilled</a>, and passes
°5uall other exceptions to the uncaught exception handler.
forkIO :: IO () -> IO ThreadId

-- | Fork a thread and call the supplied function when the thread is about
°5uto terminate, with an exception or a returned value. The function is
°5ucalled with asynchronous exceptions masked.
°5u
°5u<pre>
°5uforkFinally action and_then =
°5u  mask $ \restore -&gt;
°5u    forkIO $ try (restore action) &gt;&gt;= and_then
°5u</pre>
°5u
°5uThis function is useful for informing the parent when a child
°5uterminates, 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
°5ube used to unmask asynchronous exceptions. This function is typically
°5uused in the following way
°5u
°5u<pre>
°5u... mask_ $ forkIOWithUnmask $ \unmask -&gt;
°5u               catch (unmask ...) handler
°5u</pre>
°5u
°5uso that the exception handler in the child thread is established with
°5uasynchronous exceptions masked, meanwhile the main body of the child
°5uthread is executed in the unmasked state.
°5u
°5uNote that the unmask function passed to the child thread should only
°5ube used in that thread; the behaviour is undefined if it is invoked in
°5ua different thread.
forkIOWithUnmask :: ((forall a. IO a -> IO a) -> IO ()) -> IO ThreadId

-- | <a>killThread</a> raises the <a>ThreadKilled</a> exception in the
°5ugiven thread (GHC only).
°5u
°5u<pre>
°5ukillThread tid = throwTo tid ThreadKilled
°5u</pre>
killThread :: ThreadId -> IO ()

-- | <a>throwTo</a> raises an arbitrary exception in the target thread (GHC
°5uonly).
°5u
°5uException delivery synchronizes between the source and target thread:
°5u<a>throwTo</a> does not return until the exception has been raised in
°5uthe target thread. The calling thread can thus be certain that the
°5utarget thread has received the exception. Exception delivery is also
°5uatomic with respect to other exceptions. Atomicity is a useful
°5uproperty to have when dealing with race conditions: e.g. if there are
°5utwo threads that can kill each other, it is guaranteed that only one
°5uof the threads will get to kill the other.
°5u
°5uWhatever work the target thread was doing when the exception was
°5uraised is not lost: the computation is suspended until required by
°5uanother thread.
°5u
°5uIf the target thread is currently making a foreign call, then the
°5uexception will not be raised (and hence <a>throwTo</a> will not
°5ureturn) until the call has completed. This is the case regardless of
°5uwhether the call is inside a <a>mask</a> or not. However, in GHC a
°5uforeign call can be annotated as <tt>interruptible</tt>, in which case
°5ua <a>throwTo</a> will cause the RTS to attempt to cause the call to
°5ureturn; see the GHC documentation for more details.
°5u
°5uImportant note: the behaviour of <a>throwTo</a> differs from that
°5udescribed in the paper "Asynchronous exceptions in Haskell"
°5u(<a>http://research.microsoft.com/~simonpj/Papers/asynch-exns.htm</a>).
°5uIn the paper, <a>throwTo</a> is non-blocking; but the library
°5uimplementation adopts a more synchronous design in which
°5u<a>throwTo</a> does not return until the exception is received by the
°5utarget thread. The trade-off is discussed in Section 9 of the paper.
°5uLike any blocking operation, <a>throwTo</a> is therefore interruptible
°5u(see Section 5.3 of the paper). Unlike other interruptible operations,
°5uhowever, <a>throwTo</a> is <i>always</i> interruptible, even if it
°5udoes not actually block.
°5u
°5uThere is no guarantee that the exception will be delivered promptly,
°5ualthough the runtime will endeavour to ensure that arbitrary delays
°5udon't occur. In GHC, an exception can only be raised when a thread
°5ureaches a <i>safe point</i>, where a safe point is where memory
°5uallocation occurs. Some loops do not perform any memory allocation
°5uinside the loop and therefore cannot be interrupted by a
°5u<a>throwTo</a>.
°5u
°5uIf the target of <a>throwTo</a> is the calling thread, then the
°5ubehaviour is the same as <a>throwIO</a>, except that the exception is
°5uthrown as an asynchronous exception. This means that if there is an
°5uenclosing pure computation, which would be the case if the current IO
°5uoperation is inside <a>unsafePerformIO</a> or
°5u<a>unsafeInterleaveIO</a>, that computation is not permanently
°5ureplaced by the exception, but is suspended as if it had received an
°5uasynchronous exception.
°5u
°5uNote that if <a>throwTo</a> is called with the current thread as the
°5utarget, the exception will be thrown even if the thread is currently
°5uinside <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
°5uthread should run. Unlike a <a>forkIO</a> thread, a thread created by
°5u<a>forkOn</a> will stay on the same capability for its entire lifetime
°5u(<a>forkIO</a> threads can migrate between capabilities according to
°5uthe scheduling policy). <a>forkOn</a> is useful for overriding the
°5uscheduling policy when you know in advance how best to distribute the
°5uthreads.
°5u
°5uThe <a>Int</a> argument specifies a <i>capability number</i> (see
°5u<a>getNumCapabilities</a>). Typically capabilities correspond to
°5uphysical processors, but the exact behaviour is
°5uimplementation-dependent. The value passed to <a>forkOn</a> is
°5uinterpreted modulo the total number of capabilities as returned by
°5u<a>getNumCapabilities</a>.
°5u
°5uGHC note: the number of capabilities is specified by the <tt>+RTS
°5u-N</tt> option when the program is started. Capabilities can be fixed
°5uto actual processor cores with <tt>+RTS -qa</tt> if the underlying
°5uoperating system supports that, although in practice this is usually
°5uunnecessary (and may actually degrade performance in some cases -
°5uexperimentation is recommended).
forkOn :: Int -> IO () -> IO ThreadId

-- | Like <a>forkIOWithUnmask</a>, but the child thread is pinned to the
°5ugiven 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
°5usimultaneously (on separate physical processors) at any given time. To
°5uchange this value, use <a>setNumCapabilities</a>.
getNumCapabilities :: IO Int

-- | Set the number of Haskell threads that can run truly simultaneously
°5u(on separate physical processors) at any given time. The number passed
°5uto <a>forkOn</a> is interpreted modulo this value. The initial value
°5uis given by the <tt>+RTS -N</tt> runtime flag.
°5u
°5uThis is also the number of threads that will participate in parallel
°5ugarbage collection. It is strongly recommended that the number of
°5ucapabilities is not set larger than the number of physical processor
°5ucores, and it may often be beneficial to leave one or more cores free
°5uto avoid contention with other processes in the machine.
setNumCapabilities :: Int -> IO ()

-- | Returns the number of the capability on which the thread is currently
°5urunning, and a boolean indicating whether the thread is locked to that
°5ucapability or not. A thread is locked to a capability if it was
°5ucreated with <tt>forkOn</tt>.
threadCapability :: ThreadId -> IO (Int, Bool)

-- | The <a>yield</a> action allows (forces, in a co-operative multitasking
°5uimplementation) a context-switch to any other currently runnable
°5uthreads (if any), and is occasionally useful when implementing
°5uconcurrency abstractions.
yield :: IO ()

-- | Suspends the current thread for a given number of microseconds (GHC
°5uonly).
°5u
°5uThere is no guarantee that the thread will be rescheduled promptly
°5uwhen the delay has expired, but the thread will never continue to run
°5u<i>earlier</i> than specified.
threadDelay :: Int -> IO ()

-- | Block the current thread until data is available to read on the given
°5ufile descriptor (GHC only).
°5u
°5uThis will throw an <a>IOError</a> if the file descriptor was closed
°5uwhile this thread was blocked. To safely close a file descriptor that
°5uhas 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
°5udescriptor (GHC only).
°5u
°5uThis will throw an <a>IOError</a> if the file descriptor was closed
°5uwhile this thread was blocked. To safely close a file descriptor that
°5uhas 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
°5ufile descriptor. The second returned value is an IO action that can be
°5uused 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
°5uwritten to a file descriptor. The second returned value is an IO
°5uaction 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
°5u<tt>rtsSupportsBoundThreads</tt> is <a>False</a>,
°5u<a>isCurrentThreadBound</a> will always return <a>False</a> and both
°5u<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>
°5ucomputation passed as the first argument, and returns the
°5u<a>ThreadId</a> of the newly created thread.
°5u
°5uHowever, <a>forkOS</a> creates a <i>bound</i> thread, which is
°5unecessary if you need to call foreign (non-Haskell) libraries that
°5umake use of thread-local state, such as OpenGL (see
°5u<a>Control.Concurrent#boundthreads</a>).
°5u
°5uUsing <a>forkOS</a> instead of <a>forkIO</a> makes no difference at
°5uall to the scheduling behaviour of the Haskell runtime system. It is a
°5ucommon misconception that you need to use <a>forkOS</a> instead of
°5u<a>forkIO</a> to avoid blocking all the Haskell threads when making a
°5uforeign call; this isn't the case. To allow foreign calls to be made
°5uwithout blocking all the Haskell threads (with GHC), it is only
°5unecessary to use the <tt>-threaded</tt> option when linking your
°5uprogram, and to make sure the foreign import is not marked
°5u<tt>unsafe</tt>.
forkOS :: IO () -> IO ThreadId

-- | Like <a>forkIOWithUnmask</a>, but the child thread is a bound thread,
°5uas 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
°5uit is safe to use foreign libraries that rely on thread-local state
°5ufrom the calling thread.
isCurrentThreadBound :: IO Bool

-- | Run the <a>IO</a> computation passed as the first argument. If the
°5ucalling thread is not <i>bound</i>, a bound thread is created
°5utemporarily. <tt>runInBoundThread</tt> doesn't finish until the
°5u<a>IO</a> computation finishes.
°5u
°5uYou can wrap a series of foreign function calls that rely on
°5uthread-local state with <tt>runInBoundThread</tt> so that you can use
°5uthem 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
°5ucalling thread is <i>bound</i>, an unbound thread is created
°5utemporarily using <a>forkIO</a>. <tt>runInBoundThread</tt> doesn't
°5ufinish until the <a>IO</a> computation finishes.
°5u
°5uUse this function <i>only</i> in the rare case that you have actually
°5uobserved a performance loss due to the use of bound threads. A program
°5uthat doesn't need its main thread to be bound and makes <i>heavy</i>
°5uuse of concurrency (e.g. a web server), might want to wrap its
°5u<tt>main</tt> action in <tt>runInUnboundThread</tt>.
°5u
°5uNote that exceptions which are thrown to the current thread are thrown
°5uin turn to the thread that is executing the given computation. This
°5uensures 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
°5uthis if you want to hold a reference to a <a>ThreadId</a> while still
°5uallowing the thread to receive the <tt>BlockedIndefinitely</tt> family
°5uof exceptions (e.g. <a>BlockedIndefinitelyOnMVar</a>). Holding a
°5unormal <a>ThreadId</a> reference will prevent the delivery of
°5u<tt>BlockedIndefinitely</tt> exceptions because the reference could be
°5uused as the target of <a>throwTo</a> at any time, which would unblock
°5uthe thread.
°5u
°5uHolding a <tt>Weak ThreadId</tt>, on the other hand, will not prevent
°5uthe thread from receiving <tt>BlockedIndefinitely</tt> exceptions. It
°5uis still possible to throw an exception to a <tt>Weak ThreadId</tt>,
°5ubut the caller must use <tt>deRefWeak</tt> first to determine whether
°5uthe 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>
°5uin case no result is available within <tt>n</tt> microseconds
°5u(<tt>1/10^6</tt> seconds). In case a result is available before the
°5utimeout expires, <tt>Just a</tt> is returned. A negative timeout
°5uinterval means "wait indefinitely". When specifying long timeouts, be
°5ucareful not to exceed <tt>maxBound :: Int</tt>.
°5u
°5u<pre>
°5u&gt;&gt;&gt; timeout 1000000 (threadDelay 1000 *&gt; pure "finished on time")
°5uJust "finished on time"
°5u</pre>
°5u
°5u<pre>
°5u&gt;&gt;&gt; timeout 10000 (threadDelay 100000 *&gt; pure "finished on time")
°5uNothing
°5u</pre>
°5u
°5uThe design of this combinator was guided by the objective that
°5u<tt>timeout n f</tt> should behave exactly the same as <tt>f</tt> as
°5ulong as <tt>f</tt> doesn't time out. This means that <tt>f</tt> has
°5uthe same <a>myThreadId</a> it would have without the timeout wrapper.
°5uAny exceptions <tt>f</tt> might throw cancel the timeout and propagate
°5ufurther up. It also possible for <tt>f</tt> to receive exceptions
°5uthrown to it by another thread.
°5u
°5uA tricky implementation detail is the question of how to abort an
°5u<tt>IO</tt> computation. This combinator relies on asynchronous
°5uexceptions internally. The technique works very well for computations
°5uexecuting inside of the Haskell runtime system, but it doesn't work at
°5uall for non-Haskell code. Foreign function calls, for example, cannot
°5ube timed out with this combinator simply because an arbitrary C
°5ufunction cannot receive asynchronous exceptions. When <tt>timeout</tt>
°5uis used to wrap an FFI call that blocks, no timeout event can be
°5udelivered until the FFI call returns, which pretty much negates the
°5upurpose of the combinator. In practice, however, this limitation is
°5uless severe than it may sound. Standard I/O functions like
°5u<a>hGetBuf</a>, <a>hPutBuf</a>, Network.Socket.accept, or
°5u<a>hWaitForInput</a> appear to be blocking, but they really don't
°5ubecause the runtime system uses scheduling mechanisms like
°5u<tt>select(2)</tt> to perform asynchronous I/O, so it is possible to
°5uinterrupt 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
°5u<a>http://www.haskell.org/haskellwiki/Research_papers/Generics#Scrap_your_boilerplate.21</a>.
°5uThis module provides the <a>Data</a> class with its primitives for
°5ugeneric programming, along with instances for many datatypes. It
°5ucorresponds to a merge between the previous
°5u<a>Data.Generics.Basics</a> and almost all of
°5u<a>Data.Generics.Instances</a>. The instances that are not present in
°5uthis module were moved to the <tt>Data.Generics.Instances</tt> module
°5uin the <tt>syb</tt> package.
°5u
°5uFor more information, please visit the new SYB wiki:
°5u<a>http://www.cs.uu.nl/wiki/bin/view/GenericProgramming/SYB</a>.
module Data.Data

-- | The <a>Data</a> class comprehends a fundamental primitive
°5u<a>gfoldl</a> for folding over constructor applications, say terms.
°5uThis primitive can be instantiated in several ways to map over the
°5uimmediate subterms of a term; see the <tt>gmap</tt> combinators later
°5uin this class. Indeed, a generic programmer does not necessarily need
°5uto use the ingenious gfoldl primitive but rather the intuitive
°5u<tt>gmap</tt> combinators. The <a>gfoldl</a> primitive is completed by
°5umeans to query top-level constructors, to turn constructor
°5urepresentations into proper terms, and to list all possible datatype
°5uconstructors. This completion allows us to serve generic programming
°5uscenarios like read, show, equality, term generation.
°5u
°5uThe combinators <a>gmapT</a>, <a>gmapQ</a>, <a>gmapM</a>, etc are all
°5uprovided with default definitions in terms of <a>gfoldl</a>, leaving
°5uopen the opportunity to provide datatype-specific definitions. (The
°5uinclusion of the <tt>gmap</tt> combinators as members of class
°5u<a>Data</a> allows the programmer or the compiler to derive
°5uspecialised, and maybe more efficient code per datatype. <i>Note</i>:
°5u<a>gfoldl</a> is more higher-order than the <tt>gmap</tt> combinators.
°5uThis is subject to ongoing benchmarking experiments. It might turn out
°5uthat the <tt>gmap</tt> combinators will be moved out of the class
°5u<a>Data</a>.)
°5u
°5uConceptually, the definition of the <tt>gmap</tt> combinators in terms
°5uof the primitive <a>gfoldl</a> requires the identification of the
°5u<a>gfoldl</a> function arguments. Technically, we also need to
°5uidentify the type constructor <tt>c</tt> for the construction of the
°5uresult type from the folded term type.
°5u
°5uIn the definition of <tt>gmapQ</tt><i>x</i> combinators, we use
°5uphantom type constructors for the <tt>c</tt> in the type of
°5u<a>gfoldl</a> because the result type of a query does not involve the
°5u(polymorphic) type of the term argument. In the definition of
°5u<a>gmapQl</a> we simply use the plain constant type constructor
°5ubecause <a>gfoldl</a> is left-associative anyway and so it is readily
°5usuited to fold a left-associative binary operation over the immediate
°5usubterms. In the definition of gmapQr, extra effort is needed. We use
°5ua higher-order accumulation trick to mediate between left-associative
°5uconstructor application vs. right-associative binary operation (e.g.,
°5u<tt>(:)</tt>). When the query is meant to compute a value of type
°5u<tt>r</tt>, then the result type withing generic folding is <tt>r
°5u-&gt; r</tt>. So the result of folding is a function to which we
°5ufinally pass the right unit.
°5u
°5uWith the <tt>-XDeriveDataTypeable</tt> option, GHC can generate
°5uinstances of the <a>Data</a> class automatically. For example, given
°5uthe declaration
°5u
°5u<pre>
°5udata T a b = C1 a b | C2 deriving (Typeable, Data)
°5u</pre>
°5u
°5uGHC will generate an instance that is equivalent to
°5u
°5u<pre>
°5uinstance (Data a, Data b) =&gt; Data (T a b) where
°5u    gfoldl k z (C1 a b) = z C1 `k` a `k` b
°5u    gfoldl k z C2       = z C2
°5u
°5u    gunfold k z c = case constrIndex c of
°5u                        1 -&gt; k (k (z C1))
°5u                        2 -&gt; z C2
°5u
°5u    toConstr (C1 _ _) = con_C1
°5u    toConstr C2       = con_C2
°5u
°5u    dataTypeOf _ = ty_T
°5u
°5ucon_C1 = mkConstr ty_T "C1" [] Prefix
°5ucon_C2 = mkConstr ty_T "C2" [] Prefix
°5uty_T   = mkDataType "Module.T" [con_C1, con_C2]
°5u</pre>
°5u
°5uThis is suitable for datatypes that are exported transparently.
class Typeable a => Data a

-- | Left-associative fold operation for constructor applications.
°5u
°5uThe type of <a>gfoldl</a> is a headache, but operationally it is a
°5usimple generalisation of a list fold.
°5u
°5uThe default definition for <a>gfoldl</a> is <tt><a>const</a>
°5u<a>id</a></tt>, which is suitable for abstract datatypes with no
°5usubstructures.
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
°5uis meant to be the top-level constructor. Primitive datatypes are here
°5uviewed 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.
°5u
°5uIn <a>Data</a> instances of the form
°5u
°5u<pre>
°5uinstance (Data a, ...) =&gt; Data (T a)
°5u</pre>
°5u
°5u<a>dataCast1</a> should be defined as <a>gcast1</a>.
°5u
°5uThe default definition is <tt><a>const</a> <a>Nothing</a></tt>, which
°5uis 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.
°5u
°5uIn <a>Data</a> instances of the form
°5u
°5u<pre>
°5uinstance (Data a, Data b, ...) =&gt; Data (T a b)
°5u</pre>
°5u
°5u<a>dataCast2</a> should be defined as <a>gcast2</a>.
°5u
°5uThe default definition is <tt><a>const</a> <a>Nothing</a></tt>, which
°5uis 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
°5u
°5uThe default definition instantiates the type constructor <tt>c</tt> in
°5uthe type of <a>gfoldl</a> to an identity datatype constructor, using
°5uthe 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
°5ulist of results. The list is given in the same order as originally
°5uspecified 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
°5u
°5uThe default definition instantiates the type constructor <tt>c</tt> in
°5uthe type of <a>gfoldl</a> to the monad datatype constructor, defining
°5uinjection 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
°5uwith 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
°5uwith different types may not work -- i.e. the constructors for
°5u<a>False</a> and <a>Nothing</a> may compare equal.
data Constr

-- | Unique index for datatype constructors, counting from 1 in the order
°5uthey 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
°5uin the same order as they were given in the original constructor
°5udeclaration.
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
°5uextensions.
°5u
°5uNote: no other base module should import this module.
module GHC.Exts

-- | A fixed-precision integer type with at least the range <tt>[-2^29 ..
°5u2^29-1]</tt>. The exact range for a given implementation can be
°5udetermined by using <a>minBound</a> and <a>maxBound</a> from the
°5u<a>Bounded</a> class.
data Int
I# :: Int# -> Int

-- | A <a>Word</a> is an unsigned integral type, with the same size as
°5u<a>Int</a>.
data Word
W# :: Word# -> Word

-- | Single-precision floating point numbers. It is desirable that this
°5utype be at least equal in range and precision to the IEEE
°5usingle-precision type.
data Float
F# :: Float# -> Float

-- | Double-precision floating point numbers. It is desirable that this
°5utype be at least equal in range and precision to the IEEE
°5udouble-precision type.
data Double
D# :: Double# -> Double

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

-- | A value of type <tt><a>Ptr</a> a</tt> represents a pointer to an
°5uobject, or an array of objects, which may be marshalled to or from
°5uHaskell values of type <tt>a</tt>.
°5u
°5uThe type <tt>a</tt> will often be an instance of class <a>Storable</a>
°5uwhich provides the marshalling operations. However this is not
°5uessential, and you can provide your own operations to access the
°5upointer. For example you might write small foreign functions to get or
°5uset 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
°5ucallable from foreign code. The type <tt>a</tt> will normally be a
°5u<i>foreign type</i>, a function type with zero or more arguments where
°5u
°5u<ul>
°5u<li>the argument types are <i>marshallable foreign types</i>, i.e.
°5u<a>Char</a>, <a>Int</a>, <a>Double</a>, <a>Float</a>, <a>Bool</a>,
°5u<a>Int8</a>, <a>Int16</a>, <a>Int32</a>, <a>Int64</a>, <a>Word8</a>,
°5u<a>Word16</a>, <a>Word32</a>, <a>Word64</a>, <tt><a>Ptr</a> a</tt>,
°5u<tt><a>FunPtr</a> a</tt>, <tt><a>StablePtr</a> a</tt> or a renaming of
°5uany of these using <tt>newtype</tt>.</li>
°5u<li>the return type is either a marshallable foreign type or has the
°5uform <tt><a>IO</a> t</tt> where <tt>t</tt> is a marshallable foreign
°5utype or <tt>()</tt>.</li>
°5u</ul>
°5u
°5uA value of type <tt><a>FunPtr</a> a</tt> may be a pointer to a foreign
°5ufunction, either returned by another foreign function or imported with
°5ua a static address import like
°5u
°5u<pre>
°5uforeign import ccall "stdlib.h &amp;free"
°5u  p_free :: FunPtr (Ptr a -&gt; IO ())
°5u</pre>
°5u
°5uor a pointer to a Haskell function created using a <i>wrapper</i> stub
°5udeclared to produce a <a>FunPtr</a> of the correct type. For example:
°5u
°5u<pre>
°5utype Compare = Int -&gt; Int -&gt; Bool
°5uforeign import ccall "wrapper"
°5u  mkCompare :: Compare -&gt; IO (FunPtr Compare)
°5u</pre>
°5u
°5uCalls to wrapper stubs like <tt>mkCompare</tt> allocate storage, which
°5ushould be released with <a>freeHaskellFunPtr</a> when no longer
°5urequired.
°5u
°5uTo convert <a>FunPtr</a> values to corresponding Haskell functions,
°5uone can define a <i>dynamic</i> stub for the specific foreign type,
°5ue.g.
°5u
°5u<pre>
°5utype IntFunction = CInt -&gt; IO ()
°5uforeign import ccall "dynamic"
°5u  mkFun :: FunPtr IntFunction -&gt; IntFunction
°5u</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
°5uotherwise equal to <tt>b</tt>. In other words, it evaluates the first
°5uargument <tt>a</tt> to weak head normal form (WHNF). <tt>seq</tt> is
°5uusually introduced to improve performance by avoiding unneeded
°5ulaziness.
°5u
°5uA note on evaluation order: the expression <tt>seq a b</tt> does
°5u<i>not</i> guarantee that <tt>a</tt> will be evaluated before
°5u<tt>b</tt>. The only guarantee given by <tt>seq</tt> is that the both
°5u<tt>a</tt> and <tt>b</tt> will be evaluated before <tt>seq</tt>
°5ureturns a value. In particular, this means that <tt>b</tt> may be
°5uevaluated before <tt>a</tt>. If you need to guarantee a specific order
°5uof evaluation, you must use the function <tt>pseq</tt> from the
°5u"parallel" package.
seq :: () => a -> b -> b
realWorld# :: State# RealWorld
void# :: Void#

-- | The function <tt>unsafeCoerce#</tt> allows you to side-step the
°5utypechecker entirely. That is, it allows you to coerce any type into
°5uany other type. If you use this function, you had better get it right,
°5uotherwise segmentation faults await. It is generally used when you
°5uwant to write a program that you know is well-typed, but where
°5uHaskell's type system is not expressive enough to prove that it is
°5uwell typed.
°5u
°5uThe following uses of <tt>unsafeCoerce#</tt> are supposed to work
°5u(i.e. not lead to spurious compile-time or run-time crashes):
°5u
°5u<ul>
°5u<li>Casting any lifted type to <tt>Any</tt></li>
°5u<li>Casting <tt>Any</tt> back to the real type</li>
°5u<li>Casting an unboxed type to another unboxed type of the same size.
°5u(Casting between floating-point and integral types does not work. See
°5uthe <tt>GHC.Float</tt> module for functions to do work.)</li>
°5u<li>Casting between two types that have the same runtime
°5urepresentation. One case is when the two types differ only in
°5u"phantom" type parameters, for example <tt>Ptr Int</tt> to <tt>Ptr
°5uFloat</tt>, or <tt>[Int]</tt> to <tt>[Float]</tt> when the list is
°5uknown to be empty. Also, a <tt>newtype</tt> of a type <tt>T</tt> has
°5uthe same representation at runtime as <tt>T</tt>.</li>
°5u</ul>
°5u
°5uOther uses of <tt>unsafeCoerce#</tt> are undefined. In particular, you
°5ushould not use <tt>unsafeCoerce#</tt> to cast a T to an algebraic data
°5utype D, unless T is also an algebraic data type. For example, do not
°5ucast <tt>Int-&gt;Int</tt> to <tt>Bool</tt>, even if you later cast
°5uthat <tt>Bool</tt> back to <tt>Int-&gt;Int</tt> before applying it.
°5uThe reasons have to do with GHC's internal representation details (for
°5uthe cognoscenti, data values can be entered but function closures
°5ucannot). If you want a safe type to cast things to, use <tt>Any</tt>,
°5uwhich 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
°5urepresentation.
proxy# :: () => Proxy# a

-- | An arbitrary machine address assumed to point outside the
°5ugarbage-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
°5u<tt>MutVar#</tt>!). (Note: in a non-concurrent implementation,
°5u<tt>(MVar# a)</tt> can be represented by <tt>(MutVar# (Maybe
°5ua))</tt>.)
data MVar# (a :: *) (b :: *) :: TYPE UnliftedRep

-- | <tt>RealWorld</tt> is deeply magical. It is <i>primitive</i>, but it
°5uis not <i>unlifted</i> (hence <tt>ptrArg</tt>). We never manipulate
°5uvalues of type <tt>RealWorld</tt>; it's only used in the type system,
°5uto 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
°5utype parameter, thus <tt>State# RealWorld</tt>, or <tt>State# s</tt>,
°5uwhere s is a type variable. The only purpose of the type parameter is
°5uto keep different state threads separate. It is represented by nothing
°5uat 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,
°5uwhose (unique) value is returned by <tt>myThreadId#</tt>. The other
°5uoperations 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
°5utype variable. It's used when you want to pass around proxy values for
°5udoing things like modelling type applications. A <tt>Proxy#</tt> is
°5unot only unboxed, it also has a polymorphic kind, and has no runtime
°5urepresentation, 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
°5usigned integer multiply might contain useful information. Return zero
°5uonly if you are completely sure that no overflow can occur. On a
°5u32-bit platform, the recommended implementation is to do a 32 x 32
°5u-&gt; 64 signed multiply, and subtract result[63:32] from (result[31]
°5u&gt;&gt;signed 31). If this is zero, meaning that the upper word is
°5umerely a sign extension of the lower one, no overflow can occur.
°5u
°5uOn a 64-bit platform it is not always possible to acquire the top 64
°5ubits of the result. Therefore, a recommended implementation is to take
°5uthe absolute value of both operands, and return 0 iff bits[63:31] of
°5uthem are zero, since that means that their magnitudes fit within 31
°5ubits, so the magnitude of the product must fit into 62 bits.
°5u
°5uIf in doubt, return non-zero, but do make an effort to create the
°5ucorrect answer for small args, since otherwise the performance of
°5u<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
°5uis zero.
quotInt# :: Int# -> Int# -> Int#

-- | Satisfies <tt>(quotInt# x y) *# y +# (remInt# x y) == x</tt>. The
°5ubehavior 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
°5usum truncated to an <tt>Int#</tt>; second member is zero if the true
°5usum fits in an <tt>Int#</tt>, nonzero if overflow occurred (the sum is
°5ueither 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
°5uthe difference truncated to an <tt>Int#</tt>; second member is zero if
°5uthe true difference fits in an <tt>Int#</tt>, nonzero if overflow
°5uoccurred (the difference is either too large or too small to fit in an
°5u<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
°5uword size - 1 inclusive.
uncheckedIShiftL# :: Int# -> Int# -> Int#

-- | Shift right arithmetic. Result undefined if shift amount is not in the
°5urange 0 to word size - 1 inclusive.
uncheckedIShiftRA# :: Int# -> Int# -> Int#

-- | Shift right logical. Result undefined if shift amount is not in the
°5urange 0 to word size - 1 inclusive.
uncheckedIShiftRL# :: Int# -> Int# -> Int#
plusWord# :: Word# -> Word# -> Word#

-- | Subtract unsigned integers reporting overflow. The first element of
°5uthe pair is the result. The second element is the carry flag, which is
°5unonzero 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
°5urange 0 to word size - 1 inclusive.
uncheckedShiftL# :: Word# -> Int# -> Word#

-- | Shift right logical. Result undefined if shift amount is not in the
°5urange 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
°5umask.
pdep8# :: Word# -> Word# -> Word#

-- | Deposit bits to lower 16 bits of a word at locations specified by a
°5umask.
pdep16# :: Word# -> Word# -> Word#

-- | Deposit bits to lower 32 bits of a word at locations specified by a
°5umask.
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
°5umask.
pext8# :: Word# -> Word# -> Word#

-- | Extract bits from lower 16 bits of a word at locations specified by a
°5umask.
pext16# :: Word# -> Word# -> Word#

-- | Extract bits from lower 32 bits of a word at locations specified by a
°5umask.
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
°5uundefined.
byteSwap16# :: Word# -> Word#

-- | Swap bytes in the lower 32 bits of a word. The higher bytes are
°5uundefined.
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>.
°5uResults are undefined if the truncation if truncation yields a value
°5uoutside 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,
°5uindicating the sign of the mantissa. The next two are the high and low
°5u32 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>.
°5uResults are undefined if the truncation if truncation yields a value
°5uoutside 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;
°5usecond is the exponent.
decodeFloat_Int# :: Float# -> (# Int#, Int# #)

-- | Create a new mutable array with the specified number of elements, in
°5uthe specified state thread, with each element containing the specified
°5uinitial 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
°5uevaluated.
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
°5uan 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
°5uarray, an offset into the destination array, and a number of elements
°5uto copy, copy the elements from the source array to the destination
°5uarray. Both arrays must fully contain the specified ranges, but this
°5uis not checked. The two arrays must not be the same array in different
°5ustates, 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
°5uarray, an offset into the destination array, and a number of elements
°5uto copy, copy the elements from the source array to the destination
°5uarray. Both arrays must fully contain the specified ranges, but this
°5uis not checked. In the case where the source and destination are the
°5usame 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
°5uelements to copy, create a new array with the elements from the source
°5uarray. The provided array must fully contain the specified range, but
°5uthis is not checked.
cloneArray# :: () => Array# a -> Int# -> Int# -> Array# a

-- | Given a source array, an offset into the source array, and a number of
°5uelements to copy, create a new array with the elements from the source
°5uarray. The provided array must fully contain the specified range, but
°5uthis 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
°5uelements to copy, create a new array with the elements from the source
°5uarray. The provided array must fully contain the specified range, but
°5uthis 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
°5uelements to copy, create a new array with the elements from the source
°5uarray. The provided array must fully contain the specified range, but
°5uthis 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
°5uArray.
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
°5uthe specified state thread, with each element containing the specified
°5uinitial 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
°5uevaluated.
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
°5uan 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
°5uarray, an offset into the destination array, and a number of elements
°5uto copy, copy the elements from the source array to the destination
°5uarray. Both arrays must fully contain the specified ranges, but this
°5uis not checked. The two arrays must not be the same array in different
°5ustates, 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
°5uarray, an offset into the destination array, and a number of elements
°5uto copy, copy the elements from the source array to the destination
°5uarray. The source and destination arrays can refer to the same array.
°5uBoth arrays must fully contain the specified ranges, but this is not
°5uchecked. The regions are allowed to overlap, although this is only
°5upossible when the same array is provided as both the source and the
°5udestination.
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
°5uelements to copy, create a new array with the elements from the source
°5uarray. The provided array must fully contain the specified range, but
°5uthis is not checked.
cloneSmallArray# :: () => SmallArray# a -> Int# -> Int# -> SmallArray# a

-- | Given a source array, an offset into the source array, and a number of
°5uelements to copy, create a new array with the elements from the source
°5uarray. The provided array must fully contain the specified range, but
°5uthis 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
°5uelements to copy, create a new array with the elements from the source
°5uarray. The provided array must fully contain the specified range, but
°5uthis 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
°5uelements to copy, create a new array with the elements from the source
°5uarray. The provided array must fully contain the specified range, but
°5uthis 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
°5uarray.
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
°5uspecified 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
°5uGC guarantees not to move.
newAlignedPinnedByteArray# :: () => Int# -> Int# -> State# d -> (# State# d, MutableByteArray# d #)

-- | Determine whether a <tt>MutableByteArray#</tt> is guaranteed not to
°5umove during GC.
isMutableByteArrayPinned# :: () => MutableByteArray# d -> Int#

-- | Determine whether a <tt>ByteArray#</tt> is guaranteed not to move
°5uduring 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
°5uspecified state thread. The new size argument must be less than or
°5uequal 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).
°5uThe returned <tt>MutableByteArray#</tt> is either the original
°5u<tt>MutableByteArray#</tt> resized in-place or, if not possible, a
°5unewly allocated (unpinned) <tt>MutableByteArray#</tt> (with the
°5uoriginal content copied over).
°5u
°5uTo avoid undefined behaviour, the original <tt>MutableByteArray#</tt>
°5ushall not be accessed anymore after a <tt>resizeMutableByteArray#</tt>
°5uhas been performed. Moreover, no reference to the old one should be
°5ukept in order to allow garbage collection of the original
°5u<tt>MutableByteArray#</tt> in case a new <tt>MutableByteArray#</tt>
°5uhad 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
°5uit is unsafe in the presence of concurrent resize operations on the
°5usame 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
°5u<tt>n</tt> bytes starting at offset <tt>src1_ofs</tt> in the first
°5u<tt>ByteArray#</tt> <tt>src1</tt> to the range of <tt>n</tt> bytes
°5u(i.e. same length) starting at offset <tt>src2_ofs</tt> of the second
°5u<tt>ByteArray#</tt> <tt>src2</tt>. Both arrays must fully contain the
°5uspecified ranges, but this is not checked. Returns an <tt>Int#</tt>
°5uless than, equal to, or greater than zero if the range is found,
°5urespectively, to be byte-wise lexicographically less than, to match,
°5uor 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
°5ustarting at offset <tt>src_ofs</tt> of length <tt>n</tt> from the
°5u<tt>ByteArray#</tt> <tt>src</tt> to the <tt>MutableByteArray#</tt>
°5u<tt>dst</tt> starting at offset <tt>dst_ofs</tt>. Both arrays must
°5ufully contain the specified ranges, but this is not checked. The two
°5uarrays must not be the same array in different states, but this is not
°5uchecked either.
copyByteArray# :: () => ByteArray# -> Int# -> MutableByteArray# d -> Int# -> Int# -> State# d -> State# d

-- | Copy a range of the first MutableByteArray. Both arrays must fully
°5ucontain the specified ranges, but this is not checked. The regions are
°5uallowed to overlap, although this is only possible when the same array
°5uis 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
°5uspecified ranges, but this is not checked. The Addr# must not point
°5uinto 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
°5uthe Addr and the memory region at Addr# must fully contain the
°5uspecified ranges, but this is not checked. The Addr# must not point
°5uinto the MutableByteArray were pinned), but this is not checked
°5ueither.
copyMutableByteArrayToAddr# :: () => MutableByteArray# d -> Int# -> Addr# -> Int# -> State# d -> State# d

-- | Copy a memory range starting at the Addr# to the specified range in
°5uthe MutableByteArray and the ByteArray# must fully contain the
°5uspecified ranges, but this is not checked. The Addr# must not point
°5uinto the MutableByteArray were pinned), but this is not checked
°5ueither.
copyAddrToByteArray# :: () => Addr# -> MutableByteArray# d -> Int# -> Int# -> State# d -> State# d

-- | <tt>setByteArray# ba off len c</tt> sets the byte range <tt>[off,
°5uoff+len]</tt> of the <tt>MutableByteArray#</tt> to the byte
°5u<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
°5uis 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
°5uis 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
°5uthe new value, perform an atomic compare and swap i.e. write the new
°5uvalue if the current value matches the provided old value. Returns the
°5uvalue of the element before the operation. Implies a full memory
°5ubarrier.
casIntArray# :: () => MutableByteArray# d -> Int# -> Int# -> Int# -> State# d -> (# State# d, Int# #)

-- | Given an array, and offset in Int units, and a value to add,
°5uatomically add the value to the element. Returns the value of the
°5uelement 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,
°5uatomically substract the value to the element. Returns the value of
°5uthe 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,
°5uatomically AND the value to the element. Returns the value of the
°5uelement 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,
°5uatomically NAND the value to the element. Returns the value of the
°5uelement 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
°5uOR the value to the element. Returns the value of the element before
°5uthe 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,
°5uatomically XOR the value to the element. Returns the value of the
°5uelement 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
°5uelements, in the specified state thread, with each element recursively
°5ureferring 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
°5uspecified ranges, but this is not checked. The two arrays must not be
°5uthe 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
°5uin the second MutableArrayArray#. Both arrays must fully contain the
°5uspecified ranges, but this is not checked. The regions are allowed to
°5uoverlap, although this is only possible when the same array is
°5uprovided 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
°5utheir 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
°5u<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
°5ustate 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
°5ustrictly speaking the correct type for this function, it should really
°5ube <tt>MutVar s -&gt; ( s, b #)</tt>, however we don't know about
°5upairs 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
°5uand 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
°5uvalue undefined. Otherwise, return with integer 1 and contents of
°5u<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
°5uvalue 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.
°5uOtherwise, store value arg as <tt>MVar#</tt>'s new contents, and
°5ureturn 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
°5ucontents without modifying the MVar, without possibility of
°5uintervention from other threads.
readMVar# :: () => MVar# d a -> State# d -> (# State# d, a #)

-- | If <tt>MVar#</tt> is empty, immediately return with integer 0 and
°5uvalue undefined. Otherwise, return with integer 1 and contents of
°5u<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
°5u<tt>k</tt>, with an associated reference to some value <tt>v</tt>. If
°5u<tt>k</tt> is still alive then <tt>v</tt> can be retrieved using
°5u<tt>deRefWeak#</tt>. Note that the type of <tt>k</tt> must be
°5urepresented by a pointer (i.e. of kind <tt>TYPE 'LiftedRep</tt> or
°5u<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
°5ufunction pointer <tt>fptr</tt> to a weak pointer <tt>w</tt> as a
°5ufinalizer. If <tt>flag</tt> is zero, <tt>fptr</tt> will be called with
°5uone argument, <tt>ptr</tt>. Otherwise, it will be called with two
°5uarguments, <tt>eptr</tt> and <tt>ptr</tt>.
°5u<tt>addCFinalizerToWeak#</tt> returns 1 on success, or 0 if <tt>w</tt>
°5uis 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
°5ucontaining the new state of the world and an "unboxed Maybe",
°5urepresented by an <tt>Int#</tt> and a (possibly invalid) finalization
°5uaction. An <tt>Int#</tt> of <tt>1</tt> indicates that the finalizer is
°5uvalid. The return value <tt>b</tt> from the finalizer should be
°5uignored.
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
°5usize is rounded up to a multiple of the allocator block size, and
°5ucapped to one mega block.
compactNew# :: Word# -> State# RealWorld -> (# State# RealWorld, Compact# #)

-- | Set the new allocation size of the compact. This value (in bytes)
°5udetermines 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
°5ucompact.
compactGetFirstBlock# :: Compact# -> State# RealWorld -> (# State# RealWorld, Addr#, Word# #)

-- | Given a compact and the address of one its blocks, returns the next
°5ublock and its size, or #nullAddr if the argument was the last block in
°5uthe compact.
compactGetNextBlock# :: Compact# -> Addr# -> State# RealWorld -> (# State# RealWorld, Addr#, Word# #)

-- | Attempt to allocate a compact block with the given size (in bytes) at
°5uthe given address. The first argument is a hint to the allocator,
°5uallocation might be satisfied at a different address (which is
°5ureturned). The resulting block is not known to the GC until
°5ucompactFixupPointers# is called on it, and care must be taken so that
°5uthe 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
°5uthe root object in the old address space, fix up the internal pointers
°5uinside the compact to account for a different position in memory than
°5uwhen it was serialized. This method must be called exactly once after
°5uimporting a serialized compact, and returns the new compact and the
°5unew adjusted root address.
compactFixupPointers# :: Addr# -> Addr# -> State# RealWorld -> (# State# RealWorld, Compact#, Addr# #)

-- | Recursively add a closure and its transitive closure to a {texttt
°5uCompact#}, evaluating any unevaluated components at the same time.
°5uNote: {texttt compactAdd#} is not thread-safe, so only one thread may
°5ucall {texttt compactAdd#} with a particular {texttt Compact#} at any
°5ugiven time. The primop does not enforce any mutual exclusion; the
°5ucaller is expected to arrange this.
compactAdd# :: () => Compact# -> a -> State# RealWorld -> (# State# RealWorld, a #)

-- | Like {texttt compactAdd#}, but retains sharing and cycles during
°5ucompaction.
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#}
°5uotherwise.
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>
°5u<li>Note [dataToTag#] ~~~~~~~~~~~~~~~~~~~~ The dataToTag# primop
°5ushould always be applied to an evaluated argument. The way to ensure
°5uthis is to invoke it via the 'getTag' wrapper in GHC.Base: getTag :: a
°5u-&gt; Int# getTag !x = dataToTag# x</li>
°5u</ul>
°5u
°5uBut now consider z. case x of y -&gt; let v = dataToTag# y in ...
°5u
°5uTo improve floating, the FloatOut pass (deliberately) does a
°5ubinder-swap on the case, to give z. case x of y -&gt; let v =
°5udataToTag# x in ...
°5u
°5uNow FloatOut might float that v-binding outside the z. But that is bad
°5ubecause that might mean x gest evaluated much too early! (CorePrep
°5uadds an eval to a dataToTag# call, to ensure that the argument really
°5uis evaluated; see CorePrep Note [dataToTag magic].)
°5u
°5uSolution: make DataToTag into a can_fail primop. That will stop it
°5ufloating (see Note [PrimOp can_fail and has_side_effects] in PrimOp).
°5uIt'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
°5u{texttt unsafeCoerce#}, but if implemented as such the core lint pass
°5ucomplains and fails to compile. As a primop, it is opaque to core/stg,
°5uand only appears in cmm (where the copy propagation pass will get rid
°5uof it). Note that "a" must be a value, not a thunk! It's too late for
°5ustrictness analysis to enforce this, so you're on your own to
°5uguarantee this. Also note that {texttt Addr#} is not a GC pointer - up
°5uto you to guarantee that it does not become a dangling pointer
°5uimmediately 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
°5uvalue of the BCO when evaluated.
mkApUpd0# :: () => BCO# -> (# a #)

-- | <tt>newBCO# instrs lits ptrs arity bitmap</tt> creates a new bytecode
°5uobject. The resulting object encodes a function of the given arity
°5uwith the instructions encoded in <tt>instrs</tt>, and a static
°5ureference 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
°5uthe payload of the given closure into two new arrays, and returns a
°5upointer to the first word of the closure's info table, a pointer array
°5ufor the pointers in the payload, and a non-pointer array for the
°5unon-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>
°5uif not profiling). Takes a dummy argument which can be used to avoid
°5uthe call to <tt>getCurrentCCS#</tt> being floated out by the
°5usimplifier, 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
°5uused by the interpreter to run an interpreted computation without the
°5ucall 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
°5uevent is the zero-terminated byte string passed as the first argument.
°5uThe event will be emitted either to the .eventlog file, or to stderr,
°5udepending on the runtime RTS flags.
traceEvent# :: () => Addr# -> State# d -> State# d

-- | Emits a marker event via the RTS tracing framework. The contents of
°5uthe event is the zero-terminated byte string passed as the first
°5uargument. The event will be emitted either to the .eventlog file, or
°5uto 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;
°5uoffset is in scalar elements.
indexInt8ArrayAsInt8X16# :: ByteArray# -> Int# -> Int8X16#

-- | Read a vector from specified index of immutable array of scalars;
°5uoffset is in scalar elements.
indexInt16ArrayAsInt16X8# :: ByteArray# -> Int# -> Int16X8#

-- | Read a vector from specified index of immutable array of scalars;
°5uoffset is in scalar elements.
indexInt32ArrayAsInt32X4# :: ByteArray# -> Int# -> Int32X4#

-- | Read a vector from specified index of immutable array of scalars;
°5uoffset is in scalar elements.
indexInt64ArrayAsInt64X2# :: ByteArray# -> Int# -> Int64X2#

-- | Read a vector from specified index of immutable array of scalars;
°5uoffset is in scalar elements.
indexInt8ArrayAsInt8X32# :: ByteArray# -> Int# -> Int8X32#

-- | Read a vector from specified index of immutable array of scalars;
°5uoffset is in scalar elements.
indexInt16ArrayAsInt16X16# :: ByteArray# -> Int# -> Int16X16#

-- | Read a vector from specified index of immutable array of scalars;
°5uoffset is in scalar elements.
indexInt32ArrayAsInt32X8# :: ByteArray# -> Int# -> Int32X8#

-- | Read a vector from specified index of immutable array of scalars;
°5uoffset is in scalar elements.
indexInt64ArrayAsInt64X4# :: ByteArray# -> Int# -> Int64X4#

-- | Read a vector from specified index of immutable array of scalars;
°5uoffset is in scalar elements.
indexInt8ArrayAsInt8X64# :: ByteArray# -> Int# -> Int8X64#

-- | Read a vector from specified index of immutable array of scalars;
°5uoffset is in scalar elements.
indexInt16ArrayAsInt16X32# :: ByteArray# -> Int# -> Int16X32#

-- | Read a vector from specified index of immutable array of scalars;
°5uoffset is in scalar elements.
indexInt32ArrayAsInt32X16# :: ByteArray# -> Int# -> Int32X16#

-- | Read a vector from specified index of immutable array of scalars;
°5uoffset is in scalar elements.
indexInt64ArrayAsInt64X8# :: ByteArray# -> Int# -> Int64X8#

-- | Read a vector from specified index of immutable array of scalars;
°5uoffset is in scalar elements.
indexWord8ArrayAsWord8X16# :: ByteArray# -> Int# -> Word8X16#

-- | Read a vector from specified index of immutable array of scalars;
°5uoffset is in scalar elements.
indexWord16ArrayAsWord16X8# :: ByteArray# -> Int# -> Word16X8#

-- | Read a vector from specified index of immutable array of scalars;
°5uoffset is in scalar elements.
indexWord32ArrayAsWord32X4# :: ByteArray# -> Int# -> Word32X4#

-- | Read a vector from specified index of immutable array of scalars;
°5uoffset is in scalar elements.
indexWord64ArrayAsWord64X2# :: ByteArray# -> Int# -> Word64X2#

-- | Read a vector from specified index of immutable array of scalars;
°5uoffset is in scalar elements.
indexWord8ArrayAsWord8X32# :: ByteArray# -> Int# -> Word8X32#

-- | Read a vector from specified index of immutable array of scalars;
°5uoffset is in scalar elements.
indexWord16ArrayAsWord16X16# :: ByteArray# -> Int# -> Word16X16#

-- | Read a vector from specified index of immutable array of scalars;
°5uoffset is in scalar elements.
indexWord32ArrayAsWord32X8# :: ByteArray# -> Int# -> Word32X8#

-- | Read a vector from specified index of immutable array of scalars;
°5uoffset is in scalar elements.
indexWord64ArrayAsWord64X4# :: ByteArray# -> Int# -> Word64X4#

-- | Read a vector from specified index of immutable array of scalars;
°5uoffset is in scalar elements.
indexWord8ArrayAsWord8X64# :: ByteArray# -> Int# -> Word8X64#

-- | Read a vector from specified index of immutable array of scalars;
°5uoffset is in scalar elements.
indexWord16ArrayAsWord16X32# :: ByteArray# -> Int# -> Word16X32#

-- | Read a vector from specified index of immutable array of scalars;
°5uoffset is in scalar elements.
indexWord32ArrayAsWord32X16# :: ByteArray# -> Int# -> Word32X16#

-- | Read a vector from specified index of immutable array of scalars;
°5uoffset is in scalar elements.
indexWord64ArrayAsWord64X8# :: ByteArray# -> Int# -> Word64X8#

-- | Read a vector from specified index of immutable array of scalars;
°5uoffset is in scalar elements.
indexFloatArrayAsFloatX4# :: ByteArray# -> Int# -> FloatX4#

-- | Read a vector from specified index of immutable array of scalars;
°5uoffset is in scalar elements.
indexDoubleArrayAsDoubleX2# :: ByteArray# -> Int# -> DoubleX2#

-- | Read a vector from specified index of immutable array of scalars;
°5uoffset is in scalar elements.
indexFloatArrayAsFloatX8# :: ByteArray# -> Int# -> FloatX8#

-- | Read a vector from specified index of immutable array of scalars;
°5uoffset is in scalar elements.
indexDoubleArrayAsDoubleX4# :: ByteArray# -> Int# -> DoubleX4#

-- | Read a vector from specified index of immutable array of scalars;
°5uoffset is in scalar elements.
indexFloatArrayAsFloatX16# :: ByteArray# -> Int# -> FloatX16#

-- | Read a vector from specified index of immutable array of scalars;
°5uoffset is in scalar elements.
indexDoubleArrayAsDoubleX8# :: ByteArray# -> Int# -> DoubleX8#

-- | Read a vector from specified index of mutable array of scalars; offset
°5uis in scalar elements.
readInt8ArrayAsInt8X16# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Int8X16# #)

-- | Read a vector from specified index of mutable array of scalars; offset
°5uis in scalar elements.
readInt16ArrayAsInt16X8# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Int16X8# #)

-- | Read a vector from specified index of mutable array of scalars; offset
°5uis in scalar elements.
readInt32ArrayAsInt32X4# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Int32X4# #)

-- | Read a vector from specified index of mutable array of scalars; offset
°5uis in scalar elements.
readInt64ArrayAsInt64X2# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Int64X2# #)

-- | Read a vector from specified index of mutable array of scalars; offset
°5uis in scalar elements.
readInt8ArrayAsInt8X32# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Int8X32# #)

-- | Read a vector from specified index of mutable array of scalars; offset
°5uis in scalar elements.
readInt16ArrayAsInt16X16# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Int16X16# #)

-- | Read a vector from specified index of mutable array of scalars; offset
°5uis in scalar elements.
readInt32ArrayAsInt32X8# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Int32X8# #)

-- | Read a vector from specified index of mutable array of scalars; offset
°5uis in scalar elements.
readInt64ArrayAsInt64X4# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Int64X4# #)

-- | Read a vector from specified index of mutable array of scalars; offset
°5uis in scalar elements.
readInt8ArrayAsInt8X64# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Int8X64# #)

-- | Read a vector from specified index of mutable array of scalars; offset
°5uis in scalar elements.
readInt16ArrayAsInt16X32# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Int16X32# #)

-- | Read a vector from specified index of mutable array of scalars; offset
°5uis in scalar elements.
readInt32ArrayAsInt32X16# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Int32X16# #)

-- | Read a vector from specified index of mutable array of scalars; offset
°5uis in scalar elements.
readInt64ArrayAsInt64X8# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Int64X8# #)

-- | Read a vector from specified index of mutable array of scalars; offset
°5uis in scalar elements.
readWord8ArrayAsWord8X16# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Word8X16# #)

-- | Read a vector from specified index of mutable array of scalars; offset
°5uis in scalar elements.
readWord16ArrayAsWord16X8# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Word16X8# #)

-- | Read a vector from specified index of mutable array of scalars; offset
°5uis in scalar elements.
readWord32ArrayAsWord32X4# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Word32X4# #)

-- | Read a vector from specified index of mutable array of scalars; offset
°5uis in scalar elements.
readWord64ArrayAsWord64X2# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Word64X2# #)

-- | Read a vector from specified index of mutable array of scalars; offset
°5uis in scalar elements.
readWord8ArrayAsWord8X32# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Word8X32# #)

-- | Read a vector from specified index of mutable array of scalars; offset
°5uis in scalar elements.
readWord16ArrayAsWord16X16# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Word16X16# #)

-- | Read a vector from specified index of mutable array of scalars; offset
°5uis in scalar elements.
readWord32ArrayAsWord32X8# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Word32X8# #)

-- | Read a vector from specified index of mutable array of scalars; offset
°5uis in scalar elements.
readWord64ArrayAsWord64X4# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Word64X4# #)

-- | Read a vector from specified index of mutable array of scalars; offset
°5uis in scalar elements.
readWord8ArrayAsWord8X64# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Word8X64# #)

-- | Read a vector from specified index of mutable array of scalars; offset
°5uis in scalar elements.
readWord16ArrayAsWord16X32# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Word16X32# #)

-- | Read a vector from specified index of mutable array of scalars; offset
°5uis in scalar elements.
readWord32ArrayAsWord32X16# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Word32X16# #)

-- | Read a vector from specified index of mutable array of scalars; offset
°5uis in scalar elements.
readWord64ArrayAsWord64X8# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, Word64X8# #)

-- | Read a vector from specified index of mutable array of scalars; offset
°5uis in scalar elements.
readFloatArrayAsFloatX4# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, FloatX4# #)

-- | Read a vector from specified index of mutable array of scalars; offset
°5uis in scalar elements.
readDoubleArrayAsDoubleX2# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, DoubleX2# #)

-- | Read a vector from specified index of mutable array of scalars; offset
°5uis in scalar elements.
readFloatArrayAsFloatX8# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, FloatX8# #)

-- | Read a vector from specified index of mutable array of scalars; offset
°5uis in scalar elements.
readDoubleArrayAsDoubleX4# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, DoubleX4# #)

-- | Read a vector from specified index of mutable array of scalars; offset
°5uis in scalar elements.
readFloatArrayAsFloatX16# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, FloatX16# #)

-- | Read a vector from specified index of mutable array of scalars; offset
°5uis in scalar elements.
readDoubleArrayAsDoubleX8# :: () => MutableByteArray# d -> Int# -> State# d -> (# State# d, DoubleX8# #)

-- | Write a vector to specified index of mutable array of scalars; offset
°5uis in scalar elements.
writeInt8ArrayAsInt8X16# :: () => MutableByteArray# d -> Int# -> Int8X16# -> State# d -> State# d

-- | Write a vector to specified index of mutable array of scalars; offset
°5uis in scalar elements.
writeInt16ArrayAsInt16X8# :: () => MutableByteArray# d -> Int# -> Int16X8# -> State# d -> State# d

-- | Write a vector to specified index of mutable array of scalars; offset
°5uis in scalar elements.
writeInt32ArrayAsInt32X4# :: () => MutableByteArray# d -> Int# -> Int32X4# -> State# d -> State# d

-- | Write a vector to specified index of mutable array of scalars; offset
°5uis in scalar elements.
writeInt64ArrayAsInt64X2# :: () => MutableByteArray# d -> Int# -> Int64X2# -> State# d -> State# d

-- | Write a vector to specified index of mutable array of scalars; offset
°5uis in scalar elements.
writeInt8ArrayAsInt8X32# :: () => MutableByteArray# d -> Int# -> Int8X32# -> State# d -> State# d

-- | Write a vector to specified index of mutable array of scalars; offset
°5uis in scalar elements.
writeInt16ArrayAsInt16X16# :: () => MutableByteArray# d -> Int# -> Int16X16# -> State# d -> State# d

-- | Write a vector to specified index of mutable array of scalars; offset
°5uis in scalar elements.
writeInt32ArrayAsInt32X8# :: () => MutableByteArray# d -> Int# -> Int32X8# -> State# d -> State# d

-- | Write a vector to specified index of mutable array of scalars; offset
°5uis in scalar elements.
writeInt64ArrayAsInt64X4# :: () => MutableByteArray# d -> Int# -> Int64X4# -> State# d -> State# d

-- | Write a vector to specified index of mutable array of scalars; offset
°5uis in scalar elements.
writeInt8ArrayAsInt8X64# :: () => MutableByteArray# d -> Int# -> Int8X64# -> State# d -> State# d

-- | Write a vector to specified index of mutable array of scalars; offset
°5uis in scalar elements.
writeInt16ArrayAsInt16X32# :: () => MutableByteArray# d -> Int# -> Int16X32# -> State# d -> State# d

-- | Write a vector to specified index of mutable array of scalars; offset
°5uis in scalar elements.
writeInt32ArrayAsInt32X16# :: () => MutableByteArray# d -> Int# -> Int32X16# -> State# d -> State# d

-- | Write a vector to specified index of mutable array of scalars; offset
°5uis in scalar elements.
writeInt64ArrayAsInt64X8# :: () => MutableByteArray# d -> Int# -> Int64X8# -> State# d -> State# d

-- | Write a vector to specified index of mutable array of scalars; offset
°5uis in scalar elements.
writeWord8ArrayAsWord8X16# :: () => MutableByteArray# d -> Int# -> Word8X16# -> State# d -> State# d

-- | Write a vector to specified index of mutable array of scalars; offset
°5uis in scalar elements.
writeWord16ArrayAsWord16X8# :: () => MutableByteArray# d -> Int# -> Word16X8# -> State# d -> State# d

-- | Write a vector to specified index of mutable array of scalars; offset
°5uis in scalar elements.
writeWord32ArrayAsWord32X4# :: () => MutableByteArray# d -> Int# -> Word32X4# -> State# d -> State# d

-- | Write a vector to specified index of mutable array of scalars; offset
°5uis in scalar elements.
writeWord64ArrayAsWord64X2# :: () => MutableByteArray# d -> Int# -> Word64X2# -> State# d -> State# d

-- | Write a vector to specified index of mutable array of scalars; offset
°5uis in scalar elements.
writeWord8ArrayAsWord8X32# :: () => MutableByteArray# d -> Int# -> Word8X32# -> State# d -> State# d

-- | Write a vector to specified index of mutable array of scalars; offset
°5uis in scalar elements.
writeWord16ArrayAsWord16X16# :: () => MutableByteArray# d -> Int# -> Word16X16# -> State# d -> State# d

-- | Write a vector to specified index of mutable array of scalars; offset
°5uis in scalar elements.
writeWord32ArrayAsWord32X8# :: () => MutableByteArray# d -> Int# -> Word32X8# -> State# d -> State# d

-- | Write a vector to specified index of mutable array of scalars; offset
°5uis in scalar elements.
writeWord64ArrayAsWord64X4# :: () => MutableByteArray# d -> Int# -> Word64X4# -> State# d -> State# d

-- | Write a vector to specified index of mutable array of scalars; offset
°5uis in scalar elements.
writeWord8ArrayAsWord8X64# :: () => MutableByteArray# d -> Int# -> Word8X64# -> State# d -> State# d

-- | Write a vector to specified index of mutable array of scalars; offset
°5uis in scalar elements.
writeWord16ArrayAsWord16X32# :: () => MutableByteArray# d -> Int# -> Word16X32# -> State# d -> State# d

-- | Write a vector to specified index of mutable array of scalars; offset
°5uis in scalar elements.
writeWord32ArrayAsWord32X16# :: () => MutableByteArray# d -> Int# -> Word32X16# -> State# d -> State# d

-- | Write a vector to specified index of mutable array of scalars; offset
°5uis in scalar elements.
writeWord64ArrayAsWord64X8# :: () => MutableByteArray# d -> Int# -> Word64X8# -> State# d -> State# d

-- | Write a vector to specified index of mutable array of scalars; offset
°5uis in scalar elements.
writeFloatArrayAsFloatX4# :: () => MutableByteArray# d -> Int# -> FloatX4# -> State# d -> State# d

-- | Write a vector to specified index of mutable array of scalars; offset
°5uis in scalar elements.
writeDoubleArrayAsDoubleX2# :: () => MutableByteArray# d -> Int# -> DoubleX2# -> State# d -> State# d

-- | Write a vector to specified index of mutable array of scalars; offset
°5uis in scalar elements.
writeFloatArrayAsFloatX8# :: () => MutableByteArray# d -> Int# -> FloatX8# -> State# d -> State# d

-- | Write a vector to specified index of mutable array of scalars; offset
°5uis in scalar elements.
writeDoubleArrayAsDoubleX4# :: () => MutableByteArray# d -> Int# -> DoubleX4# -> State# d -> State# d

-- | Write a vector to specified index of mutable array of scalars; offset
°5uis in scalar elements.
writeFloatArrayAsFloatX16# :: () => MutableByteArray# d -> Int# -> FloatX16# -> State# d -> State# d

-- | Write a vector to specified index of mutable array of scalars; offset
°5uis 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
°5unon-negative).
shiftL# :: Word# -> Int# -> Word#

-- | Shift the argument right by the specified number of bits (which must
°5ube non-negative). The <a>RL</a> means "right, logical" (as opposed to
°5uRA for arithmetic) (although an arithmetic right shift wouldn't make
°5usense for Word#)
shiftRL# :: Word# -> Int# -> Word#

-- | Shift the argument left by the specified number of bits (which must be
°5unon-negative).
iShiftL# :: Int# -> Int# -> Int#

-- | Shift the argument right (signed) by the specified number of bits
°5u(which must be non-negative). The <a>RA</a> means "right, arithmetic"
°5u(as opposed to RL for logical)
iShiftRA# :: Int# -> Int# -> Int#

-- | Shift the argument right (unsigned) by the specified number of bits
°5u(which must be non-negative). The <a>RL</a> means "right, logical" (as
°5uopposed 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
°5uFalse if it is 0#.
isTrue# :: Int# -> Bool

-- | A list producer that can be fused with <a>foldr</a>. This function is
°5umerely
°5u
°5u<pre>
°5ubuild g = g (:) []
°5u</pre>
°5u
°5ubut GHC's simplifier will transform an expression of the form
°5u<tt><a>foldr</a> k z (<a>build</a> g)</tt>, which may arise after
°5uinlining, to <tt>g k z</tt>, which avoids producing an intermediate
°5ulist.
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
°5umerely
°5u
°5u<pre>
°5uaugment g xs = g (:) xs
°5u</pre>
°5u
°5ubut GHC's simplifier will transform an expression of the form
°5u<tt><a>foldr</a> k z (<a>augment</a> g xs)</tt>, which may arise after
°5uinlining, to <tt>g k (<a>foldr</a> k z xs)</tt>, which avoids
°5uproducing 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
°5uextension (-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
°5ucall <tt>lazy e</tt> means the same as <tt>e</tt>, but <a>lazy</a> has
°5ua magical property so far as strictness analysis is concerned: it is
°5ulazy in its first argument, even though its semantics is strict. After
°5ustrictness analysis has run, calls to <a>lazy</a> are inlined to be
°5uthe identity function.
°5u
°5uThis behaviour is occasionally useful when controlling evaluation
°5uorder. Notably, <a>lazy</a> is used in the library definition of
°5u<a>par</a>:
°5u
°5u<pre>
°5upar :: a -&gt; b -&gt; b
°5upar x y = case (par# x) of _ -&gt; lazy y
°5u</pre>
°5u
°5uIf <a>lazy</a> were not lazy, <tt>par</tt> would look strict in
°5u<tt>y</tt> which would defeat the whole purpose of <tt>par</tt>.
°5u
°5uLike <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,
°5uregardless of its size. More precisely, the call <tt>inline f</tt>
°5urewrites to the right-hand side of <tt>f</tt>'s definition. This
°5uallows the programmer to control inlining from a particular call site
°5urather than the definition site of the function (c.f. <tt>INLINE</tt>
°5upragmas).
°5u
°5uThis inlining occurs regardless of the argument to the call or the
°5usize of <tt>f</tt>'s definition; it is unconditional. The main caveat
°5uis that <tt>f</tt>'s definition must be visible to the compiler; it is
°5utherefore recommended to mark the function with an <tt>INLINABLE</tt>
°5upragma at its definition so that GHC guarantees to record its
°5uunfolding regardless of size.
°5u
°5uIf no inlining takes place, the <a>inline</a> function expands to the
°5uidentity 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
°5uthat its argument will be called at most once, which may (or may not)
°5uenable certain optimizations. It can be useful to improve the
°5uperformance of code in continuation passing style.
°5u
°5uIf <a>oneShot</a> is used wrongly, then it may be that computations
°5uwhose result that would otherwise be shared are re-evaluated every
°5utime they are used. Otherwise, the use of <a>oneShot</a> is safe.
°5u
°5u<a>oneShot</a> is representation polymorphic: the type variables may
°5urefer to lifted or unlifted types.
oneShot :: () => a -> b -> a -> b

-- | Apply a function to a 'State# RealWorld' token. When manually applying
°5ua function to <tt>realWorld#</tt>, it is necessary to use
°5u<tt>NOINLINE</tt> to prevent semantically undesirable floating.
°5u<a>runRW#</a> is inlined, but only very late in compilation after all
°5ufloating is complete.
runRW# :: () => State# RealWorld -> a -> a

-- | The function <tt>coerce</tt> allows you to safely convert between
°5uvalues of types that have the same representation with no run-time
°5uoverhead. In the simplest case you can use it instead of a newtype
°5uconstructor, to go from the newtype's concrete type to the abstract
°5utype. But it also works in more complicated settings, e.g. converting
°5ua 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
°5utypes <tt>a</tt> and <tt>b</tt> if the compiler can infer that they
°5uhave the same representation. This class does not have regular
°5uinstances; instead they are created on-the-fly during type-checking.
°5uTrying to manually declare an instance of <tt>Coercible</tt> is an
°5uerror.
°5u
°5uNevertheless one can pretend that the following three kinds of
°5uinstances exist. First, as a trivial base-case:
°5u
°5u<pre>
°5uinstance Coercible a a
°5u</pre>
°5u
°5uFurthermore, for every type constructor there is an instance that
°5uallows to coerce under the type constructor. For example, let
°5u<tt>D</tt> be a prototypical type constructor (<tt>data</tt> or
°5u<tt>newtype</tt>) with three type arguments, which have roles
°5u<tt>nominal</tt>, <tt>representational</tt> resp. <tt>phantom</tt>.
°5uThen there is an instance of the form
°5u
°5u<pre>
°5uinstance Coercible b b' =&gt; Coercible (D a b c) (D a b' c')
°5u</pre>
°5u
°5uNote that the <tt>nominal</tt> type arguments are equal, the
°5u<tt>representational</tt> type arguments can differ, but need to have
°5ua <tt>Coercible</tt> instance themself, and the <tt>phantom</tt> type
°5uarguments can be changed arbitrarily.
°5u
°5uThe third kind of instance exists for every <tt>newtype NT = MkNT
°5uT</tt> and comes in two variants, namely
°5u
°5u<pre>
°5uinstance Coercible a T =&gt; Coercible a NT
°5u</pre>
°5u
°5u<pre>
°5uinstance Coercible T b =&gt; Coercible NT b
°5u</pre>
°5u
°5uThis instance is only usable if the constructor <tt>MkNT</tt> is in
°5uscope.
°5u
°5uIf, as a library author of a type constructor like <tt>Set a</tt>, you
°5uwant to prevent a user of your module to write <tt>coerce :: Set T
°5u-&gt; Set NT</tt>, you need to set the role of <tt>Set</tt>'s type
°5uparameter to <tt>nominal</tt>, by writing
°5u
°5u<pre>
°5utype role Set nominal
°5u</pre>
°5u
°5uFor more details about this feature, please refer to <a>Safe
°5uCoercions</a> by Joachim Breitner, Richard A. Eisenberg, Simon Peyton
°5uJones and Stephanie Weirich.
class a ~R# b => Coercible (a :: k0) (b :: k0)

-- | Lifted, heterogeneous equality. By lifted, we mean that it can be
°5ubogus (deferred type error). By heterogeneous, the two types
°5u<tt>a</tt> and <tt>b</tt> might have different kinds. Because
°5u<tt>~~</tt> can appear unexpectedly in error messages to users who do
°5unot care about the difference between heterogeneous equality
°5u<tt>~~</tt> and homogeneous equality <tt>~</tt>, this is printed as
°5u<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
°5udistinct from type constructors or type-level data) tells us the
°5uruntime representation of values of that type. This datatype encodes
°5uthe choice of runtime value. Note that <a>TYPE</a> is parameterised by
°5u<a>RuntimeRep</a>; this is precisely what we mean by the fact that a
°5utype's kind encodes the runtime representation.
°5u
°5uFor boxed values (that is, values that are represented by a pointer),
°5ua further distinction is made, between lifted types (that contain ⊥),
°5uand 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
°5uvalue of type <tt><a>Down</a> a</tt> contains a value of type
°5u<tt>a</tt> (represented as <tt><a>Down</a> a</tt>). If <tt>a</tt> has
°5uan <tt><a>Ord</a></tt> instance associated with it then comparing two
°5uvalues thus wrapped will give you the opposite of their normal sort
°5uorder. This is particularly useful when sorting in generalised list
°5ucomprehensions, 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
°5uprojects an element out of every list element in order to first sort
°5uthe input list and then to form groups by equality on these projected
°5uelements
groupWith :: Ord b => (a -> b) -> [a] -> [[a]]

-- | The <a>sortWith</a> function sorts a list of elements using the user
°5usupplied 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
°5uthen 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
°5ucan be useful for debugging.
°5u
°5uThe implementation uses the call-stack simulation maintained by the
°5uprofiler, so it only works if the program was compiled with
°5u<tt>-prof</tt> and contains suitable SCC annotations (e.g. by using
°5u<tt>-fprof-auto</tt>). Otherwise, the list returned is likely to be
°5uempty 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
°5ucoerce any lifted type, and back. More concretely, for a lifted type
°5u<tt>t</tt> and value <tt>x :: t</tt>, -- <tt>unsafeCoerce
°5u(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
°5uconjunction with the OverloadedLists extension.
class IsList l where {
    type family Item l;
}

-- | The <a>fromList</a> function constructs the structure <tt>l</tt> from
°5uthe 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.
°5uIts behaviour should be equivalent to <a>fromList</a>. The hint can be
°5uused to construct the structure <tt>l</tt> more efficiently compared
°5uto <a>fromList</a>. If the given hint does not equal to the input
°5ulist'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
°5ustructure <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.
°5u
°5uReferences to values are usually implemented with memory addresses,
°5uand this is practical when communicating values between the different
°5upieces of a single process.
°5u
°5uWhen values are communicated across different processes running in
°5upossibly different machines, though, addresses are no longer useful
°5usince each process may use different addresses to store a given value.
°5u
°5uTo solve such concern, the references provided by this module offer a
°5ukey that can be used to locate the values on each process. Each
°5uprocess maintains a global table of references which can be looked up
°5uwith a given key. This table is known as the Static Pointer Table. The
°5ureference can then be dereferenced to obtain the value.
°5u
°5uThe various communicating processes need to aggree on the keys used to
°5urefer to the values in the Static Pointer Table, or lookups will fail.
°5uOnly processes launched from the same program binary are guaranteed to
°5uuse 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
°5u<a>unsafeLookupStaticPtr</a>.
type StaticKey = Fingerprint

-- | The <a>StaticKey</a> that can be used to look up the given
°5u<a>StaticPtr</a>.
staticKey :: StaticPtr a -> StaticKey

-- | Looks up a <a>StaticPtr</a> by its <a>StaticKey</a>.
°5u
°5uIf the <a>StaticPtr</a> is not found returns <tt>Nothing</tt>.
°5u
°5uThis function is unsafe because the program behavior is undefined if
°5uthe type of the returned <a>StaticPtr</a> does not match the expected
°5uone.
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
°5u<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
°5uset together with an associative binary operation. A semigroup
°5ugeneralizes a monoid in that there might not exist an identity
°5uelement. It also (originally) generalized a group (a monoid with all
°5uinverses) to a type where every element did not have to have an
°5uinverse, thus the name semigroup.
°5u
°5uThe use of <tt>(&lt;&gt;)</tt> in this module conflicts with an
°5uoperator with the same name that is being exported by Data.Monoid.
°5uHowever, this package re-exports (most of) the contents of
°5uData.Monoid, so to use semigroups and monoids in the same package just
°5u
°5u<pre>
°5uimport Data.Semigroup
°5u</pre>
module Data.Semigroup

-- | The class of semigroups (types with an associative binary operation).
°5u
°5uInstances should satisfy the associativity law:
°5u
°5u<ul>
°5u<li><pre>x <a>&lt;&gt;</a> (y <a>&lt;&gt;</a> z) = (x <a>&lt;&gt;</a>
°5uy) <a>&lt;&gt;</a> z</pre></li>
°5u</ul>
class Semigroup a

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

-- | Reduce a non-empty list with <tt>&lt;&gt;</tt>
°5u
°5uThe default definition should be sufficient, but this can be
°5uoverridden for efficiency.
sconcat :: Semigroup a => NonEmpty a -> a

-- | Repeat a value <tt>n</tt> times.
°5u
°5uGiven that this works on a <a>Semigroup</a> it is allowed to fail if
°5uyou request 0 or fewer repetitions, and the default definition will do
°5uso.
°5u
°5uBy making this a member of the class, idempotent semigroups and
°5umonoids can upgrade this to execute in <i>O(1)</i> by picking
°5u<tt>stimes = <tt>stimesIdempotent</tt></tt> or <tt>stimes =
°5u<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>.
°5u
°5uUnlike the default definition of <a>stimes</a>, it is defined for 0
°5uand 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
°5u<a>Semigroup</a>.
°5u
°5uWhen <tt>x &lt;&gt; x = x</tt>, this definition should be preferred,
°5ubecause 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
°5u<a>Monoid</a>.
°5u
°5uWhen <tt>mappend x x = x</tt>, this definition should be preferred,
°5ubecause 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.
°5u
°5u<pre>
°5umtimesDefault n a = a &lt;&gt; a &lt;&gt; ... &lt;&gt; a  -- using &lt;&gt; (n-1) times
°5u</pre>
°5u
°5uImplemented using <a>stimes</a> and <a>mempty</a>.
°5u
°5uThis is a suitable definition for an <tt>mtimes</tt> member of
°5u<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
°5u<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
°5u<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.
°5u
°5u<b>NOTE</b>: This is not needed anymore since <a>Semigroup</a> became
°5ua superclass of <a>Monoid</a> in <i>base-4.11</i> and this newtype be
°5udeprecated 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
°5u<a>mappend</a>.
°5u
°5u<pre>
°5u&gt;&gt;&gt; getDual (mappend (Dual "Hello") (Dual "World"))
°5u"WorldHello"
°5u</pre>
newtype Dual a
Dual :: a -> Dual a
[getDual] :: Dual a -> a

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

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

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

-- | Monoid under addition.
°5u
°5u<pre>
°5u&gt;&gt;&gt; getSum (Sum 1 &lt;&gt; Sum 2 &lt;&gt; mempty)
°5u3
°5u</pre>
newtype Sum a
Sum :: a -> Sum a
[getSum] :: Sum a -> a

-- | Monoid under multiplication.
°5u
°5u<pre>
°5u&gt;&gt;&gt; getProduct (Product 3 &lt;&gt; Product 4 &lt;&gt; mempty)
°5u12
°5u</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
°5u<a>Monoid</a>, built off of an underlying <a>Semigroup</a> instead of
°5uan underlying <a>Monoid</a>.
°5u
°5uIdeally, this type would not exist at all and we would just fix the
°5u<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
°5u<a>Monoid</a>.
diff :: Semigroup m => m -> Endo m

-- | A generalization of <a>cycle</a> to an arbitrary <a>Semigroup</a>. May
°5ufail 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
°5ucan be placed inside <a>Min</a> and <a>Max</a> to compute an arg min
°5uor 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
°5ushould not exist.
module Data.Void

-- | Uninhabited data type
data Void

-- | Since <a>Void</a> values logically don't exist, this witnesses the
°5ulogical reasoning tool of "ex falso quodlibet".
°5u
°5u<pre>
°5u&gt;&gt;&gt; let x :: Either Void Int; x = Right 5
°5u
°5u&gt;&gt;&gt; :{
°5ucase x of
°5u    Right r -&gt; r
°5u    Left l  -&gt; absurd l
°5u:}
°5u5
°5u</pre>
absurd :: Void -> a

-- | If <a>Void</a> is uninhabited then any <a>Functor</a> that holds only
°5uvalues 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
°5ufunctors is always applicative, but the composition of monads is not
°5ualways 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
°5uparameter to Fixed is any type that's an instance of HasResolution.
°5uHasResolution has a single method that gives the resolution of the
°5uFixed type.
°5u
°5uThis module also contains generalisations of div, mod, and divmod to
°5uwork 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.
°5u
°5uFor a complex number <tt>z</tt>, <tt><a>abs</a> z</tt> is a number
°5uwith the magnitude of <tt>z</tt>, but oriented in the positive real
°5udirection, whereas <tt><a>signum</a> z</tt> has the phase of
°5u<tt>z</tt>, but unit magnitude.
°5u
°5uThe <a>Foldable</a> and <a>Traversable</a> instances traverse the real
°5upart first.
data Complex a

-- | forms a complex number from its real and imaginary rectangular
°5ucomponents.
(:+) :: !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
°5uphase <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
°5u(magnitude, phase) pair in canonical form: the magnitude is
°5unonnegative, and the phase in the range <tt>(-<a>pi</a>,
°5u<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>,
°5u<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
