Sophie

Sophie

distrib > Mageia > 5 > i586 > media > core-release > by-pkgid > 6e204a966e8c42d976f99a1700ce5f20 > files > 2252

ghc-7.4.2-4.mga5.i586.rpm

<!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>Data.Maybe</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
window.onload = function () {pageLoad();setSynopsis("mini_Data-Maybe.html");};
//]]>
</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">base-4.5.1.0: Basic libraries</p></div><div id="content"><div id="module-header"><table class="info"><tr><th>Portability</th><td>portable</td></tr><tr><th>Stability</th><td>stable</td></tr><tr><th>Maintainer</th><td>libraries@haskell.org</td></tr><tr><th>Safe Haskell</th><td>Trustworthy</td></tr></table><p class="caption">Data.Maybe</p></div><div id="description"><p class="caption">Description</p><div class="doc"><p>The Maybe type, and associated operations.
</p></div></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<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"><a href="#v:maybe">maybe</a> ::  b -&gt; (a -&gt; b) -&gt; <a href="Data-Maybe.html#t:Maybe">Maybe</a> a -&gt; b</li><li class="src short"><a href="#v:isJust">isJust</a> ::  <a href="Data-Maybe.html#t:Maybe">Maybe</a> a -&gt; <a href="Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:isNothing">isNothing</a> ::  <a href="Data-Maybe.html#t:Maybe">Maybe</a> a -&gt; <a href="Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:fromJust">fromJust</a> ::  <a href="Data-Maybe.html#t:Maybe">Maybe</a> a -&gt; a</li><li class="src short"><a href="#v:fromMaybe">fromMaybe</a> ::  a -&gt; <a href="Data-Maybe.html#t:Maybe">Maybe</a> a -&gt; a</li><li class="src short"><a href="#v:listToMaybe">listToMaybe</a> ::  [a] -&gt; <a href="Data-Maybe.html#t:Maybe">Maybe</a> a</li><li class="src short"><a href="#v:maybeToList">maybeToList</a> ::  <a href="Data-Maybe.html#t:Maybe">Maybe</a> a -&gt; [a]</li><li class="src short"><a href="#v:catMaybes">catMaybes</a> ::  [<a href="Data-Maybe.html#t:Maybe">Maybe</a> a] -&gt; [a]</li><li class="src short"><a href="#v:mapMaybe">mapMaybe</a> ::  (a -&gt; <a href="Data-Maybe.html#t:Maybe">Maybe</a> b) -&gt; [a] -&gt; [b]</li></ul></div><div id="interface"><h1>Documentation</h1><div class="top"><p class="src"><span class="keyword">data</span>  <a name="t:Maybe" class="def">Maybe</a> a </p><div class="doc"><p>The <code><a href="Data-Maybe.html#t:Maybe">Maybe</a></code> type encapsulates an optional value.  A value of type
 <code><code><a href="Data-Maybe.html#t:Maybe">Maybe</a></code> a</code> either contains a value of type <code>a</code> (represented as <code><code><a href="Data-Maybe.html#v:Just">Just</a></code> a</code>), 
 or it is empty (represented as <code><a href="Data-Maybe.html#v:Nothing">Nothing</a></code>).  Using <code><a href="Data-Maybe.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="Prelude.html#v:error">error</a></code>.
</p><p>The <code><a href="Data-Maybe.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="Data-Maybe.html#v:Nothing">Nothing</a></code>.  A richer
 error monad can be built using the <code><a href="Data-Either.html#t:Either">Either</a></code> type.
</p></div><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a name="v:Nothing" class="def">Nothing</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a name="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"><a href="Control-Monad.html#t:Monad">Monad</a> <a href="Data-Maybe.html#t:Maybe">Maybe</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Control-Monad.html#t:Functor">Functor</a> <a href="Data-Maybe.html#t:Maybe">Maybe</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Data-Typeable-Internal.html#t:Typeable1">Typeable1</a> <a href="Data-Maybe.html#t:Maybe">Maybe</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Control-Monad-Fix.html#t:MonadFix">MonadFix</a> <a href="Data-Maybe.html#t:Maybe">Maybe</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Control-Monad.html#t:MonadPlus">MonadPlus</a> <a href="Data-Maybe.html#t:Maybe">Maybe</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Control-Applicative.html#t:Applicative">Applicative</a> <a href="Data-Maybe.html#t:Maybe">Maybe</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Data-Foldable.html#t:Foldable">Foldable</a> <a href="Data-Maybe.html#t:Maybe">Maybe</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Data-Traversable.html#t:Traversable">Traversable</a> <a href="Data-Maybe.html#t:Maybe">Maybe</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Control-Applicative.html#t:Alternative">Alternative</a> <a href="Data-Maybe.html#t:Maybe">Maybe</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Data-Eq.html#t:Eq">Eq</a> a =&gt; <a href="Data-Eq.html#t:Eq">Eq</a> (<a href="Data-Maybe.html#t:Maybe">Maybe</a> a)</td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Data-Data.html#t:Data">Data</a> a =&gt; <a href="Data-Data.html#t:Data">Data</a> (<a href="Data-Maybe.html#t:Maybe">Maybe</a> a)</td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Data-Ord.html#t:Ord">Ord</a> a =&gt; <a href="Data-Ord.html#t:Ord">Ord</a> (<a href="Data-Maybe.html#t:Maybe">Maybe</a> a)</td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Text-Read.html#t:Read">Read</a> a =&gt; <a href="Text-Read.html#t:Read">Read</a> (<a href="Data-Maybe.html#t:Maybe">Maybe</a> a)</td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Text-Show.html#t:Show">Show</a> a =&gt; <a href="Text-Show.html#t:Show">Show</a> (<a href="Data-Maybe.html#t:Maybe">Maybe</a> a)</td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="../ghc-prim-0.2.0.0/GHC-Generics.html#t:Generic">Generic</a> (<a href="Data-Maybe.html#t:Maybe">Maybe</a> a)</td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Data-Monoid.html#t:Monoid">Monoid</a> a =&gt; <a href="Data-Monoid.html#t:Monoid">Monoid</a> (<a href="Data-Maybe.html#t:Maybe">Maybe</a> a)</td><td class="doc"><p>Lift a semigroup into <code><a href="Data-Maybe.html#t:Maybe">Maybe</a></code> forming a <code><a href="Data-Monoid.html#t:Monoid">Monoid</a></code> according to
 <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="Data-Monoid.html#v:mappend">mappend</a></code>, we
 use <code><a href="Data-Monoid.html#t:Monoid">Monoid</a></code> instead.
</p></td></tr></table></div></div></div><div class="top"><p class="src"><a name="v:maybe" class="def">maybe</a> ::  b -&gt; (a -&gt; b) -&gt; <a href="Data-Maybe.html#t:Maybe">Maybe</a> a -&gt; b</p><div class="doc"><p>The <code><a href="Data-Maybe.html#v:maybe">maybe</a></code> function takes a default value, a function, and a <code><a href="Data-Maybe.html#t:Maybe">Maybe</a></code>
 value.  If the <code><a href="Data-Maybe.html#t:Maybe">Maybe</a></code> value is <code><a href="Data-Maybe.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="Data-Maybe.html#v:Just">Just</a></code> and returns the result.
</p></div></div><div class="top"><p class="src"><a name="v:isJust" class="def">isJust</a> ::  <a href="Data-Maybe.html#t:Maybe">Maybe</a> a -&gt; <a href="Data-Bool.html#t:Bool">Bool</a></p><div class="doc"><p>The <code><a href="Data-Maybe.html#v:isJust">isJust</a></code> function returns <code><a href="Data-Bool.html#v:True">True</a></code> iff its argument is of the
 form <code>Just _</code>.
</p></div></div><div class="top"><p class="src"><a name="v:isNothing" class="def">isNothing</a> ::  <a href="Data-Maybe.html#t:Maybe">Maybe</a> a -&gt; <a href="Data-Bool.html#t:Bool">Bool</a></p><div class="doc"><p>The <code><a href="Data-Maybe.html#v:isNothing">isNothing</a></code> function returns <code><a href="Data-Bool.html#v:True">True</a></code> iff its argument is <code><a href="Data-Maybe.html#v:Nothing">Nothing</a></code>.
</p></div></div><div class="top"><p class="src"><a name="v:fromJust" class="def">fromJust</a> ::  <a href="Data-Maybe.html#t:Maybe">Maybe</a> a -&gt; a</p><div class="doc"><p>The <code><a href="Data-Maybe.html#v:fromJust">fromJust</a></code> function extracts the element out of a <code><a href="Data-Maybe.html#v:Just">Just</a></code> and
 throws an error if its argument is <code><a href="Data-Maybe.html#v:Nothing">Nothing</a></code>.
</p></div></div><div class="top"><p class="src"><a name="v:fromMaybe" class="def">fromMaybe</a> ::  a -&gt; <a href="Data-Maybe.html#t:Maybe">Maybe</a> a -&gt; a</p><div class="doc"><p>The <code><a href="Data-Maybe.html#v:fromMaybe">fromMaybe</a></code> function takes a default value and and <code><a href="Data-Maybe.html#t:Maybe">Maybe</a></code>
 value.  If the <code><a href="Data-Maybe.html#t:Maybe">Maybe</a></code> is <code><a href="Data-Maybe.html#v:Nothing">Nothing</a></code>, it returns the default values;
 otherwise, it returns the value contained in the <code><a href="Data-Maybe.html#t:Maybe">Maybe</a></code>.
</p></div></div><div class="top"><p class="src"><a name="v:listToMaybe" class="def">listToMaybe</a> ::  [a] -&gt; <a href="Data-Maybe.html#t:Maybe">Maybe</a> a</p><div class="doc"><p>The <code><a href="Data-Maybe.html#v:listToMaybe">listToMaybe</a></code> function returns <code><a href="Data-Maybe.html#v:Nothing">Nothing</a></code> on an empty list
 or <code><code><a href="Data-Maybe.html#v:Just">Just</a></code> a</code> where <code>a</code> is the first element of the list.
</p></div></div><div class="top"><p class="src"><a name="v:maybeToList" class="def">maybeToList</a> ::  <a href="Data-Maybe.html#t:Maybe">Maybe</a> a -&gt; [a]</p><div class="doc"><p>The <code><a href="Data-Maybe.html#v:maybeToList">maybeToList</a></code> function returns an empty list when given
 <code><a href="Data-Maybe.html#v:Nothing">Nothing</a></code> or a singleton list when not given <code><a href="Data-Maybe.html#v:Nothing">Nothing</a></code>.
</p></div></div><div class="top"><p class="src"><a name="v:catMaybes" class="def">catMaybes</a> ::  [<a href="Data-Maybe.html#t:Maybe">Maybe</a> a] -&gt; [a]</p><div class="doc"><p>The <code><a href="Data-Maybe.html#v:catMaybes">catMaybes</a></code> function takes a list of <code><a href="Data-Maybe.html#t:Maybe">Maybe</a></code>s and returns
 a list of all the <code><a href="Data-Maybe.html#v:Just">Just</a></code> values. 
</p></div></div><div class="top"><p class="src"><a name="v:mapMaybe" class="def">mapMaybe</a> ::  (a -&gt; <a href="Data-Maybe.html#t:Maybe">Maybe</a> b) -&gt; [a] -&gt; [b]</p><div class="doc"><p>The <code><a href="Data-Maybe.html#v:mapMaybe">mapMaybe</a></code> function is a version of <code><a href="Data-List.html#v:map">map</a></code> which can throw
 out elements.  In particular, the functional argument returns
 something of type <code><code><a href="Data-Maybe.html#t:Maybe">Maybe</a></code> b</code>.  If this is <code><a href="Data-Maybe.html#v:Nothing">Nothing</a></code>, no element
 is added on to the result list.  If it just <code><code><a href="Data-Maybe.html#v:Just">Just</a></code> b</code>, then <code>b</code> is
 included in the result list.
</p></div></div></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.11.0</p></div></body></html>