/usr/share/doc/libghc-mmorph-doc/html/mmorph.txt is in libghc-mmorph-doc 1.0.3-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 | -- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Monad morphisms
--
-- This library provides monad morphism utilities, most commonly used for
-- manipulating monad transformer stacks.
@package mmorph
@version 1.0.3
-- | A monad morphism is a natural transformation:
--
-- <pre>
-- morph :: forall a . m a -> n a
-- </pre>
--
-- ... that obeys the following two laws:
--
-- <pre>
-- morph $ do x <- m = do x <- morph m
-- f x morph (f x)
--
-- morph (return x) = return x
-- </pre>
--
-- ... which are equivalent to the following two functor laws:
--
-- <pre>
-- morph . (f >=> g) = morph . f >=> morph . g
--
-- morph . return = return
-- </pre>
--
-- Examples of monad morphisms include:
--
-- <ul>
-- <li><a>lift</a> (from <a>MonadTrans</a>)</li>
-- <li><a>squash</a> (See below)</li>
-- <li><tt><a>hoist</a> f</tt> (See below), if <tt>f</tt> is a monad
-- morphism</li>
-- <li><tt>(f . g)</tt>, if <tt>f</tt> and <tt>g</tt> are both monad
-- morphisms</li>
-- <li><a>id</a></li>
-- </ul>
--
-- Monad morphisms commonly arise when manipulating existing monad
-- transformer code for compatibility purposes. The <a>MFunctor</a>,
-- <a>MonadTrans</a>, and <a>MMonad</a> classes define standard ways to
-- change monad transformer stacks:
--
-- <ul>
-- <li><a>lift</a> introduces a new monad transformer layer of any
-- type.</li>
-- <li><a>squash</a> flattens two identical monad transformer layers into
-- a single layer of the same type.</li>
-- <li><a>hoist</a> maps monad morphisms to modify deeper layers of the
-- monad transformer stack.</li>
-- </ul>
module Control.Monad.Morph
-- | A functor in the category of monads, using <a>hoist</a> as the analog
-- of <a>fmap</a>:
--
-- <pre>
-- hoist (f . g) = hoist f . hoist g
--
-- hoist id = id
-- </pre>
class MFunctor t
hoist :: (MFunctor t, Monad m) => (forall a. m a -> n a) -> t m b -> t n b
-- | A function that <tt>generalize</tt>s the <a>Identity</a> base monad to
-- be any monad.
generalize :: Monad m => Identity a -> m a
-- | A monad in the category of monads, using <a>lift</a> from
-- <a>MonadTrans</a> as the analog of <a>return</a> and <a>embed</a> as
-- the analog of (<a>=<<</a>):
--
-- <pre>
-- embed lift = id
--
-- embed f (lift m) = f m
--
-- embed g (embed f t) = embed (\m -> embed g (f m)) t
-- </pre>
class (MFunctor t, MonadTrans t) => MMonad t
embed :: (MMonad t, Monad n) => (forall a. m a -> t n a) -> t m b -> t n b
-- | The class of monad transformers. Instances should satisfy the
-- following laws, which state that <a>lift</a> is a transformer of
-- monads:
--
-- <ul>
-- <li><pre><a>lift</a> . <a>return</a> = <a>return</a></pre></li>
-- <li><pre><a>lift</a> (m >>= f) = <a>lift</a> m >>=
-- (<a>lift</a> . f)</pre></li>
-- </ul>
class MonadTrans (t :: (* -> *) -> * -> *)
lift :: (MonadTrans t, Monad m) => m a -> t m a
-- | Squash two <a>MMonad</a> layers into a single layer
--
-- <a>squash</a> is analogous to <a>join</a>
squash :: (Monad m, MMonad t) => t (t m) a -> t m a
-- | Compose two <a>MMonad</a> layer-building functions
--
-- (<a>>|></a>) is analogous to (<a>>=></a>)
(>|>) :: (Monad m3, MMonad t) => (forall a. m1 a -> t m2 a) -> (forall b. m2 b -> t m3 b) -> m1 c -> t m3 c
-- | Equivalent to (<a>>|></a>) with the arguments flipped
--
-- (<a><|<</a>) is analogous to (<a><=<</a>)
(<|<) :: (Monad m3, MMonad t) => (forall b. m2 b -> t m3 b) -> (forall a. m1 a -> t m2 a) -> m1 c -> t m3 c
-- | An infix operator equivalent to <a>embed</a>
--
-- (<a>=<|</a>) is analogous to (<a>=<<</a>)
(=<|) :: (Monad n, MMonad t) => (forall a. m a -> t n a) -> t m b -> t n b
-- | Equivalent to (<a>=<|</a>) with the arguments flipped
--
-- (<a>|>=</a>) is analogous to (<a>>>=</a>)
(|>=) :: (Monad n, MMonad t) => t m b -> (forall a. m a -> t n a) -> t n b
instance Monoid w => MMonad (WriterT w)
instance Monoid w => MMonad (WriterT w)
instance MMonad (ReaderT r)
instance MMonad MaybeT
instance MMonad ListT
instance MMonad IdentityT
instance Error e => MMonad (ErrorT e)
instance MFunctor Lift
instance MFunctor Backwards
instance MFunctor (Product f)
instance Functor f => MFunctor (Compose f)
instance MFunctor (WriterT w)
instance MFunctor (WriterT w)
instance MFunctor (StateT s)
instance MFunctor (StateT s)
instance MFunctor (RWST r w s)
instance MFunctor (RWST r w s)
instance MFunctor (ReaderT r)
instance MFunctor MaybeT
instance MFunctor ListT
instance MFunctor IdentityT
instance MFunctor (ErrorT e)
-- | Composition of monad transformers. A higher-order version of
-- <a>Data.Functor.Compose</a>.
module Control.Monad.Trans.Compose
-- | Composition of monad transformers.
newtype ComposeT (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *) m a
ComposeT :: f (g m) a -> ComposeT m a
getComposeT :: ComposeT m a -> f (g m) a
instance Traversable (f (g m)) => Traversable (ComposeT f g m)
instance Foldable (f (g m)) => Foldable (ComposeT f g m)
instance MonadIO (f (g m)) => MonadIO (ComposeT f g m)
instance MonadPlus (f (g m)) => MonadPlus (ComposeT f g m)
instance Monad (f (g m)) => Monad (ComposeT f g m)
instance Alternative (f (g m)) => Alternative (ComposeT f g m)
instance Applicative (f (g m)) => Applicative (ComposeT f g m)
instance Functor (f (g m)) => Functor (ComposeT f g m)
instance (MFunctor f, MonadTrans f, MonadTrans g) => MonadTrans (ComposeT f g)
|