Sophie

Sophie

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

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>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_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">haskell98-2.0.0.1: Compatibility with Haskell 98</p></div><div id="content"><div id="module-header"><table class="info"><tr><th>Safe Haskell</th><td>Safe</td></tr></table><p class="caption">Maybe</p></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"><a href="#v:isJust">isJust</a> ::  <a href="Maybe.html#t:Maybe">Maybe</a> a -&gt; <a href="Prelude.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:isNothing">isNothing</a> ::  <a href="Maybe.html#t:Maybe">Maybe</a> a -&gt; <a href="Prelude.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:fromJust">fromJust</a> ::  <a href="Maybe.html#t:Maybe">Maybe</a> a -&gt; a</li><li class="src short"><a href="#v:fromMaybe">fromMaybe</a> ::  a -&gt; <a href="Maybe.html#t:Maybe">Maybe</a> a -&gt; a</li><li class="src short"><a href="#v:listToMaybe">listToMaybe</a> ::  [a] -&gt; <a href="Maybe.html#t:Maybe">Maybe</a> a</li><li class="src short"><a href="#v:maybeToList">maybeToList</a> ::  <a href="Maybe.html#t:Maybe">Maybe</a> a -&gt; [a]</li><li class="src short"><a href="#v:catMaybes">catMaybes</a> ::  [<a href="Maybe.html#t:Maybe">Maybe</a> a] -&gt; [a]</li><li class="src short"><a href="#v:mapMaybe">mapMaybe</a> ::  (a -&gt; <a href="Maybe.html#t:Maybe">Maybe</a> b) -&gt; [a] -&gt; [b]</li><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="Maybe.html#t:Maybe">Maybe</a> a -&gt; b</li></ul></div><div id="interface"><h1>Documentation</h1><div class="top"><p class="src"><a name="v:isJust" class="def">isJust</a> ::  <a href="Maybe.html#t:Maybe">Maybe</a> a -&gt; <a href="Prelude.html#t:Bool">Bool</a><a href="../base-4.5.1.0/src/Data-Maybe.html#isJust" class="link">Source</a></p><div class="doc"><p>The <code><a href="Maybe.html#v:isJust">isJust</a></code> function returns <code><a href="Prelude.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="Maybe.html#t:Maybe">Maybe</a> a -&gt; <a href="Prelude.html#t:Bool">Bool</a><a href="../base-4.5.1.0/src/Data-Maybe.html#isNothing" class="link">Source</a></p><div class="doc"><p>The <code><a href="Maybe.html#v:isNothing">isNothing</a></code> function returns <code><a href="Prelude.html#v:True">True</a></code> iff its argument is <code><a href="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="Maybe.html#t:Maybe">Maybe</a> a -&gt; a<a href="../base-4.5.1.0/src/Data-Maybe.html#fromJust" class="link">Source</a></p><div class="doc"><p>The <code><a href="Maybe.html#v:fromJust">fromJust</a></code> function extracts the element out of a <code><a href="Maybe.html#v:Just">Just</a></code> and
 throws an error if its argument is <code><a href="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="Maybe.html#t:Maybe">Maybe</a> a -&gt; a<a href="../base-4.5.1.0/src/Data-Maybe.html#fromMaybe" class="link">Source</a></p><div class="doc"><p>The <code><a href="Maybe.html#v:fromMaybe">fromMaybe</a></code> function takes a default value and and <code><a href="Maybe.html#t:Maybe">Maybe</a></code>
 value.  If the <code><a href="Maybe.html#t:Maybe">Maybe</a></code> is <code><a href="Maybe.html#v:Nothing">Nothing</a></code>, it returns the default values;
 otherwise, it returns the value contained in the <code><a href="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="Maybe.html#t:Maybe">Maybe</a> a<a href="../base-4.5.1.0/src/Data-Maybe.html#listToMaybe" class="link">Source</a></p><div class="doc"><p>The <code><a href="Maybe.html#v:listToMaybe">listToMaybe</a></code> function returns <code><a href="Maybe.html#v:Nothing">Nothing</a></code> on an empty list
 or <code><code><a href="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="Maybe.html#t:Maybe">Maybe</a> a -&gt; [a]<a href="../base-4.5.1.0/src/Data-Maybe.html#maybeToList" class="link">Source</a></p><div class="doc"><p>The <code><a href="Maybe.html#v:maybeToList">maybeToList</a></code> function returns an empty list when given
 <code><a href="Maybe.html#v:Nothing">Nothing</a></code> or a singleton list when not given <code><a href="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="Maybe.html#t:Maybe">Maybe</a> a] -&gt; [a]<a href="../base-4.5.1.0/src/Data-Maybe.html#catMaybes" class="link">Source</a></p><div class="doc"><p>The <code><a href="Maybe.html#v:catMaybes">catMaybes</a></code> function takes a list of <code><a href="Maybe.html#t:Maybe">Maybe</a></code>s and returns
 a list of all the <code><a href="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="Maybe.html#t:Maybe">Maybe</a> b) -&gt; [a] -&gt; [b]<a href="../base-4.5.1.0/src/Data-Maybe.html#mapMaybe" class="link">Source</a></p><div class="doc"><p>The <code><a href="Maybe.html#v:mapMaybe">mapMaybe</a></code> function is a version of <code><a href="Prelude.html#v:map">map</a></code> which can throw
 out elements.  In particular, the functional argument returns
 something of type <code><code><a href="Maybe.html#t:Maybe">Maybe</a></code> b</code>.  If this is <code><a href="Maybe.html#v:Nothing">Nothing</a></code>, no element
 is added on to the result list.  If it just <code><code><a href="Maybe.html#v:Just">Just</a></code> b</code>, then <code>b</code> is
 included in the result list.
</p></div></div><div class="top"><p class="src"><span class="keyword">data</span>  <a name="t:Maybe" class="def">Maybe</a> a <a href="../base-4.5.1.0/src/Data-Maybe.html#Maybe" class="link">Source</a></p><div class="doc"><p>The <code><a href="Maybe.html#t:Maybe">Maybe</a></code> type encapsulates an optional value.  A value of type
 <code><code><a href="Maybe.html#t:Maybe">Maybe</a></code> a</code> either contains a value of type <code>a</code> (represented as <code><code><a href="Maybe.html#v:Just">Just</a></code> a</code>), 
 or it is empty (represented as <code><a href="Maybe.html#v:Nothing">Nothing</a></code>).  Using <code><a href="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="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="Maybe.html#v:Nothing">Nothing</a></code>.  A richer
 error monad can be built using the <code><a href="../base-4.5.1.0/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="Prelude.html#t:Monad">Monad</a> <a href="Maybe.html#t:Maybe">Maybe</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Prelude.html#t:Functor">Functor</a> <a href="Maybe.html#t:Maybe">Maybe</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="../base-4.5.1.0/Data-Typeable-Internal.html#t:Typeable1">Typeable1</a> <a href="Maybe.html#t:Maybe">Maybe</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Monad.html#t:MonadPlus">MonadPlus</a> <a href="Maybe.html#t:Maybe">Maybe</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Prelude.html#t:Eq">Eq</a> a =&gt; <a href="Prelude.html#t:Eq">Eq</a> (<a href="Maybe.html#t:Maybe">Maybe</a> a)</td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Prelude.html#t:Ord">Ord</a> a =&gt; <a href="Prelude.html#t:Ord">Ord</a> (<a href="Maybe.html#t:Maybe">Maybe</a> a)</td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Prelude.html#t:Read">Read</a> a =&gt; <a href="Prelude.html#t:Read">Read</a> (<a href="Maybe.html#t:Maybe">Maybe</a> a)</td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Prelude.html#t:Show">Show</a> a =&gt; <a href="Prelude.html#t:Show">Show</a> (<a href="Maybe.html#t:Maybe">Maybe</a> a)</td><td class="doc empty">&nbsp;</td></tr><tr><td class="src">Generic (<a href="Maybe.html#t:Maybe">Maybe</a> a)</td><td class="doc empty">&nbsp;</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="Maybe.html#t:Maybe">Maybe</a> a -&gt; b<a href="../base-4.5.1.0/src/Data-Maybe.html#maybe" class="link">Source</a></p><div class="doc"><p>The <code><a href="Maybe.html#v:maybe">maybe</a></code> function takes a default value, a function, and a <code><a href="Maybe.html#t:Maybe">Maybe</a></code>
 value.  If the <code><a href="Maybe.html#t:Maybe">Maybe</a></code> value is <code><a href="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="Maybe.html#v:Just">Just</a></code> and returns the result.
</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>