/usr/share/doc/libghc-free-doc/html/Control-Monad-Free-Class.html is in libghc-free-doc 4.12.1-2build1.
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 | <!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.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-Free-Class.html");};
//]]>
</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="src/Control-Monad-Free-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">free-4.12.1: Monads for free</p></div><div id="content"><div id="module-header"><table class="info"><tr><th>Copyright</th><td>(C) 2008-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>experimental</td></tr><tr><th>Portability</th><td>non-portable (fundeps, MPTCs)</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.Class</p></div><div id="description"><p class="caption">Description</p><div class="doc"><p>Monads for free.</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="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.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"><li><a href="#v:wrap">wrap</a> :: f (m a) -> m a</li></ul></li><li class="src short"><a href="#v:liftF">liftF</a> :: (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Functor.html#t:Functor">Functor</a> f, <a href="Control-Monad-Free-Class.html#t:MonadFree">MonadFree</a> f m) => f a -> m a</li><li class="src short"><a href="#v:wrapT">wrapT</a> :: (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Functor.html#t:Functor">Functor</a> f, <a href="Control-Monad-Free-Class.html#t:MonadFree">MonadFree</a> f m, <a href="file:///usr/share/doc/ghc-doc/html/libraries/transformers-0.4.2.0/Control-Monad-Trans-Class.html#t:MonadTrans">MonadTrans</a> t, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Control-Monad.html#t:Monad">Monad</a> (t m)) => f (t m a) -> t m a</li></ul></div><div id="interface"><h1>Documentation</h1><div class="top"><p class="src"><span class="keyword">class</span> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Control-Monad.html#t:Monad">Monad</a> m => <a name="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></p><div class="doc"><p>Monads provide substitution (<code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Functor.html#v:fmap">fmap</a></code>) and renormalization (<code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.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.8.2.0/Control-Monad.html#v:-62--62--61-">>>=</a></code> f = <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Control-Monad.html#v:join">join</a></code> (<code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.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.8.2.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.8.2.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.8.2.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.8.2.0/Control-Monad.html#t:Monad">Monad</a></code> Tree where
<code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.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.8.2.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.8.2.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.8.2.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.8.2.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.8.2.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.8.2.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-Class.html#t:MonadFree">MonadFree</a></code> for it directly:</p><pre>instance <code><a href="Control-Monad-Free-Class.html#t:MonadFree">MonadFree</a></code> Pair Tree where
<code><a href="Control-Monad-Free-Class.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.8.2.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-Class.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.8.2.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.8.2.0/Control-Monad.html#t:Monad">Monad</a></code>
for a <code><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Functor.html#t:Functor">Functor</a></code>.</p></div><div class="subs minimal"><p class="caption">Minimal complete definition</p><p class="src">Nothing</p></div><div class="subs methods"><p class="caption">Methods</p><p class="src"><a name="v:wrap" class="def">wrap</a> :: f (m a) -> m a <a href="src/Control-Monad-Free-Class.html#wrap" class="link">Source</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">(<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Functor.html#t:Functor">Functor</a> f, <a href="Control-Monad-Free-Class.html#t:MonadFree">MonadFree</a> f m) => <a href="Control-Monad-Free-Class.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-141" class="link">Source</a></td><td class="doc empty"> </td></tr><tr><td class="src clearfix"><span class="inst-left">(<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Functor.html#t:Functor">Functor</a> f, <a href="Control-Monad-Free-Class.html#t:MonadFree">MonadFree</a> f m) => <a href="Control-Monad-Free-Class.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> m)</span> <a href="src/Control-Monad-Free-Class.html#line-138" class="link">Source</a></td><td class="doc empty"> </td></tr><tr><td class="src clearfix"><span class="inst-left">(<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Functor.html#t:Functor">Functor</a> f, <a href="Control-Monad-Free-Class.html#t:MonadFree">MonadFree</a> f m) => <a href="Control-Monad-Free-Class.html#t:MonadFree">MonadFree</a> f (<a href="file:///usr/share/doc/ghc-doc/html/libraries/transformers-0.4.2.0/Control-Monad-Trans-Maybe.html#t:MaybeT">MaybeT</a> m)</span> <a href="src/Control-Monad-Free-Class.html#line-135" class="link">Source</a></td><td class="doc empty"> </td></tr><tr><td class="src clearfix"><span class="inst-left"><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Functor.html#t:Functor">Functor</a> f => <a href="Control-Monad-Free-Class.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-286" class="link">Source</a></td><td class="doc empty"> </td></tr><tr><td class="src clearfix"><span class="inst-left"><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Functor.html#t:Functor">Functor</a> f => <a href="Control-Monad-Free-Class.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-138" class="link">Source</a></td><td class="doc empty"> </td></tr><tr><td class="src clearfix"><span class="inst-left"><a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Control-Monad.html#t:Monad">Monad</a> m => <a href="Control-Monad-Free-Class.html#t:MonadFree">MonadFree</a> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.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></td><td class="doc empty"> </td></tr><tr><td class="src clearfix"><span class="inst-left">(<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Functor.html#t:Functor">Functor</a> f, <a href="Control-Monad-Free-Class.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-Class.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-144" class="link">Source</a></td><td class="doc empty"> </td></tr><tr><td class="src clearfix"><span class="inst-left">(<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Functor.html#t:Functor">Functor</a> f, <a href="Control-Monad-Free-Class.html#t:MonadFree">MonadFree</a> f m, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Monoid.html#t:Monoid">Monoid</a> w) => <a href="Control-Monad-Free-Class.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-126" class="link">Source</a></td><td class="doc empty"> </td></tr><tr><td class="src clearfix"><span class="inst-left">(<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Functor.html#t:Functor">Functor</a> f, <a href="Control-Monad-Free-Class.html#t:MonadFree">MonadFree</a> f m, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Monoid.html#t:Monoid">Monoid</a> w) => <a href="Control-Monad-Free-Class.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-123" class="link">Source</a></td><td class="doc empty"> </td></tr><tr><td class="src clearfix"><span class="inst-left">(<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Functor.html#t:Functor">Functor</a> f, <a href="Control-Monad-Free-Class.html#t:MonadFree">MonadFree</a> f m) => <a href="Control-Monad-Free-Class.html#t:MonadFree">MonadFree</a> f (<a href="file:///usr/share/doc/libghc-mtl-doc/html/Control-Monad-Cont.html#t:ContT">ContT</a> r m)</span> <a href="src/Control-Monad-Free-Class.html#line-120" class="link">Source</a></td><td class="doc empty"> </td></tr><tr><td class="src clearfix"><span class="inst-left">(<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Functor.html#t:Functor">Functor</a> f, <a href="Control-Monad-Free-Class.html#t:MonadFree">MonadFree</a> f m) => <a href="Control-Monad-Free-Class.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-117" class="link">Source</a></td><td class="doc empty"> </td></tr><tr><td class="src clearfix"><span class="inst-left">(<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Functor.html#t:Functor">Functor</a> f, <a href="Control-Monad-Free-Class.html#t:MonadFree">MonadFree</a> f m) => <a href="Control-Monad-Free-Class.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-114" class="link">Source</a></td><td class="doc empty"> </td></tr><tr><td class="src clearfix"><span class="inst-left">(<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Functor.html#t:Functor">Functor</a> f, <a href="Control-Monad-Free-Class.html#t:MonadFree">MonadFree</a> f m) => <a href="Control-Monad-Free-Class.html#t:MonadFree">MonadFree</a> f (<a href="file:///usr/share/doc/libghc-mtl-doc/html/Control-Monad-Reader.html#t:ReaderT">ReaderT</a> e m)</span> <a href="src/Control-Monad-Free-Class.html#line-111" class="link">Source</a></td><td class="doc empty"> </td></tr><tr><td class="src clearfix"><span class="inst-left">(<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Functor.html#t:Functor">Functor</a> f, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Control-Monad.html#t:Monad">Monad</a> m) => <a href="Control-Monad-Free-Class.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></td><td class="doc empty"> </td></tr><tr><td class="src clearfix"><span class="inst-left"><a href="Control-Monad-Free-Class.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></td><td class="doc empty"> </td></tr><tr><td class="src clearfix"><span class="inst-left">(<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Functor.html#t:Functor">Functor</a> f, <a href="Control-Monad-Free-Class.html#t:MonadFree">MonadFree</a> f m, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Monoid.html#t:Monoid">Monoid</a> w) => <a href="Control-Monad-Free-Class.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-132" class="link">Source</a></td><td class="doc empty"> </td></tr><tr><td class="src clearfix"><span class="inst-left">(<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Functor.html#t:Functor">Functor</a> f, <a href="Control-Monad-Free-Class.html#t:MonadFree">MonadFree</a> f m, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Monoid.html#t:Monoid">Monoid</a> w) => <a href="Control-Monad-Free-Class.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-129" class="link">Source</a></td><td class="doc empty"> </td></tr></table></div></div></div><div class="top"><p class="src"><a name="v:liftF" class="def">liftF</a> :: (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Functor.html#t:Functor">Functor</a> f, <a href="Control-Monad-Free-Class.html#t:MonadFree">MonadFree</a> f m) => f a -> m a <a href="src/Control-Monad-Free-Class.html#liftF" class="link">Source</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 name="v:wrapT" class="def">wrapT</a> :: (<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Data-Functor.html#t:Functor">Functor</a> f, <a href="Control-Monad-Free-Class.html#t:MonadFree">MonadFree</a> f m, <a href="file:///usr/share/doc/ghc-doc/html/libraries/transformers-0.4.2.0/Control-Monad-Trans-Class.html#t:MonadTrans">MonadTrans</a> t, <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.8.2.0/Control-Monad.html#t:Monad">Monad</a> (t m)) => f (t m a) -> t m a <a href="src/Control-Monad-Free-Class.html#wrapT" class="link">Source</a></p><div class="doc"><p>A version of wrap for monad transformers over a free monad.</p><p><em>Note:</em> that this is the default implementation for <code><a href="Control-Monad-Free-Class.html#v:wrap">wrap</a></code> for
<code>MonadFree f (t m)</code>.</p></div></div></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.16.1</p></div></body></html>
|