Sophie

Sophie

distrib > Fedora > 18 > i386 > by-pkgid > 44edde3c5c682595560925eda08a1c51 > files > 14

ghc-logict-devel-0.6-1.fc18.i686.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.Monad.Logic.Class</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-Logic-Class.html");};
//]]>
</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="src/Control-Monad-Logic-Class.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">logict-0.6: A backtracking logic-programming monad.</p></div><div id="content"><div id="module-header"><table class="info"><tr><th>Portability</th><td>non-portable (multi-parameter type classes)</td></tr><tr><th>Stability</th><td>experimental</td></tr><tr><th>Maintainer</th><td>dan.doel@gmail.com</td></tr><tr><th>Safe Haskell</th><td>Safe-Infered</td></tr></table><p class="caption">Control.Monad.Logic.Class</p></div><div id="description"><p class="caption">Description</p><div class="doc"><p>A backtracking, logic programming monad.
</p><p>Adapted from the paper
    /Backtracking, Interleaving, and Terminating
        Monad Transformers/, by
    Oleg Kiselyov, Chung-chieh Shan, Daniel P. Friedman, Amr Sabry
    (<a href="http://www.cs.rutgers.edu/~ccshan/logicprog/LogicT-icfp2005.pdf">http://www.cs.rutgers.edu/~ccshan/logicprog/LogicT-icfp2005.pdf</a>)
</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">class</span> <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Control-Monad.html#t:MonadPlus">MonadPlus</a> m =&gt; <a href="#t:MonadLogic">MonadLogic</a> m  <span class="keyword">where</span><ul class="subs"><li><a href="#v:msplit">msplit</a> ::  m a -&gt; m (<a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Maybe.html#t:Maybe">Maybe</a> (a, m a))</li><li><a href="#v:interleave">interleave</a> ::  m a -&gt; m a -&gt; m a</li><li><a href="#v:-62--62--45-">(&gt;&gt;-)</a> ::  m a -&gt; (a -&gt; m b) -&gt; m b</li><li><a href="#v:ifte">ifte</a> ::  m a -&gt; (a -&gt; m b) -&gt; m b -&gt; m b</li><li><a href="#v:once">once</a> ::  m a -&gt; m a</li></ul></li><li class="src short"><a href="#v:reflect">reflect</a> :: <a href="Control-Monad-Logic-Class.html#t:MonadLogic">MonadLogic</a> m =&gt; <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Maybe.html#t:Maybe">Maybe</a> (a, m a) -&gt; m a</li><li class="src short"><a href="#v:lnot">lnot</a> :: <a href="Control-Monad-Logic-Class.html#t:MonadLogic">MonadLogic</a> m =&gt; m a -&gt; m <a href="/usr/share/doc/ghc/html/libraries/ghc-prim-0.2.0.0/GHC-Tuple.html#t:-40--41-">()</a></li></ul></div><div id="interface"><h1>Documentation</h1><div class="top"><p class="src"><span class="keyword">class</span> <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Control-Monad.html#t:MonadPlus">MonadPlus</a> m =&gt; <a name="t:MonadLogic" class="def">MonadLogic</a> m  <span class="keyword">where</span><a href="src/Control-Monad-Logic-Class.html#MonadLogic" class="link">Source</a></p><div class="doc"><p>Minimal implementation: msplit
</p></div><div class="subs methods"><p class="caption">Methods</p><p class="src"><a name="v:msplit" class="def">msplit</a> ::  m a -&gt; m (<a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Maybe.html#t:Maybe">Maybe</a> (a, m a))<a href="src/Control-Monad-Logic-Class.html#msplit" class="link">Source</a></p><div class="doc"><p>Attempts to split the computation, giving access to the first
   result. Satisfies the following laws:
</p><pre> msplit mzero                == return Nothing
 msplit (return a `mplus` m) == return (Just (a, m))
</pre></div><p class="src"><a name="v:interleave" class="def">interleave</a> ::  m a -&gt; m a -&gt; m a<a href="src/Control-Monad-Logic-Class.html#interleave" class="link">Source</a></p><div class="doc"><p>Fair disjunction. It is possible for a logical computation
   to have an infinite number of potential results, for instance:
</p><pre> odds = return 1 `mplus` liftM (2+) odds
</pre><p>Such computations can cause problems in some circumstances. Consider:
</p><pre> do x &lt;- odds `mplus` return 2
    if even x then return x else mzero
</pre><p>Such a computation may never consider the 'return 2', and will
   therefore never terminate. By contrast, interleave ensures fair
   consideration of both branches of a disjunction
</p></div><p class="src"><a name="v:-62--62--45-" class="def">(&gt;&gt;-)</a> ::  m a -&gt; (a -&gt; m b) -&gt; m b<a href="src/Control-Monad-Logic-Class.html#%3E%3E-" class="link">Source</a></p><div class="doc"><p>Fair conjunction. Similarly to the previous function, consider
   the distributivity law for MonadPlus:
</p><pre> (mplus a b) &gt;&gt;= k = (a &gt;&gt;= k) `mplus` (b &gt;&gt;= k)
</pre><p>If 'a &gt;&gt;= k' can backtrack arbitrarily many tmes, (b &gt;&gt;= k) may never
   be considered. (&gt;&gt;-) takes similar care to consider both branches of
   a disjunctive computation.
</p></div><p class="src"><a name="v:ifte" class="def">ifte</a> ::  m a -&gt; (a -&gt; m b) -&gt; m b -&gt; m b<a href="src/Control-Monad-Logic-Class.html#ifte" class="link">Source</a></p><div class="doc"><p>Logical conditional. The equivalent of Prolog's soft-cut. If its
   first argument succeeds at all, then the results will be fed into
   the success branch. Otherwise, the failure branch is taken.
   satisfies the following laws:
</p><pre> ifte (return a) th el           == th a
 ifte mzero th el                == el
 ifte (return a `mplus` m) th el == th a `mplus` (m &gt;&gt;= th)
</pre></div><p class="src"><a name="v:once" class="def">once</a> ::  m a -&gt; m a<a href="src/Control-Monad-Logic-Class.html#once" class="link">Source</a></p><div class="doc"><p>Pruning. Selects one result out of many. Useful for when multiple
   results of a computation will be equivalent, or should be treated as
   such.
</p></div></div><div class="subs instances"><p id="control.i:MonadLogic" class="caption collapser" onclick="toggleSection('i:MonadLogic')">Instances</p><div id="section.i:MonadLogic" class="show"><table><tr><td class="src"><a href="Control-Monad-Logic-Class.html#t:MonadLogic">MonadLogic</a> []</td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Control-Monad.html#t:Monad">Monad</a> m =&gt; <a href="Control-Monad-Logic-Class.html#t:MonadLogic">MonadLogic</a> (<a href="Control-Monad-Logic.html#t:LogicT">LogicT</a> m)</td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Control-Monad-Logic-Class.html#t:MonadLogic">MonadLogic</a> m =&gt; <a href="Control-Monad-Logic-Class.html#t:MonadLogic">MonadLogic</a> (<a href="/usr/share/doc/ghc/html/libraries/mtl-2.1.1/Control-Monad-Reader.html#t:ReaderT">ReaderT</a> e m)</td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Control-Monad-Logic-Class.html#t:MonadLogic">MonadLogic</a> m =&gt; <a href="Control-Monad-Logic-Class.html#t:MonadLogic">MonadLogic</a> (<a href="/usr/share/doc/ghc/html/libraries/mtl-2.1.1/Control-Monad-State-Lazy.html#t:StateT">StateT</a> s m)</td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Control-Monad-Logic-Class.html#t:MonadLogic">MonadLogic</a> m =&gt; <a href="Control-Monad-Logic-Class.html#t:MonadLogic">MonadLogic</a> (<a href="/usr/share/doc/ghc/html/libraries/mtl-2.1.1/Control-Monad-State-Strict.html#t:StateT">StateT</a> s m)</td><td class="doc empty">&nbsp;</td></tr><tr><td class="src">(<a href="Control-Monad-Logic-Class.html#t:MonadLogic">MonadLogic</a> m, <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Monoid.html#t:Monoid">Monoid</a> w) =&gt; <a href="Control-Monad-Logic-Class.html#t:MonadLogic">MonadLogic</a> (<a href="/usr/share/doc/ghc/html/libraries/mtl-2.1.1/Control-Monad-Writer-Lazy.html#t:WriterT">WriterT</a> w m)</td><td class="doc empty">&nbsp;</td></tr><tr><td class="src">(<a href="Control-Monad-Logic-Class.html#t:MonadLogic">MonadLogic</a> m, <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Monoid.html#t:Monoid">Monoid</a> w) =&gt; <a href="Control-Monad-Logic-Class.html#t:MonadLogic">MonadLogic</a> (<a href="/usr/share/doc/ghc/html/libraries/mtl-2.1.1/Control-Monad-Writer-Strict.html#t:WriterT">WriterT</a> w m)</td><td class="doc empty">&nbsp;</td></tr></table></div></div></div><div class="top"><p class="src"><a name="v:reflect" class="def">reflect</a> :: <a href="Control-Monad-Logic-Class.html#t:MonadLogic">MonadLogic</a> m =&gt; <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Maybe.html#t:Maybe">Maybe</a> (a, m a) -&gt; m a<a href="src/Control-Monad-Logic-Class.html#reflect" class="link">Source</a></p><div class="doc"><p>The inverse of msplit. Satisfies the following law:
</p><pre> msplit m &gt;&gt;= reflect == m
</pre></div></div><div class="top"><p class="src"><a name="v:lnot" class="def">lnot</a> :: <a href="Control-Monad-Logic-Class.html#t:MonadLogic">MonadLogic</a> m =&gt; m a -&gt; m <a href="/usr/share/doc/ghc/html/libraries/ghc-prim-0.2.0.0/GHC-Tuple.html#t:-40--41-">()</a><a href="src/Control-Monad-Logic-Class.html#lnot" class="link">Source</a></p><div class="doc"><p>Inverts a logic computation. If <code>m</code> succeeds with at least one value,
 <code>lnot m</code> fails. If <code>m</code> fails, then <code>lnot m</code> succeeds the value <code>()</code>.
</p></div></div></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.10.0</p></div></body></html>