Sophie

Sophie

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

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>Control.DeepSeq</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_Control-DeepSeq.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">deepseq-1.3.0.0: Deep evaluation of data structures</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>Safe</td></tr></table><p class="caption">Control.DeepSeq</p></div><div id="description"><p class="caption">Description</p><div class="doc"><p>This module provides an overloaded function, <code><a href="Control-DeepSeq.html#v:deepseq">deepseq</a></code>, for fully
 evaluating data structures (that is, evaluating to &quot;Normal Form&quot;).
</p><p>A typical use is to prevent resource leaks in lazy IO programs, by
 forcing all characters from a file to be read. For example:
</p><pre> import System.IO
 import Control.DeepSeq
 
 main = do
     h &lt;- openFile &quot;f&quot; ReadMode
     s &lt;- hGetContents h
     s `deepseq` hClose h
     return s
</pre><p><code><a href="Control-DeepSeq.html#v:deepseq">deepseq</a></code> differs from <code><a href="../base-4.5.1.0/Prelude.html#v:seq">seq</a></code> as it traverses data structures deeply,
 for example, <code><a href="../base-4.5.1.0/Prelude.html#v:seq">seq</a></code> will evaluate only to the first constructor in
 the list:
</p><pre> &gt; [1,2,undefined] `seq` 3
 3
</pre><p>While <code><a href="Control-DeepSeq.html#v:deepseq">deepseq</a></code> will force evaluation of all the list elements:
</p><pre> &gt; [1,2,undefined] `deepseq` 3
 *** Exception: Prelude.undefined
</pre><p>Another common use is to ensure any exceptions hidden within lazy
 fields of a data structure do not leak outside the scope of the
 exception handler, or to force evaluation of a data structure in one
 thread, before passing to another thread (preventing work moving to
 the wrong threads).
</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"><a href="#v:deepseq">deepseq</a> :: <a href="Control-DeepSeq.html#t:NFData">NFData</a> a =&gt; a -&gt; b -&gt; b</li><li class="src short"><a href="#v:-36--33--33-">($!!)</a> :: <a href="Control-DeepSeq.html#t:NFData">NFData</a> a =&gt; (a -&gt; b) -&gt; a -&gt; b</li><li class="src short"><a href="#v:force">force</a> :: <a href="Control-DeepSeq.html#t:NFData">NFData</a> a =&gt; a -&gt; a</li><li class="src short"><span class="keyword">class</span>  <a href="#t:NFData">NFData</a> a  <span class="keyword">where</span><ul class="subs"><li><a href="#v:rnf">rnf</a> :: a -&gt; ()</li></ul></li></ul></div><div id="interface"><h1>Documentation</h1><div class="top"><p class="src"><a name="v:deepseq" class="def">deepseq</a> :: <a href="Control-DeepSeq.html#t:NFData">NFData</a> a =&gt; a -&gt; b -&gt; b</p><div class="doc"><p><code><a href="Control-DeepSeq.html#v:deepseq">deepseq</a></code>: fully evaluates the first argument, before returning the
 second.
</p><p>The name <code><a href="Control-DeepSeq.html#v:deepseq">deepseq</a></code> is used to illustrate the relationship to <code><a href="../base-4.5.1.0/Prelude.html#v:seq">seq</a></code>:
 where <code><a href="../base-4.5.1.0/Prelude.html#v:seq">seq</a></code> is shallow in the sense that it only evaluates the top
 level of its argument, <code><a href="Control-DeepSeq.html#v:deepseq">deepseq</a></code> traverses the entire data structure
 evaluating it completely.
</p><p><code><a href="Control-DeepSeq.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></div></div><div class="top"><p class="src"><a name="v:-36--33--33-" class="def">($!!)</a> :: <a href="Control-DeepSeq.html#t:NFData">NFData</a> a =&gt; (a -&gt; b) -&gt; a -&gt; b</p><div class="doc"><p>the deep analogue of <code><a href="../base-4.5.1.0/Prelude.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></div></div><div class="top"><p class="src"><a name="v:force" class="def">force</a> :: <a href="Control-DeepSeq.html#t:NFData">NFData</a> a =&gt; a -&gt; a</p><div class="doc"><p>a variant of <code><a href="Control-DeepSeq.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></div></div><div class="top"><p class="src"><span class="keyword">class</span>  <a name="t:NFData" class="def">NFData</a> a  <span class="keyword">where</span></p><div class="doc"><p>A class of types that can be fully evaluated.
</p></div><div class="subs methods"><p class="caption">Methods</p><p class="src"><a name="v:rnf" class="def">rnf</a> :: a -&gt; ()</p><div class="doc"><p>rnf should reduce its argument to normal form (that is, fully
 evaluate all sub-components), and then return '()'.
</p><p>The default implementation of <code><a href="Control-DeepSeq.html#v:rnf">rnf</a></code> is 
</p><pre> rnf a = a `seq` ()
</pre><p>which may be convenient when defining instances for data types with
 no unevaluated fields (e.g. enumerations).
</p></div></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"><a href="Control-DeepSeq.html#t:NFData">NFData</a> <a href="../base-4.5.1.0/Data-Bool.html#t:Bool">Bool</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Control-DeepSeq.html#t:NFData">NFData</a> <a href="../base-4.5.1.0/Data-Char.html#t:Char">Char</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Control-DeepSeq.html#t:NFData">NFData</a> <a href="../base-4.5.1.0/Prelude.html#t:Double">Double</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Control-DeepSeq.html#t:NFData">NFData</a> <a href="../base-4.5.1.0/Prelude.html#t:Float">Float</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Control-DeepSeq.html#t:NFData">NFData</a> <a href="../base-4.5.1.0/Data-Int.html#t:Int">Int</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Control-DeepSeq.html#t:NFData">NFData</a> <a href="../base-4.5.1.0/Data-Int.html#t:Int8">Int8</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Control-DeepSeq.html#t:NFData">NFData</a> <a href="../base-4.5.1.0/Data-Int.html#t:Int16">Int16</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Control-DeepSeq.html#t:NFData">NFData</a> <a href="../base-4.5.1.0/Data-Int.html#t:Int32">Int32</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Control-DeepSeq.html#t:NFData">NFData</a> <a href="../base-4.5.1.0/Data-Int.html#t:Int64">Int64</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Control-DeepSeq.html#t:NFData">NFData</a> <a href="../base-4.5.1.0/Prelude.html#t:Integer">Integer</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Control-DeepSeq.html#t:NFData">NFData</a> <a href="../base-4.5.1.0/Data-Word.html#t:Word">Word</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Control-DeepSeq.html#t:NFData">NFData</a> <a href="../base-4.5.1.0/Data-Word.html#t:Word8">Word8</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Control-DeepSeq.html#t:NFData">NFData</a> <a href="../base-4.5.1.0/Data-Word.html#t:Word16">Word16</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Control-DeepSeq.html#t:NFData">NFData</a> <a href="../base-4.5.1.0/Data-Word.html#t:Word32">Word32</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Control-DeepSeq.html#t:NFData">NFData</a> <a href="../base-4.5.1.0/Data-Word.html#t:Word64">Word64</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Control-DeepSeq.html#t:NFData">NFData</a> ()</td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Control-DeepSeq.html#t:NFData">NFData</a> <a href="../base-4.5.1.0/Data-Version.html#t:Version">Version</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Control-DeepSeq.html#t:NFData">NFData</a> a =&gt; <a href="Control-DeepSeq.html#t:NFData">NFData</a> [a]</td><td class="doc empty">&nbsp;</td></tr><tr><td class="src">(<a href="../base-4.5.1.0/Prelude.html#t:Integral">Integral</a> a, <a href="Control-DeepSeq.html#t:NFData">NFData</a> a) =&gt; <a href="Control-DeepSeq.html#t:NFData">NFData</a> (<a href="../base-4.5.1.0/Data-Ratio.html#t:Ratio">Ratio</a> a)</td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Control-DeepSeq.html#t:NFData">NFData</a> (<a href="../base-4.5.1.0/Data-Fixed.html#t:Fixed">Fixed</a> a)</td><td class="doc empty">&nbsp;</td></tr><tr><td class="src">(<a href="../base-4.5.1.0/Prelude.html#t:RealFloat">RealFloat</a> a, <a href="Control-DeepSeq.html#t:NFData">NFData</a> a) =&gt; <a href="Control-DeepSeq.html#t:NFData">NFData</a> (<a href="../base-4.5.1.0/Data-Complex.html#t:Complex">Complex</a> a)</td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Control-DeepSeq.html#t:NFData">NFData</a> a =&gt; <a href="Control-DeepSeq.html#t:NFData">NFData</a> (<a href="../base-4.5.1.0/Data-Maybe.html#t:Maybe">Maybe</a> a)</td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Control-DeepSeq.html#t:NFData">NFData</a> (a -&gt; b)</td><td class="doc"><p>This instance is for convenience and consistency with <code><a href="../base-4.5.1.0/Prelude.html#v:seq">seq</a></code>.
 This assumes that WHNF is equivalent to NF for functions.
</p></td></tr><tr><td class="src">(<a href="Control-DeepSeq.html#t:NFData">NFData</a> a, <a href="Control-DeepSeq.html#t:NFData">NFData</a> b) =&gt; <a href="Control-DeepSeq.html#t:NFData">NFData</a> (<a href="../base-4.5.1.0/Data-Either.html#t:Either">Either</a> a b)</td><td class="doc empty">&nbsp;</td></tr><tr><td class="src">(<a href="Control-DeepSeq.html#t:NFData">NFData</a> a, <a href="Control-DeepSeq.html#t:NFData">NFData</a> b) =&gt; <a href="Control-DeepSeq.html#t:NFData">NFData</a> (a, b)</td><td class="doc empty">&nbsp;</td></tr><tr><td class="src">(<a href="../base-4.5.1.0/Data-Ix.html#t:Ix">Ix</a> a, <a href="Control-DeepSeq.html#t:NFData">NFData</a> a, <a href="Control-DeepSeq.html#t:NFData">NFData</a> b) =&gt; <a href="Control-DeepSeq.html#t:NFData">NFData</a> (<a href="../array-0.4.0.0/Data-Array.html#t:Array">Array</a> a b)</td><td class="doc empty">&nbsp;</td></tr><tr><td class="src">(<a href="Control-DeepSeq.html#t:NFData">NFData</a> a, <a href="Control-DeepSeq.html#t:NFData">NFData</a> b, <a href="Control-DeepSeq.html#t:NFData">NFData</a> c) =&gt; <a href="Control-DeepSeq.html#t:NFData">NFData</a> (a, b, c)</td><td class="doc empty">&nbsp;</td></tr><tr><td class="src">(<a href="Control-DeepSeq.html#t:NFData">NFData</a> a, <a href="Control-DeepSeq.html#t:NFData">NFData</a> b, <a href="Control-DeepSeq.html#t:NFData">NFData</a> c, <a href="Control-DeepSeq.html#t:NFData">NFData</a> d) =&gt; <a href="Control-DeepSeq.html#t:NFData">NFData</a> (a, b, c, d)</td><td class="doc empty">&nbsp;</td></tr><tr><td class="src">(<a href="Control-DeepSeq.html#t:NFData">NFData</a> a1, <a href="Control-DeepSeq.html#t:NFData">NFData</a> a2, <a href="Control-DeepSeq.html#t:NFData">NFData</a> a3, <a href="Control-DeepSeq.html#t:NFData">NFData</a> a4, <a href="Control-DeepSeq.html#t:NFData">NFData</a> a5) =&gt; <a href="Control-DeepSeq.html#t:NFData">NFData</a> (a1, a2, a3, a4, a5)</td><td class="doc empty">&nbsp;</td></tr><tr><td class="src">(<a href="Control-DeepSeq.html#t:NFData">NFData</a> a1, <a href="Control-DeepSeq.html#t:NFData">NFData</a> a2, <a href="Control-DeepSeq.html#t:NFData">NFData</a> a3, <a href="Control-DeepSeq.html#t:NFData">NFData</a> a4, <a href="Control-DeepSeq.html#t:NFData">NFData</a> a5, <a href="Control-DeepSeq.html#t:NFData">NFData</a> a6) =&gt; <a href="Control-DeepSeq.html#t:NFData">NFData</a> (a1, a2, a3, a4, a5, a6)</td><td class="doc empty">&nbsp;</td></tr><tr><td class="src">(<a href="Control-DeepSeq.html#t:NFData">NFData</a> a1, <a href="Control-DeepSeq.html#t:NFData">NFData</a> a2, <a href="Control-DeepSeq.html#t:NFData">NFData</a> a3, <a href="Control-DeepSeq.html#t:NFData">NFData</a> a4, <a href="Control-DeepSeq.html#t:NFData">NFData</a> a5, <a href="Control-DeepSeq.html#t:NFData">NFData</a> a6, <a href="Control-DeepSeq.html#t:NFData">NFData</a> a7) =&gt; <a href="Control-DeepSeq.html#t:NFData">NFData</a> (a1, a2, a3, a4, a5, a6, a7)</td><td class="doc empty">&nbsp;</td></tr><tr><td class="src">(<a href="Control-DeepSeq.html#t:NFData">NFData</a> a1, <a href="Control-DeepSeq.html#t:NFData">NFData</a> a2, <a href="Control-DeepSeq.html#t:NFData">NFData</a> a3, <a href="Control-DeepSeq.html#t:NFData">NFData</a> a4, <a href="Control-DeepSeq.html#t:NFData">NFData</a> a5, <a href="Control-DeepSeq.html#t:NFData">NFData</a> a6, <a href="Control-DeepSeq.html#t:NFData">NFData</a> a7, <a href="Control-DeepSeq.html#t:NFData">NFData</a> a8) =&gt; <a href="Control-DeepSeq.html#t:NFData">NFData</a> (a1, a2, a3, a4, a5, a6, a7, a8)</td><td class="doc empty">&nbsp;</td></tr><tr><td class="src">(<a href="Control-DeepSeq.html#t:NFData">NFData</a> a1, <a href="Control-DeepSeq.html#t:NFData">NFData</a> a2, <a href="Control-DeepSeq.html#t:NFData">NFData</a> a3, <a href="Control-DeepSeq.html#t:NFData">NFData</a> a4, <a href="Control-DeepSeq.html#t:NFData">NFData</a> a5, <a href="Control-DeepSeq.html#t:NFData">NFData</a> a6, <a href="Control-DeepSeq.html#t:NFData">NFData</a> a7, <a href="Control-DeepSeq.html#t:NFData">NFData</a> a8, <a href="Control-DeepSeq.html#t:NFData">NFData</a> a9) =&gt; <a href="Control-DeepSeq.html#t:NFData">NFData</a> (a1, a2, a3, a4, a5, a6, a7, a8, a9)</td><td class="doc empty">&nbsp;</td></tr></table></div></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>