This file is indexed.

/usr/share/doc/libghc-monadrandom-doc/html/Control-Monad-Random.html is in libghc-monadrandom-doc 0.1.13-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<!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.Monad.Random</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-Monad-Random.html");};
//]]>
</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="src/Control-Monad-Random.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">MonadRandom-0.1.13: Random-number generation monad.</p></div><div id="content"><div id="module-header"><table class="info"><tr><th>Portability</th><td>non-portable (multi-parameter type classes, undecidable instances)</td></tr><tr><th>Stability</th><td>experimental</td></tr><tr><th>Safe Haskell</th><td>None</td></tr></table><p class="caption">Control.Monad.Random</p></div><div id="table-of-contents"><p class="caption">Contents</p><ul><li><a href="#g:1">Special lift functions
</a></li><li><a href="#g:2">Example
</a></li></ul></div><div id="description"><p class="caption">Description</p><div class="doc"><p>A random number generation monad.  See
<a href="http://www.haskell.org/haskellwiki/NewMonads/MonadRandom">http://www.haskell.org/haskellwiki/NewMonads/MonadRandom</a> for the original
version of this code.
</p><p>The actual interface is defined by
<code><a href="Control-Monad-Random-Class.html#t:MonadRandom">MonadRandom</a></code>.
</p><dl><dt>Computation type:</dt><dd> Computations which consume random values.
</dd><dt>Binding strategy:</dt><dd> The computation proceeds in the same fashion as the
identity monad, but it carries a random number generator that may be
queried to generate random values.
</dd><dt>Useful for:</dt><dd> Monte Carlo algorithms and simulating random processes.
</dd></dl></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">module <a href="/usr/share/doc/libghc-random-doc/html/System-Random.html">System.Random</a></li><li class="src short">module <a href="Control-Monad-Random-Class.html">Control.Monad.Random.Class</a></li><li class="src short"><a href="#v:evalRandT">evalRandT</a> :: (<a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Control-Monad.html#t:Monad">Monad</a> m, <a href="/usr/share/doc/libghc-random-doc/html/System-Random.html#t:RandomGen">RandomGen</a> g) =&gt; <a href="Control-Monad-Random.html#t:RandT">RandT</a> g m a -&gt; g -&gt; m a</li><li class="src short"><a href="#v:runRandT">runRandT</a> :: (<a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Control-Monad.html#t:Monad">Monad</a> m, <a href="/usr/share/doc/libghc-random-doc/html/System-Random.html#t:RandomGen">RandomGen</a> g) =&gt; <a href="Control-Monad-Random.html#t:RandT">RandT</a> g m a -&gt; g -&gt; m (a, g)</li><li class="src short"><a href="#v:evalRand">evalRand</a> :: <a href="/usr/share/doc/libghc-random-doc/html/System-Random.html#t:RandomGen">RandomGen</a> g =&gt; <a href="Control-Monad-Random.html#t:Rand">Rand</a> g a -&gt; g -&gt; a</li><li class="src short"><a href="#v:runRand">runRand</a> :: <a href="/usr/share/doc/libghc-random-doc/html/System-Random.html#t:RandomGen">RandomGen</a> g =&gt; <a href="Control-Monad-Random.html#t:Rand">Rand</a> g a -&gt; g -&gt; (a, g)</li><li class="src short"><a href="#v:evalRandIO">evalRandIO</a> ::  <a href="Control-Monad-Random.html#t:Rand">Rand</a> <a href="/usr/share/doc/libghc-random-doc/html/System-Random.html#t:StdGen">StdGen</a> a -&gt; <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/System-IO.html#t:IO">IO</a> a</li><li class="src short"><a href="#v:fromList">fromList</a> :: <a href="Control-Monad-Random-Class.html#t:MonadRandom">MonadRandom</a> m =&gt; [(a, <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Prelude.html#t:Rational">Rational</a>)] -&gt; m a</li><li class="src short"><a href="#v:uniform">uniform</a> :: <a href="Control-Monad-Random-Class.html#t:MonadRandom">MonadRandom</a> m =&gt; [a] -&gt; m a</li><li class="src short"><span class="keyword">data</span>  <a href="#t:Rand">Rand</a> g a</li><li class="src short"><span class="keyword">data</span>  <a href="#t:RandT">RandT</a> g m a</li><li class="src short"><a href="#v:liftRand">liftRand</a> :: (<a href="/usr/share/doc/libghc-random-doc/html/System-Random.html#t:RandomGen">RandomGen</a> g, <a href="/usr/share/doc/libghc-random-doc/html/System-Random.html#t:Random">Random</a> a) =&gt; (g -&gt; (a, g)) -&gt; <a href="Control-Monad-Random.html#t:Rand">Rand</a> g a</li><li class="src short"><a href="#v:liftRandT">liftRandT</a> :: (<a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Control-Monad.html#t:Monad">Monad</a> m, <a href="/usr/share/doc/libghc-random-doc/html/System-Random.html#t:RandomGen">RandomGen</a> g, <a href="/usr/share/doc/libghc-random-doc/html/System-Random.html#t:Random">Random</a> a) =&gt; (g -&gt; m (a, g)) -&gt; <a href="Control-Monad-Random.html#t:RandT">RandT</a> g m a</li></ul></div><div id="interface"><h1>Documentation</h1><div class="top"><p class="src">module <a href="/usr/share/doc/libghc-random-doc/html/System-Random.html">System.Random</a></p></div><div class="top"><p class="src">module <a href="Control-Monad-Random-Class.html">Control.Monad.Random.Class</a></p></div><div class="top"><p class="src"><a name="v:evalRandT" class="def">evalRandT</a> :: (<a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Control-Monad.html#t:Monad">Monad</a> m, <a href="/usr/share/doc/libghc-random-doc/html/System-Random.html#t:RandomGen">RandomGen</a> g) =&gt; <a href="Control-Monad-Random.html#t:RandT">RandT</a> g m a -&gt; g -&gt; m a<a href="src/Control-Monad-Random.html#evalRandT" class="link">Source</a></p><div class="doc"><p>Evaluate a RandT computation using the generator <code>g</code>.  Note that the
 generator <code>g</code> is not returned, so there's no way to recover the
 updated version of <code>g</code>.
</p></div></div><div class="top"><p class="src"><a name="v:runRandT" class="def">runRandT</a> :: (<a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Control-Monad.html#t:Monad">Monad</a> m, <a href="/usr/share/doc/libghc-random-doc/html/System-Random.html#t:RandomGen">RandomGen</a> g) =&gt; <a href="Control-Monad-Random.html#t:RandT">RandT</a> g m a -&gt; g -&gt; m (a, g)<a href="src/Control-Monad-Random.html#runRandT" class="link">Source</a></p><div class="doc"><p>Run a RandT computation using the generator <code>g</code>, returning the result and
 the updated generator.
</p></div></div><div class="top"><p class="src"><a name="v:evalRand" class="def">evalRand</a> :: <a href="/usr/share/doc/libghc-random-doc/html/System-Random.html#t:RandomGen">RandomGen</a> g =&gt; <a href="Control-Monad-Random.html#t:Rand">Rand</a> g a -&gt; g -&gt; a<a href="src/Control-Monad-Random.html#evalRand" class="link">Source</a></p><div class="doc"><p>Evaluate a random computation using the generator <code>g</code>.  Note that the
 generator <code>g</code> is not returned, so there's no way to recover the
 updated version of <code>g</code>.
</p></div></div><div class="top"><p class="src"><a name="v:runRand" class="def">runRand</a> :: <a href="/usr/share/doc/libghc-random-doc/html/System-Random.html#t:RandomGen">RandomGen</a> g =&gt; <a href="Control-Monad-Random.html#t:Rand">Rand</a> g a -&gt; g -&gt; (a, g)<a href="src/Control-Monad-Random.html#runRand" class="link">Source</a></p><div class="doc"><p>Run a random computation using the generator <code>g</code>, returning the result
 and the updated generator.
</p></div></div><div class="top"><p class="src"><a name="v:evalRandIO" class="def">evalRandIO</a> ::  <a href="Control-Monad-Random.html#t:Rand">Rand</a> <a href="/usr/share/doc/libghc-random-doc/html/System-Random.html#t:StdGen">StdGen</a> a -&gt; <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/System-IO.html#t:IO">IO</a> a<a href="src/Control-Monad-Random.html#evalRandIO" class="link">Source</a></p><div class="doc"><p>Evaluate a random computation in the IO monad, splitting the global standard generator to get a new one for the computation.
</p></div></div><div class="top"><p class="src"><a name="v:fromList" class="def">fromList</a> :: <a href="Control-Monad-Random-Class.html#t:MonadRandom">MonadRandom</a> m =&gt; [(a, <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Prelude.html#t:Rational">Rational</a>)] -&gt; m a<a href="src/Control-Monad-Random.html#fromList" class="link">Source</a></p><div class="doc"><p>Sample a random value from a weighted list.  The total weight of all
 elements must not be 0.
</p></div></div><div class="top"><p class="src"><a name="v:uniform" class="def">uniform</a> :: <a href="Control-Monad-Random-Class.html#t:MonadRandom">MonadRandom</a> m =&gt; [a] -&gt; m a<a href="src/Control-Monad-Random.html#uniform" class="link">Source</a></p><div class="doc"><p>Sample a value from a uniform distribution of a list of elements.
</p></div></div><div class="top"><p class="src"><span class="keyword">data</span>  <a name="t:Rand" class="def">Rand</a> g a <a href="src/Control-Monad-Random.html#Rand" class="link">Source</a></p><div class="doc"><p>A basic random monad.
</p></div><div class="subs instances"><p id="control.i:Rand" class="caption collapser" onclick="toggleSection('i:Rand')">Instances</p><div id="section.i:Rand" class="show"><table><tr><td class="src"><a href="/usr/share/doc/libghc-random-doc/html/System-Random.html#t:RandomGen">RandomGen</a> g =&gt; <a href="Control-Monad-Random-Class.html#t:MonadSplit">MonadSplit</a> g (<a href="Control-Monad-Random.html#t:Rand">Rand</a> g)</td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Control-Monad.html#t:Monad">Monad</a> (<a href="Control-Monad-Random.html#t:Rand">Rand</a> g)</td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Control-Monad.html#t:Functor">Functor</a> (<a href="Control-Monad-Random.html#t:Rand">Rand</a> g)</td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Control-Monad-Fix.html#t:MonadFix">MonadFix</a> (<a href="Control-Monad-Random.html#t:Rand">Rand</a> g)</td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Control-Applicative.html#t:Applicative">Applicative</a> (<a href="Control-Monad-Random.html#t:Rand">Rand</a> g)</td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="/usr/share/doc/libghc-random-doc/html/System-Random.html#t:RandomGen">RandomGen</a> g =&gt; <a href="Control-Monad-Random-Class.html#t:MonadRandom">MonadRandom</a> (<a href="Control-Monad-Random.html#t:Rand">Rand</a> g)</td><td class="doc empty">&nbsp;</td></tr></table></div></div></div><div class="top"><p class="src"><span class="keyword">data</span>  <a name="t:RandT" class="def">RandT</a> g m a <a href="src/Control-Monad-Random.html#RandT" class="link">Source</a></p><div class="doc"><p>A monad transformer which adds a random number generator to an
 existing monad.
</p></div><div class="subs instances"><p id="control.i:RandT" class="caption collapser" onclick="toggleSection('i:RandT')">Instances</p><div id="section.i:RandT" class="show"><table><tr><td class="src"><a href="/usr/share/doc/libghc-mtl-doc/html/Control-Monad-Reader-Class.html#t:MonadReader">MonadReader</a> r m =&gt; <a href="/usr/share/doc/libghc-mtl-doc/html/Control-Monad-Reader-Class.html#t:MonadReader">MonadReader</a> r (<a href="Control-Monad-Random.html#t:RandT">RandT</a> g m)</td><td class="doc empty">&nbsp;</td></tr><tr><td class="src">(<a href="/usr/share/doc/libghc-mtl-doc/html/Control-Monad-State-Class.html#t:MonadState">MonadState</a> s m, <a href="/usr/share/doc/libghc-random-doc/html/System-Random.html#t:RandomGen">RandomGen</a> g) =&gt; <a href="/usr/share/doc/libghc-mtl-doc/html/Control-Monad-State-Class.html#t:MonadState">MonadState</a> s (<a href="Control-Monad-Random.html#t:RandT">RandT</a> g m)</td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="/usr/share/doc/libghc-mtl-doc/html/Control-Monad-Writer-Class.html#t:MonadWriter">MonadWriter</a> w m =&gt; <a href="/usr/share/doc/libghc-mtl-doc/html/Control-Monad-Writer-Class.html#t:MonadWriter">MonadWriter</a> w (<a href="Control-Monad-Random.html#t:RandT">RandT</a> g m)</td><td class="doc empty">&nbsp;</td></tr><tr><td class="src">(<a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Control-Monad.html#t:Monad">Monad</a> m, <a href="/usr/share/doc/libghc-random-doc/html/System-Random.html#t:RandomGen">RandomGen</a> g) =&gt; <a href="Control-Monad-Random-Class.html#t:MonadSplit">MonadSplit</a> g (<a href="Control-Monad-Random.html#t:RandT">RandT</a> g m)</td><td class="doc empty">&nbsp;</td></tr><tr><td class="src">MonadTrans (<a href="Control-Monad-Random.html#t:RandT">RandT</a> g)</td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Control-Monad.html#t:Monad">Monad</a> m =&gt; <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Control-Monad.html#t:Monad">Monad</a> (<a href="Control-Monad-Random.html#t:RandT">RandT</a> g m)</td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Control-Monad.html#t:Functor">Functor</a> m =&gt; <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Control-Monad.html#t:Functor">Functor</a> (<a href="Control-Monad-Random.html#t:RandT">RandT</a> g m)</td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Control-Monad-Fix.html#t:MonadFix">MonadFix</a> m =&gt; <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Control-Monad-Fix.html#t:MonadFix">MonadFix</a> (<a href="Control-Monad-Random.html#t:RandT">RandT</a> g m)</td><td class="doc empty">&nbsp;</td></tr><tr><td class="src">(<a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Control-Monad.html#t:Functor">Functor</a> m, <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Control-Monad.html#t:Monad">Monad</a> m) =&gt; <a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Control-Applicative.html#t:Applicative">Applicative</a> (<a href="Control-Monad-Random.html#t:RandT">RandT</a> g m)</td><td class="doc empty">&nbsp;</td></tr><tr><td class="src">MonadIO m =&gt; MonadIO (<a href="Control-Monad-Random.html#t:RandT">RandT</a> g m)</td><td class="doc empty">&nbsp;</td></tr><tr><td class="src">(<a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Control-Monad.html#t:Monad">Monad</a> m, <a href="/usr/share/doc/libghc-random-doc/html/System-Random.html#t:RandomGen">RandomGen</a> g) =&gt; <a href="Control-Monad-Random-Class.html#t:MonadRandom">MonadRandom</a> (<a href="Control-Monad-Random.html#t:RandT">RandT</a> g m)</td><td class="doc empty">&nbsp;</td></tr></table></div></div></div><h1 id="g:1">Special lift functions
</h1><div class="top"><p class="src"><a name="v:liftRand" class="def">liftRand</a><a href="src/Control-Monad-Random.html#liftRand" class="link">Source</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: (<a href="/usr/share/doc/libghc-random-doc/html/System-Random.html#t:RandomGen">RandomGen</a> g, <a href="/usr/share/doc/libghc-random-doc/html/System-Random.html#t:Random">Random</a> a)</td><td class="doc empty">&nbsp;</td></tr><tr><td class="src">=&gt; (g -&gt; (a, g))</td><td class="doc"><p>action returning value and new generator state
</p></td></tr><tr><td class="src">-&gt; <a href="Control-Monad-Random.html#t:Rand">Rand</a> g a</td><td class="doc empty">&nbsp;</td></tr></table></div><div class="doc"><p>Lift arbitrary action to Rand
</p></div></div><div class="top"><p class="src"><a name="v:liftRandT" class="def">liftRandT</a><a href="src/Control-Monad-Random.html#liftRandT" class="link">Source</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: (<a href="/usr/share/doc/ghc-doc/html/libraries/base-4.6.0.1/Control-Monad.html#t:Monad">Monad</a> m, <a href="/usr/share/doc/libghc-random-doc/html/System-Random.html#t:RandomGen">RandomGen</a> g, <a href="/usr/share/doc/libghc-random-doc/html/System-Random.html#t:Random">Random</a> a)</td><td class="doc empty">&nbsp;</td></tr><tr><td class="src">=&gt; (g -&gt; m (a, g))</td><td class="doc"><p>action returning value and new generator state
</p></td></tr><tr><td class="src">-&gt; <a href="Control-Monad-Random.html#t:RandT">RandT</a> g m a</td><td class="doc empty">&nbsp;</td></tr></table></div><div class="doc"><p>Lift arbitrary action to RandT
</p></div></div><h1 id="g:2">Example
</h1><div class="doc"><p>The <code>die</code> function simulates the roll of a die, picking a number between 1
and 6, inclusive, and returning it in the <code><a href="Control-Monad-Random.html#t:Rand">Rand</a></code> monad.  Notice that this
code will work with any source of random numbers <code>g</code>.
</p><pre>die :: (RandomGen g) =&gt; Rand g Int
die = getRandomR (1,6)
</pre><p>The <code>dice</code> function uses <code>replicate</code> and <code>sequence</code> to simulate the roll of
<code>n</code> dice.
</p><pre>dice :: (RandomGen g) =&gt; Int -&gt; Rand g [Int]
dice n = sequence (replicate n die)
</pre><p>To extract a value from the <code><a href="Control-Monad-Random.html#t:Rand">Rand</a></code> monad, we can can use <code><a href="Control-Monad-Random.html#v:evalRandIO">evalRandIO</a></code>.
</p><pre>main = do
  values &lt;- evalRandIO (dice 2)
  putStrLn (show values)
</pre></div></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.13.2</p></div></body></html>