snoyman.com-content/static/safe-prelude/SafePrelude.html

731 lines
2.9 MiB
HTML
Raw Normal View History

2017-01-11 17:07:16 +00:00
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>SafePrelude</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
window.onload = function () {pageLoad();setSynopsis("mini_SafePrelude.html");};
//]]>
</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="src/SafePrelude.html">Source</a></li><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">safe-prelude-0.1.0.0: A Haskell prelude optimized for safety</p></div><div id="content"><div id="module-header"><table class="info"><tr><th>Safe Haskell</th><td>None</td></tr><tr><th>Language</th><td>Haskell2010</td></tr></table><p class="caption">SafePrelude</p></div><div id="table-of-contents"><p class="caption">Contents</p><ul><li><a href="#g:1">Types</a><ul><li><a href="#g:2">Numbers</a></li></ul></li><li><a href="#g:3">Type classes</a><ul><li><a href="#g:4">Numeric</a></li></ul></li><li><a href="#g:5">Functions</a><ul><li><a href="#g:6">Numeric</a></li><li><a href="#g:7">Foldable</a></li><li><a href="#g:8">Traversable</a></li><li><a href="#g:9">Functor</a></li><li><a href="#g:10">Applicative</a></li><li><a href="#g:11">Alternative</a></li><li><a href="#g:12">Monad</a></li><li><a href="#g:13">Concurrent</a></li><li><a href="#g:14">Reader</a></li><li><a href="#g:15">Exceptions</a></li><li><a href="#g:16">Arrow</a></li><li><a href="#g:17">Maybe</a></li><li><a href="#g:18">Either</a></li><li><a href="#g:19">Ord</a></li><li><a href="#g:20">Say</a></li><li><a href="#g:21">IORef</a></li><li><a href="#g:22">IO</a></li><li><a href="#g:23">Character encoding</a></li><li><a href="#g:24">deepseq</a></li><li><a href="#g:25">Monoids</a></li><li><a href="#g:26">Read</a></li></ul></li></ul></div><div id="synopsis"><p id="control.syn" class="caption expander" onclick="toggleSection('syn')">Synopsis</p><ul id="section.syn" class="hide" onclick="toggleSection('syn')"><li class="src short"><span class="keyword">data</span> <a href="#t:Maybe">Maybe</a> a :: <a href="../base-4.9.0.0/Data-Kind.html#t:-42-">*</a> -&gt; <a href="../base-4.9.0.0/Data-Kind.html#t:-42-">*</a><ul class="subs"><li>= <a href="#v:Nothing">Nothing</a></li><li>| <a href="#v:Just">Just</a> a</li></ul></li><li class="src short"><span class="keyword">data</span> <a href="#t:Ordering">Ordering</a> :: <a href="../base-4.9.0.0/Data-Kind.html#t:-42-">*</a><ul class="subs"><li>= <a href="#v:LT">LT</a></li><li>| <a href="#v:EQ">EQ</a></li><li>| <a href="#v:GT">GT</a></li></ul></li><li class="src short"><span class="keyword">data</span> <a href="#t:Bool">Bool</a> :: <a href="../base-4.9.0.0/Data-Kind.html#t:-42-">*</a><ul class="subs"><li>= <a href="#v:False">False</a></li><li>| <a href="#v:True">True</a></li></ul></li><li class="src short"><span class="keyword">data</span> <a href="#t:Char">Char</a> :: <a href="../base-4.9.0.0/Data-Kind.html#t:-42-">*</a></li><li class="src short"><span class="keyword">data</span> <a href="#t:IO">IO</a> a :: <a href="../base-4.9.0.0/Data-Kind.html#t:-42-">*</a> -&gt; <a href="../base-4.9.0.0/Data-Kind.html#t:-42-">*</a></li><li class="src short"><span class="keyword">data</span> <a href="#t:Either">Either</a> a b :: <a href="../base-4.9.0.0/Data-Kind.html#t:-42-">*</a> -&gt; <a href="../base-4.9.0.0/Data-Kind.html#t:-42-">*</a> -&gt; <a href="../base-4.9.0.0/Data-Kind.html#t:-42-">*</a><ul class="subs"><li>= <a href="#v:Left">Left</a> a</li><li>| <a href="#v:Right">Right</a> b</li></ul></li><li class="src short"><span class="keyword">data</span> <a href="#t:ByteString">ByteString</a> :: <a href="../base-4.9.0.0/Data-Kind.html#t:-42-">*</a></li><li class="src short"><span class="keyword">data</span> <a href="#t:Text">Text</a> :: <a href="../base-4.9.0.0/Data-Kind.html#t:-42-">*</a></li><li class="src short"><span class="keyword">data</span> <a href="#t:Map">Map</a> k a :: <a href="../base-4.9.0.0/Data-Kind.html#t:-42-">*</a> -&gt; <a href="../base-4.9.0.0/Data-Kind.html#t:-42-">*</a> -&gt; <a href="../base-4.9.0.0/Data-Kind.html#t:-42-">*</a></li><li class="src short"><span class="keyword">data</span> <a href="#t:HashMap">HashMap</a> k v :: <a href="../base-4.9.0.0/Data-Kind.html#t:-42-">*</a> -&gt; <a href="../base-4.9.0.0/Data-Kind.html#t:-42-">*</a> -&gt; <a href="../base-4.9.0.0/Data-Kind.html#t:-42-">*
<code><code><a href="SafePrelude.html#t:Maybe">Maybe</a></code> a</code> either contains a value of type <code>a</code> (represented as <code><code><a href="SafePrelude.html#v:Just">Just</a></code> a</code>),
or it is empty (represented as <code><a href="SafePrelude.html#v:Nothing">Nothing</a></code>). Using <code><a href="SafePrelude.html#t:Maybe">Maybe</a></code> is a good way to
deal with errors or exceptional cases without resorting to drastic
measures such as <code><a href="../base-4.9.0.0/Prelude.html#v:error">error</a></code>.</p><p>The <code><a href="SafePrelude.html#t:Maybe">Maybe</a></code> type is also a monad. It is a simple kind of error
monad, where all errors are represented by <code><a href="SafePrelude.html#v:Nothing">Nothing</a></code>. A richer
error monad can be built using the <code><a href="../base-4.9.0.0/Data-Either.html#v:Either">Either</a></code> type.</p></div><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a id="v:Nothing" class="def">Nothing</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a id="v:Just" class="def">Just</a> a</td><td class="doc empty">&nbsp;</td></tr></table></div><div class="subs instances"><p id="control.i:Maybe" class="caption collapser" onclick="toggleSection('i:Maybe')">Instances</p><div id="section.i:Maybe" class="show"><table><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:Maybe:Monad:1" class="instance expander" onclick="toggleSection('i:id:Maybe:Monad:1')"></span> <a href="SafePrelude.html#t:Monad">Monad</a> <a href="SafePrelude.html#t:Maybe">Maybe</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:id:Maybe:Monad:1" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:-62--62--61-">(&gt;&gt;=)</a> :: <a href="SafePrelude.html#t:Maybe">Maybe</a> a -&gt; (a -&gt; <a href="SafePrelude.html#t:Maybe">Maybe</a> b) -&gt; <a href="SafePrelude.html#t:Maybe">Maybe</a> b <a href="#v:-62--62--61-" class="selflink">#</a></p><p class="src"><a href="#v:-62--62-">(&gt;&gt;)</a> :: <a href="SafePrelude.html#t:Maybe">Maybe</a> a -&gt; <a href="SafePrelude.html#t:Maybe">Maybe</a> b -&gt; <a href="SafePrelude.html#t:Maybe">Maybe</a> b <a href="#v:-62--62-" class="selflink">#</a></p><p class="src"><a href="#v:return">return</a> :: a -&gt; <a href="SafePrelude.html#t:Maybe">Maybe</a> a <a href="#v:return" class="selflink">#</a></p><p class="src"><a href="#v:fail">fail</a> :: <a href="SafePrelude.html#t:String">String</a> -&gt; <a href="SafePrelude.html#t:Maybe">Maybe</a> a <a href="#v:fail" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:Maybe:Functor:2" class="instance expander" onclick="toggleSection('i:id:Maybe:Functor:2')"></span> <a href="SafePrelude.html#t:Functor">Functor</a> <a href="SafePrelude.html#t:Maybe">Maybe</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:id:Maybe:Functor:2" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:fmap">fmap</a> :: (a -&gt; b) -&gt; <a href="SafePrelude.html#t:Maybe">Maybe</a> a -&gt; <a href="SafePrelude.html#t:Maybe">Maybe</a> b <a href="#v:fmap" class="selflink">#</a></p><p class="src"><a href="#v:-60--36-">(&lt;$)</a> :: a -&gt; <a href="SafePrelude.html#t:Maybe">Maybe</a> b -&gt; <a href="SafePrelude.html#t:Maybe">Maybe</a> a <a href="#v:-60--36-" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:Maybe:Applicative:3" class="instance expander" onclick="toggleSection('i:id:Maybe:Applicative:3')"></span> <a href="SafePrelude.html#t:Applicative">Applicative</a> <a href="SafePrelude.html#t:Maybe">Maybe</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:id:Maybe:Applicative:3" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:pure">pure</a> :: a -&gt; <a href="SafePrelude.html#t:Maybe">Maybe</a> a <a href="#v:pure" class="selflink">#</a></p><p class="src"><a href="#v:-60--42--62-">(&lt;*&gt;)</a> :: <a href="SafePrelude.html#t:Maybe">Maybe</a> (a -&gt; b) -&gt; <a href="SafePrelude.html#t:Maybe">Maybe</a> a -&gt; <a href="SafePrelude.html#t:Maybe">Maybe</a> b <a href="#v:-60--42--62-" class="selflink">#</a></p><p class="src"><a href="#v:-42--62-">(*&gt;)</a> :: <a href="SafePrelude.html#t:Maybe">Maybe</a> a -&gt; <a href="SafePrelude.html#t:Maybe">Maybe</a> b -&gt; <a href="SafePrelude.html#t:Maybe">Maybe</a> b <a href="#v:-42--62-" class="selflink">#</a></p><p class="src"><a href="#v:-60--42-">(&lt;*)</a> :: <a href="SafePrelude.html#t:Maybe">Maybe</a> a -&gt; <a href="Saf
<a href="http://en.wikipedia.org/wiki/Monoid">http://en.wikipedia.org/wiki/Monoid</a>: &quot;Any semigroup <code>S</code> may be
turned into a monoid simply by adjoining an element <code>e</code> not in <code>S</code>
and defining <code>e*e = e</code> and <code>e*s = s = s*e</code> for all <code>s &#8712; S</code>.&quot; Since
there is no &quot;Semigroup&quot; typeclass providing just <code><a href="SafePrelude.html#v:mappend">mappend</a></code>, we
use <code><a href="SafePrelude.html#t:Monoid">Monoid</a></code> instead.</p></td></tr><tr><td colspan="2"><div id="section.i:id:Maybe:Monoid:16" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:mempty">mempty</a> :: <a href="SafePrelude.html#t:Maybe">Maybe</a> a <a href="#v:mempty" class="selflink">#</a></p><p class="src"><a href="#v:mappend">mappend</a> :: <a href="SafePrelude.html#t:Maybe">Maybe</a> a -&gt; <a href="SafePrelude.html#t:Maybe">Maybe</a> a -&gt; <a href="SafePrelude.html#t:Maybe">Maybe</a> a <a href="#v:mappend" class="selflink">#</a></p><p class="src"><a href="#v:mconcat">mconcat</a> :: [<a href="SafePrelude.html#t:Maybe">Maybe</a> a] -&gt; <a href="SafePrelude.html#t:Maybe">Maybe</a> a <a href="#v:mconcat" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:Maybe:Lift:17" class="instance expander" onclick="toggleSection('i:id:Maybe:Lift:17')"></span> <a href="../template-haskell-2.11.0.0/Language-Haskell-TH-Syntax.html#t:Lift">Lift</a> a =&gt; <a href="../template-haskell-2.11.0.0/Language-Haskell-TH-Syntax.html#t:Lift">Lift</a> (<a href="SafePrelude.html#t:Maybe">Maybe</a> a)</span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:id:Maybe:Lift:17" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:lift">lift</a> :: <a href="SafePrelude.html#t:Maybe">Maybe</a> a -&gt; <a href="../template-haskell-2.11.0.0/Language-Haskell-TH-Syntax.html#t:Q">Q</a> <a href="../template-haskell-2.11.0.0/Language-Haskell-TH-Syntax.html#t:Exp">Exp</a> <a href="#v:lift" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:Maybe:NFData:18" class="instance expander" onclick="toggleSection('i:id:Maybe:NFData:18')"></span> <a href="SafePrelude.html#t:NFData">NFData</a> a =&gt; <a href="SafePrelude.html#t:NFData">NFData</a> (<a href="SafePrelude.html#t:Maybe">Maybe</a> a)</span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:id:Maybe:NFData:18" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:rnf">rnf</a> :: <a href="SafePrelude.html#t:Maybe">Maybe</a> a -&gt; () <a href="#v:rnf" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:Maybe:Hashable:19" class="instance expander" onclick="toggleSection('i:id:Maybe:Hashable:19')"></span> <a href="SafePrelude.html#t:Hashable">Hashable</a> a =&gt; <a href="SafePrelude.html#t:Hashable">Hashable</a> (<a href="SafePrelude.html#t:Maybe">Maybe</a> a)</span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:id:Maybe:Hashable:19" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:hashWithSalt">hashWithSalt</a> :: <a href="SafePrelude.html#t:Int">Int</a> -&gt; <a href="SafePrelude.html#t:Maybe">Maybe</a> a -&gt; <a href="SafePrelude.html#t:Int">Int</a> <a href="#v:hashWithSalt" class="selflink">#</a></p><p class="src"><a href="#v:hash">hash</a> :: <a href="SafePrelude.html#t:Maybe">Maybe</a> a -&gt; <a href="SafePrelude.html#t:Int">Int</a> <a href="#v:hash" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:Maybe:SingI:20" class="instance expander" onclick="toggleSection('i:id:Maybe:SingI:20')"></span> SingI (<a href="SafePrelude.html#t:Maybe">Maybe</a> a) (<a href="SafePrelude.html#v:Nothing">Nothing</a> a)</span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:id:Maybe:SingI:20" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:sing">sing</a> :: Sing (<a href="SafePrelude.html#v:Nothing">Nothing</a> a) a</p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="
Unicode (or equivalently ISO/IEC 10646) characters (see
<a href="http://www.unicode.org/">http://www.unicode.org/</a> for details). This set extends the ISO 8859-1
(Latin-1) character set (the first 256 characters), which is itself an extension
of the ASCII character set (the first 128 characters). A character literal in
Haskell has type <code><a href="SafePrelude.html#t:Char">Char</a></code>.</p><p>To convert a <code><a href="SafePrelude.html#t:Char">Char</a></code> to or from the corresponding <code><a href="SafePrelude.html#t:Int">Int</a></code> value defined
by Unicode, use <code><a href="../base-4.9.0.0/Prelude.html#v:toEnum">toEnum</a></code> and <code><a href="../base-4.9.0.0/Prelude.html#v:fromEnum">fromEnum</a></code> from the
<code><a href="../base-4.9.0.0/Prelude.html#v:Enum">Enum</a></code> class respectively (or equivalently <code>ord</code> and <code>chr</code>).</p></div><div class="subs instances"><p id="control.i:Char" class="caption collapser" onclick="toggleSection('i:Char')">Instances</p><div id="section.i:Char" class="show"><table><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:Char:Bounded:1" class="instance expander" onclick="toggleSection('i:id:Char:Bounded:1')"></span> <a href="SafePrelude.html#t:Bounded">Bounded</a> <a href="SafePrelude.html#t:Char">Char</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:id:Char:Bounded:1" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:minBound">minBound</a> :: <a href="SafePrelude.html#t:Char">Char</a> <a href="#v:minBound" class="selflink">#</a></p><p class="src"><a href="#v:maxBound">maxBound</a> :: <a href="SafePrelude.html#t:Char">Char</a> <a href="#v:maxBound" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:Char:Enum:2" class="instance expander" onclick="toggleSection('i:id:Char:Enum:2')"></span> <a href="../base-4.9.0.0/Prelude.html#t:Enum">Enum</a> <a href="SafePrelude.html#t:Char">Char</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:id:Char:Enum:2" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:succ">succ</a> :: <a href="SafePrelude.html#t:Char">Char</a> -&gt; <a href="SafePrelude.html#t:Char">Char</a> <a href="#v:succ" class="selflink">#</a></p><p class="src"><a href="#v:pred">pred</a> :: <a href="SafePrelude.html#t:Char">Char</a> -&gt; <a href="SafePrelude.html#t:Char">Char</a> <a href="#v:pred" class="selflink">#</a></p><p class="src"><a href="#v:toEnum">toEnum</a> :: <a href="SafePrelude.html#t:Int">Int</a> -&gt; <a href="SafePrelude.html#t:Char">Char</a> <a href="#v:toEnum" class="selflink">#</a></p><p class="src"><a href="#v:fromEnum">fromEnum</a> :: <a href="SafePrelude.html#t:Char">Char</a> -&gt; <a href="SafePrelude.html#t:Int">Int</a> <a href="#v:fromEnum" class="selflink">#</a></p><p class="src"><a href="#v:enumFrom">enumFrom</a> :: <a href="SafePrelude.html#t:Char">Char</a> -&gt; [<a href="SafePrelude.html#t:Char">Char</a>] <a href="#v:enumFrom" class="selflink">#</a></p><p class="src"><a href="#v:enumFromThen">enumFromThen</a> :: <a href="SafePrelude.html#t:Char">Char</a> -&gt; <a href="SafePrelude.html#t:Char">Char</a> -&gt; [<a href="SafePrelude.html#t:Char">Char</a>] <a href="#v:enumFromThen" class="selflink">#</a></p><p class="src"><a href="#v:enumFromTo">enumFromTo</a> :: <a href="SafePrelude.html#t:Char">Char</a> -&gt; <a href="SafePrelude.html#t:Char">Char</a> -&gt; [<a href="SafePrelude.html#t:Char">Char</a>] <a href="#v:enumFromTo" class="selflink">#</a></p><p class="src"><a href="#v:enumFromThenTo">enumFromThenTo</a> :: <a href="SafePrelude.html#t:Char">Char</a> -&gt; <a href="SafePrelude.html#t:Char">Char</a> -&gt; <a href="SafePrelude.html#t:Char">Char</a> -&gt; [<a href="SafePrelude.html#t:Char">Char</a>] <a href="#v:enumFromThenTo" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:Char:Eq:3" class="instance expander" onclick="toggleSection('i:id:Char:Eq:3')"></span> <a href="SafePrelude.html#t:Eq">Eq</a> <a href="SafePrelude.html#t:Char">Char</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:id:Char:Eq:3" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:-61--61-">(==)</a> :: <a href="SafePrelude.html#t:Char">Char</a> -&gt; <a href="SafePrelude.html#t:Char">Char</a> -&gt; <a href="SafePrelude.html#t:Bool">Bool</a> <a href="#v:-61--61-" class="selflink">#</a></p><p class="src"><a href="#v:-47--61-">(/=)</a> :: <a href="SafePrelude.html#t:Char">Char</a> -&gt; <a href="SafePrelude.
does some I/O before returning a value of type <code>a</code>.</p><p>There is really only one way to &quot;perform&quot; an I/O action: bind it to
<code>Main.main</code> in your program. When your program is run, the I/O will
be performed. It isn't possible to perform I/O from an arbitrary
function, unless that function is itself in the <code><a href="SafePrelude.html#t:IO">IO</a></code> monad and called
at some point, directly or indirectly, from <code>Main.main</code>.</p><p><code><a href="SafePrelude.html#t:IO">IO</a></code> is a monad, so <code><a href="SafePrelude.html#t:IO">IO</a></code> actions can be combined using either the do-notation
or the <code>&gt;&gt;</code> and <code>&gt;&gt;=</code> operations from the <code>Monad</code> class.</p></div><div class="subs instances"><p id="control.i:IO" class="caption collapser" onclick="toggleSection('i:IO')">Instances</p><div id="section.i:IO" class="show"><table><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:IO:Monad:1" class="instance expander" onclick="toggleSection('i:id:IO:Monad:1')"></span> <a href="SafePrelude.html#t:Monad">Monad</a> <a href="SafePrelude.html#t:IO">IO</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:id:IO:Monad:1" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:-62--62--61-">(&gt;&gt;=)</a> :: <a href="SafePrelude.html#t:IO">IO</a> a -&gt; (a -&gt; <a href="SafePrelude.html#t:IO">IO</a> b) -&gt; <a href="SafePrelude.html#t:IO">IO</a> b <a href="#v:-62--62--61-" class="selflink">#</a></p><p class="src"><a href="#v:-62--62-">(&gt;&gt;)</a> :: <a href="SafePrelude.html#t:IO">IO</a> a -&gt; <a href="SafePrelude.html#t:IO">IO</a> b -&gt; <a href="SafePrelude.html#t:IO">IO</a> b <a href="#v:-62--62-" class="selflink">#</a></p><p class="src"><a href="#v:return">return</a> :: a -&gt; <a href="SafePrelude.html#t:IO">IO</a> a <a href="#v:return" class="selflink">#</a></p><p class="src"><a href="#v:fail">fail</a> :: <a href="SafePrelude.html#t:String">String</a> -&gt; <a href="SafePrelude.html#t:IO">IO</a> a <a href="#v:fail" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:IO:Functor:2" class="instance expander" onclick="toggleSection('i:id:IO:Functor:2')"></span> <a href="SafePrelude.html#t:Functor">Functor</a> <a href="SafePrelude.html#t:IO">IO</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:id:IO:Functor:2" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:fmap">fmap</a> :: (a -&gt; b) -&gt; <a href="SafePrelude.html#t:IO">IO</a> a -&gt; <a href="SafePrelude.html#t:IO">IO</a> b <a href="#v:fmap" class="selflink">#</a></p><p class="src"><a href="#v:-60--36-">(&lt;$)</a> :: a -&gt; <a href="SafePrelude.html#t:IO">IO</a> b -&gt; <a href="SafePrelude.html#t:IO">IO</a> a <a href="#v:-60--36-" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:IO:Applicative:3" class="instance expander" onclick="toggleSection('i:id:IO:Applicative:3')"></span> <a href="SafePrelude.html#t:Applicative">Applicative</a> <a href="SafePrelude.html#t:IO">IO</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:id:IO:Applicative:3" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:pure">pure</a> :: a -&gt; <a href="SafePrelude.html#t:IO">IO</a> a <a href="#v:pure" class="selflink">#</a></p><p class="src"><a href="#v:-60--42--62-">(&lt;*&gt;)</a> :: <a href="SafePrelude.html#t:IO">IO</a> (a -&gt; b) -&gt; <a href="SafePrelude.html#t:IO">IO</a> a -&gt; <a href="SafePrelude.html#t:IO">IO</a> b <a href="#v:-60--42--62-" class="selflink">#</a></p><p class="src"><a href="#v:-42--62-">(*&gt;)</a> :: <a href="SafePrelude.html#t:IO">IO</a> a -&gt; <a href="SafePrelude.html#t:IO">IO</a> b -&gt; <a href="SafePrelude.html#t:IO">IO</a> b <a href="#v:-42--62-" class="selflink">#</a></p><p class="src"><a href="#v:-60--42-">(&lt;*)</a> :: <a href="SafePrelude.html#t:IO">IO</a> a -&gt; <a href="SafePrelude.html#t:IO">IO</a> b -&gt; <a href="SafePrelude.html#t:IO">IO</a> a <a href="#v:-60--42-" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:IO:MonadIO:4" class="instance expander" onclick="toggleSection('i:id:IO:MonadIO:4')"></span> <a href="SafePrelude.html#t:MonadIO">MonadIO</a> <a href="SafePrelude.html#t:IO">IO</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="
type <code><code><a href="SafePrelude.html#t:Either">Either</a></code> a b</code> is either <code><code><a href="SafePrelude.html#v:Left">Left</a></code> a</code> or <code><code><a href="SafePrelude.html#v:Right">Right</a></code> b</code>.</p><p>The <code><a href="SafePrelude.html#t:Either">Either</a></code> type is sometimes used to represent a value which is
either correct or an error; by convention, the <code><a href="SafePrelude.html#v:Left">Left</a></code> constructor is
used to hold an error value and the <code><a href="SafePrelude.html#v:Right">Right</a></code> constructor is used to
hold a correct value (mnemonic: &quot;right&quot; also means &quot;correct&quot;).</p><h4 id="control.ch:noid:0" class="caption expander" onclick="toggleSection('ch:noid:0')">Examples</h4><div id="section.ch:noid:0" class="hide"><p>The type <code><code><a href="SafePrelude.html#t:Either">Either</a></code> <code><a href="SafePrelude.html#t:String">String</a></code> <code><a href="SafePrelude.html#t:Int">Int</a></code></code> is the type of values which can be either
a <code><a href="SafePrelude.html#t:String">String</a></code> or an <code><a href="SafePrelude.html#t:Int">Int</a></code>. The <code><a href="SafePrelude.html#v:Left">Left</a></code> constructor can be used only on
<code><a href="SafePrelude.html#t:String">String</a></code>s, and the <code><a href="SafePrelude.html#v:Right">Right</a></code> constructor can be used only on <code><a href="SafePrelude.html#t:Int">Int</a></code>s:</p><pre class="screen"><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>let s = Left &quot;foo&quot; :: Either String Int
</code></strong><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>s
</code></strong>Left &quot;foo&quot;
<code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>let n = Right 3 :: Either String Int
</code></strong><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>n
</code></strong>Right 3
<code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>:type s
</code></strong>s :: Either String Int
<code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>:type n
</code></strong>n :: Either String Int
</pre><p>The <code><a href="SafePrelude.html#v:fmap">fmap</a></code> from our <code><a href="SafePrelude.html#t:Functor">Functor</a></code> instance will ignore <code><a href="SafePrelude.html#v:Left">Left</a></code> values, but
will apply the supplied function to values contained in a <code><a href="SafePrelude.html#v:Right">Right</a></code>:</p><pre class="screen"><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>let s = Left &quot;foo&quot; :: Either String Int
</code></strong><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>let n = Right 3 :: Either String Int
</code></strong><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>fmap (*2) s
</code></strong>Left &quot;foo&quot;
<code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>fmap (*2) n
</code></strong>Right 6
</pre><p>The <code><a href="SafePrelude.html#t:Monad">Monad</a></code> instance for <code><a href="SafePrelude.html#t:Either">Either</a></code> allows us to chain together multiple
actions which may fail, and fail overall if any of the individual
steps failed. First we'll write a function that can either parse an
<code><a href="SafePrelude.html#t:Int">Int</a></code> from a <code><a href="SafePrelude.html#t:Char">Char</a></code>, or fail.</p><pre class="screen"><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>import Data.Char ( digitToInt, isDigit )
</code></strong><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>:{
</code></strong> let parseEither :: Char -&gt; Either String Int
parseEither c
| isDigit c = Right (digitToInt c)
| otherwise = Left &quot;parse error&quot;
<code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>:}
</code></strong></pre><p>The following should work, since both <code>'1'</code> and <code>'2'</code> can be
parsed as <code><a href="SafePrelude.html#t:Int">Int</a></code>s.</p><pre class="screen"><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>:{
</code></strong> let parseMultiple :: Either String Int
parseMultiple = do
x &lt;- parseEither '1'
y &lt;- parseEither '2'
return (x + y)
<code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>:}
</code></strong></pre><pre class="screen"><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>parseMultiple
</code></strong>Right 3
</pre><p>But the following should fail overall, since the first operation where
we attempt to parse <code>'m'</code> as an <code><a href="SafePrelude.html#t:Int">Int</a></code> will fail:</p><pre class="screen"><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>:{
</code></strong> let parseMultiple :: Either String Int
parseMultiple = do
x &lt;- parseEither 'm'
y &lt;- parseEither '2'
return (x + y)
<code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>:}
</code></strong></pre><pre class="screen"><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>parseMultiple
</code></strong>Left &quot;parse error&quot;
</pre></div></div><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a id="v:Left" class="def">Left</a> a</td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a id="v:Right" class="def">Right</a> b</td><td class="doc empty">&nbsp;</td></tr></table></div><div class="subs instances"><p id="control.i:Either" class="caption collapser" onclick="toggleSection('i:Either')">Instances</p><div id="section.i:Either" class="show"><table><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:Either:Monad:1" class="instance expander" onclick="toggleSection('i:id:Either:Monad:1')"></span> <a href="SafePrelude.html#t:Monad">Monad</a> (<a href="SafePrelude.html#t:Either">Either</a> e)</span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:id:Either:Monad:1" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:-62--62--61-">(&gt;&gt;=)</a> :: <a href="SafePrelude.html#t:Either">Either</a> e a -&gt; (a -&gt; <a href="SafePrelude.html#t:Either">Either</a> e b) -&gt; <a href="SafePrelude.html#t:Either">Either</a> e b <a href="#v:-62--62--61-" class="selflink">#</a></p><p class="src"><a href="#v:-62--62-">(&gt;&gt;)</a> :: <a href="SafePrelude.html#t:Either">Either</a> e a -&gt; <a href="SafePrelude.html#t:Either">Either</a> e b -&gt; <a href="SafePrelude.html#t:Either">Either</a> e b <a href="#v:-62--62-" class="selflink">#</a></p><p class="src"><a href="#v:return">return</a> :: a -&gt; <a href="SafePrelude.html#t:Either">Either</a> e a <a href="#v:return" class="selflink">#</a></p><p class="src"><a href="#v:fail">fail</a> :: <a href="SafePrelude.html#t:String">String</a> -&gt; <a href="SafePrelude.html#t:Either">Either</a> e a <a href="#v:fail" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:Either:Functor:2" class="instance expander" onclick="toggleSection('i:id:Either:Functor:2')"></span> <a href="SafePrelude.html#t:Functor">Functor</a> (<a href="SafePrelude.html#t:Either">Either</a> a)</span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:id:Either:Functor:2" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:fmap">fmap</a> :: (a -&gt; b) -&gt; <a href="SafePrelude.html#t:Either">Either</a> a a -&gt; <a href="SafePrelude.html#t:Either">Either</a> a b <a href="#v:fmap" class="selflink">#</a></p><p class="src"><a href="#v:-60--36-">(&lt;$)</a> :: a -&gt; <a href="SafePrelude.html#t:Either">Either</a> a b -&gt; <a href="SafePrelude.html#t:Either">Either</a> a a <a href="#v:-60--36-" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:Either:Applicative:3" class="instance expander" onclick="toggleSection('i:id:Either:Applicative:3')"></span> <a href="SafePrelude.html#t:Applicative">Applicative</a> (<a href="SafePrelude.html#t:Either">Either</a> e)</span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:id:Either:Applicative:3" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:pure">pure</a> :: a -&gt; <a href="SafePrelude.html#t:Either">Either</a> e a <a href="#v:pure" class="selflink">#</a></p><p class="src"><a href="#v:-60--42--62-">(&lt;*&gt;)</a> :: <a href="SafePrelude.html#t:Either">Either</a> e (a -&gt; b) -&gt; <a href="SafePrelude.html#t:Either">Either</a> e a -&gt; <a href="SafePrelude.html#t:Either">Either</a> e b <a href="#v:-60--42--62-" class="selflink">#</a></p><p class="src"><a href="#v:-42--62-">(*&gt;)</a> :: <a href="SafePrelude.html#t:Either">Either</a> e a -&gt; <a href="SafePrelude.html#t:Either">Either</a> e b -&gt; <a href="SafePrelude.html#t:Either">Either</a> e b <a href="#v:-42--62-" class="selflink">#</a></p><p class="src"><a href="#v:-60--42-">(&lt;*)</a> :: <a href="SafePrelude.html#t:Either">Either</a> e a -&gt; <a href="Safe
efficient operations.</p><p>A <code><a href="SafePrelude.html#t:ByteString">ByteString</a></code> contains 8-bit bytes, or by using the operations from
<a href="../bytestring-0.10.8.1/Data-ByteString-Char8.html">Data.ByteString.Char8</a> it can be interpreted as containing 8-bit
characters.</p></div><div class="subs instances"><p id="control.i:ByteString" class="caption collapser" onclick="toggleSection('i:ByteString')">Instances</p><div id="section.i:ByteString" class="show"><table><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:ByteString:Eq:1" class="instance expander" onclick="toggleSection('i:id:ByteString:Eq:1')"></span> <a href="SafePrelude.html#t:Eq">Eq</a> <a href="SafePrelude.html#t:ByteString">ByteString</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:id:ByteString:Eq:1" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:-61--61-">(==)</a> :: <a href="SafePrelude.html#t:ByteString">ByteString</a> -&gt; <a href="SafePrelude.html#t:ByteString">ByteString</a> -&gt; <a href="SafePrelude.html#t:Bool">Bool</a> <a href="#v:-61--61-" class="selflink">#</a></p><p class="src"><a href="#v:-47--61-">(/=)</a> :: <a href="SafePrelude.html#t:ByteString">ByteString</a> -&gt; <a href="SafePrelude.html#t:ByteString">ByteString</a> -&gt; <a href="SafePrelude.html#t:Bool">Bool</a> <a href="#v:-47--61-" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:ByteString:Data:2" class="instance expander" onclick="toggleSection('i:id:ByteString:Data:2')"></span> <a href="../base-4.9.0.0/Data-Data.html#t:Data">Data</a> <a href="SafePrelude.html#t:ByteString">ByteString</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:id:ByteString:Data:2" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:gfoldl">gfoldl</a> :: (<span class="keyword">forall</span> d b. <a href="../base-4.9.0.0/Data-Data.html#t:Data">Data</a> d =&gt; c (d -&gt; b) -&gt; d -&gt; c b) -&gt; (<span class="keyword">forall</span> g. g -&gt; c g) -&gt; <a href="SafePrelude.html#t:ByteString">ByteString</a> -&gt; c <a href="SafePrelude.html#t:ByteString">ByteString</a> <a href="#v:gfoldl" class="selflink">#</a></p><p class="src"><a href="#v:gunfold">gunfold</a> :: (<span class="keyword">forall</span> b r. <a href="../base-4.9.0.0/Data-Data.html#t:Data">Data</a> b =&gt; c (b -&gt; r) -&gt; c r) -&gt; (<span class="keyword">forall</span> r. r -&gt; c r) -&gt; <a href="../base-4.9.0.0/Data-Data.html#t:Constr">Constr</a> -&gt; c <a href="SafePrelude.html#t:ByteString">ByteString</a> <a href="#v:gunfold" class="selflink">#</a></p><p class="src"><a href="#v:toConstr">toConstr</a> :: <a href="SafePrelude.html#t:ByteString">ByteString</a> -&gt; <a href="../base-4.9.0.0/Data-Data.html#t:Constr">Constr</a> <a href="#v:toConstr" class="selflink">#</a></p><p class="src"><a href="#v:dataTypeOf">dataTypeOf</a> :: <a href="SafePrelude.html#t:ByteString">ByteString</a> -&gt; <a href="../base-4.9.0.0/Data-Data.html#t:DataType">DataType</a> <a href="#v:dataTypeOf" class="selflink">#</a></p><p class="src"><a href="#v:dataCast1">dataCast1</a> :: <a href="SafePrelude.html#t:Typeable">Typeable</a> (<a href="../base-4.9.0.0/Data-Kind.html#t:-42-">*</a> -&gt; <a href="../base-4.9.0.0/Data-Kind.html#t:-42-">*</a>) t =&gt; (<span class="keyword">forall</span> d. <a href="../base-4.9.0.0/Data-Data.html#t:Data">Data</a> d =&gt; c (t d)) -&gt; <a href="SafePrelude.html#t:Maybe">Maybe</a> (c <a href="SafePrelude.html#t:ByteString">ByteString</a>) <a href="#v:dataCast1" class="selflink">#</a></p><p class="src"><a href="#v:dataCast2">dataCast2</a> :: <a href="SafePrelude.html#t:Typeable">Typeable</a> (<a href="../base-4.9.0.0/Data-Kind.html#t:-42-">*</a> -&gt; <a href="../base-4.9.0.0/Data-Kind.html#t:-42-">*</a> -&gt; <a href="../base-4.9.0.0/Data-Kind.html#t:-42-">*</a>) t =&gt; (<span class="keyword">forall</span> d e. (<a href="../base-4.9.0.0/Data-Data.html#t:Data">Data</a> d, <a href="../base-4.9.0.0/Data-Data.html#t:Data">Data</a> e) =&gt; c (t d e)) -&gt; <a href="SafePrelude.html#t:Maybe">Maybe</a> (c <a href="SafePrelude.html#t:ByteString">ByteString</a>) <a href="#v:dataCast2"
each key can map to at most one value.</p></div><div class="subs instances"><p id="control.i:HashMap" class="caption collapser" onclick="toggleSection('i:HashMap')">Instances</p><div id="section.i:HashMap" class="show"><table><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:HashMap:Functor:1" class="instance expander" onclick="toggleSection('i:id:HashMap:Functor:1')"></span> <a href="SafePrelude.html#t:Functor">Functor</a> (<a href="SafePrelude.html#t:HashMap">HashMap</a> k)</span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:id:HashMap:Functor:1" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:fmap">fmap</a> :: (a -&gt; b) -&gt; <a href="SafePrelude.html#t:HashMap">HashMap</a> k a -&gt; <a href="SafePrelude.html#t:HashMap">HashMap</a> k b <a href="#v:fmap" class="selflink">#</a></p><p class="src"><a href="#v:-60--36-">(&lt;$)</a> :: a -&gt; <a href="SafePrelude.html#t:HashMap">HashMap</a> k b -&gt; <a href="SafePrelude.html#t:HashMap">HashMap</a> k a <a href="#v:-60--36-" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:HashMap:Foldable:2" class="instance expander" onclick="toggleSection('i:id:HashMap:Foldable:2')"></span> <a href="SafePrelude.html#t:Foldable">Foldable</a> (<a href="SafePrelude.html#t:HashMap">HashMap</a> k)</span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:id:HashMap:Foldable:2" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:fold">fold</a> :: <a href="SafePrelude.html#t:Monoid">Monoid</a> m =&gt; <a href="SafePrelude.html#t:HashMap">HashMap</a> k m -&gt; m <a href="#v:fold" class="selflink">#</a></p><p class="src"><a href="#v:foldMap">foldMap</a> :: <a href="SafePrelude.html#t:Monoid">Monoid</a> m =&gt; (a -&gt; m) -&gt; <a href="SafePrelude.html#t:HashMap">HashMap</a> k a -&gt; m <a href="#v:foldMap" class="selflink">#</a></p><p class="src"><a href="#v:foldr">foldr</a> :: (a -&gt; b -&gt; b) -&gt; b -&gt; <a href="SafePrelude.html#t:HashMap">HashMap</a> k a -&gt; b <a href="#v:foldr" class="selflink">#</a></p><p class="src"><a href="#v:foldr-39-">foldr'</a> :: (a -&gt; b -&gt; b) -&gt; b -&gt; <a href="SafePrelude.html#t:HashMap">HashMap</a> k a -&gt; b <a href="#v:foldr-39-" class="selflink">#</a></p><p class="src"><a href="#v:foldl">foldl</a> :: (b -&gt; a -&gt; b) -&gt; b -&gt; <a href="SafePrelude.html#t:HashMap">HashMap</a> k a -&gt; b <a href="#v:foldl" class="selflink">#</a></p><p class="src"><a href="#v:foldl-39-">foldl'</a> :: (b -&gt; a -&gt; b) -&gt; b -&gt; <a href="SafePrelude.html#t:HashMap">HashMap</a> k a -&gt; b <a href="#v:foldl-39-" class="selflink">#</a></p><p class="src"><a href="#v:foldr1">foldr1</a> :: (a -&gt; a -&gt; a) -&gt; <a href="SafePrelude.html#t:HashMap">HashMap</a> k a -&gt; a <a href="#v:foldr1" class="selflink">#</a></p><p class="src"><a href="#v:foldl1">foldl1</a> :: (a -&gt; a -&gt; a) -&gt; <a href="SafePrelude.html#t:HashMap">HashMap</a> k a -&gt; a <a href="#v:foldl1" class="selflink">#</a></p><p class="src"><a href="#v:toList">toList</a> :: <a href="SafePrelude.html#t:HashMap">HashMap</a> k a -&gt; [a] <a href="#v:toList" class="selflink">#</a></p><p class="src"><a href="#v:null">null</a> :: <a href="SafePrelude.html#t:HashMap">HashMap</a> k a -&gt; <a href="SafePrelude.html#t:Bool">Bool</a> <a href="#v:null" class="selflink">#</a></p><p class="src"><a href="#v:length">length</a> :: <a href="SafePrelude.html#t:HashMap">HashMap</a> k a -&gt; <a href="SafePrelude.html#t:Int">Int</a> <a href="#v:length" class="selflink">#</a></p><p class="src"><a href="#v:elem">elem</a> :: <a href="SafePrelude.html#t:Eq">Eq</a> a =&gt; a -&gt; <a href="SafePrelude.html#t:HashMap">HashMap</a> k a -&gt; <a href="SafePrelude.html#t:Bool">Bool</a> <a href="#v:elem" class="selflink">#</a></p><p class="src"><a href="#v:maximum">maximum</a> :: <a href="SafePrelude.html#t:Ord">Ord</a> a =&gt;
<code><a href="SafePrelude.html#t:Identity">Identity</a></code> newtype if the <code><a href="SafePrelude.html#v:runIdentity">runIdentity</a></code> field were removed</p></td></tr><tr><td colspan="2"><div id="section.i:id:Identity:Read:18" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:readsPrec">readsPrec</a> :: <a href="SafePrelude.html#t:Int">Int</a> -&gt; <a href="../base-4.9.0.0/Text-ParserCombinators-ReadP.html#t:ReadS">ReadS</a> (<a href="SafePrelude.html#t:Identity">Identity</a> a) <a href="#v:readsPrec" class="selflink">#</a></p><p class="src"><a href="#v:readList">readList</a> :: <a href="../base-4.9.0.0/Text-ParserCombinators-ReadP.html#t:ReadS">ReadS</a> [<a href="SafePrelude.html#t:Identity">Identity</a> a] <a href="#v:readList" class="selflink">#</a></p><p class="src"><a href="#v:readPrec">readPrec</a> :: <a href="../base-4.9.0.0/Text-ParserCombinators-ReadPrec.html#t:ReadPrec">ReadPrec</a> (<a href="SafePrelude.html#t:Identity">Identity</a> a) <a href="#v:readPrec" class="selflink">#</a></p><p class="src"><a href="#v:readListPrec">readListPrec</a> :: <a href="../base-4.9.0.0/Text-ParserCombinators-ReadPrec.html#t:ReadPrec">ReadPrec</a> [<a href="SafePrelude.html#t:Identity">Identity</a> a] <a href="#v:readListPrec" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:Identity:Real:19" class="instance expander" onclick="toggleSection('i:id:Identity:Real:19')"></span> <a href="SafePrelude.html#t:Real">Real</a> a =&gt; <a href="SafePrelude.html#t:Real">Real</a> (<a href="SafePrelude.html#t:Identity">Identity</a> a)</span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:id:Identity:Real:19" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:toRational">toRational</a> :: <a href="SafePrelude.html#t:Identity">Identity</a> a -&gt; <a href="SafePrelude.html#t:Rational">Rational</a> <a href="#v:toRational" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:Identity:RealFloat:20" class="instance expander" onclick="toggleSection('i:id:Identity:RealFloat:20')"></span> <a href="SafePrelude.html#t:RealFloat">RealFloat</a> a =&gt; <a href="SafePrelude.html#t:RealFloat">RealFloat</a> (<a href="SafePrelude.html#t:Identity">Identity</a> a)</span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:id:Identity:RealFloat:20" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:floatRadix">floatRadix</a> :: <a href="SafePrelude.html#t:Identity">Identity</a> a -&gt; <a href="SafePrelude.html#t:Integer">Integer</a> <a href="#v:floatRadix" class="selflink">#</a></p><p class="src"><a href="#v:floatDigits">floatDigits</a> :: <a href="SafePrelude.html#t:Identity">Identity</a> a -&gt; <a href="SafePrelude.html#t:Int">Int</a> <a href="#v:floatDigits" class="selflink">#</a></p><p class="src"><a href="#v:floatRange">floatRange</a> :: <a href="SafePrelude.html#t:Identity">Identity</a> a -&gt; (<a href="SafePrelude.html#t:Int">Int</a>, <a href="SafePrelude.html#t:Int">Int</a>) <a href="#v:floatRange" class="selflink">#</a></p><p class="src"><a href="#v:decodeFloat">decodeFloat</a> :: <a href="SafePrelude.html#t:Identity">Identity</a> a -&gt; (<a href="SafePrelude.html#t:Integer">Integer</a>, <a href="SafePrelude.html#t:Int">Int</a>) <a href="#v:decodeFloat" class="selflink">#</a></p><p class="src"><a href="#v:encodeFloat">encodeFloat</a> :: <a href="SafePrelude.html#t:Integer">Integer</a> -&gt; <a href="SafePrelude.html#t:Int">Int</a> -&gt; <a href="SafePrelude.html#t:Identity">Identity</a> a <a href="#v:encodeFloat" class="selflink">#</a></p><p class="src"><a href="#v:exponent">exponent</a> :: <a href="SafePrelude.html#t:Identity">Identity</a> a -&gt; <a href="SafePrelude.html#t:Int">Int</a> <a href="#v:exponent" class="selflink">#</a></p><p class="src"><a hre
<code><a href="SafePrelude.html#t:Identity">Identity</a></code> newtype if the <code><a href="SafePrelude.html#v:runIdentity">runIdentity</a></code> field were removed</p></td></tr><tr><td colspan="2"><div id="section.i:id:Identity:Show:22" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:showsPrec">showsPrec</a> :: <a href="SafePrelude.html#t:Int">Int</a> -&gt; <a href="SafePrelude.html#t:Identity">Identity</a> a -&gt; <a href="../base-4.9.0.0/Text-Show.html#t:ShowS">ShowS</a> <a href="#v:showsPrec" class="selflink">#</a></p><p class="src"><a href="#v:show">show</a> :: <a href="SafePrelude.html#t:Identity">Identity</a> a -&gt; <a href="SafePrelude.html#t:String">String</a> <a href="#v:show" class="selflink">#</a></p><p class="src"><a href="#v:showList">showList</a> :: [<a href="SafePrelude.html#t:Identity">Identity</a> a] -&gt; <a href="../base-4.9.0.0/Text-Show.html#t:ShowS">ShowS</a> <a href="#v:showList" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:Identity:Ix:23" class="instance expander" onclick="toggleSection('i:id:Identity:Ix:23')"></span> <a href="../base-4.9.0.0/Data-Ix.html#t:Ix">Ix</a> a =&gt; <a href="../base-4.9.0.0/Data-Ix.html#t:Ix">Ix</a> (<a href="SafePrelude.html#t:Identity">Identity</a> a)</span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:id:Identity:Ix:23" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:range">range</a> :: (<a href="SafePrelude.html#t:Identity">Identity</a> a, <a href="SafePrelude.html#t:Identity">Identity</a> a) -&gt; [<a href="SafePrelude.html#t:Identity">Identity</a> a] <a href="#v:range" class="selflink">#</a></p><p class="src"><a href="#v:index">index</a> :: (<a href="SafePrelude.html#t:Identity">Identity</a> a, <a href="SafePrelude.html#t:Identity">Identity</a> a) -&gt; <a href="SafePrelude.html#t:Identity">Identity</a> a -&gt; <a href="SafePrelude.html#t:Int">Int</a> <a href="#v:index" class="selflink">#</a></p><p class="src"><a href="#v:unsafeIndex">unsafeIndex</a> :: (<a href="SafePrelude.html#t:Identity">Identity</a> a, <a href="SafePrelude.html#t:Identity">Identity</a> a) -&gt; <a href="SafePrelude.html#t:Identity">Identity</a> a -&gt; <a href="SafePrelude.html#t:Int">Int</a></p><p class="src"><a href="#v:inRange">inRange</a> :: (<a href="SafePrelude.html#t:Identity">Identity</a> a, <a href="SafePrelude.html#t:Identity">Identity</a> a) -&gt; <a href="SafePrelude.html#t:Identity">Identity</a> a -&gt; <a href="SafePrelude.html#t:Bool">Bool</a> <a href="#v:inRange" class="selflink">#</a></p><p class="src"><a href="#v:rangeSize">rangeSize</a> :: (<a href="SafePrelude.html#t:Identity">Identity</a> a, <a href="SafePrelude.html#t:Identity">Identity</a> a) -&gt; <a href="SafePrelude.html#t:Int">Int</a> <a href="#v:rangeSize" class="selflink">#</a></p><p class="src"><a href="#v:unsafeRangeSize">unsafeRangeSize</a> :: (<a href="SafePrelude.html#t:Identity">Identity</a> a, <a href="SafePrelude.html#t:Identity">Identity</a> a) -&gt; <a href="SafePrelude.html#t:Int">Int</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:Identity:IsString:24" class="instance expander" onclick="toggleSection('i:id:Identity:IsString:24')"></span> <a href="SafePrelude.html#t:IsString">IsString</a> a =&gt; <a href="SafePrelude.html#t:IsString">IsString</a> (<a href="SafePrelude.html#t:Identity">Identity</a> a)</span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:id:Identity:IsString:24" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:fromString">fromString</a> :: <a href="SafePrelude.html#t:String">String</a> -&gt; <a href="SafePrelude.html#t:Identity">Identity</a> a <a href="#v:fromString" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:Identity:Gen
When an exception of type <code>e</code> is thrown, behind the scenes it is
encapsulated in a <code>SomeException</code>.</p></div><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a id="v:SomeException" class="def">SomeException</a> :: <a href="SafePrelude.html#t:SomeException">SomeException</a></td><td class="doc empty">&nbsp;</td></tr></table></div><div class="subs instances"><p id="control.i:SomeException" class="caption collapser" onclick="toggleSection('i:SomeException')">Instances</p><div id="section.i:SomeException" class="show"><table><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:SomeException:Show:1" class="instance expander" onclick="toggleSection('i:id:SomeException:Show:1')"></span> <a href="SafePrelude.html#t:Show">Show</a> <a href="SafePrelude.html#t:SomeException">SomeException</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:id:SomeException:Show:1" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:showsPrec">showsPrec</a> :: <a href="SafePrelude.html#t:Int">Int</a> -&gt; <a href="SafePrelude.html#t:SomeException">SomeException</a> -&gt; <a href="../base-4.9.0.0/Text-Show.html#t:ShowS">ShowS</a> <a href="#v:showsPrec" class="selflink">#</a></p><p class="src"><a href="#v:show">show</a> :: <a href="SafePrelude.html#t:SomeException">SomeException</a> -&gt; <a href="SafePrelude.html#t:String">String</a> <a href="#v:show" class="selflink">#</a></p><p class="src"><a href="#v:showList">showList</a> :: [<a href="SafePrelude.html#t:SomeException">SomeException</a>] -&gt; <a href="../base-4.9.0.0/Text-Show.html#t:ShowS">ShowS</a> <a href="#v:showList" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:SomeException:Exception:2" class="instance expander" onclick="toggleSection('i:id:SomeException:Exception:2')"></span> <a href="SafePrelude.html#t:Exception">Exception</a> <a href="SafePrelude.html#t:SomeException">SomeException</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:id:SomeException:Exception:2" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:toException">toException</a> :: <a href="SafePrelude.html#t:SomeException">SomeException</a> -&gt; <a href="SafePrelude.html#t:SomeException">SomeException</a> <a href="#v:toException" class="selflink">#</a></p><p class="src"><a href="#v:fromException">fromException</a> :: <a href="SafePrelude.html#t:SomeException">SomeException</a> -&gt; <a href="SafePrelude.html#t:Maybe">Maybe</a> <a href="SafePrelude.html#t:SomeException">SomeException</a> <a href="#v:fromException" class="selflink">#</a></p><p class="src"><a href="#v:displayException">displayException</a> :: <a href="SafePrelude.html#t:SomeException">SomeException</a> -&gt; <a href="SafePrelude.html#t:String">String</a> <a href="#v:displayException" class="selflink">#</a></p></div></div></td></tr></table></div></div></div><div class="top"><p class="src"><span class="keyword">data</span> <a id="t:SomeAsyncException" class="def">SomeAsyncException</a> :: <a href="../base-4.9.0.0/Data-Kind.html#t:-42-">*</a> <span class="keyword">where</span> <a href="#t:SomeAsyncException" class="selflink">#</a></p><div class="doc"><p>Superclass for asynchronous exceptions.</p><p><em>Since: 4.7.0.0</em></p></div><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a id="v:SomeAsyncException" class="def">SomeAsyncException</a> :: <a href="SafePrelude.html#t:SomeAsyncException">SomeAsyncException</a></td><td class="doc empty">&nbsp;</td></tr></table></div><div class="subs instances"><p id="control.i:SomeAsyncException" class="caption collapser" onclick="toggleSection('i:SomeAsyncException')">Instances</p><div id="section.i:SomeAsyncException" class="show"><table><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:SomeAsyncException:Show:1" class="instance expander" onclick="toggleSection('i:id:Some
of type <code><a href="SafePrelude.html#t:String">String</a></code>.</p></div></div><div class="top"><p class="src"><span class="keyword">type</span> <a id="t:FilePath" class="def">FilePath</a> = <a href="SafePrelude.html#t:String">String</a> <a href="#t:FilePath" class="selflink">#</a></p><div class="doc"><p>File and directory names are values of type <code><a href="SafePrelude.html#t:String">String</a></code>, whose precise
meaning is operating system dependent. Files can be opened, yielding a
handle which can then be used to operate on the contents of that file.</p></div></div><h2 id="g:2">Numbers</h2><div class="top"><p class="src"><span class="keyword">data</span> <a id="t:Word" class="def">Word</a> :: <a href="../base-4.9.0.0/Data-Kind.html#t:-42-">*</a> <a href="#t:Word" class="selflink">#</a></p><div class="doc"><p>A <code><a href="SafePrelude.html#t:Word">Word</a></code> is an unsigned integral type, with the same size as <code><a href="SafePrelude.html#t:Int">Int</a></code>.</p></div><div class="subs instances"><p id="control.i:Word" class="caption collapser" onclick="toggleSection('i:Word')">Instances</p><div id="section.i:Word" class="show"><table><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:Word:Bounded:1" class="instance expander" onclick="toggleSection('i:id:Word:Bounded:1')"></span> <a href="SafePrelude.html#t:Bounded">Bounded</a> <a href="SafePrelude.html#t:Word">Word</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:id:Word:Bounded:1" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:minBound">minBound</a> :: <a href="SafePrelude.html#t:Word">Word</a> <a href="#v:minBound" class="selflink">#</a></p><p class="src"><a href="#v:maxBound">maxBound</a> :: <a href="SafePrelude.html#t:Word">Word</a> <a href="#v:maxBound" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:Word:Enum:2" class="instance expander" onclick="toggleSection('i:id:Word:Enum:2')"></span> <a href="../base-4.9.0.0/Prelude.html#t:Enum">Enum</a> <a href="SafePrelude.html#t:Word">Word</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:id:Word:Enum:2" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:succ">succ</a> :: <a href="SafePrelude.html#t:Word">Word</a> -&gt; <a href="SafePrelude.html#t:Word">Word</a> <a href="#v:succ" class="selflink">#</a></p><p class="src"><a href="#v:pred">pred</a> :: <a href="SafePrelude.html#t:Word">Word</a> -&gt; <a href="SafePrelude.html#t:Word">Word</a> <a href="#v:pred" class="selflink">#</a></p><p class="src"><a href="#v:toEnum">toEnum</a> :: <a href="SafePrelude.html#t:Int">Int</a> -&gt; <a href="SafePrelude.html#t:Word">Word</a> <a href="#v:toEnum" class="selflink">#</a></p><p class="src"><a href="#v:fromEnum">fromEnum</a> :: <a href="SafePrelude.html#t:Word">Word</a> -&gt; <a href="SafePrelude.html#t:Int">Int</a> <a href="#v:fromEnum" class="selflink">#</a></p><p class="src"><a href="#v:enumFrom">enumFrom</a> :: <a href="SafePrelude.html#t:Word">Word</a> -&gt; [<a href="SafePrelude.html#t:Word">Word</a>] <a href="#v:enumFrom" class="selflink">#</a></p><p class="src"><a href="#v:enumFromThen">enumFromThen</a> :: <a href="SafePrelude.html#t:Word">Word</a> -&gt; <a href="SafePrelude.html#t:Word">Word</a> -&gt; [<a href="SafePrelude.html#t:Word">Word</a>] <a href="#v:enumFromThen" class="selflink">#</a></p><p class="src"><a href="#v:enumFromTo">enumFromTo</a> :: <a href="SafePrelude.html#t:Word">Word</a> -&gt; <a href="SafePrelude.html#t:Word">Word</a> -&gt; [<a href="SafePrelude.html#t:Word">Word</a>] <a href="#v:enumFromTo" class="selflink">#</a></p><p class="src"><a href="#v:enumFromThenTo">enumFromThenTo</a> :: <a href="SafePrelude.html#t:Word">Word</a> -&gt; <a href="SafePrelude.html#t:Word">Word</a> -&gt; <a href="SafePrelude.html#t:Word">Word</a> -&gt; [<a href="SafePrelude.html#t:Word">Word</a>] <a href="#v:enumFromThenTo" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:Word:Eq:3" class="instance expander" onclick="toggleSection('i:id:Word:Eq:3')"></span> <a href="SafePrelude.html#t:Eq">Eq</a> <a href="SafePrelude.html#t:Word">Word</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:id:Word:Eq:3" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><
The exact range for a given implementation can be determined by using
<code><a href="../base-4.9.0.0/Prelude.html#v:minBound">minBound</a></code> and <code><a href="../base-4.9.0.0/Prelude.html#v:maxBound">maxBound</a></code> from the <code><a href="../base-4.9.0.0/Prelude.html#v:Bounded">Bounded</a></code> class.</p></div><div class="subs instances"><p id="control.i:Int" class="caption collapser" onclick="toggleSection('i:Int')">Instances</p><div id="section.i:Int" class="show"><table><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:Int:Bounded:1" class="instance expander" onclick="toggleSection('i:id:Int:Bounded:1')"></span> <a href="SafePrelude.html#t:Bounded">Bounded</a> <a href="SafePrelude.html#t:Int">Int</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:id:Int:Bounded:1" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:minBound">minBound</a> :: <a href="SafePrelude.html#t:Int">Int</a> <a href="#v:minBound" class="selflink">#</a></p><p class="src"><a href="#v:maxBound">maxBound</a> :: <a href="SafePrelude.html#t:Int">Int</a> <a href="#v:maxBound" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:Int:Enum:2" class="instance expander" onclick="toggleSection('i:id:Int:Enum:2')"></span> <a href="../base-4.9.0.0/Prelude.html#t:Enum">Enum</a> <a href="SafePrelude.html#t:Int">Int</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:id:Int:Enum:2" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:succ">succ</a> :: <a href="SafePrelude.html#t:Int">Int</a> -&gt; <a href="SafePrelude.html#t:Int">Int</a> <a href="#v:succ" class="selflink">#</a></p><p class="src"><a href="#v:pred">pred</a> :: <a href="SafePrelude.html#t:Int">Int</a> -&gt; <a href="SafePrelude.html#t:Int">Int</a> <a href="#v:pred" class="selflink">#</a></p><p class="src"><a href="#v:toEnum">toEnum</a> :: <a href="SafePrelude.html#t:Int">Int</a> -&gt; <a href="SafePrelude.html#t:Int">Int</a> <a href="#v:toEnum" class="selflink">#</a></p><p class="src"><a href="#v:fromEnum">fromEnum</a> :: <a href="SafePrelude.html#t:Int">Int</a> -&gt; <a href="SafePrelude.html#t:Int">Int</a> <a href="#v:fromEnum" class="selflink">#</a></p><p class="src"><a href="#v:enumFrom">enumFrom</a> :: <a href="SafePrelude.html#t:Int">Int</a> -&gt; [<a href="SafePrelude.html#t:Int">Int</a>] <a href="#v:enumFrom" class="selflink">#</a></p><p class="src"><a href="#v:enumFromThen">enumFromThen</a> :: <a href="SafePrelude.html#t:Int">Int</a> -&gt; <a href="SafePrelude.html#t:Int">Int</a> -&gt; [<a href="SafePrelude.html#t:Int">Int</a>] <a href="#v:enumFromThen" class="selflink">#</a></p><p class="src"><a href="#v:enumFromTo">enumFromTo</a> :: <a href="SafePrelude.html#t:Int">Int</a> -&gt; <a href="SafePrelude.html#t:Int">Int</a> -&gt; [<a href="SafePrelude.html#t:Int">Int</a>] <a href="#v:enumFromTo" class="selflink">#</a></p><p class="src"><a href="#v:enumFromThenTo">enumFromThenTo</a> :: <a href="SafePrelude.html#t:Int">Int</a> -&gt; <a href="SafePrelude.html#t:Int">Int</a> -&gt; <a href="SafePrelude.html#t:Int">Int</a> -&gt; [<a href="SafePrelude.html#t:Int">Int</a>] <a href="#v:enumFromThenTo" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:Int:Eq:3" class="instance expander" onclick="toggleSection('i:id:Int:Eq:3')"></span> <a href="SafePrelude.html#t:Eq">Eq</a> <a href="SafePrelude.html#t:Int">Int</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:id:Int:Eq:3" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:-61--61-">(==)</a> :: <a href="SafePrelude.html#t:Int">Int</a> -&gt; <a href="SafePrelude.html#t:Int">Int</a> -&gt; <a href="SafePrelude.html#t:Bool">Bool</a> <a href="#v:-61--61-" class="selflink">#</a></p><p class="src"><a href="#v:-47--61-">(/=)</a> :: <a href="SafePrelude.html#t:I
two <code><a href="SafePrelude.html#t:Integer">Integer</a></code> values. A rational number may be constructed using
the <code><a href="../base-4.9.0.0/Data-Ratio.html#v:-37-">%</a></code> operator.</p></div></div><div class="top"><p class="src"><span class="keyword">data</span> <a id="t:Float" class="def">Float</a> :: <a href="../base-4.9.0.0/Data-Kind.html#t:-42-">*</a> <a href="#t:Float" class="selflink">#</a></p><div class="doc"><p>Single-precision floating point numbers.
It is desirable that this type be at least equal in range and precision
to the IEEE single-precision type.</p></div><div class="subs instances"><p id="control.i:Float" class="caption collapser" onclick="toggleSection('i:Float')">Instances</p><div id="section.i:Float" class="show"><table><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:Float:Eq:1" class="instance expander" onclick="toggleSection('i:id:Float:Eq:1')"></span> <a href="SafePrelude.html#t:Eq">Eq</a> <a href="SafePrelude.html#t:Float">Float</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:id:Float:Eq:1" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:-61--61-">(==)</a> :: <a href="SafePrelude.html#t:Float">Float</a> -&gt; <a href="SafePrelude.html#t:Float">Float</a> -&gt; <a href="SafePrelude.html#t:Bool">Bool</a> <a href="#v:-61--61-" class="selflink">#</a></p><p class="src"><a href="#v:-47--61-">(/=)</a> :: <a href="SafePrelude.html#t:Float">Float</a> -&gt; <a href="SafePrelude.html#t:Float">Float</a> -&gt; <a href="SafePrelude.html#t:Bool">Bool</a> <a href="#v:-47--61-" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:Float:Floating:2" class="instance expander" onclick="toggleSection('i:id:Float:Floating:2')"></span> <a href="SafePrelude.html#t:Floating">Floating</a> <a href="SafePrelude.html#t:Float">Float</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:id:Float:Floating:2" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:pi">pi</a> :: <a href="SafePrelude.html#t:Float">Float</a> <a href="#v:pi" class="selflink">#</a></p><p class="src"><a href="#v:exp">exp</a> :: <a href="SafePrelude.html#t:Float">Float</a> -&gt; <a href="SafePrelude.html#t:Float">Float</a> <a href="#v:exp" class="selflink">#</a></p><p class="src"><a href="#v:log">log</a> :: <a href="SafePrelude.html#t:Float">Float</a> -&gt; <a href="SafePrelude.html#t:Float">Float</a> <a href="#v:log" class="selflink">#</a></p><p class="src"><a href="#v:sqrt">sqrt</a> :: <a href="SafePrelude.html#t:Float">Float</a> -&gt; <a href="SafePrelude.html#t:Float">Float</a> <a href="#v:sqrt" class="selflink">#</a></p><p class="src"><a href="#v:-42--42-">(**)</a> :: <a href="SafePrelude.html#t:Float">Float</a> -&gt; <a href="SafePrelude.html#t:Float">Float</a> -&gt; <a href="SafePrelude.html#t:Float">Float</a> <a href="#v:-42--42-" class="selflink">#</a></p><p class="src"><a href="#v:logBase">logBase</a> :: <a href="SafePrelude.html#t:Float">Float</a> -&gt; <a href="SafePrelude.html#t:Float">Float</a> -&gt; <a href="SafePrelude.html#t:Float">Float</a> <a href="#v:logBase" class="selflink">#</a></p><p class="src"><a href="#v:sin">sin</a> :: <a href="SafePrelude.html#t:Float">Float</a> -&gt; <a href="SafePrelude.html#t:Float">Float</a> <a href="#v:sin" class="selflink">#</a></p><p class="src"><a href="#v:cos">cos</a> :: <a href="SafePrelude.html#t:Float">Float</a> -&gt; <a href="SafePrelude.html#t:Float">Float</a> <a href="#v:cos" class="selflink">#</a></p><p class="src"><a href="#v:tan">tan</a> :: <a href="SafePrelude.html#t:Float">Float</a> -&gt; <a href="SafePrelude.html#t:Float">Float</a> <a href="#v:tan" class="selflink">#</a></p><p class="src"><a href="#v:asin">asin</a> :: <a href="SafePrelude.html#t:Float">Float</a> -&gt; <a href="SafePrelude.html#t:Float">Float</a> <a href="#v:asin" class="selflink">#</a></p><p class="src"><a href="#v:acos">acos</a> :: <a href="SafePrelude.html#t:Float">Float</a> -&gt; <a href="SafePrelude.html#t:Float">Float</a> <a href="#v:acos" class="selflink">#</a></p><p class="src"><a href="#v:atan">atan</a> :: <a href="SafePrelude.html#t:Float">Float</a> -&gt; <a href="SafePrelude.html#t:Float">Float</a> <a href="#v:atan" class="selflink">#</a></p><p class="src"><a href="#v:sinh">sinh</a> :: <a href="SafePrelude.html#t:Float">Float</a> -&gt; <a href="SafePrelude.html#t:Float">Float</a> <a href="#v:sinh" class="selflink">#</a></p><p class="src"><a href
It is desirable that this type be at least equal in range and precision
to the IEEE double-precision type.</p></div><div class="subs instances"><p id="control.i:Double" class="caption collapser" onclick="toggleSection('i:Double')">Instances</p><div id="section.i:Double" class="show"><table><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:Double:Eq:1" class="instance expander" onclick="toggleSection('i:id:Double:Eq:1')"></span> <a href="SafePrelude.html#t:Eq">Eq</a> <a href="SafePrelude.html#t:Double">Double</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:id:Double:Eq:1" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:-61--61-">(==)</a> :: <a href="SafePrelude.html#t:Double">Double</a> -&gt; <a href="SafePrelude.html#t:Double">Double</a> -&gt; <a href="SafePrelude.html#t:Bool">Bool</a> <a href="#v:-61--61-" class="selflink">#</a></p><p class="src"><a href="#v:-47--61-">(/=)</a> :: <a href="SafePrelude.html#t:Double">Double</a> -&gt; <a href="SafePrelude.html#t:Double">Double</a> -&gt; <a href="SafePrelude.html#t:Bool">Bool</a> <a href="#v:-47--61-" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:Double:Floating:2" class="instance expander" onclick="toggleSection('i:id:Double:Floating:2')"></span> <a href="SafePrelude.html#t:Floating">Floating</a> <a href="SafePrelude.html#t:Double">Double</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:id:Double:Floating:2" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:pi">pi</a> :: <a href="SafePrelude.html#t:Double">Double</a> <a href="#v:pi" class="selflink">#</a></p><p class="src"><a href="#v:exp">exp</a> :: <a href="SafePrelude.html#t:Double">Double</a> -&gt; <a href="SafePrelude.html#t:Double">Double</a> <a href="#v:exp" class="selflink">#</a></p><p class="src"><a href="#v:log">log</a> :: <a href="SafePrelude.html#t:Double">Double</a> -&gt; <a href="SafePrelude.html#t:Double">Double</a> <a href="#v:log" class="selflink">#</a></p><p class="src"><a href="#v:sqrt">sqrt</a> :: <a href="SafePrelude.html#t:Double">Double</a> -&gt; <a href="SafePrelude.html#t:Double">Double</a> <a href="#v:sqrt" class="selflink">#</a></p><p class="src"><a href="#v:-42--42-">(**)</a> :: <a href="SafePrelude.html#t:Double">Double</a> -&gt; <a href="SafePrelude.html#t:Double">Double</a> -&gt; <a href="SafePrelude.html#t:Double">Double</a> <a href="#v:-42--42-" class="selflink">#</a></p><p class="src"><a href="#v:logBase">logBase</a> :: <a href="SafePrelude.html#t:Double">Double</a> -&gt; <a href="SafePrelude.html#t:Double">Double</a> -&gt; <a href="SafePrelude.html#t:Double">Double</a> <a href="#v:logBase" class="selflink">#</a></p><p class="src"><a href="#v:sin">sin</a> :: <a href="SafePrelude.html#t:Double">Double</a> -&gt; <a href="SafePrelude.html#t:Double">Double</a> <a href="#v:sin" class="selflink">#</a></p><p class="src"><a href="#v:cos">cos</a> :: <a href="SafePrelude.html#t:Double">Double</a> -&gt; <a href="SafePrelude.html#t:Double">Double</a> <a href="#v:cos" class="selflink">#</a></p><p class="src"><a href="#v:tan">tan</a> :: <a href="SafePrelude.html#t:Double">Double</a> -&gt; <a href="SafePrelude.html#t:Double">Double</a> <a href="#v:tan" class="selflink">#</a></p><p class="src"><a href="#v:asin">asin</a> :: <a href="SafePrelude.html#t:Double">Double</a> -&gt; <a href="SafePrelude.html#t:Double">Double</a> <a href="#v:asin" class="selflink">#</a></p><p class="src"><a href="#v:acos">acos</a> :: <a href="SafePrelude.html#t:Double">Double</a> -&gt; <a href="SafePrelude.html#t:Double">Double</a> <a href="#v:acos" class="selflink">#</a></p><p class="src"><a href="#v:atan">atan</a> :: <a href="SafePrelude.html#t:Double">Double</a> -&gt; <a href="SafePrelude.html#t:Double">Double</a> <a href="#v:atan" class="selflink">#</a></p><p class="src"><a href="#v:sinh">sinh</a> :: <a href="SafePrelude.html#t:Double">Double</a> -&gt; <a href="SafePrelude.html#t:Double">Do
datatype whose constituent types are in <code><a href="SafePrelude.html#t:Ord">Ord</a></code>. The declared order
of the constructors in the data declaration determines the ordering
in derived <code><a href="SafePrelude.html#t:Ord">Ord</a></code> instances. The <code><a href="SafePrelude.html#t:Ordering">Ordering</a></code> datatype allows a single
comparison to determine the precise ordering of two objects.</p><p>Minimal complete definition: either <code><a href="SafePrelude.html#v:compare">compare</a></code> or <code><a href="SafePrelude.html#v:-60--61-">&lt;=</a></code>.
Using <code><a href="SafePrelude.html#v:compare">compare</a></code> can be more efficient for complex types.</p></div><div class="subs minimal"><p class="caption">Minimal complete definition</p><p class="src"><a href="SafePrelude.html#v:compare">compare</a> | <a href="SafePrelude.html#v:-60--61-">(&lt;=)</a></p></div><div class="subs instances"><p id="control.i:Ord" class="caption collapser" onclick="toggleSection('i:Ord')">Instances</p><div id="section.i:Ord" class="show"><table><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:Ord:Ord:1" class="instance expander" onclick="toggleSection('i:ic:Ord:Ord:1')"></span> <a href="SafePrelude.html#t:Ord">Ord</a> <a href="SafePrelude.html#t:Bool">Bool</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:Ord:Ord:1" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:compare">compare</a> :: <a href="SafePrelude.html#t:Bool">Bool</a> -&gt; <a href="SafePrelude.html#t:Bool">Bool</a> -&gt; <a href="SafePrelude.html#t:Ordering">Ordering</a> <a href="#v:compare" class="selflink">#</a></p><p class="src"><a href="#v:-60-">(&lt;)</a> :: <a href="SafePrelude.html#t:Bool">Bool</a> -&gt; <a href="SafePrelude.html#t:Bool">Bool</a> -&gt; <a href="SafePrelude.html#t:Bool">Bool</a> <a href="#v:-60-" class="selflink">#</a></p><p class="src"><a href="#v:-60--61-">(&lt;=)</a> :: <a href="SafePrelude.html#t:Bool">Bool</a> -&gt; <a href="SafePrelude.html#t:Bool">Bool</a> -&gt; <a href="SafePrelude.html#t:Bool">Bool</a> <a href="#v:-60--61-" class="selflink">#</a></p><p class="src"><a href="#v:-62-">(&gt;)</a> :: <a href="SafePrelude.html#t:Bool">Bool</a> -&gt; <a href="SafePrelude.html#t:Bool">Bool</a> -&gt; <a href="SafePrelude.html#t:Bool">Bool</a> <a href="#v:-62-" class="selflink">#</a></p><p class="src"><a href="#v:-62--61-">(&gt;=)</a> :: <a href="SafePrelude.html#t:Bool">Bool</a> -&gt; <a href="SafePrelude.html#t:Bool">Bool</a> -&gt; <a href="SafePrelude.html#t:Bool">Bool</a> <a href="#v:-62--61-" class="selflink">#</a></p><p class="src"><a href="#v:max">max</a> :: <a href="SafePrelude.html#t:Bool">Bool</a> -&gt; <a href="SafePrelude.html#t:Bool">Bool</a> -&gt; <a href="SafePrelude.html#t:Bool">Bool</a> <a href="#v:max" class="selflink">#</a></p><p class="src"><a href="#v:min">min</a> :: <a href="SafePrelude.html#t:Bool">Bool</a> -&gt; <a href="SafePrelude.html#t:Bool">Bool</a> -&gt; <a href="SafePrelude.html#t:Bool">Bool</a> <a href="#v:min" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:Ord:Ord:2" class="instance expander" onclick="toggleSection('i:ic:Ord:Ord:2')"></span> <a href="SafePrelude.html#t:Ord">Ord</a> <a href="SafePrelude.html#t:Char">Char</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:Ord:Ord:2" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:compare">compare</a> :: <a href="SafePrelude.html#t:Char">Char</a> -&gt; <a href="SafePrelude.html#t:Char">Char</a> -&gt; <a href="SafePrelude.html#t:Ordering">Ordering</a> <a href="#v:compare" class="selflink">#</a></p><p class="src"><a href="#v:-60-">(&lt;)</a> :: <a href="SafePrelude.html#t:Char">Char</a> -&gt; <a href="SafePrelude.html#t:Char">Char</a> -&gt; <a href="SafePrelude.html#t:Bool">Bool</a> <a href="#v:-60-" class="selflink">#</a></p><p class="src"><a href="#v:-60--61-">(&lt;=)</a> :: <a href="SafePrelude.html#t:Char">Char</a> -&gt; <a href="SafePrelude.html#t:Char">Char</a> -&gt; <a href="SafePrelude.html#t:Bool">Bool</a> <a href="#v:-60--61-" class="selflink">#</a></p><p class="src"><a href="#v:-62-">(&gt;)</a> :: <a href="SafePrelude.html#t:Char">Char</a> -&gt; <a href="SafePrelude.html#t:Char">Char</a> -&gt; <a href="SafePrelude.html#t:Bool">Bool</a> <a href="#v:-62-" class="selflink">#</a></p><p class="src"><a href="#v:-62--61-">(&gt;=)</a> :: <a href="SafePrelude.html#t:Char">Char</a> -&gt; <a href="SafePrelude.html
All the basic datatypes exported by the <a href="../base-4.9.0.0/Prelude.html">Prelude</a> are instances of <code><a href="SafePrelude.html#t:Eq">Eq</a></code>,
and <code><a href="SafePrelude.html#t:Eq">Eq</a></code> may be derived for any datatype whose constituents are also
instances of <code><a href="SafePrelude.html#t:Eq">Eq</a></code>.</p><p>Minimal complete definition: either <code><a href="SafePrelude.html#v:-61--61-">==</a></code> or <code><a href="SafePrelude.html#v:-47--61-">/=</a></code>.</p></div><div class="subs minimal"><p class="caption">Minimal complete definition</p><p class="src"><a href="SafePrelude.html#v:-61--61-">(==)</a> | <a href="SafePrelude.html#v:-47--61-">(/=)</a></p></div><div class="subs instances"><p id="control.i:Eq" class="caption collapser" onclick="toggleSection('i:Eq')">Instances</p><div id="section.i:Eq" class="show"><table><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:Eq:Eq:1" class="instance expander" onclick="toggleSection('i:ic:Eq:Eq:1')"></span> <a href="SafePrelude.html#t:Eq">Eq</a> <a href="SafePrelude.html#t:Bool">Bool</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:Eq:Eq:1" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:-61--61-">(==)</a> :: <a href="SafePrelude.html#t:Bool">Bool</a> -&gt; <a href="SafePrelude.html#t:Bool">Bool</a> -&gt; <a href="SafePrelude.html#t:Bool">Bool</a> <a href="#v:-61--61-" class="selflink">#</a></p><p class="src"><a href="#v:-47--61-">(/=)</a> :: <a href="SafePrelude.html#t:Bool">Bool</a> -&gt; <a href="SafePrelude.html#t:Bool">Bool</a> -&gt; <a href="SafePrelude.html#t:Bool">Bool</a> <a href="#v:-47--61-" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:Eq:Eq:2" class="instance expander" onclick="toggleSection('i:ic:Eq:Eq:2')"></span> <a href="SafePrelude.html#t:Eq">Eq</a> <a href="SafePrelude.html#t:Char">Char</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:Eq:Eq:2" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:-61--61-">(==)</a> :: <a href="SafePrelude.html#t:Char">Char</a> -&gt; <a href="SafePrelude.html#t:Char">Char</a> -&gt; <a href="SafePrelude.html#t:Bool">Bool</a> <a href="#v:-61--61-" class="selflink">#</a></p><p class="src"><a href="#v:-47--61-">(/=)</a> :: <a href="SafePrelude.html#t:Char">Char</a> -&gt; <a href="SafePrelude.html#t:Char">Char</a> -&gt; <a href="SafePrelude.html#t:Bool">Bool</a> <a href="#v:-47--61-" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:Eq:Eq:3" class="instance expander" onclick="toggleSection('i:ic:Eq:Eq:3')"></span> <a href="SafePrelude.html#t:Eq">Eq</a> <a href="SafePrelude.html#t:Double">Double</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:Eq:Eq:3" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:-61--61-">(==)</a> :: <a href="SafePrelude.html#t:Double">Double</a> -&gt; <a href="SafePrelude.html#t:Double">Double</a> -&gt; <a href="SafePrelude.html#t:Bool">Bool</a> <a href="#v:-61--61-" class="selflink">#</a></p><p class="src"><a href="#v:-47--61-">(/=)</a> :: <a href="SafePrelude.html#t:Double">Double</a> -&gt; <a href="SafePrelude.html#t:Double">Double</a> -&gt; <a href="SafePrelude.html#t:Bool">Bool</a> <a href="#v:-47--61-" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:Eq:Eq:4" class="instance expander" onclick="toggleSection('i:ic:Eq:Eq:4')"></span> <a href="SafePrelude.html#t:Eq">Eq</a> <a href="SafePrelude.html#t:Float">Float</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:Eq:Eq:4" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:-61--61-">(==)</a> :: <a href="SafePrelude.html#t:Float">Float</a> -&gt; <a href="SafePrelude.html#t:Float">Float</a> -&gt; <a href="SafePrelude.html#t:Bool">Bool</a> <a href="#v:-61--61-" class="selflink">#</a></p><p class="src"><a href="#v:-47--61-">(/=)</a> ::
type. <code><a href="SafePrelude.html#t:Ord">Ord</a></code> is not a superclass of <code><a href="SafePrelude.html#t:Bounded">Bounded</a></code> since types that are not
totally ordered may also have upper and lower bounds.</p><p>The <code><a href="SafePrelude.html#t:Bounded">Bounded</a></code> class may be derived for any enumeration type;
<code><a href="SafePrelude.html#v:minBound">minBound</a></code> is the first constructor listed in the <code>data</code> declaration
and <code><a href="SafePrelude.html#v:maxBound">maxBound</a></code> is the last.
<code><a href="SafePrelude.html#t:Bounded">Bounded</a></code> may also be derived for single-constructor datatypes whose
constituent types are in <code><a href="SafePrelude.html#t:Bounded">Bounded</a></code>.</p></div><div class="subs instances"><p id="control.i:Bounded" class="caption collapser" onclick="toggleSection('i:Bounded')">Instances</p><div id="section.i:Bounded" class="show"><table><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:Bounded:Bounded:1" class="instance expander" onclick="toggleSection('i:ic:Bounded:Bounded:1')"></span> <a href="SafePrelude.html#t:Bounded">Bounded</a> <a href="SafePrelude.html#t:Bool">Bool</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:Bounded:Bounded:1" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:minBound">minBound</a> :: <a href="SafePrelude.html#t:Bool">Bool</a> <a href="#v:minBound" class="selflink">#</a></p><p class="src"><a href="#v:maxBound">maxBound</a> :: <a href="SafePrelude.html#t:Bool">Bool</a> <a href="#v:maxBound" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:Bounded:Bounded:2" class="instance expander" onclick="toggleSection('i:ic:Bounded:Bounded:2')"></span> <a href="SafePrelude.html#t:Bounded">Bounded</a> <a href="SafePrelude.html#t:Char">Char</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:Bounded:Bounded:2" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:minBound">minBound</a> :: <a href="SafePrelude.html#t:Char">Char</a> <a href="#v:minBound" class="selflink">#</a></p><p class="src"><a href="#v:maxBound">maxBound</a> :: <a href="SafePrelude.html#t:Char">Char</a> <a href="#v:maxBound" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:Bounded:Bounded:3" class="instance expander" onclick="toggleSection('i:ic:Bounded:Bounded:3')"></span> <a href="SafePrelude.html#t:Bounded">Bounded</a> <a href="SafePrelude.html#t:Int">Int</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:Bounded:Bounded:3" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:minBound">minBound</a> :: <a href="SafePrelude.html#t:Int">Int</a> <a href="#v:minBound" class="selflink">#</a></p><p class="src"><a href="#v:maxBound">maxBound</a> :: <a href="SafePrelude.html#t:Int">Int</a> <a href="#v:maxBound" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:Bounded:Bounded:4" class="instance expander" onclick="toggleSection('i:ic:Bounded:Bounded:4')"></span> <a href="SafePrelude.html#t:Bounded">Bounded</a> <a href="SafePrelude.html#t:Int8">Int8</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:Bounded:Bounded:4" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:minBound">minBound</a> :: <a href="SafePrelude.html#t:Int8">Int8</a> <a href="#v:minBound" class="selflink">#</a></p><p class="src"><a href="#v:maxBound">maxBound</a> :: <a href="SafePrelude.html#t:Int8">Int8</a> <a href="#v:maxBound" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:Bounded:Bounded:5" class="instance expander" onclick="toggleSection('i:ic:Bounded:Bounded:5')"></span> <a href="SafePrelude.html#t:Bounded">Bounded</a> <a href="SafePrelude.html#t:Int16">Int16</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:Bounded:Bounded:5" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:minBound">minBound</a> :: <a href="SafePrelude.html#t:Int16">Int16</a> <a href="#v:minBound" class="selflink">#</a></p><p class="src"><a href="#v:maxBound">maxBound</a> :: <a href="SafePrelude.html#t:Int16">Int16</a> <a href="#v:maxBound" cl
are compatible with derived instances of <code><a href="../base-4.9.0.0/Text-Read.html#v:Read">Read</a></code>:</p><ul><li>The result of <code><a href="SafePrelude.html#v:show">show</a></code> is a syntactically correct Haskell
expression containing only constants, given the fixity
declarations in force at the point where the type is declared.
It contains only the constructor names defined in the data type,
parentheses, and spaces. When labelled constructor fields are
used, braces, commas, field names, and equal signs are also used.</li><li>If the constructor is defined to be an infix operator, then
<code><a href="SafePrelude.html#v:showsPrec">showsPrec</a></code> will produce infix applications of the constructor.</li><li>the representation will be enclosed in parentheses if the
precedence of the top-level constructor in <code>x</code> is less than <code>d</code>
(associativity is ignored). Thus, if <code>d</code> is <code>0</code> then the result
is never surrounded in parentheses; if <code>d</code> is <code>11</code> it is always
surrounded in parentheses, unless it is an atomic expression.</li><li>If the constructor is defined using record syntax, then <code><a href="SafePrelude.html#v:show">show</a></code>
will produce the record-syntax form, with the fields given in the
same order as the original declaration.</li></ul><p>For example, given the declarations</p><pre>infixr 5 :^:
data Tree a = Leaf a | Tree a :^: Tree a</pre><p>the derived instance of <code><a href="SafePrelude.html#t:Show">Show</a></code> is equivalent to</p><pre>instance (Show a) =&gt; Show (Tree a) where
showsPrec d (Leaf m) = showParen (d &gt; app_prec) $
showString &quot;Leaf &quot; . showsPrec (app_prec+1) m
where app_prec = 10
showsPrec d (u :^: v) = showParen (d &gt; up_prec) $
showsPrec (up_prec+1) u .
showString &quot; :^: &quot; .
showsPrec (up_prec+1) v
where up_prec = 5</pre><p>Note that right-associativity of <code>:^:</code> is ignored. For example,</p><ul><li><code><code><a href="SafePrelude.html#v:show">show</a></code> (Leaf 1 :^: Leaf 2 :^: Leaf 3)</code> produces the string
<code>&quot;Leaf 1 :^: (Leaf 2 :^: Leaf 3)&quot;</code>.</li></ul></div><div class="subs minimal"><p class="caption">Minimal complete definition</p><p class="src"><a href="SafePrelude.html#v:showsPrec">showsPrec</a> | <a href="SafePrelude.html#v:show">show</a></p></div><div class="subs instances"><p id="control.i:Show" class="caption collapser" onclick="toggleSection('i:Show')">Instances</p><div id="section.i:Show" class="show"><table><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:Show:Show:1" class="instance expander" onclick="toggleSection('i:ic:Show:Show:1')"></span> <a href="SafePrelude.html#t:Show">Show</a> <a href="SafePrelude.html#t:Bool">Bool</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:Show:Show:1" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:showsPrec">showsPrec</a> :: <a href="SafePrelude.html#t:Int">Int</a> -&gt; <a href="SafePrelude.html#t:Bool">Bool</a> -&gt; <a href="../base-4.9.0.0/Text-Show.html#t:ShowS">ShowS</a> <a href="#v:showsPrec" class="selflink">#</a></p><p class="src"><a href="#v:show">show</a> :: <a href="SafePrelude.html#t:Bool">Bool</a> -&gt; <a href="SafePrelude.html#t:String">String</a> <a href="#v:show" class="selflink">#</a></p><p class="src"><a href="#v:showList">showList</a> :: [<a href="SafePrelude.html#t:Bool">Bool</a>] -&gt; <a href="../base-4.9.0.0/Text-Show.html#t:ShowS">ShowS</a> <a href="#v:showList" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:Show:Show:2" class="instance expander" onclick="toggleSection('i:ic:Show:Show:2')"></span> <a href="SafePrelude.html#t:Show">Show</a> <a href="SafePrelude.html#t:Char">Char</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:Show:Show:2" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:showsPrec">showsPrec</a> :: <a href="SafePrelude.html#t:Int">Int</a> -&gt; <a href="SafePrelude.html#t:Char">Char</a> -&gt; <a href="../base-4.9.0.0/Text-Show.html#t:ShowS">ShowS</a> <a href="#v:showsPrec" class="selflink">#</a></p><p class="src"><a href="#v:show">show</a> :: <a href="SafePrelude.html#t:Char">Char</a> -&gt; <a href="SafePrelude.html#t:String">String</a> <a href="#v:show" class="selflink">#</a></p><p class="src"><a href="#v:showList">showList</a> :: [<a href="SafePrelude.html#t:Char">Char</a>] -&gt; <a href="../base-4.9.0.0/Text-Show.html#t:ShowS">ShowS</a> <a href="#v:showList" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:Show:Show:3" class="instance expander" onclick="toggleSection('i:ic:Show:Show:3')"></span> <a href="SafePrelude.html#t:Show">Show</a> <a href="SafePrelude.html#t:Int">Int</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:Show:Show:3" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:showsPrec">showsPrec</a> :: <a href="SafePrelude.html#t:Int">Int</a> -&gt; <a href="SafePrelude.html#t:Int">Int</a> -&gt; <a href="../base-4.9.0.0/Text-Show.html#t:ShowS">ShowS</a> <a href="#v:showsPrec" class="selflink">#</a></p><p class="src"><a href="#v:show">show</a> :: <a href="SafePrelude.html#t:Int">Int</a> -&gt; <a href="SafePrelude.html#t:String">String</a> <a href="#v:show" class="selflink">#</a></p><p class="src"><a href="#v:showList">showList</a> :: [<a href="SafePrelude.html#t:Int">Int</a>] -&gt; <a href="../base-4.9.0.0/Text-Show.html#t:ShowS">ShowS</a> <a href="#v:showList" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:Show:Show:4" class="instance expander" onclick="toggleSection('i:ic:Show:Show:4')"></span> <a href="SafePrelude.html#t:Show">Show</a> <a href="SafePrelude.html#t:Int8">Int8</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td col
<code><a href="SafePrelude.html#t:Identity">Identity</a></code> newtype if the <code><a href="SafePrelude.html#v:runIdentity">runIdentity</a></code> field were removed</p></td></tr><tr><td colspan="2"><div id="section.i:ic:Show:Show:124" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:showsPrec">showsPrec</a> :: <a href="SafePrelude.html#t:Int">Int</a> -&gt; <a href="SafePrelude.html#t:Identity">Identity</a> a -&gt; <a href="../base-4.9.0.0/Text-Show.html#t:ShowS">ShowS</a> <a href="#v:showsPrec" class="selflink">#</a></p><p class="src"><a href="#v:show">show</a> :: <a href="SafePrelude.html#t:Identity">Identity</a> a -&gt; <a href="SafePrelude.html#t:String">String</a> <a href="#v:show" class="selflink">#</a></p><p class="src"><a href="#v:showList">showList</a> :: [<a href="SafePrelude.html#t:Identity">Identity</a> a] -&gt; <a href="../base-4.9.0.0/Text-Show.html#t:ShowS">ShowS</a> <a href="#v:showList" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:Show:Show:125" class="instance expander" onclick="toggleSection('i:ic:Show:Show:125')"></span> <a href="SafePrelude.html#t:Show">Show</a> a =&gt; <a href="SafePrelude.html#t:Show">Show</a> (<a href="../base-4.9.0.0/Data-Semigroup.html#t:Min">Min</a> a)</span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:Show:Show:125" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:showsPrec">showsPrec</a> :: <a href="SafePrelude.html#t:Int">Int</a> -&gt; <a href="../base-4.9.0.0/Data-Semigroup.html#t:Min">Min</a> a -&gt; <a href="../base-4.9.0.0/Text-Show.html#t:ShowS">ShowS</a> <a href="#v:showsPrec" class="selflink">#</a></p><p class="src"><a href="#v:show">show</a> :: <a href="../base-4.9.0.0/Data-Semigroup.html#t:Min">Min</a> a -&gt; <a href="SafePrelude.html#t:String">String</a> <a href="#v:show" class="selflink">#</a></p><p class="src"><a href="#v:showList">showList</a> :: [<a href="../base-4.9.0.0/Data-Semigroup.html#t:Min">Min</a> a] -&gt; <a href="../base-4.9.0.0/Text-Show.html#t:ShowS">ShowS</a> <a href="#v:showList" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:Show:Show:126" class="instance expander" onclick="toggleSection('i:ic:Show:Show:126')"></span> <a href="SafePrelude.html#t:Show">Show</a> a =&gt; <a href="SafePrelude.html#t:Show">Show</a> (<a href="../base-4.9.0.0/Data-Semigroup.html#t:Max">Max</a> a)</span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:Show:Show:126" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:showsPrec">showsPrec</a> :: <a href="SafePrelude.html#t:Int">Int</a> -&gt; <a href="../base-4.9.0.0/Data-Semigroup.html#t:Max">Max</a> a -&gt; <a href="../base-4.9.0.0/Text-Show.html#t:ShowS">ShowS</a> <a href="#v:showsPrec" class="selflink">#</a></p><p class="src"><a href="#v:show">show</a> :: <a href="../base-4.9.0.0/Data-Semigroup.html#t:Max">Max</a> a -&gt; <a href="SafePrelude.html#t:String">String</a> <a href="#v:show" class="selflink">#</a></p><p class="src"><a href="#v:showList">showList</a> :: [<a href="../base-4.9.0.0/Data-Semigroup.html#t:Max">Max</a> a] -&gt; <a href="../base-4.9.0.0/Text-Show.html#t:ShowS">ShowS</a> <a href="#v:showList" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:Show:Show:127" class="instance expander" onclick="toggleSection('i:ic:Show:Show:127')"></span> <a href="SafePrelude.html#t:Show">Show</a> a =&gt; <a href="SafePrelude.html#t:Show">Show</a> (<a href="../base-4.9.0.0/Data-Semigroup.html#t:First">First</a> a)</span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:Show:Show:127" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:showsPrec">showsP
<code><a href="../base-4.9.0.0/Data-Functor-Const.html#t:Const">Const</a></code> newtype if the <code>runConst</code> field were removed</p></td></tr><tr><td colspan="2"><div id="section.i:ic:Show:Show:164" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:showsPrec">showsPrec</a> :: <a href="SafePrelude.html#t:Int">Int</a> -&gt; <a href="../base-4.9.0.0/Data-Functor-Const.html#t:Const">Const</a> k a b -&gt; <a href="../base-4.9.0.0/Text-Show.html#t:ShowS">ShowS</a> <a href="#v:showsPrec" class="selflink">#</a></p><p class="src"><a href="#v:show">show</a> :: <a href="../base-4.9.0.0/Data-Functor-Const.html#t:Const">Const</a> k a b -&gt; <a href="SafePrelude.html#t:String">String</a> <a href="#v:show" class="selflink">#</a></p><p class="src"><a href="#v:showList">showList</a> :: [<a href="../base-4.9.0.0/Data-Functor-Const.html#t:Const">Const</a> k a b] -&gt; <a href="../base-4.9.0.0/Text-Show.html#t:ShowS">ShowS</a> <a href="#v:showList" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:Show:Show:165" class="instance expander" onclick="toggleSection('i:ic:Show:Show:165')"></span> <a href="SafePrelude.html#t:Show">Show</a> (f a) =&gt; <a href="SafePrelude.html#t:Show">Show</a> (<a href="../base-4.9.0.0/Data-Monoid.html#t:Alt">Alt</a> k f a)</span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:Show:Show:165" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:showsPrec">showsPrec</a> :: <a href="SafePrelude.html#t:Int">Int</a> -&gt; <a href="../base-4.9.0.0/Data-Monoid.html#t:Alt">Alt</a> k f a -&gt; <a href="../base-4.9.0.0/Text-Show.html#t:ShowS">ShowS</a> <a href="#v:showsPrec" class="selflink">#</a></p><p class="src"><a href="#v:show">show</a> :: <a href="../base-4.9.0.0/Data-Monoid.html#t:Alt">Alt</a> k f a -&gt; <a href="SafePrelude.html#t:String">String</a> <a href="#v:show" class="selflink">#</a></p><p class="src"><a href="#v:showList">showList</a> :: [<a href="../base-4.9.0.0/Data-Monoid.html#t:Alt">Alt</a> k f a] -&gt; <a href="../base-4.9.0.0/Text-Show.html#t:ShowS">ShowS</a> <a href="#v:showList" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:Show:Show:166" class="instance expander" onclick="toggleSection('i:ic:Show:Show:166')"></span> <a href="SafePrelude.html#t:Show">Show</a> (<a href="../base-4.9.0.0/Data-Type-Equality.html#t::-126-:">(:~:)</a> k a b)</span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:Show:Show:166" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:showsPrec">showsPrec</a> :: <a href="SafePrelude.html#t:Int">Int</a> -&gt; (k <a href="../base-4.9.0.0/Data-Type-Equality.html#t::-126-:">:~:</a> a) b -&gt; <a href="../base-4.9.0.0/Text-Show.html#t:ShowS">ShowS</a> <a href="#v:showsPrec" class="selflink">#</a></p><p class="src"><a href="#v:show">show</a> :: (k <a href="../base-4.9.0.0/Data-Type-Equality.html#t::-126-:">:~:</a> a) b -&gt; <a href="SafePrelude.html#t:String">String</a> <a href="#v:show" class="selflink">#</a></p><p class="src"><a href="#v:showList">showList</a> :: [(k <a href="../base-4.9.0.0/Data-Type-Equality.html#t::-126-:">:~:</a> a) b] -&gt; <a href="../base-4.9.0.0/Text-Show.html#t:ShowS">ShowS</a> <a href="#v:showList" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:Show:Show:167" class="instance expander" onclick="toggleSection('i:ic:Show:Show:167')"></span> (<a href="SafePrelude.html#t:Show">Show</a> e, <a href="../base-4.9.0.0/Data-Functor-Classes.html#t:Show1">Show1</a> m, <a href="SafePrelude.html#t:Show">Show</a> a) =&gt; <a href="SafePrelude.html#t:Show">Show</a> (<a href="../mtl-2.2.1/Control-Monad-Error.html#t:ErrorT">ErrorT</a> e m a)</span></td><td class="doc empty">&nbsp;</td></tr><tr><td c
derived instances of <code><a href="../base-4.9.0.0/Text-Show.html#v:Show">Show</a></code> obey:</p><ul><li>If the constructor is defined to be an infix operator, then the
derived <code><a href="SafePrelude.html#t:Read">Read</a></code> instance will parse only infix applications of
the constructor (not the prefix form).</li><li>Associativity is not used to reduce the occurrence of parentheses,
although precedence may be.</li><li>If the constructor is defined using record syntax, the derived <code><a href="SafePrelude.html#t:Read">Read</a></code>
will parse only the record-syntax form, and furthermore, the fields
must be given in the same order as the original declaration.</li><li>The derived <code><a href="SafePrelude.html#t:Read">Read</a></code> instance allows arbitrary Haskell whitespace
between tokens of the input string. Extra parentheses are also
allowed.</li></ul><p>For example, given the declarations</p><pre>infixr 5 :^:
data Tree a = Leaf a | Tree a :^: Tree a</pre><p>the derived instance of <code><a href="SafePrelude.html#t:Read">Read</a></code> in Haskell 2010 is equivalent to</p><pre>instance (Read a) =&gt; Read (Tree a) where
readsPrec d r = readParen (d &gt; app_prec)
(\r -&gt; [(Leaf m,t) |
(&quot;Leaf&quot;,s) &lt;- lex r,
(m,t) &lt;- readsPrec (app_prec+1) s]) r
++ readParen (d &gt; up_prec)
(\r -&gt; [(u:^:v,w) |
(u,s) &lt;- readsPrec (up_prec+1) r,
(&quot;:^:&quot;,t) &lt;- lex s,
(v,w) &lt;- readsPrec (up_prec+1) t]) r
where app_prec = 10
up_prec = 5</pre><p>Note that right-associativity of <code>:^:</code> is unused.</p><p>The derived instance in GHC is equivalent to</p><pre>instance (Read a) =&gt; Read (Tree a) where
readPrec = parens $ (prec app_prec $ do
Ident &quot;Leaf&quot; &lt;- lexP
m &lt;- step readPrec
return (Leaf m))
+++ (prec up_prec $ do
u &lt;- step readPrec
Symbol &quot;:^:&quot; &lt;- lexP
v &lt;- step readPrec
return (u :^: v))
where app_prec = 10
up_prec = 5
readListPrec = readListPrecDefault</pre></div><div class="subs minimal"><p class="caption">Minimal complete definition</p><p class="src"><a href="SafePrelude.html#v:readsPrec">readsPrec</a> | <a href="SafePrelude.html#v:readPrec">readPrec</a></p></div><div class="subs instances"><p id="control.i:Read" class="caption collapser" onclick="toggleSection('i:Read')">Instances</p><div id="section.i:Read" class="show"><table><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:Read:Read:1" class="instance expander" onclick="toggleSection('i:ic:Read:Read:1')"></span> <a href="SafePrelude.html#t:Read">Read</a> <a href="SafePrelude.html#t:Bool">Bool</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:Read:Read:1" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:readsPrec">readsPrec</a> :: <a href="SafePrelude.html#t:Int">Int</a> -&gt; <a href="../base-4.9.0.0/Text-ParserCombinators-ReadP.html#t:ReadS">ReadS</a> <a href="SafePrelude.html#t:Bool">Bool</a> <a href="#v:readsPrec" class="selflink">#</a></p><p class="src"><a href="#v:readList">readList</a> :: <a href="../base-4.9.0.0/Text-ParserCombinators-ReadP.html#t:ReadS">ReadS</a> [<a href="SafePrelude.html#t:Bool">Bool</a>] <a href="#v:readList" class="selflink">#</a></p><p class="src"><a href="#v:readPrec">readPrec</a> :: <a href="../base-4.9.0.0/Text-ParserCombinators-ReadPrec.html#t:ReadPrec">ReadPrec</a> <a href="SafePrelude.html#t:Bool">Bool</a> <a href="#v:readPrec" class="selflink">#</a></p><p class="src"><a href="#v:readListPrec">readListPrec</a> :: <a href="../base-4.9.0.0/Text-ParserCombinators-ReadPrec.html#t:ReadPrec">ReadPrec</a> [<a href="SafePrelude.html#t:Bool">Bool</a>] <a href="#v:readListPrec" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:Read:Read:2" class="instance expander" onclick="toggleSection('i:ic:Read:Read:2')"></span> <a href="SafePrelude.html#t:Read">Read</a> <a href="SafePrelude.html#t:Char">Char</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:Read:Read:2" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:readsPrec">readsPrec</a> :: <a href="SafePrelude.html#t:Int">Int</a> -&gt; <a href="../base-4.9.0.0/Text-ParserCombinators-ReadP.html#t:ReadS">ReadS</a> <a href="SafePrelude.html#t:Char">Char</a> <a href="#v:readsPrec" class="selflink">#</a></p><p class="src"><a href="#v:readList">readList</a> :: <a href="../base-4.9.0.0/Text-ParserCombinators-ReadP.html#t:ReadS">ReadS</a> [<a href="SafePrelude.html#t:Char">Char</a>] <a href="#v:readList" class="selflink">#</a></p><p class="src"><a href="#v:readPrec">readPrec</a> :: <a href="../base-4.9.0.0/Text-ParserCombinators-ReadPrec.html#t:ReadPrec">ReadPrec</a> <a href="SafePrelude.html#t:Char">Char</a> <a href="#v:readPrec" class="selflink">#</a></p><p class="src"><a href="#v:readListPrec">readListPrec</a> :: <a href="../base-4.9.0.0/Text-ParserCombinators-ReadPrec.html#t:ReadPrec">ReadPrec</a> [<a href="SafePrelude.html#t:Char">Char</a>] <a href="#v:readListPrec" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:Read:Read:3" class="instance expander" onclick="toggleSection('i:ic:Read:Read:3')"></span> <a href="SafePrelude.html#t:Read">Read</a> <a href="SafePrelude.html#t:Double">Double</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:Read:Read:3" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:readsPrec">readsPrec</a> :: <a href="SafePrelude.html#t:Int">Int</a> -&gt; <a href="../base-4.9.0.0/Text-ParserCombinators-ReadP.html#t:ReadS">ReadS</a> <a href="SafePrelude.html#t:Double">Double</a> <a href="#v:readsPrec" class="selflink">#</a></p><p class="src"><a href="#v:readList">readList</a> :: <a href="../base-4.9.0.0/Tex
<code><a href="../base-4.9.0.0/Data-Void.html#t:Void">Void</a></code> as a data type with no constructors.</p></td></tr><tr><td colspan="2"><div id="section.i:ic:Read:Read:18" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:readsPrec">readsPrec</a> :: <a href="SafePrelude.html#t:Int">Int</a> -&gt; <a href="../base-4.9.0.0/Text-ParserCombinators-ReadP.html#t:ReadS">ReadS</a> <a href="../base-4.9.0.0/Data-Void.html#t:Void">Void</a> <a href="#v:readsPrec" class="selflink">#</a></p><p class="src"><a href="#v:readList">readList</a> :: <a href="../base-4.9.0.0/Text-ParserCombinators-ReadP.html#t:ReadS">ReadS</a> [<a href="../base-4.9.0.0/Data-Void.html#t:Void">Void</a>] <a href="#v:readList" class="selflink">#</a></p><p class="src"><a href="#v:readPrec">readPrec</a> :: <a href="../base-4.9.0.0/Text-ParserCombinators-ReadPrec.html#t:ReadPrec">ReadPrec</a> <a href="../base-4.9.0.0/Data-Void.html#t:Void">Void</a> <a href="#v:readPrec" class="selflink">#</a></p><p class="src"><a href="#v:readListPrec">readListPrec</a> :: <a href="../base-4.9.0.0/Text-ParserCombinators-ReadPrec.html#t:ReadPrec">ReadPrec</a> [<a href="../base-4.9.0.0/Data-Void.html#t:Void">Void</a>] <a href="#v:readListPrec" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:Read:Read:19" class="instance expander" onclick="toggleSection('i:ic:Read:Read:19')"></span> <a href="SafePrelude.html#t:Read">Read</a> <a href="../base-4.9.0.0/Data-Version.html#t:Version">Version</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:Read:Read:19" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:readsPrec">readsPrec</a> :: <a href="SafePrelude.html#t:Int">Int</a> -&gt; <a href="../base-4.9.0.0/Text-ParserCombinators-ReadP.html#t:ReadS">ReadS</a> <a href="../base-4.9.0.0/Data-Version.html#t:Version">Version</a> <a href="#v:readsPrec" class="selflink">#</a></p><p class="src"><a href="#v:readList">readList</a> :: <a href="../base-4.9.0.0/Text-ParserCombinators-ReadP.html#t:ReadS">ReadS</a> [<a href="../base-4.9.0.0/Data-Version.html#t:Version">Version</a>] <a href="#v:readList" class="selflink">#</a></p><p class="src"><a href="#v:readPrec">readPrec</a> :: <a href="../base-4.9.0.0/Text-ParserCombinators-ReadPrec.html#t:ReadPrec">ReadPrec</a> <a href="../base-4.9.0.0/Data-Version.html#t:Version">Version</a> <a href="#v:readPrec" class="selflink">#</a></p><p class="src"><a href="#v:readListPrec">readListPrec</a> :: <a href="../base-4.9.0.0/Text-ParserCombinators-ReadPrec.html#t:ReadPrec">ReadPrec</a> [<a href="../base-4.9.0.0/Data-Version.html#t:Version">Version</a>] <a href="#v:readListPrec" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:Read:Read:20" class="instance expander" onclick="toggleSection('i:ic:Read:Read:20')"></span> <a href="SafePrelude.html#t:Read">Read</a> <a href="../base-4.9.0.0/System-Exit.html#t:ExitCode">ExitCode</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:Read:Read:20" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:readsPrec">readsPrec</a> :: <a href="SafePrelude.html#t:Int">Int</a> -&gt; <a href="../base-4.9.0.0/Text-ParserCombinators-ReadP.html#t:ReadS">ReadS</a> <a href="../base-4.9.0.0/System-Exit.html#t:ExitCode">ExitCode</a> <a href="#v:readsPrec" class="selflink">#</a></p><p class="src"><a href="#v:readList">readList</a> :: <a href="../base-4.9.0.0/Text-ParserCombinators-ReadP.html#t:ReadS">ReadS</a> [<a href="../base-4.9.0.0/System-Exit.html#t:ExitCode">ExitCode</a>] <a href="#v:readList" class="selflink">#</a></p><p class="src"><a href="#v:readPrec">readPrec</a> :: <a href="../base-4.9.0.0/Text-ParserCombinators-ReadPrec.html#t:ReadPrec">ReadPrec</a> <a href="../base-4.9.0.0/System-Exit.html#t:ExitCode">ExitCode</a> <a href="#v:readPr
<code><a href="SafePrelude.html#t:Identity">Identity</a></code> newtype if the <code><a href="SafePrelude.html#v:runIdentity">runIdentity</a></code> field were removed</p></td></tr><tr><td colspan="2"><div id="section.i:ic:Read:Read:44" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:readsPrec">readsPrec</a> :: <a href="SafePrelude.html#t:Int">Int</a> -&gt; <a href="../base-4.9.0.0/Text-ParserCombinators-ReadP.html#t:ReadS">ReadS</a> (<a href="SafePrelude.html#t:Identity">Identity</a> a) <a href="#v:readsPrec" class="selflink">#</a></p><p class="src"><a href="#v:readList">readList</a> :: <a href="../base-4.9.0.0/Text-ParserCombinators-ReadP.html#t:ReadS">ReadS</a> [<a href="SafePrelude.html#t:Identity">Identity</a> a] <a href="#v:readList" class="selflink">#</a></p><p class="src"><a href="#v:readPrec">readPrec</a> :: <a href="../base-4.9.0.0/Text-ParserCombinators-ReadPrec.html#t:ReadPrec">ReadPrec</a> (<a href="SafePrelude.html#t:Identity">Identity</a> a) <a href="#v:readPrec" class="selflink">#</a></p><p class="src"><a href="#v:readListPrec">readListPrec</a> :: <a href="../base-4.9.0.0/Text-ParserCombinators-ReadPrec.html#t:ReadPrec">ReadPrec</a> [<a href="SafePrelude.html#t:Identity">Identity</a> a] <a href="#v:readListPrec" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:Read:Read:45" class="instance expander" onclick="toggleSection('i:ic:Read:Read:45')"></span> <a href="SafePrelude.html#t:Read">Read</a> a =&gt; <a href="SafePrelude.html#t:Read">Read</a> (<a href="../base-4.9.0.0/Data-Semigroup.html#t:Min">Min</a> a)</span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:Read:Read:45" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:readsPrec">readsPrec</a> :: <a href="SafePrelude.html#t:Int">Int</a> -&gt; <a href="../base-4.9.0.0/Text-ParserCombinators-ReadP.html#t:ReadS">ReadS</a> (<a href="../base-4.9.0.0/Data-Semigroup.html#t:Min">Min</a> a) <a href="#v:readsPrec" class="selflink">#</a></p><p class="src"><a href="#v:readList">readList</a> :: <a href="../base-4.9.0.0/Text-ParserCombinators-ReadP.html#t:ReadS">ReadS</a> [<a href="../base-4.9.0.0/Data-Semigroup.html#t:Min">Min</a> a] <a href="#v:readList" class="selflink">#</a></p><p class="src"><a href="#v:readPrec">readPrec</a> :: <a href="../base-4.9.0.0/Text-ParserCombinators-ReadPrec.html#t:ReadPrec">ReadPrec</a> (<a href="../base-4.9.0.0/Data-Semigroup.html#t:Min">Min</a> a) <a href="#v:readPrec" class="selflink">#</a></p><p class="src"><a href="#v:readListPrec">readListPrec</a> :: <a href="../base-4.9.0.0/Text-ParserCombinators-ReadPrec.html#t:ReadPrec">ReadPrec</a> [<a href="../base-4.9.0.0/Data-Semigroup.html#t:Min">Min</a> a] <a href="#v:readListPrec" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:Read:Read:46" class="instance expander" onclick="toggleSection('i:ic:Read:Read:46')"></span> <a href="SafePrelude.html#t:Read">Read</a> a =&gt; <a href="SafePrelude.html#t:Read">Read</a> (<a href="../base-4.9.0.0/Data-Semigroup.html#t:Max">Max</a> a)</span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:Read:Read:46" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:readsPrec">readsPrec</a> :: <a href="SafePrelude.html#t:Int">Int</a> -&gt; <a href="../base-4.9.0.0/Text-ParserCombinators-ReadP.html#t:ReadS">ReadS</a> (<a href="../base-4.9.0.0/Data-Semigroup.html#t:Max">Max</a> a) <a href="#v:readsPrec" class="selflink">#</a></p><p class="src"><a href="#v:readList">readList</a> :: <a href="../base-4.9.0.0/Text-ParserCombinators-ReadP.html#t:ReadS">ReadS</a> [<a href="../base-4.9.0.0/Data-Semigroup.html#t:Max">Max</a> a] <a href="#v:readList" class="selflink">#</a></p><p class="src"><a href="#v:readPrec">readPrec</a> :: <a href="../base-4.9.0.0/Text-ParserCombinator
<code><a href="../base-4.9.0.0/Data-Functor-Const.html#t:Const">Const</a></code> newtype if the <code>runConst</code> field were removed</p></td></tr><tr><td colspan="2"><div id="section.i:ic:Read:Read:79" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:readsPrec">readsPrec</a> :: <a href="SafePrelude.html#t:Int">Int</a> -&gt; <a href="../base-4.9.0.0/Text-ParserCombinators-ReadP.html#t:ReadS">ReadS</a> (<a href="../base-4.9.0.0/Data-Functor-Const.html#t:Const">Const</a> k a b) <a href="#v:readsPrec" class="selflink">#</a></p><p class="src"><a href="#v:readList">readList</a> :: <a href="../base-4.9.0.0/Text-ParserCombinators-ReadP.html#t:ReadS">ReadS</a> [<a href="../base-4.9.0.0/Data-Functor-Const.html#t:Const">Const</a> k a b] <a href="#v:readList" class="selflink">#</a></p><p class="src"><a href="#v:readPrec">readPrec</a> :: <a href="../base-4.9.0.0/Text-ParserCombinators-ReadPrec.html#t:ReadPrec">ReadPrec</a> (<a href="../base-4.9.0.0/Data-Functor-Const.html#t:Const">Const</a> k a b) <a href="#v:readPrec" class="selflink">#</a></p><p class="src"><a href="#v:readListPrec">readListPrec</a> :: <a href="../base-4.9.0.0/Text-ParserCombinators-ReadPrec.html#t:ReadPrec">ReadPrec</a> [<a href="../base-4.9.0.0/Data-Functor-Const.html#t:Const">Const</a> k a b] <a href="#v:readListPrec" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:Read:Read:80" class="instance expander" onclick="toggleSection('i:ic:Read:Read:80')"></span> <a href="SafePrelude.html#t:Read">Read</a> (f a) =&gt; <a href="SafePrelude.html#t:Read">Read</a> (<a href="../base-4.9.0.0/Data-Monoid.html#t:Alt">Alt</a> k f a)</span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:Read:Read:80" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:readsPrec">readsPrec</a> :: <a href="SafePrelude.html#t:Int">Int</a> -&gt; <a href="../base-4.9.0.0/Text-ParserCombinators-ReadP.html#t:ReadS">ReadS</a> (<a href="../base-4.9.0.0/Data-Monoid.html#t:Alt">Alt</a> k f a) <a href="#v:readsPrec" class="selflink">#</a></p><p class="src"><a href="#v:readList">readList</a> :: <a href="../base-4.9.0.0/Text-ParserCombinators-ReadP.html#t:ReadS">ReadS</a> [<a href="../base-4.9.0.0/Data-Monoid.html#t:Alt">Alt</a> k f a] <a href="#v:readList" class="selflink">#</a></p><p class="src"><a href="#v:readPrec">readPrec</a> :: <a href="../base-4.9.0.0/Text-ParserCombinators-ReadPrec.html#t:ReadPrec">ReadPrec</a> (<a href="../base-4.9.0.0/Data-Monoid.html#t:Alt">Alt</a> k f a) <a href="#v:readPrec" class="selflink">#</a></p><p class="src"><a href="#v:readListPrec">readListPrec</a> :: <a href="../base-4.9.0.0/Text-ParserCombinators-ReadPrec.html#t:ReadPrec">ReadPrec</a> [<a href="../base-4.9.0.0/Data-Monoid.html#t:Alt">Alt</a> k f a] <a href="#v:readListPrec" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:Read:Read:81" class="instance expander" onclick="toggleSection('i:ic:Read:Read:81')"></span> (~) k a b =&gt; <a href="SafePrelude.html#t:Read">Read</a> (<a href="../base-4.9.0.0/Data-Type-Equality.html#t::-126-:">(:~:)</a> k a b)</span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:Read:Read:81" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:readsPrec">readsPrec</a> :: <a href="SafePrelude.html#t:Int">Int</a> -&gt; <a href="../base-4.9.0.0/Text-ParserCombinators-ReadP.html#t:ReadS">ReadS</a> ((k <a href="../base-4.9.0.0/Data-Type-Equality.html#t::-126-:">:~:</a> a) b) <a href="#v:readsPrec" class="selflink">#</a></p><p class="src"><a href="#v:readList">readList</a> :: <a href="../base-4.9.0.0/Text-ParserCombinators-ReadP.html#t:ReadS">ReadS</a> [(k <a href="../base-4.9.0.0/Data-Type-Equality.html#t::-126-:">:~:</a> a) b] <a href="#v:readList" class="selflink">#</a></p><p class="src"><a href="#v:rea
Instances of <code><a href="SafePrelude.html#t:Functor">Functor</a></code> should satisfy the following laws:</p><pre>fmap id == id
fmap (f . g) == fmap f . fmap g</pre><p>The instances of <code><a href="SafePrelude.html#t:Functor">Functor</a></code> for lists, <code><a href="../base-4.9.0.0/Data-Maybe.html#v:Maybe">Maybe</a></code> and <code><a href="../base-4.9.0.0/System-IO.html#v:IO">IO</a></code>
satisfy these laws.</p></div><div class="subs minimal"><p class="caption">Minimal complete definition</p><p class="src"><a href="SafePrelude.html#v:fmap">fmap</a></p></div><div class="subs instances"><p id="control.i:Functor" class="caption collapser" onclick="toggleSection('i:Functor')">Instances</p><div id="section.i:Functor" class="show"><table><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:Functor:Functor:1" class="instance expander" onclick="toggleSection('i:ic:Functor:Functor:1')"></span> <a href="SafePrelude.html#t:Functor">Functor</a> []</span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:Functor:Functor:1" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:fmap">fmap</a> :: (a -&gt; b) -&gt; [a] -&gt; [b] <a href="#v:fmap" class="selflink">#</a></p><p class="src"><a href="#v:-60--36-">(&lt;$)</a> :: a -&gt; [b] -&gt; [a] <a href="#v:-60--36-" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:Functor:Functor:2" class="instance expander" onclick="toggleSection('i:ic:Functor:Functor:2')"></span> <a href="SafePrelude.html#t:Functor">Functor</a> <a href="SafePrelude.html#t:Maybe">Maybe</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:Functor:Functor:2" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:fmap">fmap</a> :: (a -&gt; b) -&gt; <a href="SafePrelude.html#t:Maybe">Maybe</a> a -&gt; <a href="SafePrelude.html#t:Maybe">Maybe</a> b <a href="#v:fmap" class="selflink">#</a></p><p class="src"><a href="#v:-60--36-">(&lt;$)</a> :: a -&gt; <a href="SafePrelude.html#t:Maybe">Maybe</a> b -&gt; <a href="SafePrelude.html#t:Maybe">Maybe</a> a <a href="#v:-60--36-" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:Functor:Functor:3" class="instance expander" onclick="toggleSection('i:ic:Functor:Functor:3')"></span> <a href="SafePrelude.html#t:Functor">Functor</a> <a href="SafePrelude.html#t:IO">IO</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:Functor:Functor:3" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:fmap">fmap</a> :: (a -&gt; b) -&gt; <a href="SafePrelude.html#t:IO">IO</a> a -&gt; <a href="SafePrelude.html#t:IO">IO</a> b <a href="#v:fmap" class="selflink">#</a></p><p class="src"><a href="#v:-60--36-">(&lt;$)</a> :: a -&gt; <a href="SafePrelude.html#t:IO">IO</a> b -&gt; <a href="SafePrelude.html#t:IO">IO</a> a <a href="#v:-60--36-" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:Functor:Functor:4" class="instance expander" onclick="toggleSection('i:ic:Functor:Functor:4')"></span> <a href="SafePrelude.html#t:Functor">Functor</a> <a href="../base-4.9.0.0/GHC-Generics.html#t:V1">V1</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:Functor:Functor:4" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:fmap">fmap</a> :: (a -&gt; b) -&gt; <a href="../base-4.9.0.0/GHC-Generics.html#t:V1">V1</a> a -&gt; <a href="../base-4.9.0.0/GHC-Generics.html#t:V1">V1</a> b <a href="#v:fmap" class="selflink">#</a></p><p class="src"><a href="#v:-60--36-">(&lt;$)</a> :: a -&gt; <a href="../base-4.9.0.0/GHC-Generics.html#t:V1">V1</a> b -&gt; <a href="../base-4.9.0.0/GHC-Generics.html#t:V1">V1</a> a <a href="#v:-60--36-" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:Functor:Functor:5" class="instance expander" onclick="toggleSection('i:ic:Functor:Functor:5')"></span> <a href="SafePrelude.html#t:Functor">Functor</a> <a href="../base-4.9.0.0/GHC-Generics.html#t:U1">U1</a></span></td><td class="doc empty">&nbsp;</t
functions satisfying the following laws:</p><dl><dt><em>identity</em></dt><dd><pre><code><a href="SafePrelude.html#v:pure">pure</a></code> <code><a href="SafePrelude.html#v:id">id</a></code> <code><a href="SafePrelude.html#v:-60--42--62-">&lt;*&gt;</a></code> v = v</pre></dd><dt><em>composition</em></dt><dd><pre><code><a href="SafePrelude.html#v:pure">pure</a></code> (.) <code><a href="SafePrelude.html#v:-60--42--62-">&lt;*&gt;</a></code> u <code><a href="SafePrelude.html#v:-60--42--62-">&lt;*&gt;</a></code> v <code><a href="SafePrelude.html#v:-60--42--62-">&lt;*&gt;</a></code> w = u <code><a href="SafePrelude.html#v:-60--42--62-">&lt;*&gt;</a></code> (v <code><a href="SafePrelude.html#v:-60--42--62-">&lt;*&gt;</a></code> w)</pre></dd><dt><em>homomorphism</em></dt><dd><pre><code><a href="SafePrelude.html#v:pure">pure</a></code> f <code><a href="SafePrelude.html#v:-60--42--62-">&lt;*&gt;</a></code> <code><a href="SafePrelude.html#v:pure">pure</a></code> x = <code><a href="SafePrelude.html#v:pure">pure</a></code> (f x)</pre></dd><dt><em>interchange</em></dt><dd><pre>u <code><a href="SafePrelude.html#v:-60--42--62-">&lt;*&gt;</a></code> <code><a href="SafePrelude.html#v:pure">pure</a></code> y = <code><a href="SafePrelude.html#v:pure">pure</a></code> (<code><a href="SafePrelude.html#v:-36-">$</a></code> y) <code><a href="SafePrelude.html#v:-60--42--62-">&lt;*&gt;</a></code> u</pre></dd></dl><p>The other methods have the following default definitions, which may
be overridden with equivalent specialized implementations:</p><ul><li><pre>u <code><a href="SafePrelude.html#v:-42--62-">*&gt;</a></code> v = <code><a href="SafePrelude.html#v:pure">pure</a></code> (<code><a href="SafePrelude.html#v:const">const</a></code> <code><a href="SafePrelude.html#v:id">id</a></code>) <code><a href="SafePrelude.html#v:-60--42--62-">&lt;*&gt;</a></code> u <code><a href="SafePrelude.html#v:-60--42--62-">&lt;*&gt;</a></code> v</pre></li><li><pre>u <code><a href="SafePrelude.html#v:-60--42-">&lt;*</a></code> v = <code><a href="SafePrelude.html#v:pure">pure</a></code> <code><a href="SafePrelude.html#v:const">const</a></code> <code><a href="SafePrelude.html#v:-60--42--62-">&lt;*&gt;</a></code> u <code><a href="SafePrelude.html#v:-60--42--62-">&lt;*&gt;</a></code> v</pre></li></ul><p>As a consequence of these laws, the <code><a href="SafePrelude.html#t:Functor">Functor</a></code> instance for <code>f</code> will satisfy</p><ul><li><pre><code><a href="SafePrelude.html#v:fmap">fmap</a></code> f x = <code><a href="SafePrelude.html#v:pure">pure</a></code> f <code><a href="SafePrelude.html#v:-60--42--62-">&lt;*&gt;</a></code> x</pre></li></ul><p>If <code>f</code> is also a <code><a href="SafePrelude.html#t:Monad">Monad</a></code>, it should satisfy</p><ul><li><pre><code><a href="SafePrelude.html#v:pure">pure</a></code> = <code><a href="SafePrelude.html#v:return">return</a></code></pre></li><li><pre>(<code><a href="SafePrelude.html#v:-60--42--62-">&lt;*&gt;</a></code>) = <code><a href="SafePrelude.html#v:ap">ap</a></code></pre></li></ul><p>(which implies that <code><a href="SafePrelude.html#v:pure">pure</a></code> and <code><a href="SafePrelude.html#v:-60--42--62-">&lt;*&gt;</a></code> satisfy the applicative functor laws).</p></div><div class="subs minimal"><p class="caption">Minimal complete definition</p><p class="src"><a href="SafePrelude.html#v:pure">pure</a>, <a href="SafePrelude.html#v:-60--42--62-">(&lt;*&gt;)</a></p></div><div class="subs instances"><p id="control.i:Applicative" class="caption collapser" onclick="toggleSection('i:Applicative')">Instances</p><div id="section.i:Applicative" class="show"><table><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:Applicative:Applicative:1" class="instance expander" onclick="toggleSection('i:ic:Applicative:Applicative:1')"></span> <a href="SafePrelude.html#t:Applicative">Applicative</a> []</span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:Applicative:Applicative:1" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:pure">pure</a> :: a -&gt; [a] <a href="#v:pure" class="selflink">#</a></p><p class="src"><a href="#v:-60--42--62-">(&lt;*&gt;)</a> :: [a -&gt; b] -&gt; [a] -&gt; [b] <a href="#v:-60--42--62-" class="selflink">#</a></p><p class="src"><a href="#v:-42--62-">(*&gt;)</a> :: [a] -&gt; [b] -&gt; [b] <a href="#v:-42--62-" class="selflink">#</a></p><p class="src"><a href="#v:-60--42-">(&lt;*)</a> :: [a] -&gt; [b] -&gt; [a] <a href="#v:-60--42-" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:Applicative:Applicative:2" class="instance expander" onclick="toggleSection('i:ic:Applicative:Applicative:2')"></span> <a href="SafePrelude.html#t:Applicative">Applicative</a> <a href="SafePrelude.html#t:Maybe">Maybe</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:Applicative:Applicative:2" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:pure">pure</a> :: a -&gt; <a href="SafePrelude.html#t:Maybe">Maybe</a> a <a href="#v:pure" class="selflink">#</a></p><p class="src"><a href="#v:-60--42--62-">(&lt;*&gt;)</a> :: <a href="SafePrelude.html#t:Maybe">Maybe</a> (a -&gt; b) -&gt; <a href="SafePrelude.html#t:Maybe">Maybe</a> a -&gt; <a href="SafePrelude.html#t:Maybe">Maybe</a> b <a href="#v:-60--42--62-" class="selflink">#</a></p><p class="src"><a href="#v:-42--62-">(*&gt
of the equations:</p><ul><li><pre>some v = (:) <code>&lt;$&gt;</code> v <code><a href="SafePrelude.html#v:-60--42--62-">&lt;*&gt;</a></code> many v</pre></li><li><pre>many v = some v <code><a href="SafePrelude.html#v:-60--124--62-">&lt;|&gt;</a></code> <code><a href="SafePrelude.html#v:pure">pure</a></code> []</pre></li></ul></div><div class="subs minimal"><p class="caption">Minimal complete definition</p><p class="src"><a href="SafePrelude.html#v:empty">empty</a>, <a href="SafePrelude.html#v:-60--124--62-">(&lt;|&gt;)</a></p></div><div class="subs instances"><p id="control.i:Alternative" class="caption collapser" onclick="toggleSection('i:Alternative')">Instances</p><div id="section.i:Alternative" class="show"><table><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:Alternative:Alternative:1" class="instance expander" onclick="toggleSection('i:ic:Alternative:Alternative:1')"></span> <a href="SafePrelude.html#t:Alternative">Alternative</a> []</span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:Alternative:Alternative:1" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:empty">empty</a> :: [a] <a href="#v:empty" class="selflink">#</a></p><p class="src"><a href="#v:-60--124--62-">(&lt;|&gt;)</a> :: [a] -&gt; [a] -&gt; [a] <a href="#v:-60--124--62-" class="selflink">#</a></p><p class="src"><a href="#v:some">some</a> :: [a] -&gt; [[a]] <a href="#v:some" class="selflink">#</a></p><p class="src"><a href="#v:many">many</a> :: [a] -&gt; [[a]] <a href="#v:many" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:Alternative:Alternative:2" class="instance expander" onclick="toggleSection('i:ic:Alternative:Alternative:2')"></span> <a href="SafePrelude.html#t:Alternative">Alternative</a> <a href="SafePrelude.html#t:Maybe">Maybe</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:Alternative:Alternative:2" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:empty">empty</a> :: <a href="SafePrelude.html#t:Maybe">Maybe</a> a <a href="#v:empty" class="selflink">#</a></p><p class="src"><a href="#v:-60--124--62-">(&lt;|&gt;)</a> :: <a href="SafePrelude.html#t:Maybe">Maybe</a> a -&gt; <a href="SafePrelude.html#t:Maybe">Maybe</a> a -&gt; <a href="SafePrelude.html#t:Maybe">Maybe</a> a <a href="#v:-60--124--62-" class="selflink">#</a></p><p class="src"><a href="#v:some">some</a> :: <a href="SafePrelude.html#t:Maybe">Maybe</a> a -&gt; <a href="SafePrelude.html#t:Maybe">Maybe</a> [a] <a href="#v:some" class="selflink">#</a></p><p class="src"><a href="#v:many">many</a> :: <a href="SafePrelude.html#t:Maybe">Maybe</a> a -&gt; <a href="SafePrelude.html#t:Maybe">Maybe</a> [a] <a href="#v:many" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:Alternative:Alternative:3" class="instance expander" onclick="toggleSection('i:ic:Alternative:Alternative:3')"></span> <a href="SafePrelude.html#t:Alternative">Alternative</a> <a href="SafePrelude.html#t:IO">IO</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:Alternative:Alternative:3" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:empty">empty</a> :: <a href="SafePrelude.html#t:IO">IO</a> a <a href="#v:empty" class="selflink">#</a></p><p class="src"><a href="#v:-60--124--62-">(&lt;|&gt;)</a> :: <a href="SafePrelude.html#t:IO">IO</a> a -&gt; <a href="SafePrelude.html#t:IO">IO</a> a -&gt; <a href="SafePrelude.html#t:IO">IO</a> a <a href="#v:-60--124--62-" class="selflink">#</a></p><p class="src"><a href="#v:some">some</a> :: <a href="SafePrelude.html#t:IO">IO</a> a -&gt; <a href="SafePrelude.html#t:IO">IO</a> [a] <a href="#v:some" class="selflink">#</a></p><p class="src"><a href="#v:many">many</a> :: <a href="SafePrelude.html#t:IO">IO</a> a
a concept from a branch of mathematics known as <em>category theory</em>.
From the perspective of a Haskell programmer, however, it is best to
think of a monad as an <em>abstract datatype</em> of actions.
Haskell's <code>do</code> expressions provide a convenient syntax for writing
monadic expressions.</p><p>Instances of <code><a href="SafePrelude.html#t:Monad">Monad</a></code> should satisfy the following laws:</p><ul><li><pre><code><a href="SafePrelude.html#v:return">return</a></code> a <code><a href="SafePrelude.html#v:-62--62--61-">&gt;&gt;=</a></code> k = k a</pre></li><li><pre>m <code><a href="SafePrelude.html#v:-62--62--61-">&gt;&gt;=</a></code> <code><a href="SafePrelude.html#v:return">return</a></code> = m</pre></li><li><pre>m <code><a href="SafePrelude.html#v:-62--62--61-">&gt;&gt;=</a></code> (x -&gt; k x <code><a href="SafePrelude.html#v:-62--62--61-">&gt;&gt;=</a></code> h) = (m <code><a href="SafePrelude.html#v:-62--62--61-">&gt;&gt;=</a></code> k) <code><a href="SafePrelude.html#v:-62--62--61-">&gt;&gt;=</a></code> h</pre></li></ul><p>Furthermore, the <code><a href="SafePrelude.html#t:Monad">Monad</a></code> and <code><a href="SafePrelude.html#t:Applicative">Applicative</a></code> operations should relate as follows:</p><ul><li><pre><code><a href="SafePrelude.html#v:pure">pure</a></code> = <code><a href="SafePrelude.html#v:return">return</a></code></pre></li><li><pre>(<code><a href="SafePrelude.html#v:-60--42--62-">&lt;*&gt;</a></code>) = <code><a href="SafePrelude.html#v:ap">ap</a></code></pre></li></ul><p>The above laws imply:</p><ul><li><pre><code><a href="SafePrelude.html#v:fmap">fmap</a></code> f xs = xs <code><a href="SafePrelude.html#v:-62--62--61-">&gt;&gt;=</a></code> <code><a href="SafePrelude.html#v:return">return</a></code> . f</pre></li><li><pre>(<code><a href="SafePrelude.html#v:-62--62-">&gt;&gt;</a></code>) = (<code><a href="SafePrelude.html#v:-42--62-">*&gt;</a></code>)</pre></li></ul><p>and that <code><a href="SafePrelude.html#v:pure">pure</a></code> and (<code><a href="SafePrelude.html#v:-60--42--62-">&lt;*&gt;</a></code>) satisfy the applicative functor laws.</p><p>The instances of <code><a href="SafePrelude.html#t:Monad">Monad</a></code> for lists, <code><a href="../base-4.9.0.0/Data-Maybe.html#v:Maybe">Maybe</a></code> and <code><a href="../base-4.9.0.0/System-IO.html#v:IO">IO</a></code>
defined in the <a href="../base-4.9.0.0/Prelude.html">Prelude</a> satisfy these laws.</p></div><div class="subs minimal"><p class="caption">Minimal complete definition</p><p class="src"><a href="SafePrelude.html#v:-62--62--61-">(&gt;&gt;=)</a></p></div><div class="subs instances"><p id="control.i:Monad" class="caption collapser" onclick="toggleSection('i:Monad')">Instances</p><div id="section.i:Monad" class="show"><table><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:Monad:Monad:1" class="instance expander" onclick="toggleSection('i:ic:Monad:Monad:1')"></span> <a href="SafePrelude.html#t:Monad">Monad</a> []</span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:Monad:Monad:1" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:-62--62--61-">(&gt;&gt;=)</a> :: [a] -&gt; (a -&gt; [b]) -&gt; [b] <a href="#v:-62--62--61-" class="selflink">#</a></p><p class="src"><a href="#v:-62--62-">(&gt;&gt;)</a> :: [a] -&gt; [b] -&gt; [b] <a href="#v:-62--62-" class="selflink">#</a></p><p class="src"><a href="#v:return">return</a> :: a -&gt; [a] <a href="#v:return" class="selflink">#</a></p><p class="src"><a href="#v:fail">fail</a> :: <a href="SafePrelude.html#t:String">String</a> -&gt; [a] <a href="#v:fail" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:Monad:Monad:2" class="instance expander" onclick="toggleSection('i:ic:Monad:Monad:2')"></span> <a href="SafePrelude.html#t:Monad">Monad</a> <a href="SafePrelude.html#t:Maybe">Maybe</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:Monad:Monad:2" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:-62--62--61-">(&gt;&gt;=)</a> :: <a href="SafePrelude.html#t:Maybe">Maybe</a> a -&gt; (a -&gt; <a href="SafePrelude.html#t:Maybe">Maybe</a> b) -&gt; <a href="SafePrelude.html#t:Maybe">Maybe</a> b <a href="#v:-62--62--61-" class="selflink">#</a></p><p class="src"><a href="#v:-62--62-">(&gt;&gt;)</a> :: <a href="SafePrelude.html#t:Maybe">Maybe</a> a -&gt; <a href="SafePrelude.html#t:Maybe">Maybe</a> b -&gt; <a href="SafePrelude.html#t:Maybe">Maybe</a> b <a href="#v:-62--62-" class="selflink">#</a></p><p class="src"><a href="#v:return">return</a> :: a -&gt; <a href="SafePrelude.html#t:Maybe">Maybe</a> a <a href="#v:return" class="selflink">#</a></p><p class="src"><a href="#v:fail">fail</a> :: <a href="SafePrelude.html#t:String">String</a> -&gt; <a href="SafePrelude.html#t:Maybe">Maybe</a> a <a href="#v:fail" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:Monad:Monad:3" class="instance expander" onclick="toggleSection('i:ic:Monad:Monad:3')"></span> <a href="SafePrelude.html#t:Monad">Monad</a> <a href="SafePrelude.html#t:IO">IO</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:Monad:Monad:3" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:-62--62--61-">(&gt;&gt;=)</a> :: <a href="SafePrelude.html#t:IO">IO</a> a -&gt; (a -&gt; <a href="SafePrelude.html#t:IO">IO</a> b) -&gt; <a href="SafePrelude.html#t:IO">IO</a> b <a href="#v:-62--62--61-" class="selflink">#</a></p><p class="src"><a href="#v:-62--62-">(&gt;&gt;)</a> :: <a href="SafePrelude.html#t:IO">IO</a> a -&gt; <a href="SafePrelude.html#t:IO">IO</a> b -&gt; <a href="SafePrelude.html#t:IO">IO</a> b <a href="#v:-62--62-" class="selflink">#</a></p><p class="src"><a href="#v:return">return</a> :: a -&gt; <a href="SafePrelude.html#t:IO">IO</a> a <a href="#v:return" class="selflink">#</a></p><p class="src"><a href="#v:fail">fail</a> :: <a href="SafePrelude.html#t:String">String</a> -&gt; <a href="SafePrelude.html#t:IO">IO</a> a <a href="#v:fail" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:Monad:Monad
Any monad built by applying a sequence of monad transformers to the
<code><a href="SafePrelude.html#t:IO">IO</a></code> monad will be an instance of this class.</p><p>Instances should satisfy the following laws, which state that <code><a href="SafePrelude.html#v:liftIO">liftIO</a></code>
is a transformer of monads:</p><ul><li><pre><code><a href="SafePrelude.html#v:liftIO">liftIO</a></code> . <code><a href="SafePrelude.html#v:return">return</a></code> = <code><a href="SafePrelude.html#v:return">return</a></code></pre></li><li><pre><code><a href="SafePrelude.html#v:liftIO">liftIO</a></code> (m &gt;&gt;= f) = <code><a href="SafePrelude.html#v:liftIO">liftIO</a></code> m &gt;&gt;= (<code><a href="SafePrelude.html#v:liftIO">liftIO</a></code> . f)</pre></li></ul></div><div class="subs instances"><p id="control.i:MonadIO" class="caption collapser" onclick="toggleSection('i:MonadIO')">Instances</p><div id="section.i:MonadIO" class="show"><table><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:MonadIO:MonadIO:1" class="instance expander" onclick="toggleSection('i:ic:MonadIO:MonadIO:1')"></span> <a href="SafePrelude.html#t:MonadIO">MonadIO</a> <a href="SafePrelude.html#t:IO">IO</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:MonadIO:MonadIO:1" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:liftIO">liftIO</a> :: <a href="SafePrelude.html#t:IO">IO</a> a -&gt; <a href="SafePrelude.html#t:IO">IO</a> a <a href="#v:liftIO" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:MonadIO:MonadIO:2" class="instance expander" onclick="toggleSection('i:ic:MonadIO:MonadIO:2')"></span> (<a href="../mtl-2.2.1/Control-Monad-Error-Class.html#t:Error">Error</a> e, <a href="SafePrelude.html#t:MonadIO">MonadIO</a> m) =&gt; <a href="SafePrelude.html#t:MonadIO">MonadIO</a> (<a href="../mtl-2.2.1/Control-Monad-Error.html#t:ErrorT">ErrorT</a> e m)</span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:MonadIO:MonadIO:2" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:liftIO">liftIO</a> :: <a href="SafePrelude.html#t:IO">IO</a> a -&gt; <a href="../mtl-2.2.1/Control-Monad-Error.html#t:ErrorT">ErrorT</a> e m a <a href="#v:liftIO" class="selflink">#</a></p></div></div></td></tr></table></div></div></div><div class="top"><p class="src"><span class="keyword">class</span> <a id="t:MonadTrans" class="def">MonadTrans</a> t <span class="keyword">where</span> <a href="#t:MonadTrans" class="selflink">#</a></p><div class="doc"><p>The class of monad transformers. Instances should satisfy the
following laws, which state that <code><a href="SafePrelude.html#v:lift">lift</a></code> is a monad transformation:</p><ul><li><pre><code><a href="SafePrelude.html#v:lift">lift</a></code> . <code><a href="SafePrelude.html#v:return">return</a></code> = <code><a href="SafePrelude.html#v:return">return</a></code></pre></li><li><pre><code><a href="SafePrelude.html#v:lift">lift</a></code> (m &gt;&gt;= f) = <code><a href="SafePrelude.html#v:lift">lift</a></code> m &gt;&gt;= (<code><a href="SafePrelude.html#v:lift">lift</a></code> . f)</pre></li></ul></div><div class="subs instances"><p id="control.i:MonadTrans" class="caption collapser" onclick="toggleSection('i:MonadTrans')">Instances</p><div id="section.i:MonadTrans" class="show"><table><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:MonadTrans:MonadTrans:1" class="instance expander" onclick="toggleSection('i:ic:MonadTrans:MonadTrans:1')"></span> <a href="SafePrelude.html#t:MonadTrans">MonadTrans</a> (<a href="../mtl-2.2.1/Control-Monad-Error.html#t:ErrorT">ErrorT</a> e)</span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:MonadTrans:MonadTrans:1" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:lift">lift</a> :: <a href="SafePrelude.html#t:Monad">Monad</a> m =&gt; m a -&gt; <a href="../mtl-2.2.1/Control-Monad-Error.html#t:ErrorT">ErrorT</a> e m a <a href="#v:lift" class="selflink">#</a></p></div></div></td></tr></table></div></div></div><div class="top"><p class="src"><span class="keyword">class</span> <a href="SafePrelude.html#t:Monad">Monad</a> m =&gt; <a id="t:MonadReader" class="def">MonadReader</a> r m | m -&gt; r <span class="keyword">where</span> <a href="#t:MonadReader" class="selflink">#</a></p><div class="doc"><p>See examples in <a href="../mtl-2.2.1/Control-Monad-Reader.html">Control.Monad.Reader</a>.
Note, the partially applied function type <code>(-&gt;) r</code> is a simple reader monad.
See the <code>instance</code> declaration below.</p></div><div class="subs minimal"><p class="caption">Minimal complete definition</p><p class="src">(<a href="SafePrelude.html#v:ask">ask</a> | <a href="SafePrelude.html#v:reader">reader</a>), <a href="SafePrelude.html#v:local">local</a></p></div><div class="subs instances"><p id="control.i:MonadReader" class="caption collapser" onclick="toggleSection('i:MonadReader')">Instances</p><div id="section.i:MonadReader" class="show"><table><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:MonadReader:MonadReader:1" class="instance expander" onclick="toggleSection('i:ic:MonadReader:MonadReader:1')"></span> <a href="SafePrelude.html#t:MonadReader">MonadReader</a> r m =&gt; <a href="SafePrelude.html#t:MonadReader">MonadReader</a> r (<a href="../transformers-0.5.2.0/Control-Monad-Trans-Maybe.html#t:MaybeT">MaybeT</a> m)</span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:MonadReader:MonadReader:1" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:ask">ask</a> :: <a href="../transformers-0.5.2.0/Control-Monad-Trans-Maybe.html#t:MaybeT">MaybeT</a> m r <a href="#v:ask" class="selflink">#</a></p><p class="src"><a href="#v:local">local</a> :: (r -&gt; r) -&gt; <a href="../transformers-0.5.2.0/Control-Monad-Trans-Maybe.html#t:MaybeT">MaybeT</a> m a -&gt; <a href="../transformers-0.5.2.0/Control-Monad-Trans-Maybe.html#t:MaybeT">MaybeT</a> m a <a href="#v:local" class="selflink">#</a></p><p class="src"><a href="#v:reader">reader</a> :: (r -&gt; a) -&gt; <a href="../transformers-0.5.2.0/Control-Monad-Trans-Maybe.html#t:MaybeT">MaybeT</a> m a <a href="#v:reader" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:MonadReader:MonadReader:2" class="instance expander" onclick="toggleSection('i:ic:MonadReader:MonadReader:2')"></span> <a href="SafePrelude.html#t:MonadReader">MonadReader</a> r m =&gt; <a href="SafePrelude.html#t:MonadReader">MonadReader</a> r (<a href="../mtl-2.2.1/Control-Monad-List.html#t:ListT">ListT</a> m)</span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:MonadReader:MonadReader:2" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:ask">ask</a> :: <a href="../mtl-2.2.1/Control-Monad-List.html#t:ListT">ListT</a> m r <a href="#v:ask" class="selflink">#</a></p><p class="src"><a href="#v:local">local</a> :: (r -&gt; r) -&gt; <a href="../mtl-2.2.1/Control-Monad-List.html#t:ListT">ListT</a> m a -&gt; <a href="../mtl-2.2.1/Control-Monad-List.html#t:ListT">ListT</a> m a <a href="#v:local" class="selflink">#</a></p><p class="src"><a href="#v:reader">reader</a> :: (r -&gt; a) -&gt; <a href="../mtl-2.2.1/Control-Monad-List.html#t:ListT">ListT</a> m a <a href="#v:reader" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:MonadReader:MonadReader:3" class="instance expander" onclick="toggleSection('i:ic:MonadReader:MonadReader:3')"></span> <a href="SafePrelude.html#t:MonadReader">MonadReader</a> r ((-&gt;) r)</span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:MonadReader:MonadReader:3" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:ask">ask</a> :: r -&gt; r <a href="#v:ask" class="selflink">#</a></p><p class="src"><a href="#v:local">local</a> :: (r -&gt; r) -&gt; (r -&gt; a) -&gt; r -&gt; a <a href="#v:local" class="selflink">#</a></p><p class="src"><a href="#v:reader">reader</a> :: (r -&gt; a) -&gt; r -&gt; a <a href="#v:reader" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:MonadReader:MonadReader:4" class="instance expander" onclick="toggleSection('i:ic:MonadReader:MonadReader:4')"></span> (<a href="SafePrelude.html#t:Monoid">Monoid</a> w, <a href="Sa
computation.</p></div><div class="subs minimal"><p class="caption">Minimal complete definition</p><p class="src"><a href="../exceptions-0.8.3/Control-Monad-Catch.html#v:throwM">throwM</a></p></div><div class="subs instances"><p id="control.i:MonadThrow" class="caption collapser" onclick="toggleSection('i:MonadThrow')">Instances</p><div id="section.i:MonadThrow" class="show"><table><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:MonadThrow:MonadThrow:1" class="instance expander" onclick="toggleSection('i:ic:MonadThrow:MonadThrow:1')"></span> <a href="SafePrelude.html#t:MonadThrow">MonadThrow</a> []</span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:MonadThrow:MonadThrow:1" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:throwM">throwM</a> :: <a href="SafePrelude.html#t:Exception">Exception</a> e =&gt; e -&gt; [a] <a href="#v:throwM" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:MonadThrow:MonadThrow:2" class="instance expander" onclick="toggleSection('i:ic:MonadThrow:MonadThrow:2')"></span> <a href="SafePrelude.html#t:MonadThrow">MonadThrow</a> <a href="SafePrelude.html#t:Maybe">Maybe</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:MonadThrow:MonadThrow:2" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:throwM">throwM</a> :: <a href="SafePrelude.html#t:Exception">Exception</a> e =&gt; e -&gt; <a href="SafePrelude.html#t:Maybe">Maybe</a> a <a href="#v:throwM" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:MonadThrow:MonadThrow:3" class="instance expander" onclick="toggleSection('i:ic:MonadThrow:MonadThrow:3')"></span> <a href="SafePrelude.html#t:MonadThrow">MonadThrow</a> <a href="SafePrelude.html#t:IO">IO</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:MonadThrow:MonadThrow:3" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:throwM">throwM</a> :: <a href="SafePrelude.html#t:Exception">Exception</a> e =&gt; e -&gt; <a href="SafePrelude.html#t:IO">IO</a> a <a href="#v:throwM" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:MonadThrow:MonadThrow:4" class="instance expander" onclick="toggleSection('i:ic:MonadThrow:MonadThrow:4')"></span> <a href="SafePrelude.html#t:MonadThrow">MonadThrow</a> <a href="../template-haskell-2.11.0.0/Language-Haskell-TH-Syntax.html#t:Q">Q</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:MonadThrow:MonadThrow:4" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:throwM">throwM</a> :: <a href="SafePrelude.html#t:Exception">Exception</a> e =&gt; e -&gt; <a href="../template-haskell-2.11.0.0/Language-Haskell-TH-Syntax.html#t:Q">Q</a> a <a href="#v:throwM" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:MonadThrow:MonadThrow:5" class="instance expander" onclick="toggleSection('i:ic:MonadThrow:MonadThrow:5')"></span> <a href="SafePrelude.html#t:MonadThrow">MonadThrow</a> <a href="../base-4.9.0.0/GHC-Conc.html#t:STM">STM</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:MonadThrow:MonadThrow:5" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:throwM">throwM</a> :: <a href="SafePrelude.html#t:Exception">Exception</a> e =&gt; e -&gt; <a href="../base-4.9.0.0/GHC-Conc.html#t:STM">STM</a> a <a href="#v:throwM" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:MonadThrow:MonadThrow:6" class=
instance of the <code>Exception</code> class. The simplest case is a new exception
type directly below the root:</p><pre>data MyException = ThisException | ThatException
deriving (Show, Typeable)
instance Exception MyException</pre><p>The default method definitions in the <code>Exception</code> class do what we need
in this case. You can now throw and catch <code>ThisException</code> and
<code>ThatException</code> as exceptions:</p><pre>*Main&gt; throw ThisException `catch` \e -&gt; putStrLn (&quot;Caught &quot; ++ show (e :: MyException))
Caught ThisException
</pre><p>In more complicated examples, you may wish to define a whole hierarchy
of exceptions:</p><pre>---------------------------------------------------------------------
-- Make the root exception type for all the exceptions in a compiler
data SomeCompilerException = forall e . Exception e =&gt; SomeCompilerException e
deriving Typeable
instance Show SomeCompilerException where
show (SomeCompilerException e) = show e
instance Exception SomeCompilerException
compilerExceptionToException :: Exception e =&gt; e -&gt; SomeException
compilerExceptionToException = toException . SomeCompilerException
compilerExceptionFromException :: Exception e =&gt; SomeException -&gt; Maybe e
compilerExceptionFromException x = do
SomeCompilerException a &lt;- fromException x
cast a
---------------------------------------------------------------------
-- Make a subhierarchy for exceptions in the frontend of the compiler
data SomeFrontendException = forall e . Exception e =&gt; SomeFrontendException e
deriving Typeable
instance Show SomeFrontendException where
show (SomeFrontendException e) = show e
instance Exception SomeFrontendException where
toException = compilerExceptionToException
fromException = compilerExceptionFromException
frontendExceptionToException :: Exception e =&gt; e -&gt; SomeException
frontendExceptionToException = toException . SomeFrontendException
frontendExceptionFromException :: Exception e =&gt; SomeException -&gt; Maybe e
frontendExceptionFromException x = do
SomeFrontendException a &lt;- fromException x
cast a
---------------------------------------------------------------------
-- Make an exception type for a particular frontend compiler exception
data MismatchedParentheses = MismatchedParentheses
deriving (Typeable, Show)
instance Exception MismatchedParentheses where
toException = frontendExceptionToException
fromException = frontendExceptionFromException</pre><p>We can now catch a <code>MismatchedParentheses</code> exception as
<code>MismatchedParentheses</code>, <code>SomeFrontendException</code> or
<code>SomeCompilerException</code>, but not other types, e.g. <code>IOException</code>:</p><pre>*Main&gt; throw MismatchedParentheses <code>catch</code> e -&gt; putStrLn (&quot;Caught &quot; ++ show (e :: MismatchedParentheses))
Caught MismatchedParentheses
*Main&gt; throw MismatchedParentheses <code>catch</code> e -&gt; putStrLn (&quot;Caught &quot; ++ show (e :: SomeFrontendException))
Caught MismatchedParentheses
*Main&gt; throw MismatchedParentheses <code>catch</code> e -&gt; putStrLn (&quot;Caught &quot; ++ show (e :: SomeCompilerException))
Caught MismatchedParentheses
*Main&gt; throw MismatchedParentheses <code>catch</code> e -&gt; putStrLn (&quot;Caught &quot; ++ show (e :: IOException))
*** Exception: MismatchedParentheses
</pre></div><div class="subs minimal"><p class="caption">Minimal complete definition</p><p class="src">Nothing</p></div><div class="subs instances"><p id="control.i:Exception" class="caption collapser" onclick="toggleSection('i:Exception')">Instances</p><div id="section.i:Exception" class="show"><table><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:Exception:Exception:1" class="instance expander" onclick="toggleSection('i:ic:Exception:Exception:1')"></span> <a href="SafePrelude.html#t:Exception">Exception</a> <a href="../base-4.9.0.0/Data-Void.html#t:Void">Void</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:Exception:Exception:1" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:toException">toException</a> :: <a href="../base-4.9.0.0/Data-Void.html#t:Void">Void</a> -&gt; <a href="SafePrelude.html#t:SomeException">SomeException</a> <a href="#v:toException" class="selflink">#</a></p><p class="src"><a href="#v:fromException">fromException</a> :: <a href="SafePrelude.html#t:SomeException">SomeException</a> -&gt; <a href="SafePrelude.html#t:Maybe">Maybe</a> <a href="../base-4.9.0.0/Data-Void.html#t:Void">Void</a> <a href="#v:fromException" class="selflink">#</a></p><p class="src"><a href="#v:displayException">displayException</a> :: <a href="../base-4.9.0.0/Data-Void.html#t:Void">Void</a> -&gt; <a href="SafePrelude.html#t:String">String</a> <a href="#v:displayException" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:Exception:Exception:2" class="instance expander" onclick="toggleSection('i:ic:Exception:Exception:2')"></span> <a href="SafePrelude.html#t:Exception">Exception</a> <a href="../base-4.9.0.0/Control-Exception-Base.html#t:BlockedIndefinitelyOnMVar">BlockedIndefinitelyOnMVar</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:Exception:Exception:2" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:toException">toException</a> :: <a href="../base-4.9.0.0/Control-Exception-Base.html#t:BlockedIndefinitelyOnMVar">BlockedIndefinitelyOnMVar</a> -&gt; <a href="SafePrelude.html#t:SomeException">SomeException</a> <a href="#v:toException" class="selflink">#</a></p><p class="src"><a href="#v:fromException">fromException</a> :: <a href="SafePrelude.html#t:SomeException">SomeException</a> -&gt; <a href="SafePrelude.html#t:Maybe">Maybe</a> <a href="../base-4.9.0.0/Control-Exception-Base.html#t:BlockedIndefinitelyOnMVar">BlockedIndefinitelyOnMVar</a> <a href="#v:fromException" class="selflink">#</a></p><p class="src"><a href="#v:displayException">displayException</a> :: <a href="../base-4.9.0.0/Control-Exception-Base.html#t:BlockedIndefinitelyOnMVar">BlockedIndefinitelyOnMVar</a> -&gt; <a href="SafePrelude.html#t:String">String</a> <a href="#v:displayException" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:Exception:Exception:3" class="instance expander" onclick="toggleSection('i:ic:Exception:Exception:3')"></span> <a href="SafePrelude.html#t:Exception">Exception</a> <a href="../base-4.9.0.0/Control-Exception-Base.html#t:BlockedIndefinitelyOnSTM">BlockedIndefinitelyOnSTM</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:Exception:Exception:3" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:toException">toException</a> :: <a href="../base-4.9.0.0/Control-Exception-Base.html#t:BlockedIndefinitelyOnSTM">BlockedIndefinitelyOnSTM</a> -&gt; <a href="SafePrelude.html#t:SomeException">SomeException</a> <a href="#v:toException" class="selflink">#</a></p><p class="src"><a href="#v:fromException">fromException</a> :: <a href="SafePrelude.html#t:SomeException">SomeException</a> -&gt; <a href="SafePrelude.html#t:Maybe">Maybe</a> <a href="../base-4.9.0.0/
exceptions which were thrown by <code><a href="../exceptions-0.8.3/Control-Monad-Catch.html#v:throwM">throwM</a></code>.</p><p>Instances should obey the following law:</p><pre>catch (throwM e) f = f e</pre><p>Note that the ability to catch an exception does <em>not</em> guarantee that we can
deal with all possible exit points from a computation. Some monads, such as
continuation-based stacks, allow for more than just a success/failure
strategy, and therefore <code>catch</code> <em>cannot</em> be used by those monads to properly
implement a function such as <code>finally</code>. For more information, see
<code><a href="SafePrelude.html#t:MonadMask">MonadMask</a></code>.</p></div><div class="subs minimal"><p class="caption">Minimal complete definition</p><p class="src"><a href="../exceptions-0.8.3/Control-Monad-Catch.html#v:catch">catch</a></p></div><div class="subs instances"><p id="control.i:MonadCatch" class="caption collapser" onclick="toggleSection('i:MonadCatch')">Instances</p><div id="section.i:MonadCatch" class="show"><table><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:MonadCatch:MonadCatch:1" class="instance expander" onclick="toggleSection('i:ic:MonadCatch:MonadCatch:1')"></span> <a href="SafePrelude.html#t:MonadCatch">MonadCatch</a> <a href="SafePrelude.html#t:IO">IO</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:MonadCatch:MonadCatch:1" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:catch">catch</a> :: <a href="SafePrelude.html#t:Exception">Exception</a> e =&gt; <a href="SafePrelude.html#t:IO">IO</a> a -&gt; (e -&gt; <a href="SafePrelude.html#t:IO">IO</a> a) -&gt; <a href="SafePrelude.html#t:IO">IO</a> a <a href="#v:catch" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:MonadCatch:MonadCatch:2" class="instance expander" onclick="toggleSection('i:ic:MonadCatch:MonadCatch:2')"></span> <a href="SafePrelude.html#t:MonadCatch">MonadCatch</a> <a href="../base-4.9.0.0/GHC-Conc.html#t:STM">STM</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:MonadCatch:MonadCatch:2" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:catch">catch</a> :: <a href="SafePrelude.html#t:Exception">Exception</a> e =&gt; <a href="../base-4.9.0.0/GHC-Conc.html#t:STM">STM</a> a -&gt; (e -&gt; <a href="../base-4.9.0.0/GHC-Conc.html#t:STM">STM</a> a) -&gt; <a href="../base-4.9.0.0/GHC-Conc.html#t:STM">STM</a> a <a href="#v:catch" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:MonadCatch:MonadCatch:3" class="instance expander" onclick="toggleSection('i:ic:MonadCatch:MonadCatch:3')"></span> (~) <a href="../base-4.9.0.0/Data-Kind.html#t:-42-">*</a> e <a href="SafePrelude.html#t:SomeException">SomeException</a> =&gt; <a href="SafePrelude.html#t:MonadCatch">MonadCatch</a> (<a href="SafePrelude.html#t:Either">Either</a> e)</span></td><td class="doc"><p><em>Since: 0.8.3</em></p></td></tr><tr><td colspan="2"><div id="section.i:ic:MonadCatch:MonadCatch:3" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:catch">catch</a> :: <a href="SafePrelude.html#t:Exception">Exception</a> e =&gt; <a href="SafePrelude.html#t:Either">Either</a> e a -&gt; (e -&gt; <a href="SafePrelude.html#t:Either">Either</a> e a) -&gt; <a href="SafePrelude.html#t:Either">Either</a> e a <a href="#v:catch" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:MonadCatch:MonadCatch:4" class="instance expander" onclick="toggleSection('i:ic:MonadCatch:MonadCatch:4')"></span> <a href="SafePrelude.html#t:MonadCatch">MonadCatch</a> m =&gt; <a href="SafePrelude.html#t:MonadCatch">MonadCatch</a> (<a href="../mtl-2.2.1/Control-Monad-List.html#t:ListT">ListT</a> m)</span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:MonadCatch:MonadCatch:4" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:catch">catch</a> :: <a href="SafePrelude.html#t:Exception">Exception</a> e =&gt; <a href="../mtl-2.2.1/Control-Monad-List.html#t:ListT">ListT</a> m a -&gt; (e -&gt; <a href="../mtl-2.2.1/Control-Monad-List.html#t:ListT">ListT</a> m a) -&gt; <a href="../mtl-2.2.1/Control-Monad-List.html#t:ListT">ListT</a> m a <a href="#v:catch" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clear
possible exit points from a computation, and to mask asynchronous
exceptions. Continuation-based monads, and stacks such as <code>ErrorT e IO</code>
which provide for multiple failure modes, are invalid instances of this
class.</p><p>Note that this package <em>does</em> provide a <code>MonadMask</code> instance for <code>CatchT</code>.
This instance is <em>only</em> valid if the base monad provides no ability to
provide multiple exit. For example, <code>IO</code> or <code>Either</code> would be invalid base
monads, but <code>Reader</code> or <code>State</code> would be acceptable.</p><p>Instances should ensure that, in the following code:</p><pre>f `finally` g</pre><p>The action <code>g</code> is called regardless of what occurs within <code>f</code>, including
async exceptions.</p></div><div class="subs minimal"><p class="caption">Minimal complete definition</p><p class="src"><a href="../exceptions-0.8.3/Control-Monad-Catch.html#v:mask">mask</a>, <a href="../exceptions-0.8.3/Control-Monad-Catch.html#v:uninterruptibleMask">uninterruptibleMask</a></p></div><div class="subs instances"><p id="control.i:MonadMask" class="caption collapser" onclick="toggleSection('i:MonadMask')">Instances</p><div id="section.i:MonadMask" class="show"><table><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:MonadMask:MonadMask:1" class="instance expander" onclick="toggleSection('i:ic:MonadMask:MonadMask:1')"></span> <a href="SafePrelude.html#t:MonadMask">MonadMask</a> <a href="SafePrelude.html#t:IO">IO</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:MonadMask:MonadMask:1" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:mask">mask</a> :: ((<span class="keyword">forall</span> a. <a href="SafePrelude.html#t:IO">IO</a> a -&gt; <a href="SafePrelude.html#t:IO">IO</a> a) -&gt; <a href="SafePrelude.html#t:IO">IO</a> b) -&gt; <a href="SafePrelude.html#t:IO">IO</a> b <a href="#v:mask" class="selflink">#</a></p><p class="src"><a href="#v:uninterruptibleMask">uninterruptibleMask</a> :: ((<span class="keyword">forall</span> a. <a href="SafePrelude.html#t:IO">IO</a> a -&gt; <a href="SafePrelude.html#t:IO">IO</a> a) -&gt; <a href="SafePrelude.html#t:IO">IO</a> b) -&gt; <a href="SafePrelude.html#t:IO">IO</a> b <a href="#v:uninterruptibleMask" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:MonadMask:MonadMask:2" class="instance expander" onclick="toggleSection('i:ic:MonadMask:MonadMask:2')"></span> (~) <a href="../base-4.9.0.0/Data-Kind.html#t:-42-">*</a> e <a href="SafePrelude.html#t:SomeException">SomeException</a> =&gt; <a href="SafePrelude.html#t:MonadMask">MonadMask</a> (<a href="SafePrelude.html#t:Either">Either</a> e)</span></td><td class="doc"><p><em>Since: 0.8.3</em></p></td></tr><tr><td colspan="2"><div id="section.i:ic:MonadMask:MonadMask:2" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:mask">mask</a> :: ((<span class="keyword">forall</span> a. <a href="SafePrelude.html#t:Either">Either</a> e a -&gt; <a href="SafePrelude.html#t:Either">Either</a> e a) -&gt; <a href="SafePrelude.html#t:Either">Either</a> e b) -&gt; <a href="SafePrelude.html#t:Either">Either</a> e b <a href="#v:mask" class="selflink">#</a></p><p class="src"><a href="#v:uninterruptibleMask">uninterruptibleMask</a> :: ((<span class="keyword">forall</span> a. <a href="SafePrelude.html#t:Either">Either</a> e a -&gt; <a href="SafePrelude.html#t:Either">Either</a> e a) -&gt; <a href="SafePrelude.html#t:Either">Either</a> e b) -&gt; <a href="SafePrelude.html#t:Either">Either</a> e b <a href="#v:uninterruptibleMask" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:MonadMask:MonadMask:3" class="instance expander" onclick="toggleSection('i:ic:MonadMask:MonadMask:3')"></span> <a href="SafePrelude.html#t:MonadMask">MonadMask</a> m =&gt; <a href="SafePrelude.html#t:MonadMask">MonadMask</a> (<a href="../mtl-2.2.1/Control-Monad-State-Lazy.html#t:StateT">StateT</a> s m)</span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:MonadMask:MonadMask:3" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:mask">mask</a> :: ((<span class="keyword">forall</span> a. <a href="../mtl-2.2.1/Control-Monad-State-Lazy.html#t:StateT">StateT</a> s m a -&gt; <a href="../mtl-2.2.1/Control-Monad-State-Lazy.html#t:StateT">StateT</a> s m a) -&gt; <a href="../mtl-2.2.1/Control-Monad-State-Lazy.html#t:StateT">StateT</a> s m b) -&gt; <a href="../mtl-2.2.1/Control-Monad-State-Lazy.html#t:StateT">StateT</a> s m b <a href="#v:mask" class="selflink">#<
foldMap f Empty = mempty
foldMap f (Leaf x) = f x
foldMap f (Node l k r) = foldMap f l `mappend` f k `mappend` foldMap f r</pre><p>This is suitable even for abstract types, as the monoid is assumed
to satisfy the monoid laws. Alternatively, one could define <code>foldr</code>:</p><pre>instance Foldable Tree where
foldr f z Empty = z
foldr f z (Leaf x) = f x z
foldr f z (Node l k r) = foldr f (f k (foldr f z r)) l</pre><p><code>Foldable</code> instances are expected to satisfy the following laws:</p><pre>foldr f z t = appEndo (foldMap (Endo . f) t ) z</pre><pre>foldl f z t = appEndo (getDual (foldMap (Dual . Endo . flip f) t)) z</pre><pre>fold = foldMap id</pre><p><code>sum</code>, <code>product</code>, <code>maximum</code>, and <code>minimum</code> should all be essentially
equivalent to <code>foldMap</code> forms, such as</p><pre>sum = getSum . foldMap Sum</pre><p>but may be less defined.</p><p>If the type is also a <code><a href="SafePrelude.html#t:Functor">Functor</a></code> instance, it should satisfy</p><pre>foldMap f = fold . fmap f</pre><p>which implies that</p><pre>foldMap f . fmap g = foldMap (f . g)</pre></div><div class="subs minimal"><p class="caption">Minimal complete definition</p><p class="src"><a href="SafePrelude.html#v:foldMap">foldMap</a> | <a href="SafePrelude.html#v:foldr">foldr</a></p></div><div class="subs instances"><p id="control.i:Foldable" class="caption collapser" onclick="toggleSection('i:Foldable')">Instances</p><div id="section.i:Foldable" class="show"><table><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:Foldable:Foldable:1" class="instance expander" onclick="toggleSection('i:ic:Foldable:Foldable:1')"></span> <a href="SafePrelude.html#t:Foldable">Foldable</a> []</span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:Foldable:Foldable:1" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:fold">fold</a> :: <a href="SafePrelude.html#t:Monoid">Monoid</a> m =&gt; [m] -&gt; m <a href="#v:fold" class="selflink">#</a></p><p class="src"><a href="#v:foldMap">foldMap</a> :: <a href="SafePrelude.html#t:Monoid">Monoid</a> m =&gt; (a -&gt; m) -&gt; [a] -&gt; m <a href="#v:foldMap" class="selflink">#</a></p><p class="src"><a href="#v:foldr">foldr</a> :: (a -&gt; b -&gt; b) -&gt; b -&gt; [a] -&gt; b <a href="#v:foldr" class="selflink">#</a></p><p class="src"><a href="#v:foldr-39-">foldr'</a> :: (a -&gt; b -&gt; b) -&gt; b -&gt; [a] -&gt; b <a href="#v:foldr-39-" class="selflink">#</a></p><p class="src"><a href="#v:foldl">foldl</a> :: (b -&gt; a -&gt; b) -&gt; b -&gt; [a] -&gt; b <a href="#v:foldl" class="selflink">#</a></p><p class="src"><a href="#v:foldl-39-">foldl'</a> :: (b -&gt; a -&gt; b) -&gt; b -&gt; [a] -&gt; b <a href="#v:foldl-39-" class="selflink">#</a></p><p class="src"><a href="#v:foldr1">foldr1</a> :: (a -&gt; a -&gt; a) -&gt; [a] -&gt; a <a href="#v:foldr1" class="selflink">#</a></p><p class="src"><a href="#v:foldl1">foldl1</a> :: (a -&gt; a -&gt; a) -&gt; [a] -&gt; a <a href="#v:foldl1" class="selflink">#</a></p><p class="src"><a href="#v:toList">toList</a> :: [a] -&gt; [a] <a href="#v:toList" class="selflink">#</a></p><p class="src"><a href="#v:null">null</a> :: [a] -&gt; <a href="SafePrelude.html#t:Bool">Bool</a> <a href="#v:null" class="selflink">#</a></p><p class="src"><a href="#v:length">length</a> :: [a] -&gt; <a href="SafePrelude.html#t:Int">Int</a> <a href="#v:length" class="selflink">#</a></p><p class="src"><a href="#v:elem">elem</a> :: <a href="SafePrelude.html#t:Eq">Eq</a> a =&gt; a -&gt; [a] -&gt; <a href="SafePrelude.html#t:Bool">Bool</a> <a href="#v:elem" class="selflink">#</a></p><p class="src"><a href="#v:maximum">maximum</a> :: <a href="SafePrelude.html#t:Ord">Ord</a> a =&gt; [a] -&gt; a <a href="#v:maximum" class="selflink">#</a></p><p class="src"><a href="#v:minimum">minimum</a> :: <a href="SafePrelude.html#t:Ord">Ord</a> a =&gt; [a] -&gt; a <a href="#v:minimum" class="selflink">#</a></p><p class="src"><a href="#v:sum">sum</a> :: <a href="SafePrelude.html#t:Num">Num</a> a =&gt; [a] -&gt; a <a href="#v:sum" class="selflink">#</a></p><p class="src"><a href="#v:product">product</a> :: <a href="SafePrelude.html#t:Num">Num</a> a =&gt; [a] -&gt; a <a href="#v:product" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:Foldable:Foldable:2" class="instance expander" onclick="toggleSection('i:ic:Foldable:Foldable:2')"></span> <a href="SafePrelude.html#t:Foldable">Foldable</a> <a href="SafePrelude.html#t:Maybe">Maybe</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:Foldable:Foldable:2" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:fold">fold</a> ::
optimized for structures that are similar to cons-lists, because there
is no general way to do better.</p></div></div><div class="top"><p class="src"><a id="v:length" class="def">length</a> :: <a href="SafePrelude.html#t:Foldable">Foldable</a> t =&gt; <span class="keyword">forall</span> a. t a -&gt; <a href="SafePrelude.html#t:Int">Int</a> <a href="#v:length" class="selflink">#</a></p><div class="doc"><p>Returns the size/length of a finite structure as an <code><a href="SafePrelude.html#t:Int">Int</a></code>. The
default implementation is optimized for structures that are similar to
cons-lists, because there is no general way to do better.</p></div></div><div class="top"><p class="src"><a id="v:elem" class="def">elem</a> :: <a href="SafePrelude.html#t:Foldable">Foldable</a> t =&gt; <span class="keyword">forall</span> a. <a href="SafePrelude.html#t:Eq">Eq</a> a =&gt; a -&gt; t a -&gt; <a href="SafePrelude.html#t:Bool">Bool</a> <a href="#v:elem" class="selflink">#</a></p><div class="doc"><p>Does the element occur in the structure?</p></div></div><div class="top"><p class="src"><span class="keyword">class</span> (<a href="SafePrelude.html#t:Functor">Functor</a> t, <a href="SafePrelude.html#t:Foldable">Foldable</a> t) =&gt; <a id="t:Traversable" class="def">Traversable</a> t <span class="keyword">where</span> <a href="#t:Traversable" class="selflink">#</a></p><div class="doc"><p>Functors representing data structures that can be traversed from
left to right.</p><p>A definition of <code><a href="SafePrelude.html#v:traverse">traverse</a></code> must satisfy the following laws:</p><dl><dt><em>naturality</em></dt><dd><code>t . <code><a href="SafePrelude.html#v:traverse">traverse</a></code> f = <code><a href="SafePrelude.html#v:traverse">traverse</a></code> (t . f)</code>
for every applicative transformation <code>t</code></dd><dt><em>identity</em></dt><dd><code><code><a href="SafePrelude.html#v:traverse">traverse</a></code> Identity = Identity</code></dd><dt><em>composition</em></dt><dd><code><code><a href="SafePrelude.html#v:traverse">traverse</a></code> (Compose . <code><a href="SafePrelude.html#v:fmap">fmap</a></code> g . f) = Compose . <code><a href="SafePrelude.html#v:fmap">fmap</a></code> (<code><a href="SafePrelude.html#v:traverse">traverse</a></code> g) . <code><a href="SafePrelude.html#v:traverse">traverse</a></code> f</code></dd></dl><p>A definition of <code><a href="SafePrelude.html#v:sequenceA">sequenceA</a></code> must satisfy the following laws:</p><dl><dt><em>naturality</em></dt><dd><code>t . <code><a href="SafePrelude.html#v:sequenceA">sequenceA</a></code> = <code><a href="SafePrelude.html#v:sequenceA">sequenceA</a></code> . <code><a href="SafePrelude.html#v:fmap">fmap</a></code> t</code>
for every applicative transformation <code>t</code></dd><dt><em>identity</em></dt><dd><code><code><a href="SafePrelude.html#v:sequenceA">sequenceA</a></code> . <code><a href="SafePrelude.html#v:fmap">fmap</a></code> Identity = Identity</code></dd><dt><em>composition</em></dt><dd><code><code><a href="SafePrelude.html#v:sequenceA">sequenceA</a></code> . <code><a href="SafePrelude.html#v:fmap">fmap</a></code> Compose = Compose . <code><a href="SafePrelude.html#v:fmap">fmap</a></code> <code><a href="SafePrelude.html#v:sequenceA">sequenceA</a></code> . <code><a href="SafePrelude.html#v:sequenceA">sequenceA</a></code></code></dd></dl><p>where an <em>applicative transformation</em> is a function</p><pre>t :: (Applicative f, Applicative g) =&gt; f a -&gt; g a</pre><p>preserving the <code><a href="SafePrelude.html#t:Applicative">Applicative</a></code> operations, i.e.</p><ul><li><pre>t (<code><a href="SafePrelude.html#v:pure">pure</a></code> x) = <code><a href="SafePrelude.html#v:pure">pure</a></code> x</pre></li><li><pre>t (x <code><a href="SafePrelude.html#v:-60--42--62-">&lt;*&gt;</a></code> y) = t x <code><a href="SafePrelude.html#v:-60--42--62-">&lt;*&gt;</a></code> t y</pre></li></ul><p>and the identity functor <code>Identity</code> and composition of functors <code>Compose</code>
are defined as</p><pre> newtype Identity a = Identity a
instance Functor Identity where
fmap f (Identity x) = Identity (f x)
instance Applicative Identity where
pure x = Identity x
Identity f &lt;*&gt; Identity x = Identity (f x)
newtype Compose f g a = Compose (f (g a))
instance (Functor f, Functor g) =&gt; Functor (Compose f g) where
fmap f (Compose x) = Compose (fmap (fmap f) x)
instance (Applicative f, Applicative g) =&gt; Applicative (Compose f g) where
pure x = Compose (pure (pure x))
Compose f &lt;*&gt; Compose x = Compose ((&lt;*&gt;) &lt;$&gt; f &lt;*&gt; x)</pre><p>(The naturality law is implied by parametricity.)</p><p>Instances are similar to <code><a href="SafePrelude.html#t:Functor">Functor</a></code>, e.g. given a data type</p><pre>data Tree a = Empty | Leaf a | Node (Tree a) a (Tree a)</pre><p>a suitable instance would be</p><pre>instance Traversable Tree where
traverse f Empty = pure Empty
traverse f (Leaf x) = Leaf &lt;$&gt; f x
traverse f (Node l k r) = Node &lt;$&gt; traverse f l &lt;*&gt; f k &lt;*&gt; traverse f r</pre><p>This is suitable even for abstract types, as the laws for <code><a href="SafePrelude.html#v:-60--42--62-">&lt;*&gt;</a></code>
imply a form of associativity.</p><p>The superclass instances should satisfy the following:</p><ul><li>In the <code><a href="SafePrelude.html#t:Functor">Functor</a></code> instance, <code><a href="SafePrelude.html#v:fmap">fmap</a></code> should be equivalent to traversal
with the identity applicative functor (<code><a href="../base-4.9.0.0/Data-Traversable.html#v:fmapDefault">fmapDefault</a></code>).</li><li>In the <code><a href="SafePrelude.html#t:Foldable">Foldable</a></code> instance, <code><a href="../base-4.9.0.0/Data-Foldable.html#v:foldMap">foldMap</a></code> should be
equivalent to traversal with a constant applicative functor
(<code><a href="../base-4.9.0.0/Data-Traversable.html#v:foldMapDefault">foldMapDefault</a></code>).</li></ul></div><div class="subs minimal"><p class="caption">Minimal complete definition</p><p class="src"><a href="SafePrelude.html#v:traverse">traverse</a> | <a href="SafePrelude.html#v:sequenceA">sequenceA</a></p></div><div class="subs instances"><p id="control.i:Traversable" class="caption collapser" onclick="toggleSection('i:Traversable')">Instances</p><div id="section.i:Traversable" class="show"><table><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:Traversable:Traversable:1" class="instance expander" onclick="toggleSection('i:ic:Traversable:Traversable:1')"></span> <a href="SafePrelude.html#t:Traversable">Traversable</a> []</span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:Traversable:Traversable:1" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:traverse">traverse</a> :: <a href="SafePrelude.html#t:Applicative">Applicative</a> f =&gt; (a -&gt; f b) -&gt; [a] -&gt; f [b] <a href="#v:traverse" class="selflink">#</a></p><p class="src"><a href="#v:sequenceA">sequenceA</a> :: <a href="SafePrelude.html#t:Applicative">Applicative</a> f =&gt; [f a] -&gt; f [a] <a href="#v:sequenceA" class="selflink">#</a></p><p class="src"><a href="#v:mapM">mapM</a> :: <a href="SafePrelude.html#t:Monad">Monad</a> m =&gt; (a -&gt; m b) -&gt; [a] -&gt; m [b] <a href="#v:mapM" class="selflink">#</a></p><p class="src"><a href="#v:sequence">sequence</a> :: <a href="SafePrelude.html#t:Monad">Monad</a> m =&gt; [m a] -&gt; m [a] <a href="#v:sequence" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:Traversable:Traversable:2" class="instance expander" onclick="toggleSection('i:ic:Traversable:Traversable:2')"></span> <a href="SafePrelude.html#t:Traversable">Traversable</a> <a href="SafePrelude.html#t:Maybe">Maybe</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:Traversable:Traversable:2" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:traverse">traverse</a> :: <a href="SafePrelude.html#t:Applicative">Applicative</a> f =&gt; (a -&gt; f b) -&gt; <a href="SafePrelude.html#t:Maybe">Maybe</a> a -&gt; f (<a href="SafePrelude.html#t:Maybe">Maybe</a> b) <a href="#v:traverse" class="selflink">#</a></p><p class="src"><a href="#v:sequenceA">sequenceA</a> :: <a href="SafePrelude.html#t:Applicative">Applicative</a> f =&gt; <a href="SafePrelude.html#t:Maybe">Maybe</a> (f a) -&gt; f (<a href="SafePrelude.html#t:Maybe">Maybe</a> a) <a href="#v:sequenceA" class="selflink">#</a></p><p class="src"><a href="#v:mapM">mapM</a> :: <a href="SafePrelude.html#t:Monad">Monad</a> m =&gt; (a -&gt; m b) -&gt; <a href="SafePrelude.html#t:Maybe">Maybe</a> a -&gt; m (<a href="SafePrelude.html#t:Maybe">Maybe</a> b) <a href="#v:mapM" class="selflink">#</a></p><p class="src"><a href="#v:sequence">sequence</a> :: <a href="SafePrelude.html#t:Monad">Monad</a> m =&gt; <a href="SafePrelude.html#t:Maybe">Maybe</a> (m a) -&gt; m (<a href="SafePrelude.html#t:Maybe">Maybe</a> a) <a href="#v:sequence" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:Traversable:Traversable:3" class="instance expander" onclick="toggleSection('i:ic:Traversable:Traversable:3')"></span> <a href="SafePrelude.html#t:Traversable">Traversable</a> <a href="../base-4.9.0.0/GHC-Generics.html#t:V1">V1</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:Traversable:Traversable:3" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:traverse">traverse</a> :: <a href="SafePrelude.html#t:Applicative">Applicative</a> f =&gt; (a -&gt; f b) -&gt; <a href="../base-4.9.0.0/GHC-Generics.html#t:V1">V1</a> a -&gt; f (<a href="../base-4.9.0.0/GHC-Generics
be calculated.</p></div><div class="subs minimal"><p class="caption">Minimal complete definition</p><p class="src"><a href="../base-4.9.0.0/Data-Typeable-Internal.html#v:typeRep-35-">typeRep#</a></p></div></div><div class="top"><p class="src"><span class="keyword">class</span> <a id="t:IsString" class="def">IsString</a> a <span class="keyword">where</span> <a href="#t:IsString" class="selflink">#</a></p><div class="doc"><p>Class for string-like datastructures; used by the overloaded string
extension (-XOverloadedStrings in GHC).</p></div><div class="subs instances"><p id="control.i:IsString" class="caption collapser" onclick="toggleSection('i:IsString')">Instances</p><div id="section.i:IsString" class="show"><table><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:IsString:IsString:1" class="instance expander" onclick="toggleSection('i:ic:IsString:IsString:1')"></span> <a href="SafePrelude.html#t:IsString">IsString</a> <a href="SafePrelude.html#t:ByteString">ByteString</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:IsString:IsString:1" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:fromString">fromString</a> :: <a href="SafePrelude.html#t:String">String</a> -&gt; <a href="SafePrelude.html#t:ByteString">ByteString</a> <a href="#v:fromString" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:IsString:IsString:2" class="instance expander" onclick="toggleSection('i:ic:IsString:IsString:2')"></span> (~) <a href="../base-4.9.0.0/Data-Kind.html#t:-42-">*</a> a <a href="SafePrelude.html#t:Char">Char</a> =&gt; <a href="SafePrelude.html#t:IsString">IsString</a> [a]</span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:IsString:IsString:2" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:fromString">fromString</a> :: <a href="SafePrelude.html#t:String">String</a> -&gt; [a] <a href="#v:fromString" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:IsString:IsString:3" class="instance expander" onclick="toggleSection('i:ic:IsString:IsString:3')"></span> <a href="SafePrelude.html#t:IsString">IsString</a> a =&gt; <a href="SafePrelude.html#t:IsString">IsString</a> (<a href="SafePrelude.html#t:Identity">Identity</a> a)</span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:IsString:IsString:3" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:fromString">fromString</a> :: <a href="SafePrelude.html#t:String">String</a> -&gt; <a href="SafePrelude.html#t:Identity">Identity</a> a <a href="#v:fromString" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:IsString:IsString:4" class="instance expander" onclick="toggleSection('i:ic:IsString:IsString:4')"></span> <a href="SafePrelude.html#t:IsString">IsString</a> (<a href="SafePrelude.html#t:Seq">Seq</a> <a href="SafePrelude.html#t:Char">Char</a>)</span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:IsString:IsString:4" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:fromString">fromString</a> :: <a href="SafePrelude.html#t:String">String</a> -&gt; <a href="SafePrelude.html#t:Seq">Seq</a> <a href="SafePrelude.html#t:Char">Char</a> <a href="#v:fromString" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:IsString:IsString:5" class="instance expander" onclick="toggleSection('i:ic:IsString:IsString:5')"></span> <a href="SafePrelude.html#t:IsString">IsString</a> a =&gt; <a href="SafePrelude.html#t:IsString">IsString</a> (<a href="../base-4.9.0.0/Data-Functor-Const.html#t:Const">Const</a> <a href="../base-4.9.0.0/Data-Kind.html#t:-42-">*</a> a b)</span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:IsString:IsString:5" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:fromString">fromString</a> :: <a href="SafePrelude.html#t:String">String</a> -&gt; <a href="../base-4.9.0.0/Data-Functor-Const.html#t:Const">Const</a> <a href="../base-4.9.0.0/Data-Kind.html#t:-42-">*</a> a b <a href
has an identity). Instances should satisfy the following laws:</p><ul><li><pre>mappend mempty x = x</pre></li><li><pre>mappend x mempty = x</pre></li><li><pre>mappend x (mappend y z) = mappend (mappend x y) z</pre></li><li><pre>mconcat = <code><a href="../base-4.9.0.0/GHC-OldList.html#v:foldr">foldr</a></code> mappend mempty</pre></li></ul><p>The method names refer to the monoid of lists under concatenation,
but there are many other instances.</p><p>Some types can be viewed as a monoid in more than one way,
e.g. both addition and multiplication on numbers.
In such cases we often define <code>newtype</code>s and make those instances
of <code><a href="SafePrelude.html#t:Monoid">Monoid</a></code>, e.g. <code>Sum</code> and <code>Product</code>.</p></div><div class="subs minimal"><p class="caption">Minimal complete definition</p><p class="src"><a href="SafePrelude.html#v:mempty">mempty</a>, <a href="SafePrelude.html#v:mappend">mappend</a></p></div><div class="subs instances"><p id="control.i:Monoid" class="caption collapser" onclick="toggleSection('i:Monoid')">Instances</p><div id="section.i:Monoid" class="show"><table><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:Monoid:Monoid:1" class="instance expander" onclick="toggleSection('i:ic:Monoid:Monoid:1')"></span> <a href="SafePrelude.html#t:Monoid">Monoid</a> <a href="SafePrelude.html#t:Ordering">Ordering</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:Monoid:Monoid:1" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:mempty">mempty</a> :: <a href="SafePrelude.html#t:Ordering">Ordering</a> <a href="#v:mempty" class="selflink">#</a></p><p class="src"><a href="#v:mappend">mappend</a> :: <a href="SafePrelude.html#t:Ordering">Ordering</a> -&gt; <a href="SafePrelude.html#t:Ordering">Ordering</a> -&gt; <a href="SafePrelude.html#t:Ordering">Ordering</a> <a href="#v:mappend" class="selflink">#</a></p><p class="src"><a href="#v:mconcat">mconcat</a> :: [<a href="SafePrelude.html#t:Ordering">Ordering</a>] -&gt; <a href="SafePrelude.html#t:Ordering">Ordering</a> <a href="#v:mconcat" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:Monoid:Monoid:2" class="instance expander" onclick="toggleSection('i:ic:Monoid:Monoid:2')"></span> <a href="SafePrelude.html#t:Monoid">Monoid</a> ()</span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:Monoid:Monoid:2" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:mempty">mempty</a> :: () <a href="#v:mempty" class="selflink">#</a></p><p class="src"><a href="#v:mappend">mappend</a> :: () -&gt; () -&gt; () <a href="#v:mappend" class="selflink">#</a></p><p class="src"><a href="#v:mconcat">mconcat</a> :: [()] -&gt; () <a href="#v:mconcat" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:Monoid:Monoid:3" class="instance expander" onclick="toggleSection('i:ic:Monoid:Monoid:3')"></span> <a href="SafePrelude.html#t:Monoid">Monoid</a> <a href="../base-4.9.0.0/Data-Monoid.html#t:All">All</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:Monoid:Monoid:3" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:mempty">mempty</a> :: <a href="../base-4.9.0.0/Data-Monoid.html#t:All">All</a> <a href="#v:mempty" class="selflink">#</a></p><p class="src"><a href="#v:mappend">mappend</a> :: <a href="../base-4.9.0.0/Data-Monoid.html#t:All">All</a> -&gt; <a href="../base-4.9.0.0/Data-Monoid.html#t:All">All</a> -&gt; <a href="../base-4.9.0.0/Data-Monoid.html#t:All">All</a> <a href="#v:mappend" class="selflink">#</a></p><p class="src"><a href="#v:mconcat">mconcat</a> :: [<a href="../base-4.9.0.0/Data-Monoid.html#t:All">All</a>] -&gt; <a href="../base-4.9.0.0/Data-Monoid.html#t:All">All</a> <a href="#v:mconcat" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:Monoid:Monoid:4" class="instance expander" onclick="toggleSection('i:ic:Monoid:Monoid:4')"></span> <a href="SafePrelude.html#t:Monoid">Monoid</a> <a href="../base-4.9.0.0/Data-Monoid.html#t:Any">Any</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:Monoid:Monoid:4" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:mempty">mempty</a> :: <a href="../base-4.9.0.0/Data-Monoid.html#t:Any">Any</a> <a href="#v:me
<a href="http://en.wikipedia.org/wiki/Monoid">http://en.wikipedia.org/wiki/Monoid</a>: &quot;Any semigroup <code>S</code> may be
turned into a monoid simply by adjoining an element <code>e</code> not in <code>S</code>
and defining <code>e*e = e</code> and <code>e*s = s = s*e</code> for all <code>s &#8712; S</code>.&quot; Since
there is no &quot;Semigroup&quot; typeclass providing just <code><a href="SafePrelude.html#v:mappend">mappend</a></code>, we
use <code><a href="SafePrelude.html#t:Monoid">Monoid</a></code> instead.</p></td></tr><tr><td colspan="2"><div id="section.i:ic:Monoid:Monoid:8" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:mempty">mempty</a> :: <a href="SafePrelude.html#t:Maybe">Maybe</a> a <a href="#v:mempty" class="selflink">#</a></p><p class="src"><a href="#v:mappend">mappend</a> :: <a href="SafePrelude.html#t:Maybe">Maybe</a> a -&gt; <a href="SafePrelude.html#t:Maybe">Maybe</a> a -&gt; <a href="SafePrelude.html#t:Maybe">Maybe</a> a <a href="#v:mappend" class="selflink">#</a></p><p class="src"><a href="#v:mconcat">mconcat</a> :: [<a href="SafePrelude.html#t:Maybe">Maybe</a> a] -&gt; <a href="SafePrelude.html#t:Maybe">Maybe</a> a <a href="#v:mconcat" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:Monoid:Monoid:9" class="instance expander" onclick="toggleSection('i:ic:Monoid:Monoid:9')"></span> <a href="SafePrelude.html#t:Monoid">Monoid</a> a =&gt; <a href="SafePrelude.html#t:Monoid">Monoid</a> (<a href="SafePrelude.html#t:IO">IO</a> a)</span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:Monoid:Monoid:9" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:mempty">mempty</a> :: <a href="SafePrelude.html#t:IO">IO</a> a <a href="#v:mempty" class="selflink">#</a></p><p class="src"><a href="#v:mappend">mappend</a> :: <a href="SafePrelude.html#t:IO">IO</a> a -&gt; <a href="SafePrelude.html#t:IO">IO</a> a -&gt; <a href="SafePrelude.html#t:IO">IO</a> a <a href="#v:mappend" class="selflink">#</a></p><p class="src"><a href="#v:mconcat">mconcat</a> :: [<a href="SafePrelude.html#t:IO">IO</a> a] -&gt; <a href="SafePrelude.html#t:IO">IO</a> a <a href="#v:mconcat" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:Monoid:Monoid:10" class="instance expander" onclick="toggleSection('i:ic:Monoid:Monoid:10')"></span> <a href="SafePrelude.html#t:Ord">Ord</a> a =&gt; <a href="SafePrelude.html#t:Monoid">Monoid</a> (Max a)</span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:Monoid:Monoid:10" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:mempty">mempty</a> :: Max a <a href="#v:mempty" class="selflink">#</a></p><p class="src"><a href="#v:mappend">mappend</a> :: Max a -&gt; Max a -&gt; Max a <a href="#v:mappend" class="selflink">#</a></p><p class="src"><a href="#v:mconcat">mconcat</a> :: [Max a] -&gt; Max a <a href="#v:mconcat" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:Monoid:Monoid:11" class="instance expander" onclick="toggleSection('i:ic:Monoid:Monoid:11')"></span> <a href="SafePrelude.html#t:Ord">Ord</a> a =&gt; <a href="SafePrelude.html#t:Monoid">Monoid</a> (Min a)</span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:Monoid:Monoid:11" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:mempty">mempty</a> :: Min a <a href="#v:mempty" class="selflink">#</a></p><p class="src"><a href="#v:mappend">mappend</a> :: Min a -&gt; Min a -&gt; Min a <a href="#v:mappend" class="selflink">#</a></p><p class="src"><a href="#v:mconcat">mconcat</a> :: [Min a] -&gt; Min a <a href="#v:mconcat" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:Monoid:Monoid:12" class="instance expander" onclick="toggleSection('i:ic:Monoid:Monoid:12')"></span> <a href="SafePrelude.html#t:Monoid">Monoid</a> a =&gt; <a href="SafePrelude.html#t:Monoid">Monoid</a> (<a href="SafePrelude.html#t:Identity">Identity</a> a)</span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:Monoid:Monoid:12" class="inst-details hide"><div class="
floating-point number.</p></div><div class="subs minimal"><p class="caption">Minimal complete definition</p><p class="src"><a href="SafePrelude.html#v:floatRadix">floatRadix</a>, <a href="SafePrelude.html#v:floatDigits">floatDigits</a>, <a href="SafePrelude.html#v:floatRange">floatRange</a>, <a href="SafePrelude.html#v:decodeFloat">decodeFloat</a>, <a href="SafePrelude.html#v:encodeFloat">encodeFloat</a>, <a href="SafePrelude.html#v:isNaN">isNaN</a>, <a href="SafePrelude.html#v:isInfinite">isInfinite</a>, <a href="SafePrelude.html#v:isDenormalized">isDenormalized</a>, <a href="SafePrelude.html#v:isNegativeZero">isNegativeZero</a>, <a href="SafePrelude.html#v:isIEEE">isIEEE</a></p></div><div class="subs instances"><p id="control.i:RealFloat" class="caption collapser" onclick="toggleSection('i:RealFloat')">Instances</p><div id="section.i:RealFloat" class="show"><table><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:RealFloat:RealFloat:1" class="instance expander" onclick="toggleSection('i:ic:RealFloat:RealFloat:1')"></span> <a href="SafePrelude.html#t:RealFloat">RealFloat</a> <a href="SafePrelude.html#t:Double">Double</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:RealFloat:RealFloat:1" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:floatRadix">floatRadix</a> :: <a href="SafePrelude.html#t:Double">Double</a> -&gt; <a href="SafePrelude.html#t:Integer">Integer</a> <a href="#v:floatRadix" class="selflink">#</a></p><p class="src"><a href="#v:floatDigits">floatDigits</a> :: <a href="SafePrelude.html#t:Double">Double</a> -&gt; <a href="SafePrelude.html#t:Int">Int</a> <a href="#v:floatDigits" class="selflink">#</a></p><p class="src"><a href="#v:floatRange">floatRange</a> :: <a href="SafePrelude.html#t:Double">Double</a> -&gt; (<a href="SafePrelude.html#t:Int">Int</a>, <a href="SafePrelude.html#t:Int">Int</a>) <a href="#v:floatRange" class="selflink">#</a></p><p class="src"><a href="#v:decodeFloat">decodeFloat</a> :: <a href="SafePrelude.html#t:Double">Double</a> -&gt; (<a href="SafePrelude.html#t:Integer">Integer</a>, <a href="SafePrelude.html#t:Int">Int</a>) <a href="#v:decodeFloat" class="selflink">#</a></p><p class="src"><a href="#v:encodeFloat">encodeFloat</a> :: <a href="SafePrelude.html#t:Integer">Integer</a> -&gt; <a href="SafePrelude.html#t:Int">Int</a> -&gt; <a href="SafePrelude.html#t:Double">Double</a> <a href="#v:encodeFloat" class="selflink">#</a></p><p class="src"><a href="#v:exponent">exponent</a> :: <a href="SafePrelude.html#t:Double">Double</a> -&gt; <a href="SafePrelude.html#t:Int">Int</a> <a href="#v:exponent" class="selflink">#</a></p><p class="src"><a href="#v:significand">significand</a> :: <a href="SafePrelude.html#t:Double">Double</a> -&gt; <a href="SafePrelude.html#t:Double">Double</a> <a href="#v:significand" class="selflink">#</a></p><p class="src"><a href="#v:scaleFloat">scaleFloat</a> :: <a href="SafePrelude.html#t:Int">Int</a> -&gt; <a href="SafePrelude.html#t:Double">Double</a> -&gt; <a href="SafePrelude.html#t:Double">Double</a> <a href="#v:scaleFloat" class="selflink">#</a></p><p class="src"><a href="#v:isNaN">isNaN</a> :: <a href="SafePrelude.html#t:Double">Double</a> -&gt; <a href="SafePrelude.html#t:Bool">Bool</a> <a href="#v:isNaN" class="selflink">#</a></p><p class="src"><a href="#v:isInfinite">isInfinite</a> :: <a href="SafePrelude.html#t:Double">Double</a> -&gt; <a href="SafePrelude.html#t:Bool">Bool</a> <a href="#v:isInfinite" class="selflink">#</a></p><p class="src"><a href="#v:isDenormalized">isDenormalized</a> :: <a href="SafePrelude.html#t:Double">Double</a> -&gt; <a href="SafePrelude.html#t:Bool">Bool</a> <a href="#v:isDenormalized" class="selflink">#</a></p><p class="src"><a href="#v:isNegativeZero">isNegativeZero</a> :: <a href="SafePrelude.html#t:Double">Double</a> -&gt; <a href="SafePrelude.html#t:Bool">Bool</a> <a href="#v:isNegativeZero" class="selflink">#</a></p><p class="src"><a href="#v:isIEEE">isIEEE</a> :: <a href="SafePrelude.html#t:Do
application <code>(f x)</code> means the same as <code>(f <code><a href="SafePrelude.html#v:-36-">$</a></code> x)</code>. However, <code><a href="SafePrelude.html#v:-36-">$</a></code> has
low, right-associative binding precedence, so it sometimes allows
parentheses to be omitted; for example:</p><pre> f $ g $ h x = f (g (h x))</pre><p>It is also useful in higher-order situations, such as <code><code><a href="../base-4.9.0.0/GHC-OldList.html#v:map">map</a></code> (<code><a href="SafePrelude.html#v:-36-">$</a></code> 0) xs</code>,
or <code><code><a href="../base-4.9.0.0/Data-List.html#v:zipWith">zipWith</a></code> (<code><a href="SafePrelude.html#v:-36-">$</a></code>) fs xs</code>.</p></div></div><div class="top"><p class="src"><a id="v:-38-" class="def">(&amp;)</a> :: a -&gt; (a -&gt; b) -&gt; b <span class="fixity">infixl 1</span><span class="rightedge"></span> <a href="#v:-38-" class="selflink">#</a></p><div class="doc"><p><code><a href="SafePrelude.html#v:-38-">&amp;</a></code> is a reverse application operator. This provides notational
convenience. Its precedence is one higher than that of the forward
application operator <code><a href="SafePrelude.html#v:-36-">$</a></code>, which allows <code><a href="SafePrelude.html#v:-38-">&amp;</a></code> to be nested in <code><a href="SafePrelude.html#v:-36-">$</a></code>.</p><p><em>Since: 4.8.0.0</em></p></div></div><div class="top"><p class="src"><a id="v:-36--33-" class="def">($!)</a> :: (a -&gt; b) -&gt; a -&gt; b <span class="fixity">infixr 0</span><span class="rightedge"></span> <a href="#v:-36--33-" class="selflink">#</a></p><div class="doc"><p>Strict (call-by-value) application operator. It takes a function and an
argument, evaluates the argument to weak head normal form (WHNF), then calls
the function with that value.</p></div></div><div class="top"><p class="src"><a id="v:-38--38-" class="def">(&amp;&amp;)</a> :: <a href="SafePrelude.html#t:Bool">Bool</a> -&gt; <a href="SafePrelude.html#t:Bool">Bool</a> -&gt; <a href="SafePrelude.html#t:Bool">Bool</a> <span class="fixity">infixr 3</span><span class="rightedge"></span> <a href="#v:-38--38-" class="selflink">#</a></p><div class="doc"><p>Boolean &quot;and&quot;</p></div></div><div class="top"><p class="src"><a id="v:-124--124-" class="def">(||)</a> :: <a href="SafePrelude.html#t:Bool">Bool</a> -&gt; <a href="SafePrelude.html#t:Bool">Bool</a> -&gt; <a href="SafePrelude.html#t:Bool">Bool</a> <span class="fixity">infixr 2</span><span class="rightedge"></span> <a href="#v:-124--124-" class="selflink">#</a></p><div class="doc"><p>Boolean &quot;or&quot;</p></div></div><div class="top"><p class="src"><a id="v:." class="def">(.)</a> :: (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c <span class="fixity">infixr 9</span><span class="rightedge"></span> <a href="#v:." class="selflink">#</a></p><div class="doc"><p>Function composition.</p></div></div><div class="top"><p class="src"><a id="v:not" class="def">not</a> :: <a href="SafePrelude.html#t:Bool">Bool</a> -&gt; <a href="SafePrelude.html#t:Bool">Bool</a> <a href="#v:not" class="selflink">#</a></p><div class="doc"><p>Boolean &quot;not&quot;</p></div></div><div class="top"><p class="src"><a id="v:otherwise" class="def">otherwise</a> :: <a href="SafePrelude.html#t:Bool">Bool</a> <a href="#v:otherwise" class="selflink">#</a></p><div class="doc"><p><code><a href="SafePrelude.html#v:otherwise">otherwise</a></code> is defined as the value <code><a href="SafePrelude.html#v:True">True</a></code>. It helps to make
guards more readable. eg.</p><pre> f x | x &lt; 0 = ...
| otherwise = ...</pre></div></div><div class="top"><p class="src"><a id="v:fst" class="def">fst</a> :: (a, b) -&gt; a <a href="#v:fst" class="selflink">#</a></p><div class="doc"><p>Extract the first component of a pair.</p></div></div><div class="top"><p class="src"><a id="v:snd" class="def">snd</a> :: (a, b) -&gt; b <a href="#v:snd" class="selflink">#</a></p><div class="doc"><p>Extract the second component of a pair.</p></div></div><div class="top"><p class="src"><a id="v:id" class="def">id</a> :: a -&gt; a <a href="#v:id" class="selflink">#</a></p><div class="doc"><p>Identity function.</p></div></div><div class="top"><p class="src"><a id="v:maybe" class="def">maybe</a> :: b -&gt; (a -&gt; b) -&gt; <a href="SafePrelude.html#t:Maybe">Maybe</a> a -&gt; b <a href="#v:maybe" class="selflink">#</a></p><div class="doc"><p>The <code><a href="SafePrelude.html#v:maybe">maybe</a></code> function takes a default value, a function, and a <code><a href="SafePrelude.html#t:Maybe">Maybe</a></code>
value. If the <code><a href="SafePrelude.html#t:Maybe">Maybe</a></code> value is <code><a href="SafePrelude.html#v:Nothing">Nothing</a></code>, the function returns the
default value. Otherwise, it applies the function to the value inside
the <code><a href="SafePrelude.html#v:Just">Just</a></code> and returns the result.</p><h4 id="control.ch:maybe0" class="caption expander" onclick="toggleSection('ch:maybe0')">Examples</h4><div id="section.ch:maybe0" class="hide"><p>Basic usage:</p><pre class="screen"><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>maybe False odd (Just 3)
</code></strong>True
</pre><pre class="screen"><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>maybe False odd Nothing
</code></strong>False
</pre><p>Read an integer from a string using <code>readMaybe</code>. If we succeed,
return twice the integer; that is, apply <code>(*2)</code> to it. If instead
we fail to parse an integer, return <code>0</code> by default:</p><pre class="screen"><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>import Text.Read ( readMaybe )
</code></strong><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>maybe 0 (*2) (readMaybe &quot;5&quot;)
</code></strong>10
<code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>maybe 0 (*2) (readMaybe &quot;&quot;)
</code></strong>0
</pre><p>Apply <code>show</code> to a <code>Maybe Int</code>. If we have <code>Just n</code>, we want to show
the underlying <code><a href="SafePrelude.html#t:Int">Int</a></code> <code>n</code>. But if we have <code><a href="SafePrelude.html#v:Nothing">Nothing</a></code>, we return the
empty string instead of (for example) &quot;Nothing&quot;:</p><pre class="screen"><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>maybe &quot;&quot; show (Just 5)
</code></strong>&quot;5&quot;
<code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>maybe &quot;&quot; show Nothing
</code></strong>&quot;&quot;
</pre></div></div></div><div class="top"><p class="src"><a id="v:either" class="def">either</a> :: (a -&gt; c) -&gt; (b -&gt; c) -&gt; <a href="SafePrelude.html#t:Either">Either</a> a b -&gt; c <a href="#v:either" class="selflink">#</a></p><div class="doc"><p>Case analysis for the <code><a href="SafePrelude.html#t:Either">Either</a></code> type.
If the value is <code><code><a href="SafePrelude.html#v:Left">Left</a></code> a</code>, apply the first function to <code>a</code>;
if it is <code><code><a href="SafePrelude.html#v:Right">Right</a></code> b</code>, apply the second function to <code>b</code>.</p><h4 id="control.ch:either0" class="caption expander" onclick="toggleSection('ch:either0')">Examples</h4><div id="section.ch:either0" class="hide"><p>We create two values of type <code><code><a href="SafePrelude.html#t:Either">Either</a></code> <code><a href="SafePrelude.html#t:String">String</a></code> <code><a href="SafePrelude.html#t:Int">Int</a></code></code>, one using the
<code><a href="SafePrelude.html#v:Left">Left</a></code> constructor and another using the <code><a href="SafePrelude.html#v:Right">Right</a></code> constructor. Then
we apply &quot;either&quot; the <code>length</code> function (if we have a <code><a href="SafePrelude.html#t:String">String</a></code>)
or the &quot;times-two&quot; function (if we have an <code><a href="SafePrelude.html#t:Int">Int</a></code>):</p><pre class="screen"><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>let s = Left &quot;foo&quot; :: Either String Int
</code></strong><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>let n = Right 3 :: Either String Int
</code></strong><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>either length (*2) s
</code></strong>3
<code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>either length (*2) n
</code></strong>6
</pre></div></div></div><div class="top"><p class="src"><a id="v:flip" class="def">flip</a> :: (a -&gt; b -&gt; c) -&gt; b -&gt; a -&gt; c <a href="#v:flip" class="selflink">#</a></p><div class="doc"><p><code><code><a href="SafePrelude.html#v:flip">flip</a></code> f</code> takes its (first) two arguments in the reverse order of <code>f</code>.</p></div></div><div class="top"><p class="src"><a id="v:const" class="def">const</a> :: a -&gt; b -&gt; a <a href="#v:const" class="selflink">#</a></p><div class="doc"><p><code>const x</code> is a unary function which evaluates to <code>x</code> for all inputs.</p><p>For instance,</p><pre class="screen"><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>map (const 42) [0..3]
</code></strong>[42,42,42,42]
</pre></div></div><div class="top"><p class="src"><a id="v:odd" class="def">odd</a> :: <a href="SafePrelude.html#t:Integral">Integral</a> a =&gt; a -&gt; <a href="SafePrelude.html#t:Bool">Bool</a> <a href="#v:odd" class="selflink">#</a></p></div><div class="top"><p class="src"><a id="v:even" class="def">even</a> :: <a href="SafePrelude.html#t:Integral">Integral</a> a =&gt; a -&gt; <a href="SafePrelude.html#t:Bool">Bool</a> <a href="#v:even" class="selflink">#</a></p></div><div class="top"><p class="src"><a id="v:uncurry" class="def">uncurry</a> :: (a -&gt; b -&gt; c) -&gt; (a, b) -&gt; c <a href="#v:uncurry" class="selflink">#</a></p><div class="doc"><p><code><a href="SafePrelude.html#v:uncurry">uncurry</a></code> converts a curried function to a function on pairs.</p></div></div><div class="top"><p class="src"><a id="v:curry" class="def">curry</a> :: ((a, b) -&gt; c) -&gt; a -&gt; b -&gt; c <a href="#v:curry" class="selflink">#</a></p><div class="doc"><p><code><a href="SafePrelude.html#v:curry">curry</a></code> converts an uncurried function to a curried function.</p></div></div><div class="top"><p class="src"><a id="v:asTypeOf" class="def">asTypeOf</a> :: a -&gt; a -&gt; a <a href="#v:asTypeOf" class="selflink">#</a></p><div class="doc"><p><code><a href="SafePrelude.html#v:asTypeOf">asTypeOf</a></code> is a type-restricted version of <code><a href="SafePrelude.html#v:const">const</a></code>. It is usually
used as an infix operator, and its typing forces its first argument
(which is usually overloaded) to have the same type as the second.</p></div></div><div class="top"><p class="src"><a id="v:seq" class="def">seq</a> :: a -&gt; b -&gt; b <a href="#v:seq" class="selflink">#</a></p><div class="doc"><p>The value of <code>seq a b</code> is bottom if <code>a</code> is bottom, and
otherwise equal to <code>b</code>. <code>seq</code> is usually introduced to
improve performance by avoiding unneeded laziness.</p><p>A note on evaluation order: the expression <code>seq a b</code> does
<em>not</em> guarantee that <code>a</code> will be evaluated before <code>b</code>.
The only guarantee given by <code>seq</code> is that the both <code>a</code>
and <code>b</code> will be evaluated before <code>seq</code> returns a value.
In particular, this means that <code>b</code> may be evaluated before
<code>a</code>. If you need to guarantee a specific order of evaluation,
you must use the function <code>pseq</code> from the &quot;parallel&quot; package. </p></div></div><div class="top"><p class="src"><a id="v:fix" class="def">fix</a> :: (a -&gt; a) -&gt; a <a href="#v:fix" class="selflink">#</a></p><div class="doc"><p><code><code><a href="SafePrelude.html#v:fix">fix</a></code> f</code> is the least fixed point of the function <code>f</code>,
i.e. the least defined <code>x</code> such that <code>f x = x</code>.</p></div></div><h2 id="g:6">Numeric</h2><div class="top"><p class="src"><a id="v:-94-" class="def">(^)</a> :: (<a href="SafePrelude.html#t:Num">Num</a> a, <a href="SafePrelude.html#t:Integral">Integral</a> b) =&gt; a -&gt; b -&gt; a <span class="fixity">infixr 8</span><span class="rightedge"></span> <a href="#v:-94-" class="selflink">#</a></p><div class="doc"><p>raise a number to a non-negative integral power</p></div></div><div class="top"><p class="src"><a id="v:-94--94-" class="def">(^^)</a> :: (<a href="SafePrelude.html#t:Fractional">Fractional</a> a, <a href="SafePrelude.html#t:Integral">Integral</a> b) =&gt; a -&gt; b -&gt; a <span class="fixity">infixr 8</span><span class="rightedge"></span> <a href="#v:-94--94-" class="selflink">#</a></p><div class="doc"><p>raise a number to an integral power</p></div></div><div class="top"><p class="src"><a id="v:subtract" class="def">subtract</a> :: <a href="SafePrelude.html#t:Num">Num</a> a =&gt; a -&gt; a -&gt; a <a href="#v:subtract" class="selflink">#</a></p><div class="doc"><p>the same as <code><code><a href="SafePrelude.html#v:flip">flip</a></code> (<code><a href="SafePrelude.html#v:-45-">-</a></code>)</code>.</p><p>Because <code>-</code> is treated specially in the Haskell grammar,
<code>(-</code> <em>e</em><code>)</code> is not a section, but an application of prefix negation.
However, <code>(<code><a href="SafePrelude.html#v:subtract">subtract</a></code></code> <em>exp</em><code>)</code> is equivalent to the disallowed section.</p></div></div><div class="top"><p class="src"><a id="v:fromIntegral" class="def">fromIntegral</a> :: (<a href="SafePrelude.html#t:Integral">Integral</a> a, <a href="SafePrelude.html#t:Num">Num</a> b) =&gt; a -&gt; b <a href="#v:fromIntegral" class="selflink">#</a></p><div class="doc"><p>general coercion from integral types</p></div></div><div class="top"><p class="src"><a id="v:realToFrac" class="def">realToFrac</a> :: (<a href="SafePrelude.html#t:Real">Real</a> a, <a href="SafePrelude.html#t:Fractional">Fractional</a> b) =&gt; a -&gt; b <a href="#v:realToFrac" class="selflink">#</a></p><div class="doc"><p>general coercion to fractional types</p></div></div><h2 id="g:7">Foldable</h2><div class="top"><p class="src"><a id="v:sum" class="def">sum</a> :: (<a href="SafePrelude.html#t:Foldable">Foldable</a> f, <a href="SafePrelude.html#t:Num">Num</a> a) =&gt; f a -&gt; a <a href="src/SafePrelude.html#sum" class="link">Source</a> <a href="#v:sum" class="selflink">#</a></p><div class="doc"><p>Get the sum of the elements in a <code><a href="SafePrelude.html#t:Foldable">Foldable</a></code>.</p><p>This is not the same as the function from <code><a href="Data.html#v:Foldable">Foldable</a></code>; instead,
this function uses a strict left fold.</p><p><em>Since: 0.1.0.0</em></p></div></div><div class="top"><p class="src"><a id="v:product" class="def">product</a> :: (<a href="SafePrelude.html#t:Foldable">Foldable</a> f, <a href="SafePrelude.html#t:Num">Num</a> a) =&gt; f a -&gt; a <a href="src/SafePrelude.html#product" class="link">Source</a> <a href="#v:product" class="selflink">#</a></p><div class="doc"><p>Get the product of the elements in a <code><a href="SafePrelude.html#t:Foldable">Foldable</a></code>.</p><p>This is not the same as the function from <code><a href="Data.html#v:Foldable">Foldable</a></code>; instead,
this function uses a strict left fold.</p><p><em>Since: 0.1.0.0</em></p></div></div><div class="top"><p class="src"><a id="v:foldrM" class="def">foldrM</a> :: (<a href="SafePrelude.html#t:Foldable">Foldable</a> t, <a href="SafePrelude.html#t:Monad">Monad</a> m) =&gt; (a -&gt; b -&gt; m b) -&gt; b -&gt; t a -&gt; m b <a href="#v:foldrM" class="selflink">#</a></p><div class="doc"><p>Monadic fold over the elements of a structure,
associating to the right, i.e. from right to left.</p></div></div><div class="top"><p class="src"><a id="v:foldlM" class="def">foldlM</a> :: (<a href="SafePrelude.html#t:Foldable">Foldable</a> t, <a href="SafePrelude.html#t:Monad">Monad</a> m) =&gt; (b -&gt; a -&gt; m b) -&gt; b -&gt; t a -&gt; m b <a href="#v:foldlM" class="selflink">#</a></p><div class="doc"><p>Monadic fold over the elements of a structure,
associating to the left, i.e. from left to right.</p></div></div><div class="top"><p class="src"><a id="v:traverse_" class="def">traverse_</a> :: (<a href="SafePrelude.html#t:Foldable">Foldable</a> t, <a href="SafePrelude.html#t:Applicative">Applicative</a> f) =&gt; (a -&gt; f b) -&gt; t a -&gt; f () <a href="#v:traverse_" class="selflink">#</a></p><div class="doc"><p>Map each element of a structure to an action, evaluate these
actions from left to right, and ignore the results. For a version
that doesn't ignore the results see <code><a href="../base-4.9.0.0/Data-Traversable.html#v:traverse">traverse</a></code>.</p></div></div><div class="top"><p class="src"><a id="v:for_" class="def">for_</a> :: (<a href="SafePrelude.html#t:Foldable">Foldable</a> t, <a href="SafePrelude.html#t:Applicative">Applicative</a> f) =&gt; t a -&gt; (a -&gt; f b) -&gt; f () <a href="#v:for_" class="selflink">#</a></p><div class="doc"><p><code><a href="SafePrelude.html#v:for_">for_</a></code> is <code><a href="SafePrelude.html#v:traverse_">traverse_</a></code> with its arguments flipped. For a version
that doesn't ignore the results see <code><a href="../base-4.9.0.0/Data-Traversable.html#v:for">for</a></code>.</p><pre class="screen"><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>for_ [1..4] print
</code></strong>1
2
3
4
</pre></div></div><div class="top"><p class="src"><a id="v:sequenceA_" class="def">sequenceA_</a> :: (<a href="SafePrelude.html#t:Foldable">Foldable</a> t, <a href="SafePrelude.html#t:Applicative">Applicative</a> f) =&gt; t (f a) -&gt; f () <a href="#v:sequenceA_" class="selflink">#</a></p><div class="doc"><p>Evaluate each action in the structure from left to right, and
ignore the results. For a version that doesn't ignore the results
see <code><a href="../base-4.9.0.0/Data-Traversable.html#v:sequenceA">sequenceA</a></code>.</p></div></div><div class="top"><p class="src"><a id="v:asum" class="def">asum</a> :: (<a href="SafePrelude.html#t:Foldable">Foldable</a> t, <a href="SafePrelude.html#t:Alternative">Alternative</a> f) =&gt; t (f a) -&gt; f a <a href="#v:asum" class="selflink">#</a></p><div class="doc"><p>The sum of a collection of actions, generalizing <code><a href="SafePrelude.html#v:concat">concat</a></code>.</p></div></div><div class="top"><p class="src"><a id="v:mapM_" class="def">mapM_</a> :: (<a href="SafePrelude.html#t:Applicative">Applicative</a> m, <a href="SafePrelude.html#t:Foldable">Foldable</a> f) =&gt; (a -&gt; m b) -&gt; f a -&gt; m () <a href="src/SafePrelude.html#mapM_" class="link">Source</a> <a href="#v:mapM_" class="selflink">#</a></p><div class="doc"><p>Synonym for <code><a href="SafePrelude.html#v:traverse_">traverse_</a></code>; different from base to generalize to
<code><a href="SafePrelude.html#t:Applicative">Applicative</a></code>.</p><p><em>Since: 0.1.0.0</em></p></div></div><div class="top"><p class="src"><a id="v:forM_" class="def">forM_</a> :: (<a href="SafePrelude.html#t:Applicative">Applicative</a> m, <a href="SafePrelude.html#t:Foldable">Foldable</a> f) =&gt; f a -&gt; (a -&gt; m b) -&gt; m () <a href="src/SafePrelude.html#forM_" class="link">Source</a> <a href="#v:forM_" class="selflink">#</a></p><div class="doc"><p>Flipped version of <code><a href="SafePrelude.html#v:mapM_">mapM_</a></code>.</p><p><em>Since: 0.1.0.0</em></p></div></div><div class="top"><p class="src"><a id="v:sequence_" class="def">sequence_</a> :: (<a href="SafePrelude.html#t:Applicative">Applicative</a> m, <a href="SafePrelude.html#t:Foldable">Foldable</a> f) =&gt; f (m a) -&gt; m () <a href="src/SafePrelude.html#sequence_" class="link">Source</a> <a href="#v:sequence_" class="selflink">#</a></p><div class="doc"><p>Synonym for <code><a href="SafePrelude.html#v:sequence_">sequence_</a></code>; different from base to generalize to
<code><a href="SafePrelude.html#t:Applicative">Applicative</a></code>.</p><p><em>Since: 0.1.0.0</em></p></div></div><div class="top"><p class="src"><a id="v:msum" class="def">msum</a> :: (<a href="SafePrelude.html#t:Foldable">Foldable</a> t, <a href="../base-4.9.0.0/Control-Monad.html#t:MonadPlus">MonadPlus</a> m) =&gt; t (m a) -&gt; m a <a href="#v:msum" class="selflink">#</a></p><div class="doc"><p>The sum of a collection of actions, generalizing <code><a href="SafePrelude.html#v:concat">concat</a></code>.
As of base 4.8.0.0, <code><a href="SafePrelude.html#v:msum">msum</a></code> is just <code><a href="SafePrelude.html#v:asum">asum</a></code>, specialized to <code><a href="../base-4.9.0.0/Control-Monad.html#t:MonadPlus">MonadPlus</a></code>.</p></div></div><div class="top"><p class="src"><a id="v:concat" class="def">concat</a> :: <a href="SafePrelude.html#t:Foldable">Foldable</a> t =&gt; t [a] -&gt; [a] <a href="#v:concat" class="selflink">#</a></p><div class="doc"><p>The concatenation of all the elements of a container of lists.</p></div></div><div class="top"><p class="src"><a id="v:concatMap" class="def">concatMap</a> :: <a href="SafePrelude.html#t:Foldable">Foldable</a> t =&gt; (a -&gt; [b]) -&gt; t a -&gt; [b] <a href="#v:concatMap" class="selflink">#</a></p><div class="doc"><p>Map a function over all the elements of a container and concatenate
the resulting lists.</p></div></div><div class="top"><p class="src"><a id="v:and" class="def">and</a> :: <a href="SafePrelude.html#t:Foldable">Foldable</a> t =&gt; t <a href="SafePrelude.html#t:Bool">Bool</a> -&gt; <a href="SafePrelude.html#t:Bool">Bool</a> <a href="#v:and" class="selflink">#</a></p><div class="doc"><p><code><a href="SafePrelude.html#v:and">and</a></code> returns the conjunction of a container of Bools. For the
result to be <code><a href="SafePrelude.html#v:True">True</a></code>, the container must be finite; <code><a href="SafePrelude.html#v:False">False</a></code>, however,
results from a <code><a href="SafePrelude.html#v:False">False</a></code> value finitely far from the left end.</p></div></div><div class="top"><p class="src"><a id="v:or" class="def">or</a> :: <a href="SafePrelude.html#t:Foldable">Foldable</a> t =&gt; t <a href="SafePrelude.html#t:Bool">Bool</a> -&gt; <a href="SafePrelude.html#t:Bool">Bool</a> <a href="#v:or" class="selflink">#</a></p><div class="doc"><p><code><a href="SafePrelude.html#v:or">or</a></code> returns the disjunction of a container of Bools. For the
result to be <code><a href="SafePrelude.html#v:False">False</a></code>, the container must be finite; <code><a href="SafePrelude.html#v:True">True</a></code>, however,
results from a <code><a href="SafePrelude.html#v:True">True</a></code> value finitely far from the left end.</p></div></div><div class="top"><p class="src"><a id="v:any" class="def">any</a> :: <a href="SafePrelude.html#t:Foldable">Foldable</a> t =&gt; (a -&gt; <a href="SafePrelude.html#t:Bool">Bool</a>) -&gt; t a -&gt; <a href="SafePrelude.html#t:Bool">Bool</a> <a href="#v:any" class="selflink">#</a></p><div class="doc"><p>Determines whether any element of the structure satisfies the predicate.</p></div></div><div class="top"><p class="src"><a id="v:all" class="def">all</a> :: <a href="SafePrelude.html#t:Foldable">Foldable</a> t =&gt; (a -&gt; <a href="SafePrelude.html#t:Bool">Bool</a>) -&gt; t a -&gt; <a href="SafePrelude.html#t:Bool">Bool</a> <a href="#v:all" class="selflink">#</a></p><div class="doc"><p>Determines whether all elements of the structure satisfy the predicate.</p></div></div><div class="top"><p class="src"><a id="v:notElem" class="def">notElem</a> :: (<a href="SafePrelude.html#t:Foldable">Foldable</a> t, <a href="SafePrelude.html#t:Eq">Eq</a> a) =&gt; a -&gt; t a -&gt; <a href="SafePrelude.html#t:Bool">Bool</a> <span class="fixity">infix 4</span><span class="rightedge"></span> <a href="#v:notElem" class="selflink">#</a></p><div class="doc"><p><code><a href="SafePrelude.html#v:notElem">notElem</a></code> is the negation of <code><a href="SafePrelude.html#v:elem">elem</a></code>.</p></div></div><div class="top"><p class="src"><a id="v:find" class="def">find</a> :: <a href="SafePrelude.html#t:Foldable">Foldable</a> t =&gt; (a -&gt; <a href="SafePrelude.html#t:Bool">Bool</a>) -&gt; t a -&gt; <a href="SafePrelude.html#t:Maybe">Maybe</a> a <a href="#v:find" class="selflink">#</a></p><div class="doc"><p>The <code><a href="SafePrelude.html#v:find">find</a></code> function takes a predicate and a structure and returns
the leftmost element of the structure matching the predicate, or
<code><a href="SafePrelude.html#v:Nothing">Nothing</a></code> if there is no such element.</p></div></div><h2 id="g:8">Traversable</h2><div class="top"><p class="src"><a id="v:mapM" class="def">mapM</a> :: (<a href="SafePrelude.html#t:Applicative">Applicative</a> m, <a href="SafePrelude.html#t:Traversable">Traversable</a> t) =&gt; (a -&gt; m b) -&gt; t a -&gt; m (t b) <a href="src/SafePrelude.html#mapM" class="link">Source</a> <a href="#v:mapM" class="selflink">#</a></p><div class="doc"><p>Synonym for <code><a href="SafePrelude.html#v:traverse">traverse</a></code>; different from base to generalize to
<code><a href="SafePrelude.html#t:Applicative">Applicative</a></code>.</p><p><em>Since: 0.1.0.0</em></p></div></div><div class="top"><p class="src"><a id="v:sequence" class="def">sequence</a> :: (<a href="SafePrelude.html#t:Applicative">Applicative</a> m, <a href="SafePrelude.html#t:Traversable">Traversable</a> t) =&gt; t (m a) -&gt; m (t a) <a href="src/SafePrelude.html#sequence" class="link">Source</a> <a href="#v:sequence" class="selflink">#</a></p><div class="doc"><p>Synonym for <code><a href="SafePrelude.html#v:sequenceA">sequenceA</a></code>; different from base to generalize to
<code><a href="SafePrelude.html#t:Applicative">Applicative</a></code>.</p><p><em>Since: 0.1.0.0</em></p></div></div><div class="top"><p class="src"><a id="v:for" class="def">for</a> :: (<a href="SafePrelude.html#t:Traversable">Traversable</a> t, <a href="SafePrelude.html#t:Applicative">Applicative</a> f) =&gt; t a -&gt; (a -&gt; f b) -&gt; f (t b) <a href="#v:for" class="selflink">#</a></p><div class="doc"><p><code><a href="SafePrelude.html#v:for">for</a></code> is <code><a href="SafePrelude.html#v:traverse">traverse</a></code> with its arguments flipped. For a version
that ignores the results see <code><a href="../base-4.9.0.0/Data-Foldable.html#v:for_">for_</a></code>.</p></div></div><div class="top"><p class="src"><a id="v:forM" class="def">forM</a> :: (<a href="SafePrelude.html#t:Applicative">Applicative</a> m, <a href="SafePrelude.html#t:Traversable">Traversable</a> t) =&gt; t a -&gt; (a -&gt; m b) -&gt; m (t b) <a href="src/SafePrelude.html#forM" class="link">Source</a> <a href="#v:forM" class="selflink">#</a></p><div class="doc"><p>Flipped version of <code><a href="SafePrelude.html#v:mapM">mapM</a></code>.</p><p><em>Since: 0.1.0.0</em></p></div></div><div class="top"><p class="src"><a id="v:mapAccumL" class="def">mapAccumL</a> :: <a href="SafePrelude.html#t:Traversable">Traversable</a> t =&gt; (a -&gt; b -&gt; (a, c)) -&gt; a -&gt; t b -&gt; (a, t c) <a href="#v:mapAccumL" class="selflink">#</a></p><div class="doc"><p>The <code><a href="SafePrelude.html#v:mapAccumL">mapAccumL</a></code> function behaves like a combination of <code><a href="SafePrelude.html#v:fmap">fmap</a></code>
and <code>foldl</code>; it applies a function to each element of a structure,
passing an accumulating parameter from left to right, and returning
a final value of this accumulator together with the new structure.</p></div></div><div class="top"><p class="src"><a id="v:mapAccumR" class="def">mapAccumR</a> :: <a href="SafePrelude.html#t:Traversable">Traversable</a> t =&gt; (a -&gt; b -&gt; (a, c)) -&gt; a -&gt; t b -&gt; (a, t c) <a href="#v:mapAccumR" class="selflink">#</a></p><div class="doc"><p>The <code><a href="SafePrelude.html#v:mapAccumR">mapAccumR</a></code> function behaves like a combination of <code><a href="SafePrelude.html#v:fmap">fmap</a></code>
and <code>foldr</code>; it applies a function to each element of a structure,
passing an accumulating parameter from right to left, and returning
a final value of this accumulator together with the new structure.</p></div></div><h2 id="g:9">Functor</h2><div class="top"><p class="src"><a id="v:-36--62-" class="def">($&gt;)</a> :: <a href="SafePrelude.html#t:Functor">Functor</a> f =&gt; f a -&gt; b -&gt; f b <span class="fixity">infixl 4</span><span class="rightedge"></span> <a href="#v:-36--62-" class="selflink">#</a></p><div class="doc"><p>Flipped version of <code><a href="SafePrelude.html#v:-60--36-">&lt;$</a></code>.</p><h4 id="control.ch:-36--62-0" class="caption expander" onclick="toggleSection('ch:-36--62-0')">Examples</h4><div id="section.ch:-36--62-0" class="hide"><p>Replace the contents of a <code><code>Maybe</code> <code>Int</code></code> with a constant <code>String</code>:</p><pre class="screen"><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>Nothing $&gt; &quot;foo&quot;
</code></strong>Nothing
<code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>Just 90210 $&gt; &quot;foo&quot;
</code></strong>Just &quot;foo&quot;
</pre><p>Replace the contents of an <code><code>Either</code> <code>Int</code> <code>Int</code></code> with a constant
<code>String</code>, resulting in an <code><code>Either</code> <code>Int</code> <code>String</code></code>:</p><pre class="screen"><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>Left 8675309 $&gt; &quot;foo&quot;
</code></strong>Left 8675309
<code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>Right 8675309 $&gt; &quot;foo&quot;
</code></strong>Right &quot;foo&quot;
</pre><p>Replace each element of a list with a constant <code>String</code>:</p><pre class="screen"><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>[1,2,3] $&gt; &quot;foo&quot;
</code></strong>[&quot;foo&quot;,&quot;foo&quot;,&quot;foo&quot;]
</pre><p>Replace the second element of a pair with a constant <code>String</code>:</p><pre class="screen"><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>(1,2) $&gt; &quot;foo&quot;
</code></strong>(1,&quot;foo&quot;)
</pre></div><p><em>Since: 4.7.0.0</em></p></div></div><div class="top"><p class="src"><a id="v:-60--36--62-" class="def">(&lt;$&gt;)</a> :: <a href="SafePrelude.html#t:Functor">Functor</a> f =&gt; (a -&gt; b) -&gt; f a -&gt; f b <span class="fixity">infixl 4</span><span class="rightedge"></span> <a href="#v:-60--36--62-" class="selflink">#</a></p><div class="doc"><p>An infix synonym for <code><a href="SafePrelude.html#v:fmap">fmap</a></code>.</p><p>The name of this operator is an allusion to <code>$</code>.
Note the similarities between their types:</p><pre> ($) :: (a -&gt; b) -&gt; a -&gt; b
(&lt;$&gt;) :: Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b</pre><p>Whereas <code>$</code> is function application, <code><a href="SafePrelude.html#v:-60--36--62-">&lt;$&gt;</a></code> is function
application lifted over a <code><a href="SafePrelude.html#t:Functor">Functor</a></code>.</p><h4 id="control.ch:-60--36--62-0" class="caption expander" onclick="toggleSection('ch:-60--36--62-0')">Examples</h4><div id="section.ch:-60--36--62-0" class="hide"><p>Convert from a <code><code>Maybe</code> <code>Int</code></code> to a <code><code>Maybe</code> <code>String</code></code> using <code>show</code>:</p><pre class="screen"><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>show &lt;$&gt; Nothing
</code></strong>Nothing
<code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>show &lt;$&gt; Just 3
</code></strong>Just &quot;3&quot;
</pre><p>Convert from an <code><code>Either</code> <code>Int</code> <code>Int</code></code> to an <code><code>Either</code> <code>Int</code></code>
<code>String</code> using <code>show</code>:</p><pre class="screen"><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>show &lt;$&gt; Left 17
</code></strong>Left 17
<code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>show &lt;$&gt; Right 17
</code></strong>Right &quot;17&quot;
</pre><p>Double each element of a list:</p><pre class="screen"><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>(*2) &lt;$&gt; [1,2,3]
</code></strong>[2,4,6]
</pre><p>Apply <code>even</code> to the second element of a pair:</p><pre class="screen"><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>even &lt;$&gt; (2,2)
</code></strong>(2,True)
</pre></div></div></div><div class="top"><p class="src"><a id="v:void" class="def">void</a> :: <a href="SafePrelude.html#t:Functor">Functor</a> f =&gt; f a -&gt; f () <a href="#v:void" class="selflink">#</a></p><div class="doc"><p><code><code><a href="SafePrelude.html#v:void">void</a></code> value</code> discards or ignores the result of evaluation, such
as the return value of an <code><a href="../base-4.9.0.0/System-IO.html#v:IO">IO</a></code> action.</p><h4 id="control.ch:void0" class="caption expander" onclick="toggleSection('ch:void0')">Examples</h4><div id="section.ch:void0" class="hide"><p>Replace the contents of a <code><code>Maybe</code> <code>Int</code></code> with unit:</p><pre class="screen"><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>void Nothing
</code></strong>Nothing
<code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>void (Just 3)
</code></strong>Just ()
</pre><p>Replace the contents of an <code><code>Either</code> <code>Int</code> <code>Int</code></code> with unit,
resulting in an <code><code>Either</code> <code>Int</code> '()'</code>:</p><pre class="screen"><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>void (Left 8675309)
</code></strong>Left 8675309
<code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>void (Right 8675309)
</code></strong>Right ()
</pre><p>Replace every element of a list with unit:</p><pre class="screen"><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>void [1,2,3]
</code></strong>[(),(),()]
</pre><p>Replace the second element of a pair with unit:</p><pre class="screen"><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>void (1,2)
</code></strong>(1,())
</pre><p>Discard the result of an <code><a href="../base-4.9.0.0/System-IO.html#v:IO">IO</a></code> action:</p><pre class="screen"><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>mapM print [1,2]
</code></strong>1
2
[(),()]
<code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>void $ mapM print [1,2]
</code></strong>1
2
</pre></div></div></div><h2 id="g:10">Applicative</h2><div class="top"><p class="src"><a id="v:liftA" class="def">liftA</a> :: <a href="SafePrelude.html#t:Applicative">Applicative</a> f =&gt; (a -&gt; b) -&gt; f a -&gt; f b <a href="#v:liftA" class="selflink">#</a></p><div class="doc"><p>Lift a function to actions.
This function may be used as a value for <code><a href="SafePrelude.html#v:fmap">fmap</a></code> in a <code><a href="SafePrelude.html#t:Functor">Functor</a></code> instance.</p></div></div><div class="top"><p class="src"><a id="v:liftA2" class="def">liftA2</a> :: <a href="SafePrelude.html#t:Applicative">Applicative</a> f =&gt; (a -&gt; b -&gt; c) -&gt; f a -&gt; f b -&gt; f c <a href="#v:liftA2" class="selflink">#</a></p><div class="doc"><p>Lift a binary function to actions.</p></div></div><div class="top"><p class="src"><a id="v:liftA3" class="def">liftA3</a> :: <a href="SafePrelude.html#t:Applicative">Applicative</a> f =&gt; (a -&gt; b -&gt; c -&gt; d) -&gt; f a -&gt; f b -&gt; f c -&gt; f d <a href="#v:liftA3" class="selflink">#</a></p><div class="doc"><p>Lift a ternary function to actions.</p></div></div><h2 id="g:11">Alternative</h2><div class="top"><p class="src"><a id="v:optional" class="def">optional</a> :: <a href="SafePrelude.html#t:Alternative">Alternative</a> f =&gt; f a -&gt; f (<a href="SafePrelude.html#t:Maybe">Maybe</a> a) <a href="#v:optional" class="selflink">#</a></p><div class="doc"><p>One or none.</p></div></div><h2 id="g:12">Monad</h2><div class="top"><p class="src"><a id="v:-61--60--60-" class="def">(=&lt;&lt;)</a> :: <a href="SafePrelude.html#t:Monad">Monad</a> m =&gt; (a -&gt; m b) -&gt; m a -&gt; m b <span class="fixity">infixr 1</span><span class="rightedge"></span> <a href="#v:-61--60--60-" class="selflink">#</a></p><div class="doc"><p>Same as <code><a href="SafePrelude.html#v:-62--62--61-">&gt;&gt;=</a></code>, but with the arguments interchanged.</p></div></div><div class="top"><p class="src"><a id="v:-62--61--62-" class="def">(&gt;=&gt;)</a> :: <a href="SafePrelude.html#t:Monad">Monad</a> m =&gt; (a -&gt; m b) -&gt; (b -&gt; m c) -&gt; a -&gt; m c <span class="fixity">infixr 1</span><span class="rightedge"></span> <a href="#v:-62--61--62-" class="selflink">#</a></p><div class="doc"><p>Left-to-right Kleisli composition of monads.</p></div></div><div class="top"><p class="src"><a id="v:-60--61--60-" class="def">(&lt;=&lt;)</a> :: <a href="SafePrelude.html#t:Monad">Monad</a> m =&gt; (b -&gt; m c) -&gt; (a -&gt; m b) -&gt; a -&gt; m c <span class="fixity">infixr 1</span><span class="rightedge"></span> <a href="#v:-60--61--60-" class="selflink">#</a></p><div class="doc"><p>Right-to-left Kleisli composition of monads. <code>(<code><a href="SafePrelude.html#v:-62--61--62-">&gt;=&gt;</a></code>)</code>, with the arguments flipped.</p><p>Note how this operator resembles function composition <code>(<code><a href="SafePrelude.html#v:.">.</a></code>)</code>:</p><pre>(.) :: (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
(&lt;=&lt;) :: Monad m =&gt; (b -&gt; m c) -&gt; (a -&gt; m b) -&gt; a -&gt; m c</pre></div></div><div class="top"><p class="src"><a id="v:forever" class="def">forever</a> :: <a href="SafePrelude.html#t:Applicative">Applicative</a> f =&gt; f a -&gt; f b <a href="#v:forever" class="selflink">#</a></p><div class="doc"><p><code><code><a href="SafePrelude.html#v:forever">forever</a></code> act</code> repeats the action infinitely.</p></div></div><div class="top"><p class="src"><a id="v:join" class="def">join</a> :: <a href="SafePrelude.html#t:Monad">Monad</a> m =&gt; m (m a) -&gt; m a <a href="#v:join" class="selflink">#</a></p><div class="doc"><p>The <code><a href="SafePrelude.html#v:join">join</a></code> function is the conventional monad join operator. It
is used to remove one level of monadic structure, projecting its
bound argument into the outer level.</p></div></div><div class="top"><p class="src"><a id="v:foldM" class="def">foldM</a> :: (<a href="SafePrelude.html#t:Foldable">Foldable</a> t, <a href="SafePrelude.html#t:Monad">Monad</a> m) =&gt; (b -&gt; a -&gt; m b) -&gt; b -&gt; t a -&gt; m b <a href="#v:foldM" class="selflink">#</a></p><div class="doc"><p>The <code><a href="SafePrelude.html#v:foldM">foldM</a></code> function is analogous to <code>foldl</code>, except that its result is
encapsulated in a monad. Note that <code><a href="SafePrelude.html#v:foldM">foldM</a></code> works from left-to-right over
the list arguments. This could be an issue where <code>(<code><a href="SafePrelude.html#v:-62--62-">&gt;&gt;</a></code>)</code> and the `folded
function' are not commutative.</p><pre> foldM f a1 [x1, x2, ..., xm]</pre><p>==</p><pre> do
a2 &lt;- f a1 x1
a3 &lt;- f a2 x2
...
f am xm</pre><p>If right-to-left evaluation is required, the input list should be reversed.</p><p>Note: <code><a href="SafePrelude.html#v:foldM">foldM</a></code> is the same as <code><a href="SafePrelude.html#v:foldlM">foldlM</a></code></p></div></div><div class="top"><p class="src"><a id="v:foldM_" class="def">foldM_</a> :: (<a href="SafePrelude.html#t:Foldable">Foldable</a> t, <a href="SafePrelude.html#t:Monad">Monad</a> m) =&gt; (b -&gt; a -&gt; m b) -&gt; b -&gt; t a -&gt; m () <a href="#v:foldM_" class="selflink">#</a></p><div class="doc"><p>Like <code><a href="SafePrelude.html#v:foldM">foldM</a></code>, but discards the result.</p></div></div><div class="top"><p class="src"><a id="v:replicateM_" class="def">replicateM_</a> :: <a href="SafePrelude.html#t:Applicative">Applicative</a> m =&gt; <a href="SafePrelude.html#t:Int">Int</a> -&gt; m a -&gt; m () <a href="#v:replicateM_" class="selflink">#</a></p><div class="doc"><p>Like <code><a href="../base-4.9.0.0/Control-Monad.html#v:replicateM">replicateM</a></code>, but discards the result.</p></div></div><div class="top"><p class="src"><a id="v:guard" class="def">guard</a> :: <a href="SafePrelude.html#t:Alternative">Alternative</a> f =&gt; <a href="SafePrelude.html#t:Bool">Bool</a> -&gt; f () <a href="#v:guard" class="selflink">#</a></p><div class="doc"><p><code><code><a href="SafePrelude.html#v:guard">guard</a></code> b</code> is <code><code><a href="SafePrelude.html#v:pure">pure</a></code> ()</code> if <code>b</code> is <code><a href="SafePrelude.html#v:True">True</a></code>,
and <code><a href="SafePrelude.html#v:empty">empty</a></code> if <code>b</code> is <code><a href="SafePrelude.html#v:False">False</a></code>.</p></div></div><div class="top"><p class="src"><a id="v:when" class="def">when</a> :: <a href="SafePrelude.html#t:Applicative">Applicative</a> f =&gt; <a href="SafePrelude.html#t:Bool">Bool</a> -&gt; f () -&gt; f () <a href="#v:when" class="selflink">#</a></p><div class="doc"><p>Conditional execution of <code><a href="SafePrelude.html#t:Applicative">Applicative</a></code> expressions. For example,</p><pre>when debug (putStrLn &quot;Debugging&quot;)</pre><p>will output the string <code>Debugging</code> if the Boolean value <code>debug</code>
is <code><a href="SafePrelude.html#v:True">True</a></code>, and otherwise do nothing.</p></div></div><div class="top"><p class="src"><a id="v:unless" class="def">unless</a> :: <a href="SafePrelude.html#t:Applicative">Applicative</a> f =&gt; <a href="SafePrelude.html#t:Bool">Bool</a> -&gt; f () -&gt; f () <a href="#v:unless" class="selflink">#</a></p><div class="doc"><p>The reverse of <code><a href="SafePrelude.html#v:when">when</a></code>.</p></div></div><div class="top"><p class="src"><a id="v:liftM" class="def">liftM</a> :: <a href="SafePrelude.html#t:Monad">Monad</a> m =&gt; (a1 -&gt; r) -&gt; m a1 -&gt; m r <a href="#v:liftM" class="selflink">#</a></p><div class="doc"><p>Promote a function to a monad.</p></div></div><div class="top"><p class="src"><a id="v:ap" class="def">ap</a> :: <a href="SafePrelude.html#t:Monad">Monad</a> m =&gt; m (a -&gt; b) -&gt; m a -&gt; m b <a href="#v:ap" class="selflink">#</a></p><div class="doc"><p>In many situations, the <code><a href="SafePrelude.html#v:liftM">liftM</a></code> operations can be replaced by uses of
<code><a href="SafePrelude.html#v:ap">ap</a></code>, which promotes function application.</p><pre> return f `ap` x1 `ap` ... `ap` xn</pre><p>is equivalent to</p><pre> liftMn f x1 x2 ... xn</pre></div></div><div class="top"><p class="src"><a id="v:-60--36--33--62-" class="def">(&lt;$!&gt;)</a> :: <a href="SafePrelude.html#t:Monad">Monad</a> m =&gt; (a -&gt; b) -&gt; m a -&gt; m b <span class="fixity">infixl 4</span><span class="rightedge"></span> <a href="#v:-60--36--33--62-" class="selflink">#</a></p><div class="doc"><p>Strict version of <code><a href="SafePrelude.html#v:-60--36--62-">&lt;$&gt;</a></code>.</p><p><em>Since: 4.8.0.0</em></p></div></div><h2 id="g:13">Concurrent</h2><div class="top"><p class="src"><a id="v:threadDelay" class="def">threadDelay</a> :: <a href="SafePrelude.html#t:Int">Int</a> -&gt; <a href="SafePrelude.html#t:IO">IO</a> () <a href="#v:threadDelay" class="selflink">#</a></p><div class="doc"><p>Suspends the current thread for a given number of microseconds
(GHC only).</p><p>There is no guarantee that the thread will be rescheduled promptly
when the delay has expired, but the thread will never continue to
run <em>earlier</em> than specified.</p></div></div><div class="top"><p class="src"><span class="keyword">data</span> <a id="t:MVar" class="def">MVar</a> a :: <a href="../base-4.9.0.0/Data-Kind.html#t:-42-">*</a> -&gt; <a href="../base-4.9.0.0/Data-Kind.html#t:-42-">*</a> <a href="#t:MVar" class="selflink">#</a></p><div class="doc"><p>An <code><a href="SafePrelude.html#t:MVar">MVar</a></code> (pronounced &quot;em-var&quot;) is a synchronising variable, used
for communication between concurrent threads. It can be thought of
as a a box, which may be empty or full.</p></div><div class="subs instances"><p id="control.i:MVar" class="caption collapser" onclick="toggleSection('i:MVar')">Instances</p><div id="section.i:MVar" class="show"><table><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:MVar:Eq:1" class="instance expander" onclick="toggleSection('i:id:MVar:Eq:1')"></span> <a href="SafePrelude.html#t:Eq">Eq</a> (<a href="SafePrelude.html#t:MVar">MVar</a> a)</span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:id:MVar:Eq:1" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:-61--61-">(==)</a> :: <a href="SafePrelude.html#t:MVar">MVar</a> a -&gt; <a href="SafePrelude.html#t:MVar">MVar</a> a -&gt; <a href="SafePrelude.html#t:Bool">Bool</a> <a href="#v:-61--61-" class="selflink">#</a></p><p class="src"><a href="#v:-47--61-">(/=)</a> :: <a href="SafePrelude.html#t:MVar">MVar</a> a -&gt; <a href="SafePrelude.html#t:MVar">MVar</a> a -&gt; <a href="SafePrelude.html#t:Bool">Bool</a> <a href="#v:-47--61-" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:MVar:NFData:2" class="instance expander" onclick="toggleSection('i:id:MVar:NFData:2')"></span> <a href="SafePrelude.html#t:NFData">NFData</a> (<a href="SafePrelude.html#t:MVar">MVar</a> a)</span></td><td class="doc"><p><strong>NOTE</strong>: Only strict in the reference and not the referenced value.</p><p><em>Since: 1.4.2.0</em></p></td></tr><tr><td colspan="2"><div id="section.i:id:MVar:NFData:2" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:rnf">rnf</a> :: <a href="SafePrelude.html#t:MVar">MVar</a> a -&gt; () <a href="#v:rnf" class="selflink">#</a></p></div></div></td></tr></table></div></div></div><div class="top"><p class="src"><a id="v:newEmptyMVar" class="def">newEmptyMVar</a> :: <a href="SafePrelude.html#t:IO">IO</a> (<a href="SafePrelude.html#t:MVar">MVar</a> a) <a href="#v:newEmptyMVar" class="selflink">#</a></p><div class="doc"><p>Create an <code><a href="SafePrelude.html#t:MVar">MVar</a></code> which is initially empty.</p></div></div><div class="top"><p class="src"><a id="v:newMVar" class="def">newMVar</a> :: a -&gt; <a href="SafePrelude.html#t:IO">IO</a> (<a href="SafePrelude.html#t:MVar">MVar</a> a) <a href="#v:newMVar" class="selflink">#</a></p><div class="doc"><p>Create an <code><a href="SafePrelude.html#t:MVar">MVar</a></code> which contains the supplied value.</p></div></div><div class="top"><p class="src"><a id="v:takeMVar" class="def">takeMVar</a> :: <a href="SafePrelude.html#t:MVar">MVar</a> a -&gt; <a href="SafePrelude.html#t:IO">IO</a> a <a href="#v:takeMVar" class="selflink">#</a></p><div class="doc"><p>Return the contents of the <code><a href="SafePrelude.html#t:MVar">MVar</a></code>. If the <code><a href="SafePrelude.html#t:MVar">MVar</a></code> is currently
empty, <code><a href="SafePrelude.html#v:takeMVar">takeMVar</a></code> will wait until it is full. After a <code><a href="SafePrelude.html#v:takeMVar">takeMVar</a></code>,
the <code><a href="SafePrelude.html#t:MVar">MVar</a></code> is left empty.</p><p>There are two further important properties of <code><a href="SafePrelude.html#v:takeMVar">takeMVar</a></code>:</p><ul><li><code><a href="SafePrelude.html#v:takeMVar">takeMVar</a></code> is single-wakeup. That is, if there are multiple
threads blocked in <code><a href="SafePrelude.html#v:takeMVar">takeMVar</a></code>, and the <code><a href="SafePrelude.html#t:MVar">MVar</a></code> becomes full,
only one thread will be woken up. The runtime guarantees that
the woken thread completes its <code><a href="SafePrelude.html#v:takeMVar">takeMVar</a></code> operation.</li><li>When multiple threads are blocked on an <code><a href="SafePrelude.html#t:MVar">MVar</a></code>, they are
woken up in FIFO order. This is useful for providing
fairness properties of abstractions built using <code><a href="SafePrelude.html#t:MVar">MVar</a></code>s.</li></ul></div></div><div class="top"><p class="src"><a id="v:putMVar" class="def">putMVar</a> :: <a href="SafePrelude.html#t:MVar">MVar</a> a -&gt; a -&gt; <a href="SafePrelude.html#t:IO">IO</a> () <a href="#v:putMVar" class="selflink">#</a></p><div class="doc"><p>Put a value into an <code><a href="SafePrelude.html#t:MVar">MVar</a></code>. If the <code><a href="SafePrelude.html#t:MVar">MVar</a></code> is currently full,
<code><a href="SafePrelude.html#v:putMVar">putMVar</a></code> will wait until it becomes empty.</p><p>There are two further important properties of <code><a href="SafePrelude.html#v:putMVar">putMVar</a></code>:</p><ul><li><code><a href="SafePrelude.html#v:putMVar">putMVar</a></code> is single-wakeup. That is, if there are multiple
threads blocked in <code><a href="SafePrelude.html#v:putMVar">putMVar</a></code>, and the <code><a href="SafePrelude.html#t:MVar">MVar</a></code> becomes empty,
only one thread will be woken up. The runtime guarantees that
the woken thread completes its <code><a href="SafePrelude.html#v:putMVar">putMVar</a></code> operation.</li><li>When multiple threads are blocked on an <code><a href="SafePrelude.html#t:MVar">MVar</a></code>, they are
woken up in FIFO order. This is useful for providing
fairness properties of abstractions built using <code><a href="SafePrelude.html#t:MVar">MVar</a></code>s.</li></ul></div></div><div class="top"><p class="src"><a id="v:readMVar" class="def">readMVar</a> :: <a href="SafePrelude.html#t:MVar">MVar</a> a -&gt; <a href="SafePrelude.html#t:IO">IO</a> a <a href="#v:readMVar" class="selflink">#</a></p><div class="doc"><p>Atomically read the contents of an <code><a href="SafePrelude.html#t:MVar">MVar</a></code>. If the <code><a href="SafePrelude.html#t:MVar">MVar</a></code> is
currently empty, <code><a href="SafePrelude.html#v:readMVar">readMVar</a></code> will wait until its full.
<code><a href="SafePrelude.html#v:readMVar">readMVar</a></code> is guaranteed to receive the next <code><a href="SafePrelude.html#v:putMVar">putMVar</a></code>.</p><p><code><a href="SafePrelude.html#v:readMVar">readMVar</a></code> is multiple-wakeup, so when multiple readers are
blocked on an <code><a href="SafePrelude.html#t:MVar">MVar</a></code>, all of them are woken up at the same time.</p><p><em>Compatibility note:</em> Prior to base 4.7, <code><a href="SafePrelude.html#v:readMVar">readMVar</a></code> was a combination
of <code><a href="SafePrelude.html#v:takeMVar">takeMVar</a></code> and <code><a href="SafePrelude.html#v:putMVar">putMVar</a></code>. This mean that in the presence of
other threads attempting to <code><a href="SafePrelude.html#v:putMVar">putMVar</a></code>, <code><a href="SafePrelude.html#v:readMVar">readMVar</a></code> could block.
Furthermore, <code><a href="SafePrelude.html#v:readMVar">readMVar</a></code> would not receive the next <code><a href="SafePrelude.html#v:putMVar">putMVar</a></code> if there
was already a pending thread blocked on <code><a href="SafePrelude.html#v:takeMVar">takeMVar</a></code>. The old behavior
can be recovered by implementing 'readMVar as follows:</p><pre> readMVar :: MVar a -&gt; IO a
readMVar m =
mask_ $ do
a &lt;- takeMVar m
putMVar m a
return a
</pre></div></div><div class="top"><p class="src"><a id="v:swapMVar" class="def">swapMVar</a> :: <a href="SafePrelude.html#t:MVar">MVar</a> a -&gt; a -&gt; <a href="SafePrelude.html#t:IO">IO</a> a <a href="#v:swapMVar" class="selflink">#</a></p><div class="doc"><p>Take a value from an <code><a href="SafePrelude.html#t:MVar">MVar</a></code>, put a new value into the <code><a href="SafePrelude.html#t:MVar">MVar</a></code> and
return the value taken. This function is atomic only if there are
no other producers for this <code><a href="SafePrelude.html#t:MVar">MVar</a></code>.</p></div></div><div class="top"><p class="src"><a id="v:tryTakeMVar" class="def">tryTakeMVar</a> :: <a href="SafePrelude.html#t:MVar">MVar</a> a -&gt; <a href="SafePrelude.html#t:IO">IO</a> (<a href="SafePrelude.html#t:Maybe">Maybe</a> a) <a href="#v:tryTakeMVar" class="selflink">#</a></p><div class="doc"><p>A non-blocking version of <code><a href="SafePrelude.html#v:takeMVar">takeMVar</a></code>. The <code><a href="SafePrelude.html#v:tryTakeMVar">tryTakeMVar</a></code> function
returns immediately, with <code><a href="SafePrelude.html#v:Nothing">Nothing</a></code> if the <code><a href="SafePrelude.html#t:MVar">MVar</a></code> was empty, or
<code><code><a href="SafePrelude.html#v:Just">Just</a></code> a</code> if the <code><a href="SafePrelude.html#t:MVar">MVar</a></code> was full with contents <code>a</code>. After <code><a href="SafePrelude.html#v:tryTakeMVar">tryTakeMVar</a></code>,
the <code><a href="SafePrelude.html#t:MVar">MVar</a></code> is left empty.</p></div></div><div class="top"><p class="src"><a id="v:tryPutMVar" class="def">tryPutMVar</a> :: <a href="SafePrelude.html#t:MVar">MVar</a> a -&gt; a -&gt; <a href="SafePrelude.html#t:IO">IO</a> <a href="SafePrelude.html#t:Bool">Bool</a> <a href="#v:tryPutMVar" class="selflink">#</a></p><div class="doc"><p>A non-blocking version of <code><a href="SafePrelude.html#v:putMVar">putMVar</a></code>. The <code><a href="SafePrelude.html#v:tryPutMVar">tryPutMVar</a></code> function
attempts to put the value <code>a</code> into the <code><a href="SafePrelude.html#t:MVar">MVar</a></code>, returning <code><a href="SafePrelude.html#v:True">True</a></code> if
it was successful, or <code><a href="SafePrelude.html#v:False">False</a></code> otherwise.</p></div></div><div class="top"><p class="src"><a id="v:isEmptyMVar" class="def">isEmptyMVar</a> :: <a href="SafePrelude.html#t:MVar">MVar</a> a -&gt; <a href="SafePrelude.html#t:IO">IO</a> <a href="SafePrelude.html#t:Bool">Bool</a> <a href="#v:isEmptyMVar" class="selflink">#</a></p><div class="doc"><p>Check whether a given <code><a href="SafePrelude.html#t:MVar">MVar</a></code> is empty.</p><p>Notice that the boolean value returned is just a snapshot of
the state of the MVar. By the time you get to react on its result,
the MVar may have been filled (or emptied) - so be extremely
careful when using this operation. Use <code><a href="SafePrelude.html#v:tryTakeMVar">tryTakeMVar</a></code> instead if possible.</p></div></div><div class="top"><p class="src"><a id="v:withMVar" class="def">withMVar</a> :: <a href="SafePrelude.html#t:MVar">MVar</a> a -&gt; (a -&gt; <a href="SafePrelude.html#t:IO">IO</a> b) -&gt; <a href="SafePrelude.html#t:IO">IO</a> b <a href="#v:withMVar" class="selflink">#</a></p><div class="doc"><p><code><a href="SafePrelude.html#v:withMVar">withMVar</a></code> is an exception-safe wrapper for operating on the contents
of an <code><a href="SafePrelude.html#t:MVar">MVar</a></code>. This operation is exception-safe: it will replace the
original contents of the <code><a href="SafePrelude.html#t:MVar">MVar</a></code> if an exception is raised (see
<a href="../base-4.9.0.0/Control-Exception.html">Control.Exception</a>). However, it is only atomic if there are no
other producers for this <code><a href="SafePrelude.html#t:MVar">MVar</a></code>.</p></div></div><div class="top"><p class="src"><a id="v:withMVarMasked" class="def">withMVarMasked</a> :: <a href="SafePrelude.html#t:MVar">MVar</a> a -&gt; (a -&gt; <a href="SafePrelude.html#t:IO">IO</a> b) -&gt; <a href="SafePrelude.html#t:IO">IO</a> b <a href="#v:withMVarMasked" class="selflink">#</a></p><div class="doc"><p>Like <code><a href="SafePrelude.html#v:withMVar">withMVar</a></code>, but the <code>IO</code> action in the second argument is executed
with asynchronous exceptions masked.</p><p><em>Since: 4.7.0.0</em></p></div></div><div class="top"><p class="src"><a id="v:modifyMVar_" class="def">modifyMVar_</a> :: <a href="SafePrelude.html#t:MVar">MVar</a> a -&gt; (a -&gt; <a href="SafePrelude.html#t:IO">IO</a> a) -&gt; <a href="SafePrelude.html#t:IO">IO</a> () <a href="#v:modifyMVar_" class="selflink">#</a></p><div class="doc"><p>An exception-safe wrapper for modifying the contents of an <code><a href="SafePrelude.html#t:MVar">MVar</a></code>.
Like <code><a href="SafePrelude.html#v:withMVar">withMVar</a></code>, <code><a href="SafePrelude.html#v:modifyMVar">modifyMVar</a></code> will replace the original contents of
the <code><a href="SafePrelude.html#t:MVar">MVar</a></code> if an exception is raised during the operation. This
function is only atomic if there are no other producers for this
<code><a href="SafePrelude.html#t:MVar">MVar</a></code>.</p></div></div><div class="top"><p class="src"><a id="v:modifyMVar" class="def">modifyMVar</a> :: <a href="SafePrelude.html#t:MVar">MVar</a> a -&gt; (a -&gt; <a href="SafePrelude.html#t:IO">IO</a> (a, b)) -&gt; <a href="SafePrelude.html#t:IO">IO</a> b <a href="#v:modifyMVar" class="selflink">#</a></p><div class="doc"><p>A slight variation on <code><a href="SafePrelude.html#v:modifyMVar_">modifyMVar_</a></code> that allows a value to be
returned (<code>b</code>) in addition to the modified value of the <code><a href="SafePrelude.html#t:MVar">MVar</a></code>.</p></div></div><div class="top"><p class="src"><a id="v:modifyMVarMasked_" class="def">modifyMVarMasked_</a> :: <a href="SafePrelude.html#t:MVar">MVar</a> a -&gt; (a -&gt; <a href="SafePrelude.html#t:IO">IO</a> a) -&gt; <a href="SafePrelude.html#t:IO">IO</a> () <a href="#v:modifyMVarMasked_" class="selflink">#</a></p><div class="doc"><p>Like <code><a href="SafePrelude.html#v:modifyMVar_">modifyMVar_</a></code>, but the <code>IO</code> action in the second argument is executed with
asynchronous exceptions masked.</p><p><em>Since: 4.6.0.0</em></p></div></div><div class="top"><p class="src"><a id="v:modifyMVarMasked" class="def">modifyMVarMasked</a> :: <a href="SafePrelude.html#t:MVar">MVar</a> a -&gt; (a -&gt; <a href="SafePrelude.html#t:IO">IO</a> (a, b)) -&gt; <a href="SafePrelude.html#t:IO">IO</a> b <a href="#v:modifyMVarMasked" class="selflink">#</a></p><div class="doc"><p>Like <code><a href="SafePrelude.html#v:modifyMVar">modifyMVar</a></code>, but the <code>IO</code> action in the second argument is executed with
asynchronous exceptions masked.</p><p><em>Since: 4.6.0.0</em></p></div></div><div class="top"><p class="src"><a id="v:tryReadMVar" class="def">tryReadMVar</a> :: <a href="SafePrelude.html#t:MVar">MVar</a> a -&gt; <a href="SafePrelude.html#t:IO">IO</a> (<a href="SafePrelude.html#t:Maybe">Maybe</a> a) <a href="#v:tryReadMVar" class="selflink">#</a></p><div class="doc"><p>A non-blocking version of <code><a href="SafePrelude.html#v:readMVar">readMVar</a></code>. The <code><a href="SafePrelude.html#v:tryReadMVar">tryReadMVar</a></code> function
returns immediately, with <code><a href="SafePrelude.html#v:Nothing">Nothing</a></code> if the <code><a href="SafePrelude.html#t:MVar">MVar</a></code> was empty, or
<code><code><a href="SafePrelude.html#v:Just">Just</a></code> a</code> if the <code><a href="SafePrelude.html#t:MVar">MVar</a></code> was full with contents <code>a</code>.</p><p><em>Since: 4.7.0.0</em></p></div></div><div class="top"><p class="src"><a id="v:mkWeakMVar" class="def">mkWeakMVar</a> :: <a href="SafePrelude.html#t:MVar">MVar</a> a -&gt; <a href="SafePrelude.html#t:IO">IO</a> () -&gt; <a href="SafePrelude.html#t:IO">IO</a> (<a href="../base-4.9.0.0/System-Mem-Weak.html#t:Weak">Weak</a> (<a href="SafePrelude.html#t:MVar">MVar</a> a)) <a href="#v:mkWeakMVar" class="selflink">#</a></p><div class="doc"><p>Make a <code><a href="../base-4.9.0.0/System-Mem-Weak.html#t:Weak">Weak</a></code> pointer to an <code><a href="SafePrelude.html#t:MVar">MVar</a></code>, using the second argument as
a finalizer to run when <code><a href="SafePrelude.html#t:MVar">MVar</a></code> is garbage-collected</p><p><em>Since: 4.6.0.0</em></p></div></div><div class="top"><p class="src"><span class="keyword">data</span> <a id="t:Chan" class="def">Chan</a> a :: <a href="../base-4.9.0.0/Data-Kind.html#t:-42-">*</a> -&gt; <a href="../base-4.9.0.0/Data-Kind.html#t:-42-">*</a> <a href="#t:Chan" class="selflink">#</a></p><div class="doc"><p><code><a href="SafePrelude.html#t:Chan">Chan</a></code> is an abstract type representing an unbounded FIFO channel.</p></div><div class="subs instances"><p id="control.i:Chan" class="caption collapser" onclick="toggleSection('i:Chan')">Instances</p><div id="section.i:Chan" class="show"><table><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:Chan:Eq:1" class="instance expander" onclick="toggleSection('i:id:Chan:Eq:1')"></span> <a href="SafePrelude.html#t:Eq">Eq</a> (<a href="SafePrelude.html#t:Chan">Chan</a> a)</span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:id:Chan:Eq:1" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:-61--61-">(==)</a> :: <a href="SafePrelude.html#t:Chan">Chan</a> a -&gt; <a href="SafePrelude.html#t:Chan">Chan</a> a -&gt; <a href="SafePrelude.html#t:Bool">Bool</a> <a href="#v:-61--61-" class="selflink">#</a></p><p class="src"><a href="#v:-47--61-">(/=)</a> :: <a href="SafePrelude.html#t:Chan">Chan</a> a -&gt; <a href="SafePrelude.html#t:Chan">Chan</a> a -&gt; <a href="SafePrelude.html#t:Bool">Bool</a> <a href="#v:-47--61-" class="selflink">#</a></p></div></div></td></tr></table></div></div></div><div class="top"><p class="src"><a id="v:newChan" class="def">newChan</a> :: <a href="SafePrelude.html#t:IO">IO</a> (<a href="SafePrelude.html#t:Chan">Chan</a> a) <a href="#v:newChan" class="selflink">#</a></p><div class="doc"><p>Build and returns a new instance of <code><a href="SafePrelude.html#t:Chan">Chan</a></code>.</p></div></div><div class="top"><p class="src"><a id="v:writeChan" class="def">writeChan</a> :: <a href="SafePrelude.html#t:Chan">Chan</a> a -&gt; a -&gt; <a href="SafePrelude.html#t:IO">IO</a> () <a href="#v:writeChan" class="selflink">#</a></p><div class="doc"><p>Write a value to a <code><a href="SafePrelude.html#t:Chan">Chan</a></code>.</p></div></div><div class="top"><p class="src"><a id="v:readChan" class="def">readChan</a> :: <a href="SafePrelude.html#t:Chan">Chan</a> a -&gt; <a href="SafePrelude.html#t:IO">IO</a> a <a href="#v:readChan" class="selflink">#</a></p><div class="doc"><p>Read the next value from the <code><a href="SafePrelude.html#t:Chan">Chan</a></code>.</p></div></div><div class="top"><p class="src"><a id="v:dupChan" class="def">dupChan</a> :: <a href="SafePrelude.html#t:Chan">Chan</a> a -&gt; <a href="SafePrelude.html#t:IO">IO</a> (<a href="SafePrelude.html#t:Chan">Chan</a> a) <a href="#v:dupChan" class="selflink">#</a></p><div class="doc"><p>Duplicate a <code><a href="SafePrelude.html#t:Chan">Chan</a></code>: the duplicate channel begins empty, but data written to
either channel from then on will be available from both. Hence this creates
a kind of broadcast channel, where data written by anyone is seen by
everyone else.</p><p>(Note that a duplicated channel is not equal to its original.
So: <code>fmap (c /=) $ dupChan c</code> returns <code>True</code> for all <code>c</code>.)</p></div></div><h2 id="g:14">Reader</h2><div class="top"><p class="src"><a id="v:asks" class="def">asks</a> <a href="#v:asks" class="selflink">#</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="SafePrelude.html#t:MonadReader">MonadReader</a> r m</td><td class="doc empty">&nbsp;</td></tr><tr><td class="src">=&gt; (r -&gt; a)</td><td class="doc"><p>The selector function to apply to the environment.</p></td></tr><tr><td class="src">-&gt; m a</td><td class="doc empty">&nbsp;</td></tr></table></div><div class="doc"><p>Retrieves a function of the current environment.</p></div></div><h2 id="g:15">Exceptions</h2><div class="top"><p class="src"><a id="v:throwIO" class="def">throwIO</a> :: (<a href="SafePrelude.html#t:MonadThrow">MonadThrow</a> m, <a href="SafePrelude.html#t:Exception">Exception</a> e) =&gt; e -&gt; m a <a href="#v:throwIO" class="selflink">#</a></p><div class="doc"><p>Synonym for <code><a href="../safe-exceptions-0.1.4.0/Control-Exception-Safe.html#v:throw">throw</a></code></p><p><em>Since: 0.1.0.0</em></p></div></div><div class="top"><p class="src"><a id="v:throwM" class="def">throwM</a> :: (<a href="SafePrelude.html#t:MonadThrow">MonadThrow</a> m, <a href="SafePrelude.html#t:Exception">Exception</a> e) =&gt; e -&gt; m a <a href="#v:throwM" class="selflink">#</a></p><div class="doc"><p>Synonym for <code><a href="../safe-exceptions-0.1.4.0/Control-Exception-Safe.html#v:throw">throw</a></code></p><p><em>Since: 0.1.0.0</em></p></div></div><div class="top"><p class="src"><a id="v:throwTo" class="def">throwTo</a> :: (<a href="SafePrelude.html#t:Exception">Exception</a> e, <a href="SafePrelude.html#t:MonadIO">MonadIO</a> m) =&gt; <a href="../base-4.9.0.0/Control-Concurrent.html#t:ThreadId">ThreadId</a> -&gt; e -&gt; m () <a href="#v:throwTo" class="selflink">#</a></p><div class="doc"><p>Throw an asynchronous exception to another thread</p><p>It's usually a better idea to use the async package, see
<a href="https://github.com/fpco/safe-exceptions#quickstart">https://github.com/fpco/safe-exceptions#quickstart</a></p><p><em>Since: 0.1.0.0</em></p></div></div><div class="top"><p class="src"><a id="v:catch" class="def">catch</a> :: (<a href="SafePrelude.html#t:MonadCatch">MonadCatch</a> m, <a href="SafePrelude.html#t:Exception">Exception</a> e) =&gt; m a -&gt; (e -&gt; m a) -&gt; m a <a href="#v:catch" class="selflink">#</a></p><div class="doc"><p>Same as upstream <code><a href="../exceptions-0.8.3/Control-Monad-Catch.html#v:catch">catch</a></code>, but will not catch asynchronous
exceptions</p><p><em>Since: 0.1.0.0</em></p></div></div><div class="top"><p class="src"><a id="v:catchIO" class="def">catchIO</a> :: <a href="SafePrelude.html#t:MonadCatch">MonadCatch</a> m =&gt; m a -&gt; (<a href="../base-4.9.0.0/Control-Exception-Base.html#t:IOException">IOException</a> -&gt; m a) -&gt; m a <a href="#v:catchIO" class="selflink">#</a></p><div class="doc"><p><code><a href="../exceptions-0.8.3/Control-Monad-Catch.html#v:catch">catch</a></code> specialized to only catching <code><a href="../base-4.9.0.0/Control-Exception-Base.html#t:IOException">IOException</a></code>s</p><p><em>Since: 0.1.3.0</em></p></div></div><div class="top"><p class="src"><a id="v:catchAny" class="def">catchAny</a> :: <a href="SafePrelude.html#t:MonadCatch">MonadCatch</a> m =&gt; m a -&gt; (<a href="SafePrelude.html#t:SomeException">SomeException</a> -&gt; m a) -&gt; m a <a href="#v:catchAny" class="selflink">#</a></p><div class="doc"><p><code><a href="SafePrelude.html#v:catch">catch</a></code> specialized to catch all synchronous exception</p><p><em>Since: 0.1.0.0</em></p></div></div><div class="top"><p class="src"><a id="v:catchDeep" class="def">catchDeep</a> :: (<a href="SafePrelude.html#t:MonadCatch">MonadCatch</a> m, <a href="SafePrelude.html#t:MonadIO">MonadIO</a> m, <a href="SafePrelude.html#t:Exception">Exception</a> e, <a href="SafePrelude.html#t:NFData">NFData</a> a) =&gt; m a -&gt; (e -&gt; m a) -&gt; m a <a href="#v:catchDeep" class="selflink">#</a></p><div class="doc"><p>Same as <code><a href="SafePrelude.html#v:catch">catch</a></code>, but fully force evaluation of the result value
to find all impure exceptions.</p><p><em>Since: 0.1.1.0</em></p></div></div><div class="top"><p class="src"><a id="v:catchAnyDeep" class="def">catchAnyDeep</a> :: (<a href="SafePrelude.html#t:MonadCatch">MonadCatch</a> m, <a href="SafePrelude.html#t:MonadIO">MonadIO</a> m, <a href="SafePrelude.html#t:NFData">NFData</a> a) =&gt; m a -&gt; (<a href="SafePrelude.html#t:SomeException">SomeException</a> -&gt; m a) -&gt; m a <a href="#v:catchAnyDeep" class="selflink">#</a></p><div class="doc"><p><code><a href="SafePrelude.html#v:catchDeep">catchDeep</a></code> specialized to catch all synchronous exception</p><p><em>Since: 0.1.1.0</em></p></div></div><div class="top"><p class="src"><a id="v:handle" class="def">handle</a> :: (<a href="SafePrelude.html#t:MonadCatch">MonadCatch</a> m, <a href="SafePrelude.html#t:Exception">Exception</a> e) =&gt; (e -&gt; m a) -&gt; m a -&gt; m a <a href="#v:handle" class="selflink">#</a></p><div class="doc"><p>Flipped version of <code><a href="SafePrelude.html#v:catch">catch</a></code></p><p><em>Since: 0.1.0.0</em></p></div></div><div class="top"><p class="src"><a id="v:handleIO" class="def">handleIO</a> :: <a href="SafePrelude.html#t:MonadCatch">MonadCatch</a> m =&gt; (<a href="../base-4.9.0.0/Control-Exception-Base.html#t:IOException">IOException</a> -&gt; m a) -&gt; m a -&gt; m a <a href="#v:handleIO" class="selflink">#</a></p><div class="doc"><p><code><a href="../exceptions-0.8.3/Control-Monad-Catch.html#v:handle">handle</a></code> specialized to only catching <code><a href="../base-4.9.0.0/Control-Exception-Base.html#t:IOException">IOException</a></code>s</p><p><em>Since: 0.1.3.0</em></p></div></div><div class="top"><p class="src"><a id="v:handleAny" class="def">handleAny</a> :: <a href="SafePrelude.html#t:MonadCatch">MonadCatch</a> m =&gt; (<a href="SafePrelude.html#t:SomeException">SomeException</a> -&gt; m a) -&gt; m a -&gt; m a <a href="#v:handleAny" class="selflink">#</a></p><div class="doc"><p>Flipped version of <code><a href="SafePrelude.html#v:catchAny">catchAny</a></code></p><p><em>Since: 0.1.0.0</em></p></div></div><div class="top"><p class="src"><a id="v:handleDeep" class="def">handleDeep</a> :: (<a href="SafePrelude.html#t:MonadCatch">MonadCatch</a> m, <a href="SafePrelude.html#t:Exception">Exception</a> e, <a href="SafePrelude.html#t:MonadIO">MonadIO</a> m, <a href="SafePrelude.html#t:NFData">NFData</a> a) =&gt; (e -&gt; m a) -&gt; m a -&gt; m a <a href="#v:handleDeep" class="selflink">#</a></p><div class="doc"><p>Flipped version of <code><a href="SafePrelude.html#v:catchDeep">catchDeep</a></code></p><p><em>Since: 0.1.1.0</em></p></div></div><div class="top"><p class="src"><a id="v:handleAnyDeep" class="def">handleAnyDeep</a> :: (<a href="SafePrelude.html#t:MonadCatch">MonadCatch</a> m, <a href="SafePrelude.html#t:MonadIO">MonadIO</a> m, <a href="SafePrelude.html#t:NFData">NFData</a> a) =&gt; (<a href="SafePrelude.html#t:SomeException">SomeException</a> -&gt; m a) -&gt; m a -&gt; m a <a href="#v:handleAnyDeep" class="selflink">#</a></p><div class="doc"><p>Flipped version of <code><a href="SafePrelude.html#v:catchAnyDeep">catchAnyDeep</a></code></p><p><em>Since: 0.1.1.0</em></p></div></div><div class="top"><p class="src"><a id="v:try" class="def">try</a> :: (<a href="SafePrelude.html#t:MonadCatch">MonadCatch</a> m, <a href="SafePrelude.html#t:Exception">Exception</a> e) =&gt; m a -&gt; m (<a href="SafePrelude.html#t:Either">Either</a> e a) <a href="#v:try" class="selflink">#</a></p><div class="doc"><p>Same as upstream <code><a href="../exceptions-0.8.3/Control-Monad-Catch.html#v:try">try</a></code>, but will not catch asynchronous
exceptions</p><p><em>Since: 0.1.0.0</em></p></div></div><div class="top"><p class="src"><a id="v:tryIO" class="def">tryIO</a> :: <a href="SafePrelude.html#t:MonadCatch">MonadCatch</a> m =&gt; m a -&gt; m (<a href="SafePrelude.html#t:Either">Either</a> <a href="../base-4.9.0.0/Control-Exception-Base.html#t:IOException">IOException</a> a) <a href="#v:tryIO" class="selflink">#</a></p><div class="doc"><p><code><a href="../exceptions-0.8.3/Control-Monad-Catch.html#v:try">try</a></code> specialized to only catching <code><a href="../base-4.9.0.0/Control-Exception-Base.html#t:IOException">IOException</a></code>s</p><p><em>Since: 0.1.3.0</em></p></div></div><div class="top"><p class="src"><a id="v:tryAny" class="def">tryAny</a> :: <a href="SafePrelude.html#t:MonadCatch">MonadCatch</a> m =&gt; m a -&gt; m (<a href="SafePrelude.html#t:Either">Either</a> <a href="SafePrelude.html#t:SomeException">SomeException</a> a) <a href="#v:tryAny" class="selflink">#</a></p><div class="doc"><p><code><a href="SafePrelude.html#v:try">try</a></code> specialized to catch all synchronous exceptions</p><p><em>Since: 0.1.0.0</em></p></div></div><div class="top"><p class="src"><a id="v:tryDeep" class="def">tryDeep</a> :: (<a href="SafePrelude.html#t:MonadCatch">MonadCatch</a> m, <a href="SafePrelude.html#t:MonadIO">MonadIO</a> m, <a href="SafePrelude.html#t:Exception">Exception</a> e, <a href="SafePrelude.html#t:NFData">NFData</a> a) =&gt; m a -&gt; m (<a href="SafePrelude.html#t:Either">Either</a> e a) <a href="#v:tryDeep" class="selflink">#</a></p><div class="doc"><p>Same as <code><a href="SafePrelude.html#v:try">try</a></code>, but fully force evaluation of the result value
to find all impure exceptions.</p><p><em>Since: 0.1.1.0</em></p></div></div><div class="top"><p class="src"><a id="v:tryAnyDeep" class="def">tryAnyDeep</a> :: (<a href="SafePrelude.html#t:MonadCatch">MonadCatch</a> m, <a href="SafePrelude.html#t:MonadIO">MonadIO</a> m, <a href="SafePrelude.html#t:NFData">NFData</a> a) =&gt; m a -&gt; m (<a href="SafePrelude.html#t:Either">Either</a> <a href="SafePrelude.html#t:SomeException">SomeException</a> a) <a href="#v:tryAnyDeep" class="selflink">#</a></p><div class="doc"><p><code><a href="SafePrelude.html#v:tryDeep">tryDeep</a></code> specialized to catch all synchronous exceptions</p><p><em>Since: 0.1.1.0</em></p></div></div><div class="top"><p class="src"><a id="v:onException" class="def">onException</a> :: <a href="SafePrelude.html#t:MonadMask">MonadMask</a> m =&gt; m a -&gt; m b -&gt; m a <a href="#v:onException" class="selflink">#</a></p><div class="doc"><p>Async safe version of <code><a href="../base-4.9.0.0/Control-Exception-Base.html#v:onException">onException</a></code></p><p><em>Since: 0.1.0.0</em></p></div></div><div class="top"><p class="src"><a id="v:bracket" class="def">bracket</a> :: <a href="SafePrelude.html#t:MonadMask">MonadMask</a> m =&gt; m a -&gt; (a -&gt; m b) -&gt; (a -&gt; m c) -&gt; m c <a href="#v:bracket" class="selflink">#</a></p><div class="doc"><p>Async safe version of <code><a href="../base-4.9.0.0/Control-Exception-Base.html#v:bracket">bracket</a></code></p><p><em>Since: 0.1.0.0</em></p></div></div><div class="top"><p class="src"><a id="v:bracket_" class="def">bracket_</a> :: <a href="SafePrelude.html#t:MonadMask">MonadMask</a> m =&gt; m a -&gt; m b -&gt; m c -&gt; m c <a href="#v:bracket_" class="selflink">#</a></p><div class="doc"><p>Async safe version of <code><a href="../base-4.9.0.0/Control-Exception-Base.html#v:bracket_">bracket_</a></code></p><p><em>Since: 0.1.0.0</em></p></div></div><div class="top"><p class="src"><a id="v:finally" class="def">finally</a> :: <a href="SafePrelude.html#t:MonadMask">MonadMask</a> m =&gt; m a -&gt; m b -&gt; m a <a href="#v:finally" class="selflink">#</a></p><div class="doc"><p>Async safe version of <code><a href="../base-4.9.0.0/Control-Exception-Base.html#v:finally">finally</a></code></p><p><em>Since: 0.1.0.0</em></p></div></div><div class="top"><p class="src"><a id="v:withException" class="def">withException</a> :: (<a href="SafePrelude.html#t:MonadMask">MonadMask</a> m, <a href="SafePrelude.html#t:Exception">Exception</a> e) =&gt; m a -&gt; (e -&gt; m b) -&gt; m a <a href="#v:withException" class="selflink">#</a></p><div class="doc"><p>Like <code><a href="SafePrelude.html#v:onException">onException</a></code>, but provides the handler the thrown
exception.</p><p><em>Since: 0.1.0.0</em></p></div></div><div class="top"><p class="src"><a id="v:bracketOnError" class="def">bracketOnError</a> :: <a href="SafePrelude.html#t:MonadMask">MonadMask</a> m =&gt; m a -&gt; (a -&gt; m b) -&gt; (a -&gt; m c) -&gt; m c <a href="#v:bracketOnError" class="selflink">#</a></p><div class="doc"><p>Async safe version of <code><a href="../base-4.9.0.0/Control-Exception-Base.html#v:bracketOnError">bracketOnError</a></code></p><p><em>Since: 0.1.0.0</em></p></div></div><div class="top"><p class="src"><a id="v:bracketOnError_" class="def">bracketOnError_</a> :: <a href="SafePrelude.html#t:MonadMask">MonadMask</a> m =&gt; m a -&gt; m b -&gt; m c -&gt; m c <a href="#v:bracketOnError_" class="selflink">#</a></p><div class="doc"><p>Async safe version of <code><a href="E.html#v:bracketOnError_">bracketOnError_</a></code></p><p><em>Since: 0.1.0.0</em></p></div></div><div class="top"><p class="src"><a id="v:displayException" class="def">displayException</a> :: <a href="SafePrelude.html#t:Exception">Exception</a> e =&gt; e -&gt; <a href="SafePrelude.html#t:String">String</a> <a href="#v:displayException" class="selflink">#</a></p><div class="doc"><p>Render this exception value in a human-friendly manner.</p><p>Default implementation: <code><code><a href="SafePrelude.html#v:show">show</a></code></code>.</p><p><em>Since: 4.8.0.0</em></p></div></div><h2 id="g:16">Arrow</h2><div class="top"><p class="src"><a id="v:-38--38--38-" class="def">(&amp;&amp;&amp;)</a> :: <a href="../base-4.9.0.0/Control-Arrow.html#t:Arrow">Arrow</a> a =&gt; <span class="keyword">forall</span> b c c'. a b c -&gt; a b c' -&gt; a b (c, c') <a href="#v:-38--38--38-" class="selflink">#</a></p><div class="doc"><p>Fanout: send the input to both argument arrows and combine
their output.</p><p>The default definition may be overridden with a more efficient
version if desired.</p></div></div><div class="top"><p class="src"><a id="v:-42--42--42-" class="def">(***)</a> :: <a href="../base-4.9.0.0/Control-Arrow.html#t:Arrow">Arrow</a> a =&gt; <span class="keyword">forall</span> b c b' c'. a b c -&gt; a b' c' -&gt; a (b, b') (c, c') <a href="#v:-42--42--42-" class="selflink">#</a></p><div class="doc"><p>Split the input between the two argument arrows and combine
their output. Note that this is in general not a functor.</p><p>The default definition may be overridden with a more efficient
version if desired.</p></div></div><h2 id="g:17">Maybe</h2><div class="top"><p class="src"><a id="v:mapMaybe" class="def">mapMaybe</a> :: (a -&gt; <a href="SafePrelude.html#t:Maybe">Maybe</a> b) -&gt; [a] -&gt; [b] <a href="#v:mapMaybe" class="selflink">#</a></p><div class="doc"><p>The <code><a href="SafePrelude.html#v:mapMaybe">mapMaybe</a></code> function is a version of <code><a href="../base-4.9.0.0/GHC-OldList.html#v:map">map</a></code> which can throw
out elements. In particular, the functional argument returns
something of type <code><code><a href="SafePrelude.html#t:Maybe">Maybe</a></code> b</code>. If this is <code><a href="SafePrelude.html#v:Nothing">Nothing</a></code>, no element
is added on to the result list. If it is <code><code><a href="SafePrelude.html#v:Just">Just</a></code> b</code>, then <code>b</code> is
included in the result list.</p><h4 id="control.ch:mapMaybe0" class="caption expander" onclick="toggleSection('ch:mapMaybe0')">Examples</h4><div id="section.ch:mapMaybe0" class="hide"><p>Using <code><code><a href="SafePrelude.html#v:mapMaybe">mapMaybe</a></code> f x</code> is a shortcut for <code><code><a href="SafePrelude.html#v:catMaybes">catMaybes</a></code> $ <code><a href="../base-4.9.0.0/GHC-OldList.html#v:map">map</a></code> f x</code>
in most cases:</p><pre class="screen"><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>import Text.Read ( readMaybe )
</code></strong><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>let readMaybeInt = readMaybe :: String -&gt; Maybe Int
</code></strong><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>mapMaybe readMaybeInt [&quot;1&quot;, &quot;Foo&quot;, &quot;3&quot;]
</code></strong>[1,3]
<code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>catMaybes $ map readMaybeInt [&quot;1&quot;, &quot;Foo&quot;, &quot;3&quot;]
</code></strong>[1,3]
</pre><p>If we map the <code><a href="SafePrelude.html#v:Just">Just</a></code> constructor, the entire list should be returned:</p><pre class="screen"><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>mapMaybe Just [1,2,3]
</code></strong>[1,2,3]
</pre></div></div></div><div class="top"><p class="src"><a id="v:catMaybes" class="def">catMaybes</a> :: [<a href="SafePrelude.html#t:Maybe">Maybe</a> a] -&gt; [a] <a href="#v:catMaybes" class="selflink">#</a></p><div class="doc"><p>The <code><a href="SafePrelude.html#v:catMaybes">catMaybes</a></code> function takes a list of <code><a href="SafePrelude.html#t:Maybe">Maybe</a></code>s and returns
a list of all the <code><a href="SafePrelude.html#v:Just">Just</a></code> values.</p><h4 id="control.ch:catMaybes0" class="caption expander" onclick="toggleSection('ch:catMaybes0')">Examples</h4><div id="section.ch:catMaybes0" class="hide"><p>Basic usage:</p><pre class="screen"><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>catMaybes [Just 1, Nothing, Just 3]
</code></strong>[1,3]
</pre><p>When constructing a list of <code><a href="SafePrelude.html#t:Maybe">Maybe</a></code> values, <code><a href="SafePrelude.html#v:catMaybes">catMaybes</a></code> can be used
to return all of the &quot;success&quot; results (if the list is the result
of a <code><a href="../base-4.9.0.0/GHC-OldList.html#v:map">map</a></code>, then <code><a href="SafePrelude.html#v:mapMaybe">mapMaybe</a></code> would be more appropriate):</p><pre class="screen"><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>import Text.Read ( readMaybe )
</code></strong><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>[readMaybe x :: Maybe Int | x &lt;- [&quot;1&quot;, &quot;Foo&quot;, &quot;3&quot;] ]
</code></strong>[Just 1,Nothing,Just 3]
<code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>catMaybes $ [readMaybe x :: Maybe Int | x &lt;- [&quot;1&quot;, &quot;Foo&quot;, &quot;3&quot;] ]
</code></strong>[1,3]
</pre></div></div></div><div class="top"><p class="src"><a id="v:fromMaybe" class="def">fromMaybe</a> :: a -&gt; <a href="SafePrelude.html#t:Maybe">Maybe</a> a -&gt; a <a href="#v:fromMaybe" class="selflink">#</a></p><div class="doc"><p>The <code><a href="SafePrelude.html#v:fromMaybe">fromMaybe</a></code> function takes a default value and and <code><a href="SafePrelude.html#t:Maybe">Maybe</a></code>
value. If the <code><a href="SafePrelude.html#t:Maybe">Maybe</a></code> is <code><a href="SafePrelude.html#v:Nothing">Nothing</a></code>, it returns the default values;
otherwise, it returns the value contained in the <code><a href="SafePrelude.html#t:Maybe">Maybe</a></code>.</p><h4 id="control.ch:fromMaybe0" class="caption expander" onclick="toggleSection('ch:fromMaybe0')">Examples</h4><div id="section.ch:fromMaybe0" class="hide"><p>Basic usage:</p><pre class="screen"><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>fromMaybe &quot;&quot; (Just &quot;Hello, World!&quot;)
</code></strong>&quot;Hello, World!&quot;
</pre><pre class="screen"><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>fromMaybe &quot;&quot; Nothing
</code></strong>&quot;&quot;
</pre><p>Read an integer from a string using <code>readMaybe</code>. If we fail to
parse an integer, we want to return <code>0</code> by default:</p><pre class="screen"><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>import Text.Read ( readMaybe )
</code></strong><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>fromMaybe 0 (readMaybe &quot;5&quot;)
</code></strong>5
<code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>fromMaybe 0 (readMaybe &quot;&quot;)
</code></strong>0
</pre></div></div></div><div class="top"><p class="src"><a id="v:isJust" class="def">isJust</a> :: <a href="SafePrelude.html#t:Maybe">Maybe</a> a -&gt; <a href="SafePrelude.html#t:Bool">Bool</a> <a href="#v:isJust" class="selflink">#</a></p><div class="doc"><p>The <code><a href="SafePrelude.html#v:isJust">isJust</a></code> function returns <code><a href="SafePrelude.html#v:True">True</a></code> iff its argument is of the
form <code>Just _</code>.</p><h4 id="control.ch:isJust0" class="caption expander" onclick="toggleSection('ch:isJust0')">Examples</h4><div id="section.ch:isJust0" class="hide"><p>Basic usage:</p><pre class="screen"><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>isJust (Just 3)
</code></strong>True
</pre><pre class="screen"><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>isJust (Just ())
</code></strong>True
</pre><pre class="screen"><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>isJust Nothing
</code></strong>False
</pre><p>Only the outer constructor is taken into consideration:</p><pre class="screen"><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>isJust (Just Nothing)
</code></strong>True
</pre></div></div></div><div class="top"><p class="src"><a id="v:isNothing" class="def">isNothing</a> :: <a href="SafePrelude.html#t:Maybe">Maybe</a> a -&gt; <a href="SafePrelude.html#t:Bool">Bool</a> <a href="#v:isNothing" class="selflink">#</a></p><div class="doc"><p>The <code><a href="SafePrelude.html#v:isNothing">isNothing</a></code> function returns <code><a href="SafePrelude.html#v:True">True</a></code> iff its argument is <code><a href="SafePrelude.html#v:Nothing">Nothing</a></code>.</p><h4 id="control.ch:isNothing0" class="caption expander" onclick="toggleSection('ch:isNothing0')">Examples</h4><div id="section.ch:isNothing0" class="hide"><p>Basic usage:</p><pre class="screen"><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>isNothing (Just 3)
</code></strong>False
</pre><pre class="screen"><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>isNothing (Just ())
</code></strong>False
</pre><pre class="screen"><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>isNothing Nothing
</code></strong>True
</pre><p>Only the outer constructor is taken into consideration:</p><pre class="screen"><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>isNothing (Just Nothing)
</code></strong>False
</pre></div></div></div><div class="top"><p class="src"><a id="v:listToMaybe" class="def">listToMaybe</a> :: [a] -&gt; <a href="SafePrelude.html#t:Maybe">Maybe</a> a <a href="#v:listToMaybe" class="selflink">#</a></p><div class="doc"><p>The <code><a href="SafePrelude.html#v:listToMaybe">listToMaybe</a></code> function returns <code><a href="SafePrelude.html#v:Nothing">Nothing</a></code> on an empty list
or <code><code><a href="SafePrelude.html#v:Just">Just</a></code> a</code> where <code>a</code> is the first element of the list.</p><h4 id="control.ch:listToMaybe0" class="caption expander" onclick="toggleSection('ch:listToMaybe0')">Examples</h4><div id="section.ch:listToMaybe0" class="hide"><p>Basic usage:</p><pre class="screen"><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>listToMaybe []
</code></strong>Nothing
</pre><pre class="screen"><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>listToMaybe [9]
</code></strong>Just 9
</pre><pre class="screen"><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>listToMaybe [1,2,3]
</code></strong>Just 1
</pre><p>Composing <code><a href="../base-4.9.0.0/Data-Maybe.html#v:maybeToList">maybeToList</a></code> with <code><a href="SafePrelude.html#v:listToMaybe">listToMaybe</a></code> should be the identity
on singleton/empty lists:</p><pre class="screen"><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>maybeToList $ listToMaybe [5]
</code></strong>[5]
<code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>maybeToList $ listToMaybe []
</code></strong>[]
</pre><p>But not on lists with more than one element:</p><pre class="screen"><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>maybeToList $ listToMaybe [1,2,3]
</code></strong>[1]
</pre></div></div></div><h2 id="g:18">Either</h2><div class="top"><p class="src"><a id="v:partitionEithers" class="def">partitionEithers</a> :: [<a href="SafePrelude.html#t:Either">Either</a> a b] -&gt; ([a], [b]) <a href="#v:partitionEithers" class="selflink">#</a></p><div class="doc"><p>Partitions a list of <code><a href="SafePrelude.html#t:Either">Either</a></code> into two lists.
All the <code><a href="SafePrelude.html#v:Left">Left</a></code> elements are extracted, in order, to the first
component of the output. Similarly the <code><a href="SafePrelude.html#v:Right">Right</a></code> elements are extracted
to the second component of the output.</p><h4 id="control.ch:partitionEithers0" class="caption expander" onclick="toggleSection('ch:partitionEithers0')">Examples</h4><div id="section.ch:partitionEithers0" class="hide"><p>Basic usage:</p><pre class="screen"><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>let list = [ Left &quot;foo&quot;, Right 3, Left &quot;bar&quot;, Right 7, Left &quot;baz&quot; ]
</code></strong><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>partitionEithers list
</code></strong>([&quot;foo&quot;,&quot;bar&quot;,&quot;baz&quot;],[3,7])
</pre><p>The pair returned by <code><code><a href="SafePrelude.html#v:partitionEithers">partitionEithers</a></code> x</code> should be the same
pair as <code>(<code><a href="SafePrelude.html#v:lefts">lefts</a></code> x, <code><a href="SafePrelude.html#v:rights">rights</a></code> x)</code>:</p><pre class="screen"><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>let list = [ Left &quot;foo&quot;, Right 3, Left &quot;bar&quot;, Right 7, Left &quot;baz&quot; ]
</code></strong><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>partitionEithers list == (lefts list, rights list)
</code></strong>True
</pre></div></div></div><div class="top"><p class="src"><a id="v:lefts" class="def">lefts</a> :: [<a href="SafePrelude.html#t:Either">Either</a> a b] -&gt; [a] <a href="#v:lefts" class="selflink">#</a></p><div class="doc"><p>Extracts from a list of <code><a href="SafePrelude.html#t:Either">Either</a></code> all the <code><a href="SafePrelude.html#v:Left">Left</a></code> elements.
All the <code><a href="SafePrelude.html#v:Left">Left</a></code> elements are extracted in order.</p><h4 id="control.ch:lefts0" class="caption expander" onclick="toggleSection('ch:lefts0')">Examples</h4><div id="section.ch:lefts0" class="hide"><p>Basic usage:</p><pre class="screen"><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>let list = [ Left &quot;foo&quot;, Right 3, Left &quot;bar&quot;, Right 7, Left &quot;baz&quot; ]
</code></strong><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>lefts list
</code></strong>[&quot;foo&quot;,&quot;bar&quot;,&quot;baz&quot;]
</pre></div></div></div><div class="top"><p class="src"><a id="v:rights" class="def">rights</a> :: [<a href="SafePrelude.html#t:Either">Either</a> a b] -&gt; [b] <a href="#v:rights" class="selflink">#</a></p><div class="doc"><p>Extracts from a list of <code><a href="SafePrelude.html#t:Either">Either</a></code> all the <code><a href="SafePrelude.html#v:Right">Right</a></code> elements.
All the <code><a href="SafePrelude.html#v:Right">Right</a></code> elements are extracted in order.</p><h4 id="control.ch:rights0" class="caption expander" onclick="toggleSection('ch:rights0')">Examples</h4><div id="section.ch:rights0" class="hide"><p>Basic usage:</p><pre class="screen"><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>let list = [ Left &quot;foo&quot;, Right 3, Left &quot;bar&quot;, Right 7, Left &quot;baz&quot; ]
</code></strong><code class="prompt">&gt;&gt;&gt; </code><strong class="userinput"><code>rights list
</code></strong>[3,7]
</pre></div></div></div><h2 id="g:19">Ord</h2><div class="top"><p class="src"><a id="v:on" class="def">on</a> :: (b -&gt; b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; a -&gt; c <span class="fixity">infixl 0</span><span class="rightedge"></span> <a href="#v:on" class="selflink">#</a></p><div class="doc"><p><code>(*) `on` f = \x y -&gt; f x * f y</code>.</p><p>Typical usage: <code><code><a href="../base-4.9.0.0/Data-List.html#v:sortBy">sortBy</a></code> (<code>compare</code> `on` <code>fst</code>)</code>.</p><p>Algebraic properties:</p><ul><li><code>(*) `on` <code><a href="SafePrelude.html#v:id">id</a></code> = (*)</code> (if <code>(*) &#8713; {&#8869;, <code><a href="SafePrelude.html#v:const">const</a></code> &#8869;}</code>)</li><li><pre>((*) `on` f) `on` g = (*) `on` (f . g)</pre></li><li><pre><code><a href="SafePrelude.html#v:flip">flip</a></code> on f . <code><a href="SafePrelude.html#v:flip">flip</a></code> on g = <code><a href="SafePrelude.html#v:flip">flip</a></code> on (g . f)</pre></li></ul></div></div><div class="top"><p class="src"><a id="v:comparing" class="def">comparing</a> :: <a href="SafePrelude.html#t:Ord">Ord</a> a =&gt; (b -&gt; a) -&gt; b -&gt; b -&gt; <a href="SafePrelude.html#t:Ordering">Ordering</a> <a href="#v:comparing" class="selflink">#</a></p><div class="doc"><pre>comparing p x y = compare (p x) (p y)</pre><p>Useful combinator for use in conjunction with the <code>xxxBy</code> family
of functions from <a href="../base-4.9.0.0/Data-List.html">Data.List</a>, for example:</p><pre> ... sortBy (comparing fst) ...</pre></div></div><h2 id="g:20">Say</h2><div class="top"><p class="src"><a id="v:say" class="def">say</a> :: <a href="SafePrelude.html#t:MonadIO">MonadIO</a> m =&gt; <a href="SafePrelude.html#t:Text">Text</a> -&gt; m () <a href="#v:say" class="selflink">#</a></p><div class="doc"><p>Send a <code><a href="SafePrelude.html#t:Text">Text</a></code> to standard output, appending a newline, and chunking the
data. By default, the chunk size is 2048 characters, so any messages below
that size will be sent as one contiguous unit. If larger messages are used,
it is possible for interleaving with other threads to occur.</p><p><em>Since: 0.1.0.0</em></p></div></div><div class="top"><p class="src"><a id="v:sayString" class="def">sayString</a> :: <a href="SafePrelude.html#t:MonadIO">MonadIO</a> m =&gt; <a href="SafePrelude.html#t:String">String</a> -&gt; m () <a href="#v:sayString" class="selflink">#</a></p><div class="doc"><p>Same as <code><a href="SafePrelude.html#v:say">say</a></code>, but operates on a <code><a href="SafePrelude.html#t:String">String</a></code>. Note that this will
force the entire <code>String</code> into memory at once, and will fail for
infinite <code>String</code>s.</p><p><em>Since: 0.1.0.0</em></p></div></div><div class="top"><p class="src"><a id="v:sayShow" class="def">sayShow</a> :: (<a href="SafePrelude.html#t:MonadIO">MonadIO</a> m, <a href="SafePrelude.html#t:Show">Show</a> a) =&gt; a -&gt; m () <a href="#v:sayShow" class="selflink">#</a></p><div class="doc"><p>Same as <code><a href="SafePrelude.html#v:say">say</a></code>, but for instances of <code><a href="SafePrelude.html#t:Show">Show</a></code>.</p><p>If your <code>Show</code> instance generates infinite output, this will fail. However,
an infinite result for <code>show</code> would generally be considered an invalid
instance anyway.</p><p><em>Since: 0.1.0.0</em></p></div></div><div class="top"><p class="src"><a id="v:sayErr" class="def">sayErr</a> :: <a href="SafePrelude.html#t:MonadIO">MonadIO</a> m =&gt; <a href="SafePrelude.html#t:Text">Text</a> -&gt; m () <a href="#v:sayErr" class="selflink">#</a></p><div class="doc"><p>Same as <code><a href="SafePrelude.html#v:say">say</a></code>, but data is sent to standard error.</p><p><em>Since: 0.1.0.0</em></p></div></div><div class="top"><p class="src"><a id="v:sayErrString" class="def">sayErrString</a> :: <a href="SafePrelude.html#t:MonadIO">MonadIO</a> m =&gt; <a href="SafePrelude.html#t:String">String</a> -&gt; m () <a href="#v:sayErrString" class="selflink">#</a></p><div class="doc"><p>Same as <code><a href="SafePrelude.html#v:sayString">sayString</a></code>, but data is sent to standard error.</p><p><em>Since: 0.1.0.0</em></p></div></div><div class="top"><p class="src"><a id="v:sayErrShow" class="def">sayErrShow</a> :: (<a href="SafePrelude.html#t:MonadIO">MonadIO</a> m, <a href="SafePrelude.html#t:Show">Show</a> a) =&gt; a -&gt; m () <a href="#v:sayErrShow" class="selflink">#</a></p><div class="doc"><p>Same as <code><a href="SafePrelude.html#v:sayShow">sayShow</a></code>, but data is sent to standard error.</p><p><em>Since: 0.1.0.0</em></p></div></div><div class="top"><p class="src"><a id="v:hSay" class="def">hSay</a> :: <a href="SafePrelude.html#t:MonadIO">MonadIO</a> m =&gt; <a href="SafePrelude.html#t:Handle">Handle</a> -&gt; <a href="SafePrelude.html#t:Text">Text</a> -&gt; m () <a href="#v:hSay" class="selflink">#</a></p><div class="doc"><p>Same as <code><a href="SafePrelude.html#v:say">say</a></code>, but data is sent to the provided <code><a href="SafePrelude.html#t:Handle">Handle</a></code>.</p><p><em>Since: 0.1.0.0</em></p></div></div><div class="top"><p class="src"><a id="v:hSayString" class="def">hSayString</a> :: <a href="SafePrelude.html#t:MonadIO">MonadIO</a> m =&gt; <a href="SafePrelude.html#t:Handle">Handle</a> -&gt; <a href="SafePrelude.html#t:String">String</a> -&gt; m () <a href="#v:hSayString" class="selflink">#</a></p><div class="doc"><p>Same as <code><a href="SafePrelude.html#v:sayString">sayString</a></code>, but data is sent to the provided <code><a href="SafePrelude.html#t:Handle">Handle</a></code>.</p><p><em>Since: 0.1.0.0</em></p></div></div><div class="top"><p class="src"><a id="v:hSayShow" class="def">hSayShow</a> :: (<a href="SafePrelude.html#t:MonadIO">MonadIO</a> m, <a href="SafePrelude.html#t:Show">Show</a> a) =&gt; <a href="SafePrelude.html#t:Handle">Handle</a> -&gt; a -&gt; m () <a href="#v:hSayShow" class="selflink">#</a></p><div class="doc"><p>Same as <code><a href="SafePrelude.html#v:sayShow">sayShow</a></code>, but data is sent to the provided <code><a href="SafePrelude.html#t:Handle">Handle</a></code>.</p><p><em>Since: 0.1.0.0</em></p></div></div><h2 id="g:21">IORef</h2><div class="top"><p class="src"><span class="keyword">data</span> <a id="t:IORef" class="def">IORef</a> a :: <a href="../base-4.9.0.0/Data-Kind.html#t:-42-">*</a> -&gt; <a href="../base-4.9.0.0/Data-Kind.html#t:-42-">*</a> <a href="#t:IORef" class="selflink">#</a></p><div class="doc"><p>A mutable variable in the <code><a href="SafePrelude.html#t:IO">IO</a></code> monad</p></div><div class="subs instances"><p id="control.i:IORef" class="caption collapser" onclick="toggleSection('i:IORef')">Instances</p><div id="section.i:IORef" class="show"><table><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:IORef:Eq:1" class="instance expander" onclick="toggleSection('i:id:IORef:Eq:1')"></span> <a href="SafePrelude.html#t:Eq">Eq</a> (<a href="SafePrelude.html#t:IORef">IORef</a> a)</span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:id:IORef:Eq:1" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:-61--61-">(==)</a> :: <a href="SafePrelude.html#t:IORef">IORef</a> a -&gt; <a href="SafePrelude.html#t:IORef">IORef</a> a -&gt; <a href="SafePrelude.html#t:Bool">Bool</a> <a hre
means if the program calls <code><a href="SafePrelude.html#v:modifyIORef">modifyIORef</a></code> many times, but seldomly uses the
value, thunks will pile up in memory resulting in a space leak. This is a
common mistake made when using an IORef as a counter. For example, the
following will likely produce a stack overflow:</p><pre>ref &lt;- newIORef 0
replicateM_ 1000000 $ modifyIORef ref (+1)
readIORef ref &gt;&gt;= print</pre><p>To avoid this problem, use <code><a href="SafePrelude.html#v:modifyIORef-39-">modifyIORef'</a></code> instead.</p></div></div><div class="top"><p class="src"><a id="v:modifyIORef-39-" class="def">modifyIORef'</a> :: <a href="SafePrelude.html#t:IORef">IORef</a> a -&gt; (a -&gt; a) -&gt; <a href="SafePrelude.html#t:IO">IO</a> () <a href="#v:modifyIORef-39-" class="selflink">#</a></p><div class="doc"><p>Strict version of <code><a href="SafePrelude.html#v:modifyIORef">modifyIORef</a></code></p><p><em>Since: 4.6.0.0</em></p></div></div><div class="top"><p class="src"><a id="v:atomicModifyIORef" class="def">atomicModifyIORef</a> :: <a href="SafePrelude.html#t:IORef">IORef</a> a -&gt; (a -&gt; (a, b)) -&gt; <a href="SafePrelude.html#t:IO">IO</a> b <a href="#v:atomicModifyIORef" class="selflink">#</a></p><div class="doc"><p>Atomically modifies the contents of an <code><a href="SafePrelude.html#t:IORef">IORef</a></code>.</p><p>This function is useful for using <code><a href="SafePrelude.html#t:IORef">IORef</a></code> in a safe way in a multithreaded
program. If you only have one <code><a href="SafePrelude.html#t:IORef">IORef</a></code>, then using <code><a href="SafePrelude.html#v:atomicModifyIORef">atomicModifyIORef</a></code> to
access and modify it will prevent race conditions.</p><p>Extending the atomicity to multiple <code><a href="SafePrelude.html#t:IORef">IORef</a></code>s is problematic, so it
is recommended that if you need to do anything more complicated
then using <code><a href="../base-4.9.0.0/Control-Concurrent-MVar.html#v:MVar">MVar</a></code> instead is a good idea.</p><p><code><a href="SafePrelude.html#v:atomicModifyIORef">atomicModifyIORef</a></code> does not apply the function strictly. This is important
to know even if all you are doing is replacing the value. For example, this
will leak memory:</p><pre>ref &lt;- newIORef '1'
forever $ atomicModifyIORef ref (\_ -&gt; ('2', ()))</pre><p>Use <code><a href="SafePrelude.html#v:atomicModifyIORef-39-">atomicModifyIORef'</a></code> or <code><a href="SafePrelude.html#v:atomicWriteIORef">atomicWriteIORef</a></code> to avoid this problem.</p></div></div><div class="top"><p class="src"><a id="v:atomicModifyIORef-39-" class="def">atomicModifyIORef'</a> :: <a href="SafePrelude.html#t:IORef">IORef</a> a -&gt; (a -&gt; (a, b)) -&gt; <a href="SafePrelude.html#t:IO">IO</a> b <a href="#v:atomicModifyIORef-39-" class="selflink">#</a></p><div class="doc"><p>Strict version of <code><a href="SafePrelude.html#v:atomicModifyIORef">atomicModifyIORef</a></code>. This forces both the value stored
in the <code><a href="SafePrelude.html#t:IORef">IORef</a></code> as well as the value returned.</p><p><em>Since: 4.6.0.0</em></p></div></div><div class="top"><p class="src"><a id="v:atomicWriteIORef" class="def">atomicWriteIORef</a> :: <a href="SafePrelude.html#t:IORef">IORef</a> a -&gt; a -&gt; <a href="SafePrelude.html#t:IO">IO</a> () <a href="#v:atomicWriteIORef" class="selflink">#</a></p><div class="doc"><p>Variant of <code><a href="SafePrelude.html#v:writeIORef">writeIORef</a></code> with the &quot;barrier to reordering&quot; property that
<code><a href="SafePrelude.html#v:atomicModifyIORef">atomicModifyIORef</a></code> has.</p><p><em>Since: 4.6.0.0</em></p></div></div><div class="top"><p class="src"><a id="v:mkWeakIORef" class="def">mkWeakIORef</a> :: <a href="SafePrelude.html#t:IORef">IORef</a> a -&gt; <a href="SafePrelude.html#t:IO">IO</a> () -&gt; <a href="SafePrelude.html#t:IO">IO</a> (<a href="../base-4.9.0.0/System-Mem-Weak.html#t:Weak">Weak</a> (<a href="SafePrelude.html#t:IORef">IORef</a> a)) <a href="#v:mkWeakIORef" class="selflink">#</a></p><div class="doc"><p>Make a <code><a href="../base-4.9.0.0/System-Mem-Weak.html#t:Weak">Weak</a></code> pointer to an <code><a href="SafePrelude.html#t:IORef">IORef</a></code>, using the second argument as a finalizer
to run when <code><a href="SafePrelude.html#t:IORef">IORef</a></code> is garbage-collected</p></div></div><h2 id="g:22">IO</h2><div class="top"><p class="src"><span class="keyword">data</span> <a id="t:Handle" class="def">Handle</a> :: <a href="../base-4.9.0.0/Data-Kind.html#t:-42-">*</a> <a href="#t:Handle" class="selflink">#</a></p><div class="doc"><p>Haskell defines operations to read and write characters from and to files,
represented by values of type <code>Handle</code>. Each value of this type is a
<em>handle</em>: a record used by the Haskell run-time system to <em>manage</em> I/O
with file system objects. A handle has at least the following properties:</p><ul><li>whether it manages input or output or both;</li><li>whether it is <em>open</em>, <em>closed</em> or <em>semi-closed</em>;</li><li>whether the object is seekable;</li><li>whether buffering is disabled, or enabled on a line or block basis;</li><li>a buffer (whose length may be zero).</li></ul><p>Most handles will also have a current I/O position indicating where the next
input or output operation will occur. A handle is <em>readable</em> if it
manages only input or both input and output; likewise, it is <em>writable</em> if
it manages only output or both input and output. A handle is <em>open</em> when
first allocated.
Once it is closed it can no longer be used for either input or output,
though an implementation cannot re-use its storage while references
remain to it. Handles are in the <code><a href="SafePrelude.html#t:Show">Show</a></code> and <code><a href="SafePrelude.html#t:Eq">Eq</a></code> classes. The string
produced by showing a handle is system dependent; it should include
enough information to identify the handle for debugging. A handle is
equal according to <code><a href="SafePrelude.html#v:-61--61-">==</a></code> only to itself; no attempt
is made to compare the internal state of different handles for equality.</p></div><div class="subs instances"><p id="control.i:Handle" class="caption collapser" onclick="toggleSection('i:Handle')">Instances</p><div id="section.i:Handle" class="show"><table><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:Handle:Eq:1" class="instance expander" onclick="toggleSection('i:id:Handle:Eq:1')"></span> <a href="SafePrelude.html#t:Eq">Eq</a> <a href="SafePrelude.html#t:Handle">Handle</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:id:Handle:Eq:1" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:-61--61-">(==)</a> :: <a href="SafePrelude.html#t:Handle">Handle</a> -&gt; <a href="SafePrelude.html#t:Handle">Handle</a> -&gt; <a href="SafePrelude.html#t:Bool">Bool</a> <a href="#v:-61--61-" class="selflink">#</a></p><p class="src"><a href="#v:-47--61-">(/=)</a> :: <a href="SafePrelude.html#t:Handle">Handle</a> -&gt; <a href="SafePrelude.html#t:Handle">Handle</a> -&gt; <a href="SafePrelude.html#t:Bool">Bool</a> <a href="#v:-47--61-" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:Handle:Show:2" class="instance expander" onclick="toggleSection('i:id:Handle:Show:2')"></span> <a href="SafePrelude.html#t:Show">Show</a> <a href="SafePrelude.html#t:Handle">Handle</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:id:Handle:Show:2" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:showsPrec">showsPrec</a> :: <a href="SafePrelude.html#t:Int">Int</a> -&gt; <a href="SafePrelude.html#t:Handle">Handle</a> -&gt; <a href="../base-4.9.0.0/Text-Show.html#t:ShowS">ShowS</a> <a href="#v:showsPrec" class="selflink">#</a></p><p class="src"><a href="#v:show">show</a> :: <a href="SafePrelude.html#t:Handle">Handle</a> -&gt; <a href="SafePrelude.html#t:String">String</a> <a href="#v:show" class="selflink">#</a></p><p class="src"><a href="#v:showList">showList</a> :: [<a href="SafePrelude.html#t:Handle">Handle</a>] -&gt; <a href="../base-4.9.0.0/Text-Show.html#t:ShowS">ShowS</a> <a href="#v:showList" class="selflink">#</a></p></div></div></td></tr></table></div></div></div><div class="top"><p class="src"><span class="keyword">data</span> <a id="t:IOMode" class="def">IOMode</a> :: <a href="../base-4.9.0.0/Data-Kind.html#t:-42-">*</a> <a href="#t:IOMode" class="selflink">#</a></p><div class="doc"><p>See <code><a href="../base-4.9.0.0/System-IO.html#v:openFile">openFile</a></code></p></div><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a id="v:ReadMode" class="def">ReadMode</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a id="v:WriteMode" class="def">WriteMode</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a id="v:AppendMode" class="def">AppendMode</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a id="v:ReadWriteMode" class="def">ReadWriteMode</a></td><td class="doc empty">&nbsp;</td></tr></table></div><div class="subs instances"><p id="control.i:IOMode" class="caption collapser" onclick="toggleSection('i:IOMode')">Instances</p><div id="section.i:IOMode" class="show"><table><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:IOMode:Enum:1" class="instance expander" onclick="toggleSection('i:id:IOMode:Enum:1')"></span> <a href="../base-4.9.0.0/Prelude.html#t:Enum">Enum</a> <a href="SafePrelude.html#t:IOMode">IOMode</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:id:IOMode:Enum:1" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:succ">succ</a> :: <a href="SafePrelude.html#t:IOMode">IOMode</a> -&gt; <a href="SafePrelude.html#t:IOMode">IOMode</a> <a href="#v:succ" class="selflink">#</a></p><p class="src"><a href="#v:pred">pred</a> :: <a
computation finishes, if <code>hdl</code> is writable its buffer is flushed as
for <code><a href="../base-4.9.0.0/GHC-IO-Handle.html#v:hFlush">hFlush</a></code>.
Performing <code><a href="SafePrelude.html#v:hClose">hClose</a></code> on a handle that has already been closed has no effect;
doing so is not an error. All other operations on a closed handle will fail.
If <code><a href="SafePrelude.html#v:hClose">hClose</a></code> fails for any reason, any further operations (apart from
<code><a href="SafePrelude.html#v:hClose">hClose</a></code>) on the handle will still fail as if <code>hdl</code> had been successfully
closed.</p></div></div><div class="top"><p class="src"><a id="v:withBinaryFile" class="def">withBinaryFile</a> :: <a href="SafePrelude.html#t:FilePath">FilePath</a> -&gt; <a href="SafePrelude.html#t:IOMode">IOMode</a> -&gt; (<a href="SafePrelude.html#t:Handle">Handle</a> -&gt; <a href="SafePrelude.html#t:IO">IO</a> r) -&gt; <a href="SafePrelude.html#t:IO">IO</a> r <a href="#v:withBinaryFile" class="selflink">#</a></p><div class="doc"><p><code><code><a href="SafePrelude.html#v:withBinaryFile">withBinaryFile</a></code> name mode act</code> opens a file using <code><a href="../base-4.9.0.0/GHC-IO-Handle-FD.html#v:openBinaryFile">openBinaryFile</a></code>
and passes the resulting handle to the computation <code>act</code>. The handle
will be closed on exit from <code><a href="SafePrelude.html#v:withBinaryFile">withBinaryFile</a></code>, whether by normal
termination or by raising an exception.</p></div></div><div class="top"><p class="src"><a id="v:readFile" class="def">readFile</a> :: <a href="SafePrelude.html#t:FilePath">FilePath</a> -&gt; <a href="SafePrelude.html#t:IO">IO</a> <a href="SafePrelude.html#t:ByteString">ByteString</a> <a href="#v:readFile" class="selflink">#</a></p><div class="doc"><p>Read an entire file strictly into a <code><a href="SafePrelude.html#t:ByteString">ByteString</a></code>.</p></div></div><div class="top"><p class="src"><a id="v:writeFile" class="def">writeFile</a> :: <a href="SafePrelude.html#t:FilePath">FilePath</a> -&gt; <a href="SafePrelude.html#t:ByteString">ByteString</a> -&gt; <a href="SafePrelude.html#t:IO">IO</a> () <a href="#v:writeFile" class="selflink">#</a></p><div class="doc"><p>Write a <code><a href="SafePrelude.html#t:ByteString">ByteString</a></code> to a file.</p></div></div><div class="top"><p class="src"><a id="v:readFileUtf8" class="def">readFileUtf8</a> :: <a href="SafePrelude.html#t:MonadIO">MonadIO</a> m =&gt; <a href="SafePrelude.html#t:FilePath">FilePath</a> -&gt; m <a href="SafePrelude.html#t:Text">Text</a> <a href="src/SafePrelude.html#readFileUtf8" class="link">Source</a> <a href="#v:readFileUtf8" class="selflink">#</a></p><div class="doc"><p>Read a file assuming a UTF-8 character encoding.</p><p>This leverages <code><a href="SafePrelude.html#v:decodeUtf8">decodeUtf8</a></code>, so in the event of a character
encoding issue, replacement characters will be used.</p><p><em>Since: 0.1.0.0</em></p></div></div><div class="top"><p class="src"><a id="v:writeFileUtf8" class="def">writeFileUtf8</a> :: <a href="SafePrelude.html#t:MonadIO">MonadIO</a> m =&gt; <a href="SafePrelude.html#t:FilePath">FilePath</a> -&gt; <a href="SafePrelude.html#t:Text">Text</a> -&gt; m () <a href="src/SafePrelude.html#writeFileUtf8" class="link">Source</a> <a href="#v:writeFileUtf8" class="selflink">#</a></p><div class="doc"><p>Write a file using a UTF-8 character encoding.</p><p><em>Since: 0.1.0.0</em></p></div></div><h2 id="g:23">Character encoding</h2><div class="top"><p class="src"><a id="v:encodeUtf8" class="def">encodeUtf8</a> :: <a href="SafePrelude.html#t:Text">Text</a> -&gt; <a href="SafePrelude.html#t:ByteString">ByteString</a> <a href="#v:encodeUtf8" class="selflink">#</a></p><div class="doc"><p>Encode text using UTF-8 encoding.</p></div></div><div class="top"><p class="src"><a id="v:decodeUtf8" class="def">decodeUtf8</a> :: <a href="SafePrelude.html#t:ByteString">ByteString</a> -&gt; <a href="SafePrelude.html#t:Text">Text</a> <a href="src/SafePrelude.html#decodeUtf8" class="link">Source</a> <a href="#v:decodeUtf8" class="selflink">#</a></p><div class="doc"><p>A total function for decoding a <code><a href="SafePrelude.html#t:ByteString">ByteString</a></code> into <code><a href="SafePrelude.html#t:Text">Text</a></code> using a
UTF-8 character encoding. This uses <code><a href="../text-1.2.2.1/Data-Text-Encoding-Error.html#v:lenientDecode">lenientDecode</a></code> in the case of
any encoding errors.</p><p><em>Since: 0.1.0.0</em></p></div></div><h2 id="g:24">deepseq</h2><div class="top"><p class="src"><span class="keyword">class</span> <a id="t:NFData" class="def">NFData</a> a <span class="keyword">where</span> <a href="#t:NFData" class="selflink">#</a></p><div class="doc"><p>A class of types that can be fully evaluated.</p><p><em>Since: 1.1.0.0</em></p></div><div class="subs minimal"><p class="caption">Minimal complete definition</p><p class="src">Nothing</p></div><div class="subs instances"><p id="control.i:NFData" class="caption collapser" onclick="toggleSection('i:NFData')">Instances</p><div id="section.i:NFData" class="show"><table><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:NFData:NFData:1" class="instance expander" onclick="toggleSection('i:ic:NFData:NFData:1')"></span> <a href="SafePrelude.html#t:NFData">NFData</a> <a href="SafePrelude.html#t:Bool">Bool</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:NFData:NFData:1" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:rnf">rnf</a> :: <a href="SafePrelude.html#t:Bool">Bool</a> -&gt; () <a href="#v:rnf" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:NFData:NFData:2" class="instance expander" onclick="toggleSection('i:ic:NFData:NFData:2')"></span> <a href="SafePrelude.html#t:NFData">NFData</a> <a href="SafePrelude.html#t:Char">Char</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:NFData:NFData:2" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:rnf">rnf</a> :: <a href="SafePrelude.html#t:Char">Char</a> -&gt; () <a href="#v:rnf" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:NFData:NFData:3" class="instance expander" onclick="toggleSection('i:ic:NFData:NFData:3')"></span> <a href="SafePrelude.html#t:NFData">NFData</a> <a href="SafePrelude.html#t:Double">Double</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:NFData:NFData:3" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:rnf">rnf</a> :: <a href="SafePrelude.html#t:Double">Double</a> -&gt; () <a href="#v:rnf" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:NFData:NFData:4" class="instance expander" onclick="toggleSection('i:ic:NFData:NFData:4')"></span> <a href="SafePrelude.html#t:NFData">NFData</a> <a href="SafePrelude.html#t:Float">Float</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:NFData:NFData:4" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:rnf">rnf</a> :: <a href="SafePrelude.html#t:Float">Float</a> -&gt; () <a href="#v:rnf" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:NFData:NFData:5" class="instance expander" onclick="toggleSection('i:ic:NFData:NFData:5')"></span> <a href="SafePrelude.html#t:NFData">NFData</a> <a href="SafePrelude.html#t:Int">Int</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:NFData:NFData:5" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:rnf">rnf</a> :: <a href="SafePrelude.html#t:Int">Int</a> -&gt; () <a href="#v:rnf" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:NFData:NFData:6" class="instance expander" onclick="toggleSection('i:ic:NFData:NFData:6')"></span> <a href="SafePrelude.html#t:NFData">NFData</a> <a href="SafePrelude.html#t:Int8">Int8</a></span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id
This assumes that WHNF is equivalent to NF for functions.</p><p><em>Since: 1.3.0.0</em></p></td></tr><tr><td colspan="2"><div id="section.i:ic:NFData:NFData:95" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:rnf">rnf</a> :: (a -&gt; b) -&gt; () <a href="#v:rnf" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:NFData:NFData:96" class="instance expander" onclick="toggleSection('i:ic:NFData:NFData:96')"></span> (<a href="SafePrelude.html#t:NFData">NFData</a> a, <a href="SafePrelude.html#t:NFData">NFData</a> b) =&gt; <a href="SafePrelude.html#t:NFData">NFData</a> (<a href="SafePrelude.html#t:Either">Either</a> a b)</span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:NFData:NFData:96" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:rnf">rnf</a> :: <a href="SafePrelude.html#t:Either">Either</a> a b -&gt; () <a href="#v:rnf" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:NFData:NFData:97" class="instance expander" onclick="toggleSection('i:ic:NFData:NFData:97')"></span> (<a href="SafePrelude.html#t:NFData">NFData</a> a, <a href="SafePrelude.html#t:NFData">NFData</a> b) =&gt; <a href="SafePrelude.html#t:NFData">NFData</a> (a, b)</span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:NFData:NFData:97" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:rnf">rnf</a> :: (a, b) -&gt; () <a href="#v:rnf" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:NFData:NFData:98" class="instance expander" onclick="toggleSection('i:ic:NFData:NFData:98')"></span> (<a href="SafePrelude.html#t:NFData">NFData</a> a, <a href="SafePrelude.html#t:NFData">NFData</a> b) =&gt; <a href="SafePrelude.html#t:NFData">NFData</a> (<a href="../array-0.5.1.1/Data-Array.html#t:Array">Array</a> a b)</span></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div id="section.i:ic:NFData:NFData:98" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:rnf">rnf</a> :: <a href="../array-0.5.1.1/Data-Array.html#t:Array">Array</a> a b -&gt; () <a href="#v:rnf" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:NFData:NFData:99" class="instance expander" onclick="toggleSection('i:ic:NFData:NFData:99')"></span> (<a href="SafePrelude.html#t:NFData">NFData</a> a, <a href="SafePrelude.html#t:NFData">NFData</a> b) =&gt; <a href="SafePrelude.html#t:NFData">NFData</a> (<a href="../base-4.9.0.0/Data-Semigroup.html#t:Arg">Arg</a> a b)</span></td><td class="doc"><p><em>Since: 1.4.2.0</em></p></td></tr><tr><td colspan="2"><div id="section.i:ic:NFData:NFData:99" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:rnf">rnf</a> :: <a href="../base-4.9.0.0/Data-Semigroup.html#t:Arg">Arg</a> a b -&gt; () <a href="#v:rnf" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:NFData:NFData:100" class="instance expander" onclick="toggleSection('i:ic:NFData:NFData:100')"></span> <a href="SafePrelude.html#t:NFData">NFData</a> (<a href="SafePrelude.html#t:Proxy">Proxy</a> k a)</span></td><td class="doc"><p><em>Since: 1.4.0.0</em></p></td></tr><tr><td colspan="2"><div id="section.i:ic:NFData:NFData:100" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:rnf">rnf</a> :: <a href="SafePrelude.html#t:Proxy">Proxy</a> k a -&gt; () <a href="#v:rnf" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:NFData:NFData:101" class="instance expa
second.</p><p>The name <code><a href="SafePrelude.html#v:deepseq">deepseq</a></code> is used to illustrate the relationship to <code><a href="SafePrelude.html#v:seq">seq</a></code>:
where <code><a href="SafePrelude.html#v:seq">seq</a></code> is shallow in the sense that it only evaluates the top
level of its argument, <code><a href="SafePrelude.html#v:deepseq">deepseq</a></code> traverses the entire data structure
evaluating it completely.</p><p><code><a href="SafePrelude.html#v:deepseq">deepseq</a></code> can be useful for forcing pending exceptions,
eradicating space leaks, or forcing lazy I/O to happen. It is
also useful in conjunction with parallel Strategies (see the
<code>parallel</code> package).</p><p>There is no guarantee about the ordering of evaluation. The
implementation may evaluate the components of the structure in
any order or in parallel. To impose an actual order on
evaluation, use <code>pseq</code> from <a href="Control-Parallel.html">Control.Parallel</a> in the
<code>parallel</code> package.</p><p><em>Since: 1.1.0.0</em></p></div></div><div class="top"><p class="src"><a id="v:-36--33--33-" class="def">($!!)</a> :: <a href="SafePrelude.html#t:NFData">NFData</a> a =&gt; (a -&gt; b) -&gt; a -&gt; b <span class="fixity">infixr 0</span><span class="rightedge"></span> <a href="#v:-36--33--33-" class="selflink">#</a></p><div class="doc"><p>the deep analogue of <code><a href="SafePrelude.html#v:-36--33-">$!</a></code>. In the expression <code>f $!! x</code>, <code>x</code> is
fully evaluated before the function <code>f</code> is applied to it.</p><p><em>Since: 1.2.0.0</em></p></div></div><div class="top"><p class="src"><a id="v:force" class="def">force</a> :: <a href="SafePrelude.html#t:NFData">NFData</a> a =&gt; a -&gt; a <a href="#v:force" class="selflink">#</a></p><div class="doc"><p>a variant of <code><a href="SafePrelude.html#v:deepseq">deepseq</a></code> that is useful in some circumstances:</p><pre>force x = x `deepseq` x</pre><p><code>force x</code> fully evaluates <code>x</code>, and then returns it. Note that
<code>force x</code> only performs evaluation when the value of <code>force x</code>
itself is demanded, so essentially it turns shallow evaluation into
deep evaluation.</p><p><code><a href="SafePrelude.html#v:force">force</a></code> can be conveniently used in combination with <code>ViewPatterns</code>:</p><pre>{-# LANGUAGE BangPatterns, ViewPatterns #-}
import Control.DeepSeq
someFun :: ComplexData -&gt; SomeResult
someFun (force -&gt; !arg) = {- 'arg' will be fully evaluated -}</pre><p>Another useful application is to combine <code><a href="SafePrelude.html#v:force">force</a></code> with
<code><a href="../base-4.9.0.0/Control-Exception.html#v:evaluate">evaluate</a></code> in order to force deep evaluation
relative to other <code><a href="SafePrelude.html#t:IO">IO</a></code> operations:</p><pre>import Control.Exception (evaluate)
import Control.DeepSeq
main = do
result &lt;- evaluate $ force $ pureComputation
{- 'result' will be fully evaluated at this point -}
return ()</pre><p><em>Since: 1.2.0.0</em></p></div></div><h2 id="g:25">Monoids</h2><div class="top"><p class="src"><a id="v:-43--43-" class="def">(++)</a> :: <a href="SafePrelude.html#t:Monoid">Monoid</a> m =&gt; m -&gt; m -&gt; m <span class="fixity">infixr 5</span><span class="rightedge"></span> <a href="src/SafePrelude.html#%2B%2B" class="link">Source</a> <a href="#v:-43--43-" class="selflink">#</a></p><div class="doc"><p>Operator version of <code><a href="SafePrelude.html#v:mappend">mappend</a></code>.</p><p>In base, this operator is known as <code><a href="SafePrelude.html#v:-60--62-">&lt;&gt;</a></code>. However, this is the name
of the operator for <code><a href="SafePrelude.html#t:Semigroup">Semigroup</a></code> as well. Once <code><a href="SafePrelude.html#t:Semigroup">Semigroup</a></code> is a
superclass of <code><a href="SafePrelude.html#t:Monoid">Monoid</a></code>, this historical accident will be
unimportant. In the meanwhile, <code>SafePrelude</code> deals with this
situation by making <code><a href="SafePrelude.html#v:-60--62-">&lt;&gt;</a></code> the <code><a href="SafePrelude.html#t:Semigroup">Semigroup</a></code> operator, and <code><a href="SafePrelude.html#v:-43--43-">++</a></code> the
<code><a href="SafePrelude.html#t:Monoid">Monoid</a></code> operator.</p><p><em>Since: 0.1.0.0</em></p></div></div><h2 id="g:26">Read</h2><div class="top"><p class="src"><a id="v:readMaybe" class="def">readMaybe</a> :: <a href="SafePrelude.html#t:Read">Read</a> a =&gt; <a href="SafePrelude.html#t:String">String</a> -&gt; <a href="SafePrelude.html#t:Maybe">Maybe</a> a <a href="#v:readMaybe" class="selflink">#</a></p><div class="doc"><p>Parse a string using the <code><a href="SafePrelude.html#t:Read">Read</a></code> instance.
Succeeds if there is exactly one valid result.</p><p><em>Since: 4.6.0.0</em></p></div></div><div class="top"><p class="src"><a id="v:readEither" class="def">readEither</a> :: <a href="SafePrelude.html#t:Read">Read</a> a =&gt; <a href="SafePrelude.html#t:String">String</a> -&gt; <a href="SafePrelude.html#t:Either">Either</a> <a href="SafePrelude.html#t:String">String</a> a <a href="#v:readEither" class="selflink">#</a></p><div class="doc"><p>Parse a string using the <code><a href="SafePrelude.html#t:Read">Read</a></code> instance.
Succeeds if there is exactly one valid result.
A <code><a href="SafePrelude.html#v:Left">Left</a></code> value indicates a parse error.</p><p><em>Since: 4.6.0.0</em></p></div></div></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.17.2</p></div></body></html>