/usr/share/doc/libghc-free-doc/html/Control-Monad-Free-Church.html is in libghc-free-doc 4.12.4-3.
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 | <!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.Free.Church</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script src="file:///usr/share/javascript/mathjax/MathJax.js" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
window.onload = function () {pageLoad();setSynopsis("mini_Control-Monad-Free-Church.html");};
//]]>
</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="src/Control-Monad-Free-Church.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">free-4.12.4: Monads for free</p></div><div id="content"><div id="module-header"><table class="info"><tr><th>Copyright</th><td>(C) 2011-2015 Edward Kmett</td></tr><tr><th>License</th><td>BSD-style (see the file LICENSE)</td></tr><tr><th>Maintainer</th><td>Edward Kmett <ekmett@gmail.com></td></tr><tr><th>Stability</th><td>provisional</td></tr><tr><th>Portability</th><td>non-portable (rank-2 polymorphism)</td></tr><tr><th>Safe Haskell</th><td>Safe</td></tr><tr><th>Language</th><td>Haskell2010</td></tr></table><p class="caption">Control.Monad.Free.Church</p></div><div id="description"><p class="caption">Description</p><div class="doc"><p>"Free Monads for Less"</p><p>The most straightforward way of implementing free monads is as a recursive
datatype that allows for arbitrarily deep nesting of the base functor. This is
akin to a tree, with the leaves containing the values, and the nodes being a
level of <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Functor.html#t:Functor">Functor</a></code> over subtrees.</p><p>For each time that the <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Functor.html#v:fmap">fmap</a></code> or <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad.html#v:-62--62--61-">>>=</a></code> operations is used, the old tree is
traversed up to the leaves, a new set of nodes is allocated, and
the old ones are garbage collected. Even if the Haskell runtime
optimizes some of the overhead through laziness and generational garbage
collection, the asymptotic runtime is still quadratic.</p><p>On the other hand, if the Church encoding is used, the tree only needs to be
constructed once, because:</p><ul><li>All uses of <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Functor.html#v:fmap">fmap</a></code> are collapsed into a single one, so that the values on the
_leaves_ are transformed in one pass.</li></ul><pre>fmap f . fmap g == fmap (f . g)</pre><ul><li>All uses of <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad.html#v:-62--62--61-">>>=</a></code> are right associated, so that every new subtree created
is final.</li></ul><pre>(m >>= f) >>= g == m >>= (\x -> f x >>= g)</pre><p>Asymptotically, the Church encoding supports the monadic operations more
efficiently than the naïve <code><a href="Control-Monad-Free.html#t:Free">Free</a></code>.</p><p>This is based on the "Free Monads for Less" series of articles by Edward Kmett:</p><ul><li><a href="http://comonad.com/reader/2011/free-monads-for-less/">Free monads for less — Part 1</a></li><li><a href="http://comonad.com/reader/2011/free-monads-for-less-2/">Free monads for less — Part 2</a></li></ul></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">newtype</span> <a href="#t:F">F</a> f a = <a href="#v:F">F</a> {<ul class="subs"><li><a href="#v:runF">runF</a> :: <span class="keyword">forall</span> r. (a -> r) -> (f r -> r) -> r</li></ul>}</li><li class="src short"><a href="#v:improve">improve</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Functor.html#t:Functor">Functor</a> f => (<span class="keyword">forall</span> m. <a href="Control-Monad-Free-Church.html#t:MonadFree">MonadFree</a> f m => m a) -> <a href="Control-Monad-Free.html#t:Free">Free</a> f a</li><li class="src short"><a href="#v:fromF">fromF</a> :: <a href="Control-Monad-Free-Church.html#t:MonadFree">MonadFree</a> f m => <a href="Control-Monad-Free-Church.html#t:F">F</a> f a -> m a</li><li class="src short"><a href="#v:iter">iter</a> :: (f a -> a) -> <a href="Control-Monad-Free-Church.html#t:F">F</a> f a -> a</li><li class="src short"><a href="#v:iterM">iterM</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad.html#t:Monad">Monad</a> m => (f (m a) -> m a) -> <a href="Control-Monad-Free-Church.html#t:F">F</a> f a -> m a</li><li class="src short"><a href="#v:toF">toF</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Functor.html#t:Functor">Functor</a> f => <a href="Control-Monad-Free.html#t:Free">Free</a> f a -> <a href="Control-Monad-Free-Church.html#t:F">F</a> f a</li><li class="src short"><a href="#v:retract">retract</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad.html#t:Monad">Monad</a> m => <a href="Control-Monad-Free-Church.html#t:F">F</a> m a -> m a</li><li class="src short"><a href="#v:hoistF">hoistF</a> :: (<span class="keyword">forall</span> x. f x -> g x) -> <a href="Control-Monad-Free-Church.html#t:F">F</a> f a -> <a href="Control-Monad-Free-Church.html#t:F">F</a> g a</li><li class="src short"><a href="#v:foldF">foldF</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad.html#t:Monad">Monad</a> m => (<span class="keyword">forall</span> x. f x -> m x) -> <a href="Control-Monad-Free-Church.html#t:F">F</a> f a -> m a</li><li class="src short"><span class="keyword">class</span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad.html#t:Monad">Monad</a> m => <a href="#t:MonadFree">MonadFree</a> f m | m -> f <span class="keyword">where</span><ul class="subs"></ul></li><li class="src short"><a href="#v:liftF">liftF</a> :: (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Functor.html#t:Functor">Functor</a> f, <a href="Control-Monad-Free-Church.html#t:MonadFree">MonadFree</a> f m) => f a -> m a</li><li class="src short"><a href="#v:cutoff">cutoff</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Functor.html#t:Functor">Functor</a> f => <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Prelude.html#t:Integer">Integer</a> -> <a href="Control-Monad-Free-Church.html#t:F">F</a> f a -> <a href="Control-Monad-Free-Church.html#t:F">F</a> f (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Maybe.html#t:Maybe">Maybe</a> a)</li></ul></div><div id="interface"><h1>Documentation</h1><div class="top"><p class="src"><span class="keyword">newtype</span> <a id="t:F" class="def">F</a> f a <a href="src/Control-Monad-Free-Church.html#F" class="link">Source</a> <a href="#t:F" class="selflink">#</a></p><div class="doc"><p>The Church-encoded free monad for a functor <code>f</code>.</p><p>It is <em>asymptotically</em> more efficient to use (<code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad.html#v:-62--62--61-">>>=</a></code>) for <code><a href="Control-Monad-Free-Church.html#t:F">F</a></code> than it is to (<code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad.html#v:-62--62--61-">>>=</a></code>) with <code><a href="Control-Monad-Free.html#t:Free">Free</a></code>.</p><p><a href="http://comonad.com/reader/2011/free-monads-for-less-2/">http://comonad.com/reader/2011/free-monads-for-less-2/</a></p></div><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a id="v:F" class="def">F</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div class="subs fields"><p class="caption">Fields</p><ul><li><dfn class="src"><a id="v:runF" class="def">runF</a> :: <span class="keyword">forall</span> r. (a -> r) -> (f r -> r) -> r</dfn><div class="doc empty"> </div></li></ul></div></td></tr></table></div><div class="subs instances"><p id="control.i:F" class="caption collapser" onclick="toggleSection('i:F')">Instances</p><div id="section.i:F" class="show"><table><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:F:MonadTrans:1" class="instance expander" onclick="toggleSection('i:id:F:MonadTrans:1')"></span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/transformers-0.5.2.0/Control-Monad-Trans-Class.html#t:MonadTrans">MonadTrans</a> <a href="Control-Monad-Free-Church.html#t:F">F</a></span> <a href="src/Control-Monad-Free-Church.html#line-140" class="link">Source</a> <a href="#t:F" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:id:F:MonadTrans:1" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:lift">lift</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad.html#t:Monad">Monad</a> m => m a -> <a href="Control-Monad-Free-Church.html#t:F">F</a> m a <a href="#v:lift" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:F:MonadReader:2" class="instance expander" onclick="toggleSection('i:id:F:MonadReader:2')"></span> <a href="file:///usr/share/doc/libghc-mtl-doc/html/Control-Monad-Reader-Class.html#t:MonadReader">MonadReader</a> e m => <a href="file:///usr/share/doc/libghc-mtl-doc/html/Control-Monad-Reader-Class.html#t:MonadReader">MonadReader</a> e (<a href="Control-Monad-Free-Church.html#t:F">F</a> m)</span> <a href="src/Control-Monad-Free-Church.html#line-150" class="link">Source</a> <a href="#t:F" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:id:F:MonadReader:2" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:ask">ask</a> :: <a href="Control-Monad-Free-Church.html#t:F">F</a> m e <a href="#v:ask" class="selflink">#</a></p><p class="src"><a href="#v:local">local</a> :: (e -> e) -> <a href="Control-Monad-Free-Church.html#t:F">F</a> m a -> <a href="Control-Monad-Free-Church.html#t:F">F</a> m a <a href="#v:local" class="selflink">#</a></p><p class="src"><a href="#v:reader">reader</a> :: (e -> a) -> <a href="Control-Monad-Free-Church.html#t:F">F</a> m a <a href="#v:reader" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:F:MonadState:3" class="instance expander" onclick="toggleSection('i:id:F:MonadState:3')"></span> <a href="file:///usr/share/doc/libghc-mtl-doc/html/Control-Monad-State-Class.html#t:MonadState">MonadState</a> s m => <a href="file:///usr/share/doc/libghc-mtl-doc/html/Control-Monad-State-Class.html#t:MonadState">MonadState</a> s (<a href="Control-Monad-Free-Church.html#t:F">F</a> m)</span> <a href="src/Control-Monad-Free-Church.html#line-146" class="link">Source</a> <a href="#t:F" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:id:F:MonadState:3" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:get">get</a> :: <a href="Control-Monad-Free-Church.html#t:F">F</a> m s <a href="#v:get" class="selflink">#</a></p><p class="src"><a href="#v:put">put</a> :: s -> <a href="Control-Monad-Free-Church.html#t:F">F</a> m () <a href="#v:put" class="selflink">#</a></p><p class="src"><a href="#v:state">state</a> :: (s -> (a, s)) -> <a href="Control-Monad-Free-Church.html#t:F">F</a> m a <a href="#v:state" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:F:MonadWriter:4" class="instance expander" onclick="toggleSection('i:id:F:MonadWriter:4')"></span> <a href="file:///usr/share/doc/libghc-mtl-doc/html/Control-Monad-Writer-Class.html#t:MonadWriter">MonadWriter</a> w m => <a href="file:///usr/share/doc/libghc-mtl-doc/html/Control-Monad-Writer-Class.html#t:MonadWriter">MonadWriter</a> w (<a href="Control-Monad-Free-Church.html#t:F">F</a> m)</span> <a href="src/Control-Monad-Free-Church.html#line-154" class="link">Source</a> <a href="#t:F" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:id:F:MonadWriter:4" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:writer">writer</a> :: (a, w) -> <a href="Control-Monad-Free-Church.html#t:F">F</a> m a <a href="#v:writer" class="selflink">#</a></p><p class="src"><a href="#v:tell">tell</a> :: w -> <a href="Control-Monad-Free-Church.html#t:F">F</a> m () <a href="#v:tell" class="selflink">#</a></p><p class="src"><a href="#v:listen">listen</a> :: <a href="Control-Monad-Free-Church.html#t:F">F</a> m a -> <a href="Control-Monad-Free-Church.html#t:F">F</a> m (a, w) <a href="#v:listen" class="selflink">#</a></p><p class="src"><a href="#v:pass">pass</a> :: <a href="Control-Monad-Free-Church.html#t:F">F</a> m (a, w -> w) -> <a href="Control-Monad-Free-Church.html#t:F">F</a> m a <a href="#v:pass" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:F:MonadFree:5" class="instance expander" onclick="toggleSection('i:id:F:MonadFree:5')"></span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Functor.html#t:Functor">Functor</a> f => <a href="Control-Monad-Free-Church.html#t:MonadFree">MonadFree</a> f (<a href="Control-Monad-Free-Church.html#t:F">F</a> f)</span> <a href="src/Control-Monad-Free-Church.html#line-143" class="link">Source</a> <a href="#t:F" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:id:F:MonadFree:5" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:wrap">wrap</a> :: f (<a href="Control-Monad-Free-Church.html#t:F">F</a> f a) -> <a href="Control-Monad-Free-Church.html#t:F">F</a> f a <a href="src/Control-Monad-Free-Class.html#wrap" class="link">Source</a> <a href="#v:wrap" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:F:Monad:6" class="instance expander" onclick="toggleSection('i:id:F:Monad:6')"></span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad.html#t:Monad">Monad</a> (<a href="Control-Monad-Free-Church.html#t:F">F</a> f)</span> <a href="src/Control-Monad-Free-Church.html#line-117" class="link">Source</a> <a href="#t:F" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:id:F:Monad:6" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:-62--62--61-">(>>=)</a> :: <a href="Control-Monad-Free-Church.html#t:F">F</a> f a -> (a -> <a href="Control-Monad-Free-Church.html#t:F">F</a> f b) -> <a href="Control-Monad-Free-Church.html#t:F">F</a> f b <a href="#v:-62--62--61-" class="selflink">#</a></p><p class="src"><a href="#v:-62--62-">(>>)</a> :: <a href="Control-Monad-Free-Church.html#t:F">F</a> f a -> <a href="Control-Monad-Free-Church.html#t:F">F</a> f b -> <a href="Control-Monad-Free-Church.html#t:F">F</a> f b <a href="#v:-62--62-" class="selflink">#</a></p><p class="src"><a href="#v:return">return</a> :: a -> <a href="Control-Monad-Free-Church.html#t:F">F</a> f a <a href="#v:return" class="selflink">#</a></p><p class="src"><a href="#v:fail">fail</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-String.html#t:String">String</a> -> <a href="Control-Monad-Free-Church.html#t:F">F</a> f a <a href="#v:fail" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:F:Functor:7" class="instance expander" onclick="toggleSection('i:id:F:Functor:7')"></span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Functor.html#t:Functor">Functor</a> (<a href="Control-Monad-Free-Church.html#t:F">F</a> f)</span> <a href="src/Control-Monad-Free-Church.html#line-99" class="link">Source</a> <a href="#t:F" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:id:F:Functor:7" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:fmap">fmap</a> :: (a -> b) -> <a href="Control-Monad-Free-Church.html#t:F">F</a> f a -> <a href="Control-Monad-Free-Church.html#t:F">F</a> f b <a href="#v:fmap" class="selflink">#</a></p><p class="src"><a href="#v:-60--36-">(<$)</a> :: a -> <a href="Control-Monad-Free-Church.html#t:F">F</a> f b -> <a href="Control-Monad-Free-Church.html#t:F">F</a> f a <a href="#v:-60--36-" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:F:MonadFix:8" class="instance expander" onclick="toggleSection('i:id:F:MonadFix:8')"></span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad-Fix.html#t:MonadFix">MonadFix</a> (<a href="Control-Monad-Free-Church.html#t:F">F</a> f)</span> <a href="src/Control-Monad-Free-Church.html#line-121" class="link">Source</a> <a href="#t:F" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:id:F:MonadFix:8" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:mfix">mfix</a> :: (a -> <a href="Control-Monad-Free-Church.html#t:F">F</a> f a) -> <a href="Control-Monad-Free-Church.html#t:F">F</a> f a <a href="#v:mfix" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:F:Applicative:9" class="instance expander" onclick="toggleSection('i:id:F:Applicative:9')"></span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Applicative.html#t:Applicative">Applicative</a> (<a href="Control-Monad-Free-Church.html#t:F">F</a> f)</span> <a href="src/Control-Monad-Free-Church.html#line-105" class="link">Source</a> <a href="#t:F" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:id:F:Applicative:9" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:pure">pure</a> :: a -> <a href="Control-Monad-Free-Church.html#t:F">F</a> f a <a href="#v:pure" class="selflink">#</a></p><p class="src"><a href="#v:-60--42--62-">(<*>)</a> :: <a href="Control-Monad-Free-Church.html#t:F">F</a> f (a -> b) -> <a href="Control-Monad-Free-Church.html#t:F">F</a> f a -> <a href="Control-Monad-Free-Church.html#t:F">F</a> f b <a href="#v:-60--42--62-" class="selflink">#</a></p><p class="src"><a href="#v:-42--62-">(*>)</a> :: <a href="Control-Monad-Free-Church.html#t:F">F</a> f a -> <a href="Control-Monad-Free-Church.html#t:F">F</a> f b -> <a href="Control-Monad-Free-Church.html#t:F">F</a> f b <a href="#v:-42--62-" class="selflink">#</a></p><p class="src"><a href="#v:-60--42-">(<*)</a> :: <a href="Control-Monad-Free-Church.html#t:F">F</a> f a -> <a href="Control-Monad-Free-Church.html#t:F">F</a> f b -> <a href="Control-Monad-Free-Church.html#t:F">F</a> f a <a href="#v:-60--42-" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:F:Foldable:10" class="instance expander" onclick="toggleSection('i:id:F:Foldable:10')"></span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Foldable.html#t:Foldable">Foldable</a> f => <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Foldable.html#t:Foldable">Foldable</a> (<a href="Control-Monad-Free-Church.html#t:F">F</a> f)</span> <a href="src/Control-Monad-Free-Church.html#line-126" class="link">Source</a> <a href="#t:F" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:id:F:Foldable:10" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:fold">fold</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Monoid.html#t:Monoid">Monoid</a> m => <a href="Control-Monad-Free-Church.html#t:F">F</a> f m -> m <a href="#v:fold" class="selflink">#</a></p><p class="src"><a href="#v:foldMap">foldMap</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Monoid.html#t:Monoid">Monoid</a> m => (a -> m) -> <a href="Control-Monad-Free-Church.html#t:F">F</a> f a -> m <a href="#v:foldMap" class="selflink">#</a></p><p class="src"><a href="#v:foldr">foldr</a> :: (a -> b -> b) -> b -> <a href="Control-Monad-Free-Church.html#t:F">F</a> f a -> b <a href="#v:foldr" class="selflink">#</a></p><p class="src"><a href="#v:foldr-39-">foldr'</a> :: (a -> b -> b) -> b -> <a href="Control-Monad-Free-Church.html#t:F">F</a> f a -> b <a href="#v:foldr-39-" class="selflink">#</a></p><p class="src"><a href="#v:foldl">foldl</a> :: (b -> a -> b) -> b -> <a href="Control-Monad-Free-Church.html#t:F">F</a> f a -> b <a href="#v:foldl" class="selflink">#</a></p><p class="src"><a href="#v:foldl-39-">foldl'</a> :: (b -> a -> b) -> b -> <a href="Control-Monad-Free-Church.html#t:F">F</a> f a -> b <a href="#v:foldl-39-" class="selflink">#</a></p><p class="src"><a href="#v:foldr1">foldr1</a> :: (a -> a -> a) -> <a href="Control-Monad-Free-Church.html#t:F">F</a> f a -> a <a href="#v:foldr1" class="selflink">#</a></p><p class="src"><a href="#v:foldl1">foldl1</a> :: (a -> a -> a) -> <a href="Control-Monad-Free-Church.html#t:F">F</a> f a -> a <a href="#v:foldl1" class="selflink">#</a></p><p class="src"><a href="#v:toList">toList</a> :: <a href="Control-Monad-Free-Church.html#t:F">F</a> f a -> [a] <a href="#v:toList" class="selflink">#</a></p><p class="src"><a href="#v:null">null</a> :: <a href="Control-Monad-Free-Church.html#t:F">F</a> f a -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Bool.html#t:Bool">Bool</a> <a href="#v:null" class="selflink">#</a></p><p class="src"><a href="#v:length">length</a> :: <a href="Control-Monad-Free-Church.html#t:F">F</a> f a -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Int.html#t:Int">Int</a> <a href="#v:length" class="selflink">#</a></p><p class="src"><a href="#v:elem">elem</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Eq.html#t:Eq">Eq</a> a => a -> <a href="Control-Monad-Free-Church.html#t:F">F</a> f a -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Bool.html#t:Bool">Bool</a> <a href="#v:elem" class="selflink">#</a></p><p class="src"><a href="#v:maximum">maximum</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Ord.html#t:Ord">Ord</a> a => <a href="Control-Monad-Free-Church.html#t:F">F</a> f a -> a <a href="#v:maximum" class="selflink">#</a></p><p class="src"><a href="#v:minimum">minimum</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Ord.html#t:Ord">Ord</a> a => <a href="Control-Monad-Free-Church.html#t:F">F</a> f a -> a <a href="#v:minimum" class="selflink">#</a></p><p class="src"><a href="#v:sum">sum</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Prelude.html#t:Num">Num</a> a => <a href="Control-Monad-Free-Church.html#t:F">F</a> f a -> a <a href="#v:sum" class="selflink">#</a></p><p class="src"><a href="#v:product">product</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Prelude.html#t:Num">Num</a> a => <a href="Control-Monad-Free-Church.html#t:F">F</a> f a -> a <a href="#v:product" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:F:Alternative:11" class="instance expander" onclick="toggleSection('i:id:F:Alternative:11')"></span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Applicative.html#t:Alternative">Alternative</a> f => <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Applicative.html#t:Alternative">Alternative</a> (<a href="Control-Monad-Free-Church.html#t:F">F</a> f)</span> <a href="src/Control-Monad-Free-Church.html#line-110" class="link">Source</a> <a href="#t:F" class="selflink">#</a></td><td class="doc"><p>This violates the Alternative laws, handle with care.</p></td></tr><tr><td colspan="2"><div id="section.i:id:F:Alternative:11" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:empty">empty</a> :: <a href="Control-Monad-Free-Church.html#t:F">F</a> f a <a href="#v:empty" class="selflink">#</a></p><p class="src"><a href="#v:-60--124--62-">(<|>)</a> :: <a href="Control-Monad-Free-Church.html#t:F">F</a> f a -> <a href="Control-Monad-Free-Church.html#t:F">F</a> f a -> <a href="Control-Monad-Free-Church.html#t:F">F</a> f a <a href="#v:-60--124--62-" class="selflink">#</a></p><p class="src"><a href="#v:some">some</a> :: <a href="Control-Monad-Free-Church.html#t:F">F</a> f a -> <a href="Control-Monad-Free-Church.html#t:F">F</a> f [a] <a href="#v:some" class="selflink">#</a></p><p class="src"><a href="#v:many">many</a> :: <a href="Control-Monad-Free-Church.html#t:F">F</a> f a -> <a href="Control-Monad-Free-Church.html#t:F">F</a> f [a] <a href="#v:many" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:F:MonadPlus:12" class="instance expander" onclick="toggleSection('i:id:F:MonadPlus:12')"></span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad.html#t:MonadPlus">MonadPlus</a> f => <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad.html#t:MonadPlus">MonadPlus</a> (<a href="Control-Monad-Free-Church.html#t:F">F</a> f)</span> <a href="src/Control-Monad-Free-Church.html#line-136" class="link">Source</a> <a href="#t:F" class="selflink">#</a></td><td class="doc"><p>This violates the MonadPlus laws, handle with care.</p></td></tr><tr><td colspan="2"><div id="section.i:id:F:MonadPlus:12" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:mzero">mzero</a> :: <a href="Control-Monad-Free-Church.html#t:F">F</a> f a <a href="#v:mzero" class="selflink">#</a></p><p class="src"><a href="#v:mplus">mplus</a> :: <a href="Control-Monad-Free-Church.html#t:F">F</a> f a -> <a href="Control-Monad-Free-Church.html#t:F">F</a> f a -> <a href="Control-Monad-Free-Church.html#t:F">F</a> f a <a href="#v:mplus" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:F:MonadCont:13" class="instance expander" onclick="toggleSection('i:id:F:MonadCont:13')"></span> <a href="file:///usr/share/doc/libghc-mtl-doc/html/Control-Monad-Cont-Class.html#t:MonadCont">MonadCont</a> m => <a href="file:///usr/share/doc/libghc-mtl-doc/html/Control-Monad-Cont-Class.html#t:MonadCont">MonadCont</a> (<a href="Control-Monad-Free-Church.html#t:F">F</a> m)</span> <a href="src/Control-Monad-Free-Church.html#line-159" class="link">Source</a> <a href="#t:F" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:id:F:MonadCont:13" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:callCC">callCC</a> :: ((a -> <a href="Control-Monad-Free-Church.html#t:F">F</a> m b) -> <a href="Control-Monad-Free-Church.html#t:F">F</a> m a) -> <a href="Control-Monad-Free-Church.html#t:F">F</a> m a <a href="#v:callCC" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:F:Apply:14" class="instance expander" onclick="toggleSection('i:id:F:Apply:14')"></span> <a href="file:///usr/share/doc/libghc-semigroupoids-doc/html/Data-Functor-Apply.html#t:Apply">Apply</a> (<a href="Control-Monad-Free-Church.html#t:F">F</a> f)</span> <a href="src/Control-Monad-Free-Church.html#line-102" class="link">Source</a> <a href="#t:F" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:id:F:Apply:14" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:-60-.-62-">(<.>)</a> :: <a href="Control-Monad-Free-Church.html#t:F">F</a> f (a -> b) -> <a href="Control-Monad-Free-Church.html#t:F">F</a> f a -> <a href="Control-Monad-Free-Church.html#t:F">F</a> f b <a href="#v:-60-.-62-" class="selflink">#</a></p><p class="src"><a href="#v:.-62-">(.>)</a> :: <a href="Control-Monad-Free-Church.html#t:F">F</a> f a -> <a href="Control-Monad-Free-Church.html#t:F">F</a> f b -> <a href="Control-Monad-Free-Church.html#t:F">F</a> f b <a href="#v:.-62-" class="selflink">#</a></p><p class="src"><a href="#v:-60-.">(<.)</a> :: <a href="Control-Monad-Free-Church.html#t:F">F</a> f a -> <a href="Control-Monad-Free-Church.html#t:F">F</a> f b -> <a href="Control-Monad-Free-Church.html#t:F">F</a> f a <a href="#v:-60-." class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:id:F:Bind:15" class="instance expander" onclick="toggleSection('i:id:F:Bind:15')"></span> <a href="file:///usr/share/doc/libghc-semigroupoids-doc/html/Data-Functor-Bind.html#t:Bind">Bind</a> (<a href="Control-Monad-Free-Church.html#t:F">F</a> f)</span> <a href="src/Control-Monad-Free-Church.html#line-114" class="link">Source</a> <a href="#t:F" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:id:F:Bind:15" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:-62--62--45-">(>>-)</a> :: <a href="Control-Monad-Free-Church.html#t:F">F</a> f a -> (a -> <a href="Control-Monad-Free-Church.html#t:F">F</a> f b) -> <a href="Control-Monad-Free-Church.html#t:F">F</a> f b <a href="#v:-62--62--45-" class="selflink">#</a></p><p class="src"><a href="#v:join">join</a> :: <a href="Control-Monad-Free-Church.html#t:F">F</a> f (<a href="Control-Monad-Free-Church.html#t:F">F</a> f a) -> <a href="Control-Monad-Free-Church.html#t:F">F</a> f a <a href="#v:join" class="selflink">#</a></p></div></div></td></tr></table></div></div></div><div class="top"><p class="src"><a id="v:improve" class="def">improve</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Functor.html#t:Functor">Functor</a> f => (<span class="keyword">forall</span> m. <a href="Control-Monad-Free-Church.html#t:MonadFree">MonadFree</a> f m => m a) -> <a href="Control-Monad-Free.html#t:Free">Free</a> f a <a href="src/Control-Monad-Free-Church.html#improve" class="link">Source</a> <a href="#v:improve" class="selflink">#</a></p><div class="doc"><p>Improve the asymptotic performance of code that builds a free monad with only binds and returns by using <code><a href="Control-Monad-Free-Church.html#t:F">F</a></code> behind the scenes.</p><p>This is based on the "Free Monads for Less" series of articles by Edward Kmett:</p><ul><li><a href="http://comonad.com/reader/2011/free-monads-for-less/">Free monads for less — Part 1</a></li><li><a href="http://comonad.com/reader/2011/free-monads-for-less-2/">Free monads for less — Part 2</a></li></ul><p>and <a href="http://www.iai.uni-bonn.de/~jv/mpc08.pdf">"Asymptotic Improvement of Computations over Free Monads"</a> by Janis Voightländer.</p></div></div><div class="top"><p class="src"><a id="v:fromF" class="def">fromF</a> :: <a href="Control-Monad-Free-Church.html#t:MonadFree">MonadFree</a> f m => <a href="Control-Monad-Free-Church.html#t:F">F</a> f a -> m a <a href="src/Control-Monad-Free-Church.html#fromF" class="link">Source</a> <a href="#v:fromF" class="selflink">#</a></p><div class="doc"><p>Convert to another free monad representation.</p></div></div><div class="top"><p class="src"><a id="v:iter" class="def">iter</a> :: (f a -> a) -> <a href="Control-Monad-Free-Church.html#t:F">F</a> f a -> a <a href="src/Control-Monad-Free-Church.html#iter" class="link">Source</a> <a href="#v:iter" class="selflink">#</a></p><div class="doc"><p>Tear down a <code><a href="Control-Monad-Free.html#t:Free">Free</a></code> <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad.html#t:Monad">Monad</a></code> using iteration.</p></div></div><div class="top"><p class="src"><a id="v:iterM" class="def">iterM</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad.html#t:Monad">Monad</a> m => (f (m a) -> m a) -> <a href="Control-Monad-Free-Church.html#t:F">F</a> f a -> m a <a href="src/Control-Monad-Free-Church.html#iterM" class="link">Source</a> <a href="#v:iterM" class="selflink">#</a></p><div class="doc"><p>Like iter for monadic values.</p></div></div><div class="top"><p class="src"><a id="v:toF" class="def">toF</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Functor.html#t:Functor">Functor</a> f => <a href="Control-Monad-Free.html#t:Free">Free</a> f a -> <a href="Control-Monad-Free-Church.html#t:F">F</a> f a <a href="src/Control-Monad-Free-Church.html#toF" class="link">Source</a> <a href="#v:toF" class="selflink">#</a></p><div class="doc"><p>Generate a Church-encoded free monad from a <code><a href="Control-Monad-Free.html#t:Free">Free</a></code> monad.</p></div></div><div class="top"><p class="src"><a id="v:retract" class="def">retract</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad.html#t:Monad">Monad</a> m => <a href="Control-Monad-Free-Church.html#t:F">F</a> m a -> m a <a href="src/Control-Monad-Free-Church.html#retract" class="link">Source</a> <a href="#v:retract" class="selflink">#</a></p><div class="doc"><p><code><a href="Control-Monad-Free-Church.html#v:retract">retract</a></code> is the left inverse of <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/transformers-0.5.2.0/Control-Monad-Trans-Class.html#v:lift">lift</a></code> and <code><a href="Control-Monad-Free-Church.html#v:liftF">liftF</a></code></p><pre><code><a href="Control-Monad-Free-Church.html#v:retract">retract</a></code> . <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/transformers-0.5.2.0/Control-Monad-Trans-Class.html#v:lift">lift</a></code> = <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Function.html#v:id">id</a></code>
<code><a href="Control-Monad-Free-Church.html#v:retract">retract</a></code> . <code><a href="Control-Monad-Free-Church.html#v:liftF">liftF</a></code> = <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Function.html#v:id">id</a></code>
</pre></div></div><div class="top"><p class="src"><a id="v:hoistF" class="def">hoistF</a> :: (<span class="keyword">forall</span> x. f x -> g x) -> <a href="Control-Monad-Free-Church.html#t:F">F</a> f a -> <a href="Control-Monad-Free-Church.html#t:F">F</a> g a <a href="src/Control-Monad-Free-Church.html#hoistF" class="link">Source</a> <a href="#v:hoistF" class="selflink">#</a></p><div class="doc"><p>Lift a natural transformation from <code>f</code> to <code>g</code> into a natural transformation from <code>F f</code> to <code>F g</code>.</p></div></div><div class="top"><p class="src"><a id="v:foldF" class="def">foldF</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad.html#t:Monad">Monad</a> m => (<span class="keyword">forall</span> x. f x -> m x) -> <a href="Control-Monad-Free-Church.html#t:F">F</a> f a -> m a <a href="src/Control-Monad-Free-Church.html#foldF" class="link">Source</a> <a href="#v:foldF" class="selflink">#</a></p><div class="doc"><p>The very definition of a free monad is that given a natural transformation you get a monad homomorphism.</p></div></div><div class="top"><p class="src"><span class="keyword">class</span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad.html#t:Monad">Monad</a> m => <a id="t:MonadFree" class="def">MonadFree</a> f m | m -> f <span class="keyword">where</span> <a href="src/Control-Monad-Free-Class.html#MonadFree" class="link">Source</a> <a href="#t:MonadFree" class="selflink">#</a></p><div class="doc"><p>Monads provide substitution (<code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Functor.html#v:fmap">fmap</a></code>) and renormalization (<code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad.html#v:join">join</a></code>):</p><pre>m <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad.html#v:-62--62--61-">>>=</a></code> f = <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad.html#v:join">join</a></code> (<code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Functor.html#v:fmap">fmap</a></code> f m)</pre><p>A free <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad.html#t:Monad">Monad</a></code> is one that does no work during the normalization step beyond simply grafting the two monadic values together.</p><p><code>[]</code> is not a free <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad.html#t:Monad">Monad</a></code> (in this sense) because <code><code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad.html#v:join">join</a></code> [[a]]</code> smashes the lists flat.</p><p>On the other hand, consider:</p><pre>data Tree a = Bin (Tree a) (Tree a) | Tip a
</pre><pre>instance <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad.html#t:Monad">Monad</a></code> Tree where
<code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad.html#v:return">return</a></code> = Tip
Tip a <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad.html#v:-62--62--61-">>>=</a></code> f = f a
Bin l r <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad.html#v:-62--62--61-">>>=</a></code> f = Bin (l <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad.html#v:-62--62--61-">>>=</a></code> f) (r <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad.html#v:-62--62--61-">>>=</a></code> f)
</pre><p>This <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad.html#t:Monad">Monad</a></code> is the free <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad.html#t:Monad">Monad</a></code> of Pair:</p><pre>data Pair a = Pair a a
</pre><p>And we could make an instance of <code><a href="Control-Monad-Free-Church.html#t:MonadFree">MonadFree</a></code> for it directly:</p><pre>instance <code><a href="Control-Monad-Free-Church.html#t:MonadFree">MonadFree</a></code> Pair Tree where
<code><a href="Control-Monad-Free-Church.html#v:wrap">wrap</a></code> (Pair l r) = Bin l r
</pre><p>Or we could choose to program with <code><code><a href="Control-Monad-Free.html#v:Free">Free</a></code> Pair</code> instead of <code>Tree</code>
and thereby avoid having to define our own <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad.html#t:Monad">Monad</a></code> instance.</p><p>Moreover, <a href="Control-Monad-Free-Church.html">Control.Monad.Free.Church</a> provides a <code><a href="Control-Monad-Free-Church.html#t:MonadFree">MonadFree</a></code>
instance that can improve the <em>asymptotic</em> complexity of code that
constructs free monads by effectively reassociating the use of
(<code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad.html#v:-62--62--61-">>>=</a></code>). You may also want to take a look at the <code>kan-extensions</code>
package (<a href="http://hackage.haskell.org/package/kan-extensions">http://hackage.haskell.org/package/kan-extensions</a>).</p><p>See <code><a href="Control-Monad-Free.html#v:Free">Free</a></code> for a more formal definition of the free <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad.html#t:Monad">Monad</a></code>
for a <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Functor.html#t:Functor">Functor</a></code>.</p></div><div class="subs methods"><p class="caption">Methods</p><p class="src"><a id="v:wrap" class="def">wrap</a> :: f (m a) -> m a <a href="src/Control-Monad-Free-Class.html#wrap" class="link">Source</a> <a href="#v:wrap" class="selflink">#</a></p><div class="doc"><p>Add a layer.</p><pre>wrap (fmap f x) ≡ wrap (fmap return x) >>= f
</pre></div><p class="src"><a id="v:wrap" class="def">wrap</a> :: (m ~ t n, <a href="file:///usr/share/doc/ghc-doc/html/libraries/transformers-0.5.2.0/Control-Monad-Trans-Class.html#t:MonadTrans">MonadTrans</a> t, <a href="Control-Monad-Free-Church.html#t:MonadFree">MonadFree</a> f n, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Functor.html#t:Functor">Functor</a> f) => f (m a) -> m a <a href="src/Control-Monad-Free-Class.html#wrap" class="link">Source</a> <a href="#v:wrap" class="selflink">#</a></p><div class="doc"><p>Add a layer.</p><pre>wrap (fmap f x) ≡ wrap (fmap return x) >>= f
</pre></div></div><div class="subs instances"><p id="control.i:MonadFree" class="caption collapser" onclick="toggleSection('i:MonadFree')">Instances</p><div id="section.i:MonadFree" class="show"><table><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:MonadFree:MonadFree:1" class="instance expander" onclick="toggleSection('i:ic:MonadFree:MonadFree:1')"></span> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Functor.html#t:Functor">Functor</a> f, <a href="Control-Monad-Free-Church.html#t:MonadFree">MonadFree</a> f m) => <a href="Control-Monad-Free-Church.html#t:MonadFree">MonadFree</a> f (<a href="file:///usr/share/doc/libghc-mtl-doc/html/Control-Monad-List.html#t:ListT">ListT</a> m)</span> <a href="src/Control-Monad-Free-Class.html#line-142" class="link">Source</a> <a href="#t:MonadFree" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:ic:MonadFree:MonadFree:1" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:wrap">wrap</a> :: f (<a href="file:///usr/share/doc/libghc-mtl-doc/html/Control-Monad-List.html#t:ListT">ListT</a> m a) -> <a href="file:///usr/share/doc/libghc-mtl-doc/html/Control-Monad-List.html#t:ListT">ListT</a> m a <a href="src/Control-Monad-Free-Class.html#wrap" class="link">Source</a> <a href="#v:wrap" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:MonadFree:MonadFree:2" class="instance expander" onclick="toggleSection('i:ic:MonadFree:MonadFree:2')"></span> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Functor.html#t:Functor">Functor</a> f, <a href="Control-Monad-Free-Church.html#t:MonadFree">MonadFree</a> f m) => <a href="Control-Monad-Free-Church.html#t:MonadFree">MonadFree</a> f (<a href="file:///usr/share/doc/ghc-doc/html/libraries/transformers-0.5.2.0/Control-Monad-Trans-Maybe.html#t:MaybeT">MaybeT</a> m)</span> <a href="src/Control-Monad-Free-Class.html#line-136" class="link">Source</a> <a href="#t:MonadFree" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:ic:MonadFree:MonadFree:2" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:wrap">wrap</a> :: f (<a href="file:///usr/share/doc/ghc-doc/html/libraries/transformers-0.5.2.0/Control-Monad-Trans-Maybe.html#t:MaybeT">MaybeT</a> m a) -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/transformers-0.5.2.0/Control-Monad-Trans-Maybe.html#t:MaybeT">MaybeT</a> m a <a href="src/Control-Monad-Free-Class.html#wrap" class="link">Source</a> <a href="#v:wrap" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:MonadFree:MonadFree:3" class="instance expander" onclick="toggleSection('i:ic:MonadFree:MonadFree:3')"></span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Functor.html#t:Functor">Functor</a> f => <a href="Control-Monad-Free-Church.html#t:MonadFree">MonadFree</a> f (<a href="Control-Monad-Free.html#t:Free">Free</a> f)</span> <a href="src/Control-Monad-Free-Class.html#line-287" class="link">Source</a> <a href="#t:MonadFree" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:ic:MonadFree:MonadFree:3" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:wrap">wrap</a> :: f (<a href="Control-Monad-Free.html#t:Free">Free</a> f a) -> <a href="Control-Monad-Free.html#t:Free">Free</a> f a <a href="src/Control-Monad-Free-Class.html#wrap" class="link">Source</a> <a href="#v:wrap" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:MonadFree:MonadFree:4" class="instance expander" onclick="toggleSection('i:ic:MonadFree:MonadFree:4')"></span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Functor.html#t:Functor">Functor</a> f => <a href="Control-Monad-Free-Church.html#t:MonadFree">MonadFree</a> f (<a href="Control-Monad-Free-Church.html#t:F">F</a> f)</span> <a href="src/Control-Monad-Free-Class.html#line-143" class="link">Source</a> <a href="#t:MonadFree" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:ic:MonadFree:MonadFree:4" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:wrap">wrap</a> :: f (<a href="Control-Monad-Free-Church.html#t:F">F</a> f a) -> <a href="Control-Monad-Free-Church.html#t:F">F</a> f a <a href="src/Control-Monad-Free-Class.html#wrap" class="link">Source</a> <a href="#v:wrap" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:MonadFree:MonadFree:5" class="instance expander" onclick="toggleSection('i:ic:MonadFree:MonadFree:5')"></span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad.html#t:Monad">Monad</a> m => <a href="Control-Monad-Free-Church.html#t:MonadFree">MonadFree</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Functor-Identity.html#t:Identity">Identity</a> (<a href="Control-Monad-Trans-Iter.html#t:IterT">IterT</a> m)</span> <a href="src/Control-Monad-Free-Class.html#line-276" class="link">Source</a> <a href="#t:MonadFree" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:ic:MonadFree:MonadFree:5" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:wrap">wrap</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Functor-Identity.html#t:Identity">Identity</a> (<a href="Control-Monad-Trans-Iter.html#t:IterT">IterT</a> m a) -> <a href="Control-Monad-Trans-Iter.html#t:IterT">IterT</a> m a <a href="src/Control-Monad-Free-Class.html#wrap" class="link">Source</a> <a href="#v:wrap" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:MonadFree:MonadFree:6" class="instance expander" onclick="toggleSection('i:ic:MonadFree:MonadFree:6')"></span> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Functor.html#t:Functor">Functor</a> f, <a href="Control-Monad-Free-Church.html#t:MonadFree">MonadFree</a> f m) => <a href="Control-Monad-Free-Church.html#t:MonadFree">MonadFree</a> f (<a href="file:///usr/share/doc/libghc-mtl-doc/html/Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m)</span> <a href="src/Control-Monad-Free-Class.html#line-148" class="link">Source</a> <a href="#t:MonadFree" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:ic:MonadFree:MonadFree:6" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:wrap">wrap</a> :: f (<a href="file:///usr/share/doc/libghc-mtl-doc/html/Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a) -> <a href="file:///usr/share/doc/libghc-mtl-doc/html/Control-Monad-Except.html#t:ExceptT">ExceptT</a> e m a <a href="src/Control-Monad-Free-Class.html#wrap" class="link">Source</a> <a href="#v:wrap" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:MonadFree:MonadFree:7" class="instance expander" onclick="toggleSection('i:ic:MonadFree:MonadFree:7')"></span> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Functor.html#t:Functor">Functor</a> f, <a href="Control-Monad-Free-Church.html#t:MonadFree">MonadFree</a> f m, <a href="file:///usr/share/doc/libghc-mtl-doc/html/Control-Monad-Error-Class.html#t:Error">Error</a> e) => <a href="Control-Monad-Free-Church.html#t:MonadFree">MonadFree</a> f (<a href="file:///usr/share/doc/libghc-mtl-doc/html/Control-Monad-Error.html#t:ErrorT">ErrorT</a> e m)</span> <a href="src/Control-Monad-Free-Class.html#line-145" class="link">Source</a> <a href="#t:MonadFree" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:ic:MonadFree:MonadFree:7" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:wrap">wrap</a> :: f (<a href="file:///usr/share/doc/libghc-mtl-doc/html/Control-Monad-Error.html#t:ErrorT">ErrorT</a> e m a) -> <a href="file:///usr/share/doc/libghc-mtl-doc/html/Control-Monad-Error.html#t:ErrorT">ErrorT</a> e m a <a href="src/Control-Monad-Free-Class.html#wrap" class="link">Source</a> <a href="#v:wrap" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:MonadFree:MonadFree:8" class="instance expander" onclick="toggleSection('i:ic:MonadFree:MonadFree:8')"></span> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Functor.html#t:Functor">Functor</a> f, <a href="Control-Monad-Free-Church.html#t:MonadFree">MonadFree</a> f m) => <a href="Control-Monad-Free-Church.html#t:MonadFree">MonadFree</a> f (<a href="file:///usr/share/doc/libghc-comonad-doc/html/Control-Comonad-Trans-Identity.html#t:IdentityT">IdentityT</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> m)</span> <a href="src/Control-Monad-Free-Class.html#line-139" class="link">Source</a> <a href="#t:MonadFree" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:ic:MonadFree:MonadFree:8" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:wrap">wrap</a> :: f (<a href="file:///usr/share/doc/libghc-comonad-doc/html/Control-Comonad-Trans-Identity.html#t:IdentityT">IdentityT</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> m a) -> <a href="file:///usr/share/doc/libghc-comonad-doc/html/Control-Comonad-Trans-Identity.html#t:IdentityT">IdentityT</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> m a <a href="src/Control-Monad-Free-Class.html#wrap" class="link">Source</a> <a href="#v:wrap" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:MonadFree:MonadFree:9" class="instance expander" onclick="toggleSection('i:ic:MonadFree:MonadFree:9')"></span> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Functor.html#t:Functor">Functor</a> f, <a href="Control-Monad-Free-Church.html#t:MonadFree">MonadFree</a> f m, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Monoid.html#t:Monoid">Monoid</a> w) => <a href="Control-Monad-Free-Church.html#t:MonadFree">MonadFree</a> f (<a href="file:///usr/share/doc/libghc-mtl-doc/html/Control-Monad-Writer-Strict.html#t:WriterT">WriterT</a> w m)</span> <a href="src/Control-Monad-Free-Class.html#line-127" class="link">Source</a> <a href="#t:MonadFree" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:ic:MonadFree:MonadFree:9" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:wrap">wrap</a> :: f (<a href="file:///usr/share/doc/libghc-mtl-doc/html/Control-Monad-Writer-Strict.html#t:WriterT">WriterT</a> w m a) -> <a href="file:///usr/share/doc/libghc-mtl-doc/html/Control-Monad-Writer-Strict.html#t:WriterT">WriterT</a> w m a <a href="src/Control-Monad-Free-Class.html#wrap" class="link">Source</a> <a href="#v:wrap" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:MonadFree:MonadFree:10" class="instance expander" onclick="toggleSection('i:ic:MonadFree:MonadFree:10')"></span> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Functor.html#t:Functor">Functor</a> f, <a href="Control-Monad-Free-Church.html#t:MonadFree">MonadFree</a> f m, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Monoid.html#t:Monoid">Monoid</a> w) => <a href="Control-Monad-Free-Church.html#t:MonadFree">MonadFree</a> f (<a href="file:///usr/share/doc/libghc-mtl-doc/html/Control-Monad-Writer-Lazy.html#t:WriterT">WriterT</a> w m)</span> <a href="src/Control-Monad-Free-Class.html#line-124" class="link">Source</a> <a href="#t:MonadFree" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:ic:MonadFree:MonadFree:10" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:wrap">wrap</a> :: f (<a href="file:///usr/share/doc/libghc-mtl-doc/html/Control-Monad-Writer-Lazy.html#t:WriterT">WriterT</a> w m a) -> <a href="file:///usr/share/doc/libghc-mtl-doc/html/Control-Monad-Writer-Lazy.html#t:WriterT">WriterT</a> w m a <a href="src/Control-Monad-Free-Class.html#wrap" class="link">Source</a> <a href="#v:wrap" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:MonadFree:MonadFree:11" class="instance expander" onclick="toggleSection('i:ic:MonadFree:MonadFree:11')"></span> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Functor.html#t:Functor">Functor</a> f, <a href="Control-Monad-Free-Church.html#t:MonadFree">MonadFree</a> f m) => <a href="Control-Monad-Free-Church.html#t:MonadFree">MonadFree</a> f (<a href="file:///usr/share/doc/libghc-mtl-doc/html/Control-Monad-State-Strict.html#t:StateT">StateT</a> s m)</span> <a href="src/Control-Monad-Free-Class.html#line-118" class="link">Source</a> <a href="#t:MonadFree" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:ic:MonadFree:MonadFree:11" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:wrap">wrap</a> :: f (<a href="file:///usr/share/doc/libghc-mtl-doc/html/Control-Monad-State-Strict.html#t:StateT">StateT</a> s m a) -> <a href="file:///usr/share/doc/libghc-mtl-doc/html/Control-Monad-State-Strict.html#t:StateT">StateT</a> s m a <a href="src/Control-Monad-Free-Class.html#wrap" class="link">Source</a> <a href="#v:wrap" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:MonadFree:MonadFree:12" class="instance expander" onclick="toggleSection('i:ic:MonadFree:MonadFree:12')"></span> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Functor.html#t:Functor">Functor</a> f, <a href="Control-Monad-Free-Church.html#t:MonadFree">MonadFree</a> f m) => <a href="Control-Monad-Free-Church.html#t:MonadFree">MonadFree</a> f (<a href="file:///usr/share/doc/libghc-mtl-doc/html/Control-Monad-State-Lazy.html#t:StateT">StateT</a> s m)</span> <a href="src/Control-Monad-Free-Class.html#line-115" class="link">Source</a> <a href="#t:MonadFree" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:ic:MonadFree:MonadFree:12" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:wrap">wrap</a> :: f (<a href="file:///usr/share/doc/libghc-mtl-doc/html/Control-Monad-State-Lazy.html#t:StateT">StateT</a> s m a) -> <a href="file:///usr/share/doc/libghc-mtl-doc/html/Control-Monad-State-Lazy.html#t:StateT">StateT</a> s m a <a href="src/Control-Monad-Free-Class.html#wrap" class="link">Source</a> <a href="#v:wrap" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:MonadFree:MonadFree:13" class="instance expander" onclick="toggleSection('i:ic:MonadFree:MonadFree:13')"></span> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Functor.html#t:Functor">Functor</a> f, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Control-Monad.html#t:Monad">Monad</a> m) => <a href="Control-Monad-Free-Church.html#t:MonadFree">MonadFree</a> f (<a href="Control-Monad-Trans-Free.html#t:FreeT">FreeT</a> f m)</span> <a href="src/Control-Monad-Free-Class.html#line-294" class="link">Source</a> <a href="#t:MonadFree" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:ic:MonadFree:MonadFree:13" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:wrap">wrap</a> :: f (<a href="Control-Monad-Trans-Free.html#t:FreeT">FreeT</a> f m a) -> <a href="Control-Monad-Trans-Free.html#t:FreeT">FreeT</a> f m a <a href="src/Control-Monad-Free-Class.html#wrap" class="link">Source</a> <a href="#v:wrap" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:MonadFree:MonadFree:14" class="instance expander" onclick="toggleSection('i:ic:MonadFree:MonadFree:14')"></span> <a href="Control-Monad-Free-Church.html#t:MonadFree">MonadFree</a> f (<a href="Control-Monad-Trans-Free-Church.html#t:FT">FT</a> f m)</span> <a href="src/Control-Monad-Free-Class.html#line-106" class="link">Source</a> <a href="#t:MonadFree" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:ic:MonadFree:MonadFree:14" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:wrap">wrap</a> :: f (<a href="Control-Monad-Trans-Free-Church.html#t:FT">FT</a> f m a) -> <a href="Control-Monad-Trans-Free-Church.html#t:FT">FT</a> f m a <a href="src/Control-Monad-Free-Class.html#wrap" class="link">Source</a> <a href="#v:wrap" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:MonadFree:MonadFree:15" class="instance expander" onclick="toggleSection('i:ic:MonadFree:MonadFree:15')"></span> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Functor.html#t:Functor">Functor</a> f, <a href="Control-Monad-Free-Church.html#t:MonadFree">MonadFree</a> f m) => <a href="Control-Monad-Free-Church.html#t:MonadFree">MonadFree</a> f (<a href="file:///usr/share/doc/libghc-mtl-doc/html/Control-Monad-Cont.html#t:ContT">ContT</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> r m)</span> <a href="src/Control-Monad-Free-Class.html#line-121" class="link">Source</a> <a href="#t:MonadFree" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:ic:MonadFree:MonadFree:15" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:wrap">wrap</a> :: f (<a href="file:///usr/share/doc/libghc-mtl-doc/html/Control-Monad-Cont.html#t:ContT">ContT</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> r m a) -> <a href="file:///usr/share/doc/libghc-mtl-doc/html/Control-Monad-Cont.html#t:ContT">ContT</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> r m a <a href="src/Control-Monad-Free-Class.html#wrap" class="link">Source</a> <a href="#v:wrap" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:MonadFree:MonadFree:16" class="instance expander" onclick="toggleSection('i:ic:MonadFree:MonadFree:16')"></span> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Functor.html#t:Functor">Functor</a> f, <a href="Control-Monad-Free-Church.html#t:MonadFree">MonadFree</a> f m) => <a href="Control-Monad-Free-Church.html#t:MonadFree">MonadFree</a> f (<a href="file:///usr/share/doc/libghc-mtl-doc/html/Control-Monad-Reader.html#t:ReaderT">ReaderT</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> e m)</span> <a href="src/Control-Monad-Free-Class.html#line-112" class="link">Source</a> <a href="#t:MonadFree" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:ic:MonadFree:MonadFree:16" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:wrap">wrap</a> :: f (<a href="file:///usr/share/doc/libghc-mtl-doc/html/Control-Monad-Reader.html#t:ReaderT">ReaderT</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> e m a) -> <a href="file:///usr/share/doc/libghc-mtl-doc/html/Control-Monad-Reader.html#t:ReaderT">ReaderT</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Kind.html#t:-42-">*</a> e m a <a href="src/Control-Monad-Free-Class.html#wrap" class="link">Source</a> <a href="#v:wrap" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:MonadFree:MonadFree:17" class="instance expander" onclick="toggleSection('i:ic:MonadFree:MonadFree:17')"></span> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Functor.html#t:Functor">Functor</a> f, <a href="Control-Monad-Free-Church.html#t:MonadFree">MonadFree</a> f m, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Monoid.html#t:Monoid">Monoid</a> w) => <a href="Control-Monad-Free-Church.html#t:MonadFree">MonadFree</a> f (<a href="file:///usr/share/doc/libghc-mtl-doc/html/Control-Monad-RWS-Lazy.html#t:RWST">RWST</a> r w s m)</span> <a href="src/Control-Monad-Free-Class.html#line-133" class="link">Source</a> <a href="#t:MonadFree" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:ic:MonadFree:MonadFree:17" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:wrap">wrap</a> :: f (<a href="file:///usr/share/doc/libghc-mtl-doc/html/Control-Monad-RWS-Lazy.html#t:RWST">RWST</a> r w s m a) -> <a href="file:///usr/share/doc/libghc-mtl-doc/html/Control-Monad-RWS-Lazy.html#t:RWST">RWST</a> r w s m a <a href="src/Control-Monad-Free-Class.html#wrap" class="link">Source</a> <a href="#v:wrap" class="selflink">#</a></p></div></div></td></tr><tr><td class="src clearfix"><span class="inst-left"><span id="control.i:ic:MonadFree:MonadFree:18" class="instance expander" onclick="toggleSection('i:ic:MonadFree:MonadFree:18')"></span> (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Functor.html#t:Functor">Functor</a> f, <a href="Control-Monad-Free-Church.html#t:MonadFree">MonadFree</a> f m, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Monoid.html#t:Monoid">Monoid</a> w) => <a href="Control-Monad-Free-Church.html#t:MonadFree">MonadFree</a> f (<a href="file:///usr/share/doc/libghc-mtl-doc/html/Control-Monad-RWS-Strict.html#t:RWST">RWST</a> r w s m)</span> <a href="src/Control-Monad-Free-Class.html#line-130" class="link">Source</a> <a href="#t:MonadFree" class="selflink">#</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div id="section.i:ic:MonadFree:MonadFree:18" class="inst-details hide"><div class="subs methods"><p class="caption">Methods</p><p class="src"><a href="#v:wrap">wrap</a> :: f (<a href="file:///usr/share/doc/libghc-mtl-doc/html/Control-Monad-RWS-Strict.html#t:RWST">RWST</a> r w s m a) -> <a href="file:///usr/share/doc/libghc-mtl-doc/html/Control-Monad-RWS-Strict.html#t:RWST">RWST</a> r w s m a <a href="src/Control-Monad-Free-Class.html#wrap" class="link">Source</a> <a href="#v:wrap" class="selflink">#</a></p></div></div></td></tr></table></div></div></div><div class="top"><p class="src"><a id="v:liftF" class="def">liftF</a> :: (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Functor.html#t:Functor">Functor</a> f, <a href="Control-Monad-Free-Church.html#t:MonadFree">MonadFree</a> f m) => f a -> m a <a href="src/Control-Monad-Free-Class.html#liftF" class="link">Source</a> <a href="#v:liftF" class="selflink">#</a></p><div class="doc"><p>A version of lift that can be used with just a Functor for f.</p></div></div><div class="top"><p class="src"><a id="v:cutoff" class="def">cutoff</a> :: <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Functor.html#t:Functor">Functor</a> f => <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Prelude.html#t:Integer">Integer</a> -> <a href="Control-Monad-Free-Church.html#t:F">F</a> f a -> <a href="Control-Monad-Free-Church.html#t:F">F</a> f (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.0.0/Data-Maybe.html#t:Maybe">Maybe</a> a) <a href="src/Control-Monad-Free-Church.html#cutoff" class="link">Source</a> <a href="#v:cutoff" class="selflink">#</a></p><div class="doc"><p>Cuts off a tree of computations at a given depth.
If the depth is 0 or less, no computation nor
monadic effects will take place.</p><p>Some examples (<code>n ≥ 0</code>):</p><pre>cutoff 0 _ == return Nothing</pre><pre>cutoff (n+1) . return == return . Just</pre><pre>cutoff (n+1) . lift == lift . liftM Just</pre><pre>cutoff (n+1) . wrap == wrap . fmap (cutoff n)</pre><p>Calling <code><code><a href="Control-Monad-Free-Church.html#v:retract">retract</a></code> . <code><a href="Control-Monad-Free-Church.html#v:cutoff">cutoff</a></code> n</code> is always terminating, provided each of the
steps in the iteration is terminating.</p></div></div></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.17.2</p></div></body></html>
|