-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Concrete functor and monad transformers
°5u
°5uA portable library of functor and monad transformers, inspired by the
°5upaper "Functional Programming with Overloading and Higher-Order
°5uPolymorphism", by Mark P Jones, in <i>Advanced School of Functional
°5uProgramming</i>, 1995
°5u(<a>http://web.cecs.pdx.edu/~mpj/pubs/springschool.html</a>).
°5u
°5uThis package contains:
°5u
°5u<ul>
°5u<li>the monad transformer class (in
°5u<a>Control.Monad.Trans.Class</a>)</li>
°5u<li>concrete functor and monad transformers, each with associated
°5uoperations and functions to lift operations associated with other
°5utransformers.</li>
°5u</ul>
°5u
°5uThe package can be used on its own in portable Haskell code, in which
°5ucase operations need to be manually lifted through transformer stacks
°5u(see <a>Control.Monad.Trans.Class</a> for some examples).
°5uAlternatively, it can be used with the non-portable monad classes in
°5uthe <tt>mtl</tt> or <tt>monads-tf</tt> packages, which automatically
°5ulift operations introduced by monad transformers through other
°5utransformers.
@package transformers
@version 0.5.4.0


-- | Making functors with an <a>Applicative</a> instance that performs
°5uactions in the reverse order.
module Control.Applicative.Backwards

-- | The same functor, but with an <a>Applicative</a> instance that
°5uperforms actions in the reverse order.
newtype Backwards f a
Backwards :: f a -> Backwards f a
[forwards] :: Backwards f a -> f a
instance Data.Functor.Classes.Eq1 f => Data.Functor.Classes.Eq1 (Control.Applicative.Backwards.Backwards f)
instance Data.Functor.Classes.Ord1 f => Data.Functor.Classes.Ord1 (Control.Applicative.Backwards.Backwards f)
instance Data.Functor.Classes.Read1 f => Data.Functor.Classes.Read1 (Control.Applicative.Backwards.Backwards f)
instance Data.Functor.Classes.Show1 f => Data.Functor.Classes.Show1 (Control.Applicative.Backwards.Backwards f)
instance (Data.Functor.Classes.Eq1 f, GHC.Classes.Eq a) => GHC.Classes.Eq (Control.Applicative.Backwards.Backwards f a)
instance (Data.Functor.Classes.Ord1 f, GHC.Classes.Ord a) => GHC.Classes.Ord (Control.Applicative.Backwards.Backwards f a)
instance (Data.Functor.Classes.Read1 f, GHC.Read.Read a) => GHC.Read.Read (Control.Applicative.Backwards.Backwards f a)
instance (Data.Functor.Classes.Show1 f, GHC.Show.Show a) => GHC.Show.Show (Control.Applicative.Backwards.Backwards f a)
instance GHC.Base.Functor f => GHC.Base.Functor (Control.Applicative.Backwards.Backwards f)
instance GHC.Base.Applicative f => GHC.Base.Applicative (Control.Applicative.Backwards.Backwards f)
instance GHC.Base.Alternative f => GHC.Base.Alternative (Control.Applicative.Backwards.Backwards f)
instance Data.Foldable.Foldable f => Data.Foldable.Foldable (Control.Applicative.Backwards.Backwards f)
instance Data.Traversable.Traversable f => Data.Traversable.Traversable (Control.Applicative.Backwards.Backwards f)


-- | Signatures for monad operations that require specialized lifting. Each
°5usignature has a uniformity property that the lifting should satisfy.
module Control.Monad.Signatures

-- | Signature of the <tt>callCC</tt> operation, introduced in
°5u<a>Control.Monad.Trans.Cont</a>. Any lifting function
°5u<tt>liftCallCC</tt> should satisfy
°5u
°5u<ul>
°5u<li><pre><tt>lift</tt> (f k) = f' (<tt>lift</tt> . k) =&gt;
°5u<tt>lift</tt> (cf f) = liftCallCC cf f'</pre></li>
°5u</ul>
type CallCC m a b = ((a -> m b) -> m a) -> m a

-- | Signature of the <tt>catchE</tt> operation, introduced in
°5u<a>Control.Monad.Trans.Except</a>. Any lifting function
°5u<tt>liftCatch</tt> should satisfy
°5u
°5u<ul>
°5u<li><pre><tt>lift</tt> (cf m f) = liftCatch (<tt>lift</tt> . cf)
°5u(<tt>lift</tt> f)</pre></li>
°5u</ul>
type Catch e m a = m a -> (e -> m a) -> m a

-- | Signature of the <tt>listen</tt> operation, introduced in
°5u<a>Control.Monad.Trans.Writer</a>. Any lifting function
°5u<tt>liftListen</tt> should satisfy
°5u
°5u<ul>
°5u<li><pre><tt>lift</tt> . liftListen = liftListen .
°5u<tt>lift</tt></pre></li>
°5u</ul>
type Listen w m a = m a -> m (a, w)

-- | Signature of the <tt>pass</tt> operation, introduced in
°5u<a>Control.Monad.Trans.Writer</a>. Any lifting function
°5u<tt>liftPass</tt> should satisfy
°5u
°5u<ul>
°5u<li><pre><tt>lift</tt> . liftPass = liftPass .
°5u<tt>lift</tt></pre></li>
°5u</ul>
type Pass w m a = m (a, w -> w) -> m a


-- | The class of monad transformers.
°5u
°5uA monad transformer makes a new monad out of an existing monad, such
°5uthat computations of the old monad may be embedded in the new one. To
°5uconstruct a monad with a desired set of features, one typically starts
°5uwith a base monad, such as <a>Identity</a>, <tt>[]</tt> or <a>IO</a>,
°5uand applies a sequence of monad transformers.
module Control.Monad.Trans.Class

-- | The class of monad transformers. Instances should satisfy the
°5ufollowing laws, which state that <a>lift</a> is a monad
°5utransformation:
°5u
°5u<ul>
°5u<li><pre><a>lift</a> . <a>return</a> = <a>return</a></pre></li>
°5u<li><pre><a>lift</a> (m &gt;&gt;= f) = <a>lift</a> m &gt;&gt;=
°5u(<a>lift</a> . f)</pre></li>
°5u</ul>
class MonadTrans t

-- | Lift a computation from the argument monad to the constructed monad.
lift :: (MonadTrans t, (Monad m)) => m a -> t m a


-- | Continuation monads.
°5u
°5uDelimited continuation operators are taken from Kenichi Asai and Oleg
°5uKiselyov's tutorial at CW 2011, "Introduction to programming with
°5ushift and reset"
°5u(<a>http://okmij.org/ftp/continuations/#tutorial</a>).
module Control.Monad.Trans.Cont

-- | Continuation monad. <tt>Cont r a</tt> is a CPS ("continuation-passing
°5ustyle") computation that produces an intermediate result of type
°5u<tt>a</tt> within a CPS computation whose final result type is
°5u<tt>r</tt>.
°5u
°5uThe <tt>return</tt> function simply creates a continuation which
°5upasses the value on.
°5u
°5uThe <tt>&gt;&gt;=</tt> operator adds the bound function into the
°5ucontinuation chain.
type Cont r = ContT r Identity

-- | Construct a continuation-passing computation from a function. (The
°5uinverse of <a>runCont</a>)
cont :: ((a -> r) -> r) -> Cont r a

-- | The result of running a CPS computation with a given final
°5ucontinuation. (The inverse of <a>cont</a>)
runCont :: Cont r a -> (a -> r) -> r

-- | The result of running a CPS computation with the identity as the final
°5ucontinuation.
°5u
°5u<ul>
°5u<li><pre><a>evalCont</a> (<a>return</a> x) = x</pre></li>
°5u</ul>
evalCont :: Cont r r -> r

-- | Apply a function to transform the result of a continuation-passing
°5ucomputation.
°5u
°5u<ul>
°5u<li><pre><a>runCont</a> (<a>mapCont</a> f m) = f . <a>runCont</a>
°5um</pre></li>
°5u</ul>
mapCont :: (r -> r) -> Cont r a -> Cont r a

-- | Apply a function to transform the continuation passed to a CPS
°5ucomputation.
°5u
°5u<ul>
°5u<li><pre><a>runCont</a> (<a>withCont</a> f m) = <a>runCont</a> m .
°5uf</pre></li>
°5u</ul>
withCont :: ((b -> r) -> (a -> r)) -> Cont r a -> Cont r b

-- | <tt><a>reset</a> m</tt> delimits the continuation of any <a>shift</a>
°5uinside <tt>m</tt>.
°5u
°5u<ul>
°5u<li><pre><a>reset</a> (<a>return</a> m) = <a>return</a> m</pre></li>
°5u</ul>
reset :: Cont r r -> Cont r' r

-- | <tt><a>shift</a> f</tt> captures the continuation up to the nearest
°5uenclosing <a>reset</a> and passes it to <tt>f</tt>:
°5u
°5u<ul>
°5u<li><pre><a>reset</a> (<a>shift</a> f &gt;&gt;= k) = <a>reset</a> (f
°5u(<a>evalCont</a> . k))</pre></li>
°5u</ul>
shift :: ((a -> r) -> Cont r r) -> Cont r a

-- | The continuation monad transformer. Can be used to add continuation
°5uhandling to any type constructor: the <a>Monad</a> instance and most
°5uof the operations do not require <tt>m</tt> to be a monad.
°5u
°5u<a>ContT</a> is not a functor on the category of monads, and many
°5uoperations cannot be lifted through it.
newtype ContT r m a
ContT :: (a -> m r) -> m r -> ContT r m a
[runContT] :: ContT r m a -> (a -> m r) -> m r

-- | The result of running a CPS computation with <a>return</a> as the
°5ufinal continuation.
°5u
°5u<ul>
°5u<li><pre><a>evalContT</a> (<a>lift</a> m) = m</pre></li>
°5u</ul>
evalContT :: (Monad m) => ContT r m r -> m r

-- | Apply a function to transform the result of a continuation-passing
°5ucomputation. This has a more restricted type than the <tt>map</tt>
°5uoperations for other monad transformers, because <a>ContT</a> does not
°5udefine a functor in the category of monads.
°5u
°5u<ul>
°5u<li><pre><a>runContT</a> (<a>mapContT</a> f m) = f . <a>runContT</a>
°5um</pre></li>
°5u</ul>
mapContT :: (m r -> m r) -> ContT r m a -> ContT r m a

-- | Apply a function to transform the continuation passed to a CPS
°5ucomputation.
°5u
°5u<ul>
°5u<li><pre><a>runContT</a> (<a>withContT</a> f m) = <a>runContT</a> m .
°5uf</pre></li>
°5u</ul>
withContT :: ((b -> m r) -> (a -> m r)) -> ContT r m a -> ContT r m b

-- | <tt>callCC</tt> (call-with-current-continuation) calls its argument
°5ufunction, passing it the current continuation. It provides an escape
°5ucontinuation mechanism for use with continuation monads. Escape
°5ucontinuations one allow to abort the current computation and return a
°5uvalue immediately. They achieve a similar effect to <a>throwE</a> and
°5u<a>catchE</a> within an <a>ExceptT</a> monad. The advantage of this
°5ufunction over calling <a>return</a> is that it makes the continuation
°5uexplicit, allowing more flexibility and better control.
°5u
°5uThe standard idiom used with <tt>callCC</tt> is to provide a
°5ulambda-expression to name the continuation. Then calling the named
°5ucontinuation anywhere within its scope will escape from the
°5ucomputation, even if it is many layers deep within nested
°5ucomputations.
callCC :: ((a -> ContT r m b) -> ContT r m a) -> ContT r m a

-- | <tt><a>resetT</a> m</tt> delimits the continuation of any
°5u<a>shiftT</a> inside <tt>m</tt>.
°5u
°5u<ul>
°5u<li><pre><a>resetT</a> (<a>lift</a> m) = <a>lift</a> m</pre></li>
°5u</ul>
resetT :: (Monad m) => ContT r m r -> ContT r' m r

-- | <tt><a>shiftT</a> f</tt> captures the continuation up to the nearest
°5uenclosing <a>resetT</a> and passes it to <tt>f</tt>:
°5u
°5u<ul>
°5u<li><pre><a>resetT</a> (<a>shiftT</a> f &gt;&gt;= k) = <a>resetT</a>
°5u(f (<a>evalContT</a> . k))</pre></li>
°5u</ul>
shiftT :: (Monad m) => ((a -> m r) -> ContT r m r) -> ContT r m a

-- | <tt><a>liftLocal</a> ask local</tt> yields a <tt>local</tt> function
°5ufor <tt><a>ContT</a> r m</tt>.
liftLocal :: (Monad m) => m r' -> ((r' -> r') -> m r -> m r) -> (r' -> r') -> ContT r m a -> ContT r m a
instance forall k (r :: k) (m :: k -> *). GHC.Base.Functor (Control.Monad.Trans.Cont.ContT r m)
instance forall k (r :: k) (m :: k -> *). GHC.Base.Applicative (Control.Monad.Trans.Cont.ContT r m)
instance forall k (r :: k) (m :: k -> *). GHC.Base.Monad (Control.Monad.Trans.Cont.ContT r m)
instance Control.Monad.Fail.MonadFail m => Control.Monad.Fail.MonadFail (Control.Monad.Trans.Cont.ContT r m)
instance Control.Monad.Trans.Class.MonadTrans (Control.Monad.Trans.Cont.ContT r)
instance Control.Monad.IO.Class.MonadIO m => Control.Monad.IO.Class.MonadIO (Control.Monad.Trans.Cont.ContT r m)


-- | This monad transformer adds the ability to fail or throw exceptions to
°5ua monad.
°5u
°5uA sequence of actions succeeds, producing a value, only if all the
°5uactions in the sequence are successful. If one fails with an error,
°5uthe rest of the sequence is skipped and the composite action fails
°5uwith that error.
°5u
°5uIf the value of the error is not required, the variant in
°5u<a>Control.Monad.Trans.Maybe</a> may be used instead.
°5u
°5u<i>Note:</i> This module will be removed in a future release. Instead,
°5uuse <a>Control.Monad.Trans.Except</a>, which does not restrict the
°5uexception type, and also includes a base exception monad.

-- | <i>Deprecated: Use Control.Monad.Trans.Except instead</i>
module Control.Monad.Trans.Error

-- | An exception to be thrown.
°5u
°5uMinimal complete definition: <a>noMsg</a> or <a>strMsg</a>.
class Error a

-- | Creates an exception without a message. The default implementation is
°5u<tt><a>strMsg</a> ""</tt>.
noMsg :: Error a => a

-- | Creates an exception with a message. The default implementation of
°5u<tt><a>strMsg</a> s</tt> is <a>noMsg</a>.
strMsg :: Error a => String -> a

-- | Workaround so that we can have a Haskell 98 instance <tt><a>Error</a>
°5u<a>String</a></tt>.
class ErrorList a
listMsg :: ErrorList a => String -> [a]

-- | The error monad transformer. It can be used to add error handling to
°5uother monads.
°5u
°5uThe <tt>ErrorT</tt> Monad structure is parameterized over two things:
°5u
°5u<ul>
°5u<li>e - The error type.</li>
°5u<li>m - The inner monad.</li>
°5u</ul>
°5u
°5uThe <a>return</a> function yields a successful computation, while
°5u<tt>&gt;&gt;=</tt> sequences two subcomputations, failing on the first
°5uerror.
newtype ErrorT e m a
ErrorT :: m (Either e a) -> ErrorT e m a
[runErrorT] :: ErrorT e m a -> m (Either e a)

-- | Map the unwrapped computation using the given function.
°5u
°5u<ul>
°5u<li><pre><a>runErrorT</a> (<a>mapErrorT</a> f m) = f (<a>runErrorT</a>
°5um)</pre></li>
°5u</ul>
mapErrorT :: (m (Either e a) -> n (Either e' b)) -> ErrorT e m a -> ErrorT e' n b

-- | Signal an error value <tt>e</tt>.
°5u
°5u<ul>
°5u<li><pre><a>runErrorT</a> (<a>throwError</a> e) = <a>return</a>
°5u(<a>Left</a> e)</pre></li>
°5u<li><pre><a>throwError</a> e &gt;&gt;= m = <a>throwError</a>
°5ue</pre></li>
°5u</ul>
throwError :: (Monad m) => e -> ErrorT e m a

-- | Handle an error.
°5u
°5u<ul>
°5u<li><pre><a>catchError</a> h (<a>lift</a> m) = <a>lift</a>
°5um</pre></li>
°5u<li><pre><a>catchError</a> h (<a>throwError</a> e) = h e</pre></li>
°5u</ul>
catchError :: (Monad m) => ErrorT e m a -> (e -> ErrorT e m a) -> ErrorT e m a

-- | Lift a <tt>callCC</tt> operation to the new monad.
liftCallCC :: CallCC m (Either e a) (Either e b) -> CallCC (ErrorT e m) a b

-- | Lift a <tt>listen</tt> operation to the new monad.
liftListen :: (Monad m) => Listen w m (Either e a) -> Listen w (ErrorT e m) a

-- | Lift a <tt>pass</tt> operation to the new monad.
liftPass :: (Monad m) => Pass w m (Either e a) -> Pass w (ErrorT e m) a
instance (GHC.Classes.Eq e, Data.Functor.Classes.Eq1 m) => Data.Functor.Classes.Eq1 (Control.Monad.Trans.Error.ErrorT e m)
instance (GHC.Classes.Ord e, Data.Functor.Classes.Ord1 m) => Data.Functor.Classes.Ord1 (Control.Monad.Trans.Error.ErrorT e m)
instance (GHC.Read.Read e, Data.Functor.Classes.Read1 m) => Data.Functor.Classes.Read1 (Control.Monad.Trans.Error.ErrorT e m)
instance (GHC.Show.Show e, Data.Functor.Classes.Show1 m) => Data.Functor.Classes.Show1 (Control.Monad.Trans.Error.ErrorT e m)
instance (GHC.Classes.Eq e, Data.Functor.Classes.Eq1 m, GHC.Classes.Eq a) => GHC.Classes.Eq (Control.Monad.Trans.Error.ErrorT e m a)
instance (GHC.Classes.Ord e, Data.Functor.Classes.Ord1 m, GHC.Classes.Ord a) => GHC.Classes.Ord (Control.Monad.Trans.Error.ErrorT e m a)
instance (GHC.Read.Read e, Data.Functor.Classes.Read1 m, GHC.Read.Read a) => GHC.Read.Read (Control.Monad.Trans.Error.ErrorT e m a)
instance (GHC.Show.Show e, Data.Functor.Classes.Show1 m, GHC.Show.Show a) => GHC.Show.Show (Control.Monad.Trans.Error.ErrorT e m a)
instance GHC.Base.Functor m => GHC.Base.Functor (Control.Monad.Trans.Error.ErrorT e m)
instance Data.Foldable.Foldable f => Data.Foldable.Foldable (Control.Monad.Trans.Error.ErrorT e f)
instance Data.Traversable.Traversable f => Data.Traversable.Traversable (Control.Monad.Trans.Error.ErrorT e f)
instance (GHC.Base.Functor m, GHC.Base.Monad m) => GHC.Base.Applicative (Control.Monad.Trans.Error.ErrorT e m)
instance (GHC.Base.Functor m, GHC.Base.Monad m, Control.Monad.Trans.Error.Error e) => GHC.Base.Alternative (Control.Monad.Trans.Error.ErrorT e m)
instance (GHC.Base.Monad m, Control.Monad.Trans.Error.Error e) => GHC.Base.Monad (Control.Monad.Trans.Error.ErrorT e m)
instance (GHC.Base.Monad m, Control.Monad.Trans.Error.Error e) => Control.Monad.Fail.MonadFail (Control.Monad.Trans.Error.ErrorT e m)
instance (GHC.Base.Monad m, Control.Monad.Trans.Error.Error e) => GHC.Base.MonadPlus (Control.Monad.Trans.Error.ErrorT e m)
instance (Control.Monad.Fix.MonadFix m, Control.Monad.Trans.Error.Error e) => Control.Monad.Fix.MonadFix (Control.Monad.Trans.Error.ErrorT e m)
instance Control.Monad.Trans.Class.MonadTrans (Control.Monad.Trans.Error.ErrorT e)
instance (Control.Monad.Trans.Error.Error e, Control.Monad.IO.Class.MonadIO m) => Control.Monad.IO.Class.MonadIO (Control.Monad.Trans.Error.ErrorT e m)
instance Control.Monad.Trans.Error.ErrorList a => Control.Monad.Trans.Error.Error [a]
instance Control.Monad.Trans.Error.ErrorList GHC.Types.Char
instance Control.Monad.Trans.Error.Error e => GHC.Base.Alternative (Data.Either.Either e)
instance Control.Monad.Trans.Error.Error e => GHC.Base.MonadPlus (Data.Either.Either e)
instance Control.Monad.Trans.Error.Error GHC.IO.Exception.IOException


-- | This monad transformer extends a monad with the ability throw
°5uexceptions.
°5u
°5uA sequence of actions terminates normally, producing a value, only if
°5unone of the actions in the sequence throws an exception. If one throws
°5uan exception, the rest of the sequence is skipped and the composite
°5uaction exits with that exception.
°5u
°5uIf the value of the exception is not required, the variant in
°5u<a>Control.Monad.Trans.Maybe</a> may be used instead.
module Control.Monad.Trans.Except

-- | The parameterizable exception monad.
°5u
°5uComputations are either exceptions or normal values.
°5u
°5uThe <a>return</a> function returns a normal value, while
°5u<tt>&gt;&gt;=</tt> exits on the first exception. For a variant that
°5ucontinues after an error and collects all the errors, see
°5u<a>Errors</a>.
type Except e = ExceptT e Identity

-- | Constructor for computations in the exception monad. (The inverse of
°5u<a>runExcept</a>).
except :: Either e a -> Except e a

-- | Extractor for computations in the exception monad. (The inverse of
°5u<a>except</a>).
runExcept :: Except e a -> Either e a

-- | Map the unwrapped computation using the given function.
°5u
°5u<ul>
°5u<li><pre><a>runExcept</a> (<a>mapExcept</a> f m) = f (<a>runExcept</a>
°5um)</pre></li>
°5u</ul>
mapExcept :: (Either e a -> Either e' b) -> Except e a -> Except e' b

-- | Transform any exceptions thrown by the computation using the given
°5ufunction (a specialization of <a>withExceptT</a>).
withExcept :: (e -> e') -> Except e a -> Except e' a

-- | A monad transformer that adds exceptions to other monads.
°5u
°5u<tt>ExceptT</tt> constructs a monad parameterized over two things:
°5u
°5u<ul>
°5u<li>e - The exception type.</li>
°5u<li>m - The inner monad.</li>
°5u</ul>
°5u
°5uThe <a>return</a> function yields a computation that produces the
°5ugiven value, while <tt>&gt;&gt;=</tt> sequences two subcomputations,
°5uexiting on the first exception.
newtype ExceptT e m a
ExceptT :: (m (Either e a)) -> ExceptT e m a

-- | The inverse of <a>ExceptT</a>.
runExceptT :: ExceptT e m a -> m (Either e a)

-- | Map the unwrapped computation using the given function.
°5u
°5u<ul>
°5u<li><pre><a>runExceptT</a> (<a>mapExceptT</a> f m) = f
°5u(<a>runExceptT</a> m)</pre></li>
°5u</ul>
mapExceptT :: (m (Either e a) -> n (Either e' b)) -> ExceptT e m a -> ExceptT e' n b

-- | Transform any exceptions thrown by the computation using the given
°5ufunction.
withExceptT :: (Functor m) => (e -> e') -> ExceptT e m a -> ExceptT e' m a

-- | Signal an exception value <tt>e</tt>.
°5u
°5u<ul>
°5u<li><pre><a>runExceptT</a> (<a>throwE</a> e) = <a>return</a>
°5u(<a>Left</a> e)</pre></li>
°5u<li><pre><a>throwE</a> e &gt;&gt;= m = <a>throwE</a> e</pre></li>
°5u</ul>
throwE :: (Monad m) => e -> ExceptT e m a

-- | Handle an exception.
°5u
°5u<ul>
°5u<li><pre><a>catchE</a> h (<a>lift</a> m) = <a>lift</a> m</pre></li>
°5u<li><pre><a>catchE</a> h (<a>throwE</a> e) = h e</pre></li>
°5u</ul>
catchE :: (Monad m) => ExceptT e m a -> (e -> ExceptT e' m a) -> ExceptT e' m a

-- | Lift a <tt>callCC</tt> operation to the new monad.
liftCallCC :: CallCC m (Either e a) (Either e b) -> CallCC (ExceptT e m) a b

-- | Lift a <tt>listen</tt> operation to the new monad.
liftListen :: (Monad m) => Listen w m (Either e a) -> Listen w (ExceptT e m) a

-- | Lift a <tt>pass</tt> operation to the new monad.
liftPass :: (Monad m) => Pass w m (Either e a) -> Pass w (ExceptT e m) a
instance (GHC.Classes.Eq e, Data.Functor.Classes.Eq1 m) => Data.Functor.Classes.Eq1 (Control.Monad.Trans.Except.ExceptT e m)
instance (GHC.Classes.Ord e, Data.Functor.Classes.Ord1 m) => Data.Functor.Classes.Ord1 (Control.Monad.Trans.Except.ExceptT e m)
instance (GHC.Read.Read e, Data.Functor.Classes.Read1 m) => Data.Functor.Classes.Read1 (Control.Monad.Trans.Except.ExceptT e m)
instance (GHC.Show.Show e, Data.Functor.Classes.Show1 m) => Data.Functor.Classes.Show1 (Control.Monad.Trans.Except.ExceptT e m)
instance (GHC.Classes.Eq e, Data.Functor.Classes.Eq1 m, GHC.Classes.Eq a) => GHC.Classes.Eq (Control.Monad.Trans.Except.ExceptT e m a)
instance (GHC.Classes.Ord e, Data.Functor.Classes.Ord1 m, GHC.Classes.Ord a) => GHC.Classes.Ord (Control.Monad.Trans.Except.ExceptT e m a)
instance (GHC.Read.Read e, Data.Functor.Classes.Read1 m, GHC.Read.Read a) => GHC.Read.Read (Control.Monad.Trans.Except.ExceptT e m a)
instance (GHC.Show.Show e, Data.Functor.Classes.Show1 m, GHC.Show.Show a) => GHC.Show.Show (Control.Monad.Trans.Except.ExceptT e m a)
instance GHC.Base.Functor m => GHC.Base.Functor (Control.Monad.Trans.Except.ExceptT e m)
instance Data.Foldable.Foldable f => Data.Foldable.Foldable (Control.Monad.Trans.Except.ExceptT e f)
instance Data.Traversable.Traversable f => Data.Traversable.Traversable (Control.Monad.Trans.Except.ExceptT e f)
instance (GHC.Base.Functor m, GHC.Base.Monad m) => GHC.Base.Applicative (Control.Monad.Trans.Except.ExceptT e m)
instance (GHC.Base.Functor m, GHC.Base.Monad m, GHC.Base.Monoid e) => GHC.Base.Alternative (Control.Monad.Trans.Except.ExceptT e m)
instance GHC.Base.Monad m => GHC.Base.Monad (Control.Monad.Trans.Except.ExceptT e m)
instance Control.Monad.Fail.MonadFail m => Control.Monad.Fail.MonadFail (Control.Monad.Trans.Except.ExceptT e m)
instance (GHC.Base.Monad m, GHC.Base.Monoid e) => GHC.Base.MonadPlus (Control.Monad.Trans.Except.ExceptT e m)
instance Control.Monad.Fix.MonadFix m => Control.Monad.Fix.MonadFix (Control.Monad.Trans.Except.ExceptT e m)
instance Control.Monad.Trans.Class.MonadTrans (Control.Monad.Trans.Except.ExceptT e)
instance Control.Monad.IO.Class.MonadIO m => Control.Monad.IO.Class.MonadIO (Control.Monad.Trans.Except.ExceptT e m)
instance Control.Monad.Zip.MonadZip m => Control.Monad.Zip.MonadZip (Control.Monad.Trans.Except.ExceptT e m)


-- | The identity monad transformer.
°5u
°5uThis is useful for functions parameterized by a monad transformer.
module Control.Monad.Trans.Identity

-- | The trivial monad transformer, which maps a monad to an equivalent
°5umonad.
newtype IdentityT f a
IdentityT :: f a -> IdentityT f a
[runIdentityT] :: IdentityT f a -> f a

-- | Lift a unary operation to the new monad.
mapIdentityT :: (m a -> n b) -> IdentityT m a -> IdentityT n b

-- | Lift a <tt>catchE</tt> operation to the new monad.
liftCatch :: Catch e m a -> Catch e (IdentityT m) a

-- | Lift a <tt>callCC</tt> operation to the new monad.
liftCallCC :: CallCC m a b -> CallCC (IdentityT m) a b
instance Data.Functor.Classes.Eq1 f => Data.Functor.Classes.Eq1 (Control.Monad.Trans.Identity.IdentityT f)
instance Data.Functor.Classes.Ord1 f => Data.Functor.Classes.Ord1 (Control.Monad.Trans.Identity.IdentityT f)
instance Data.Functor.Classes.Read1 f => Data.Functor.Classes.Read1 (Control.Monad.Trans.Identity.IdentityT f)
instance Data.Functor.Classes.Show1 f => Data.Functor.Classes.Show1 (Control.Monad.Trans.Identity.IdentityT f)
instance (Data.Functor.Classes.Eq1 f, GHC.Classes.Eq a) => GHC.Classes.Eq (Control.Monad.Trans.Identity.IdentityT f a)
instance (Data.Functor.Classes.Ord1 f, GHC.Classes.Ord a) => GHC.Classes.Ord (Control.Monad.Trans.Identity.IdentityT f a)
instance (Data.Functor.Classes.Read1 f, GHC.Read.Read a) => GHC.Read.Read (Control.Monad.Trans.Identity.IdentityT f a)
instance (Data.Functor.Classes.Show1 f, GHC.Show.Show a) => GHC.Show.Show (Control.Monad.Trans.Identity.IdentityT f a)
instance GHC.Base.Functor m => GHC.Base.Functor (Control.Monad.Trans.Identity.IdentityT m)
instance Data.Foldable.Foldable f => Data.Foldable.Foldable (Control.Monad.Trans.Identity.IdentityT f)
instance Data.Traversable.Traversable f => Data.Traversable.Traversable (Control.Monad.Trans.Identity.IdentityT f)
instance GHC.Base.Applicative m => GHC.Base.Applicative (Control.Monad.Trans.Identity.IdentityT m)
instance GHC.Base.Alternative m => GHC.Base.Alternative (Control.Monad.Trans.Identity.IdentityT m)
instance GHC.Base.Monad m => GHC.Base.Monad (Control.Monad.Trans.Identity.IdentityT m)
instance Control.Monad.Fail.MonadFail m => Control.Monad.Fail.MonadFail (Control.Monad.Trans.Identity.IdentityT m)
instance GHC.Base.MonadPlus m => GHC.Base.MonadPlus (Control.Monad.Trans.Identity.IdentityT m)
instance Control.Monad.Fix.MonadFix m => Control.Monad.Fix.MonadFix (Control.Monad.Trans.Identity.IdentityT m)
instance Control.Monad.IO.Class.MonadIO m => Control.Monad.IO.Class.MonadIO (Control.Monad.Trans.Identity.IdentityT m)
instance Control.Monad.Zip.MonadZip m => Control.Monad.Zip.MonadZip (Control.Monad.Trans.Identity.IdentityT m)
instance Control.Monad.Trans.Class.MonadTrans Control.Monad.Trans.Identity.IdentityT


-- | The ListT monad transformer, adding backtracking to a given monad,
°5uwhich must be commutative.

-- | <i>Deprecated: This transformer is invalid on most monads</i>
module Control.Monad.Trans.List

-- | Parameterizable list monad, with an inner monad.
°5u
°5u<i>Note:</i> this does not yield a monad unless the argument monad is
°5ucommutative.
newtype ListT m a
ListT :: m [a] -> ListT m a
[runListT] :: ListT m a -> m [a]

-- | Map between <a>ListT</a> computations.
°5u
°5u<ul>
°5u<li><pre><a>runListT</a> (<a>mapListT</a> f m) = f (<a>runListT</a>
°5um)</pre></li>
°5u</ul>
mapListT :: (m [a] -> n [b]) -> ListT m a -> ListT n b

-- | Lift a <tt>callCC</tt> operation to the new monad.
liftCallCC :: CallCC m [a] [b] -> CallCC (ListT m) a b

-- | Lift a <tt>catchE</tt> operation to the new monad.
liftCatch :: Catch e m [a] -> Catch e (ListT m) a
instance Data.Functor.Classes.Eq1 m => Data.Functor.Classes.Eq1 (Control.Monad.Trans.List.ListT m)
instance Data.Functor.Classes.Ord1 m => Data.Functor.Classes.Ord1 (Control.Monad.Trans.List.ListT m)
instance Data.Functor.Classes.Read1 m => Data.Functor.Classes.Read1 (Control.Monad.Trans.List.ListT m)
instance Data.Functor.Classes.Show1 m => Data.Functor.Classes.Show1 (Control.Monad.Trans.List.ListT m)
instance (Data.Functor.Classes.Eq1 m, GHC.Classes.Eq a) => GHC.Classes.Eq (Control.Monad.Trans.List.ListT m a)
instance (Data.Functor.Classes.Ord1 m, GHC.Classes.Ord a) => GHC.Classes.Ord (Control.Monad.Trans.List.ListT m a)
instance (Data.Functor.Classes.Read1 m, GHC.Read.Read a) => GHC.Read.Read (Control.Monad.Trans.List.ListT m a)
instance (Data.Functor.Classes.Show1 m, GHC.Show.Show a) => GHC.Show.Show (Control.Monad.Trans.List.ListT m a)
instance GHC.Base.Functor m => GHC.Base.Functor (Control.Monad.Trans.List.ListT m)
instance Data.Foldable.Foldable f => Data.Foldable.Foldable (Control.Monad.Trans.List.ListT f)
instance Data.Traversable.Traversable f => Data.Traversable.Traversable (Control.Monad.Trans.List.ListT f)
instance GHC.Base.Applicative m => GHC.Base.Applicative (Control.Monad.Trans.List.ListT m)
instance GHC.Base.Applicative m => GHC.Base.Alternative (Control.Monad.Trans.List.ListT m)
instance GHC.Base.Monad m => GHC.Base.Monad (Control.Monad.Trans.List.ListT m)
instance GHC.Base.Monad m => Control.Monad.Fail.MonadFail (Control.Monad.Trans.List.ListT m)
instance GHC.Base.Monad m => GHC.Base.MonadPlus (Control.Monad.Trans.List.ListT m)
instance Control.Monad.Trans.Class.MonadTrans Control.Monad.Trans.List.ListT
instance Control.Monad.IO.Class.MonadIO m => Control.Monad.IO.Class.MonadIO (Control.Monad.Trans.List.ListT m)
instance Control.Monad.Zip.MonadZip m => Control.Monad.Zip.MonadZip (Control.Monad.Trans.List.ListT m)


-- | The <a>MaybeT</a> monad transformer extends a monad with the ability
°5uto exit the computation without returning a value.
°5u
°5uA sequence of actions produces a value only if all the actions in the
°5usequence do. If one exits, the rest of the sequence is skipped and the
°5ucomposite action exits.
°5u
°5uFor a variant allowing a range of exception values, see
°5u<a>Control.Monad.Trans.Except</a>.
module Control.Monad.Trans.Maybe

-- | The parameterizable maybe monad, obtained by composing an arbitrary
°5umonad with the <a>Maybe</a> monad.
°5u
°5uComputations are actions that may produce a value or exit.
°5u
°5uThe <a>return</a> function yields a computation that produces that
°5uvalue, while <tt>&gt;&gt;=</tt> sequences two subcomputations, exiting
°5uif either computation does.
newtype MaybeT m a
MaybeT :: m (Maybe a) -> MaybeT m a
[runMaybeT] :: MaybeT m a -> m (Maybe a)

-- | Transform the computation inside a <tt>MaybeT</tt>.
°5u
°5u<ul>
°5u<li><pre><a>runMaybeT</a> (<a>mapMaybeT</a> f m) = f (<a>runMaybeT</a>
°5um)</pre></li>
°5u</ul>
mapMaybeT :: (m (Maybe a) -> n (Maybe b)) -> MaybeT m a -> MaybeT n b

-- | Convert a <a>MaybeT</a> computation to <a>ExceptT</a>, with a default
°5uexception value.
maybeToExceptT :: (Functor m) => e -> MaybeT m a -> ExceptT e m a

-- | Convert a <a>ExceptT</a> computation to <a>MaybeT</a>, discarding the
°5uvalue of any exception.
exceptToMaybeT :: (Functor m) => ExceptT e m a -> MaybeT m a

-- | Lift a <tt>callCC</tt> operation to the new monad.
liftCallCC :: CallCC m (Maybe a) (Maybe b) -> CallCC (MaybeT m) a b

-- | Lift a <tt>catchE</tt> operation to the new monad.
liftCatch :: Catch e m (Maybe a) -> Catch e (MaybeT m) a

-- | Lift a <tt>listen</tt> operation to the new monad.
liftListen :: (Monad m) => Listen w m (Maybe a) -> Listen w (MaybeT m) a

-- | Lift a <tt>pass</tt> operation to the new monad.
liftPass :: (Monad m) => Pass w m (Maybe a) -> Pass w (MaybeT m) a
instance Data.Functor.Classes.Eq1 m => Data.Functor.Classes.Eq1 (Control.Monad.Trans.Maybe.MaybeT m)
instance Data.Functor.Classes.Ord1 m => Data.Functor.Classes.Ord1 (Control.Monad.Trans.Maybe.MaybeT m)
instance Data.Functor.Classes.Read1 m => Data.Functor.Classes.Read1 (Control.Monad.Trans.Maybe.MaybeT m)
instance Data.Functor.Classes.Show1 m => Data.Functor.Classes.Show1 (Control.Monad.Trans.Maybe.MaybeT m)
instance (Data.Functor.Classes.Eq1 m, GHC.Classes.Eq a) => GHC.Classes.Eq (Control.Monad.Trans.Maybe.MaybeT m a)
instance (Data.Functor.Classes.Ord1 m, GHC.Classes.Ord a) => GHC.Classes.Ord (Control.Monad.Trans.Maybe.MaybeT m a)
instance (Data.Functor.Classes.Read1 m, GHC.Read.Read a) => GHC.Read.Read (Control.Monad.Trans.Maybe.MaybeT m a)
instance (Data.Functor.Classes.Show1 m, GHC.Show.Show a) => GHC.Show.Show (Control.Monad.Trans.Maybe.MaybeT m a)
instance GHC.Base.Functor m => GHC.Base.Functor (Control.Monad.Trans.Maybe.MaybeT m)
instance Data.Foldable.Foldable f => Data.Foldable.Foldable (Control.Monad.Trans.Maybe.MaybeT f)
instance Data.Traversable.Traversable f => Data.Traversable.Traversable (Control.Monad.Trans.Maybe.MaybeT f)
instance (GHC.Base.Functor m, GHC.Base.Monad m) => GHC.Base.Applicative (Control.Monad.Trans.Maybe.MaybeT m)
instance (GHC.Base.Functor m, GHC.Base.Monad m) => GHC.Base.Alternative (Control.Monad.Trans.Maybe.MaybeT m)
instance GHC.Base.Monad m => GHC.Base.Monad (Control.Monad.Trans.Maybe.MaybeT m)
instance GHC.Base.Monad m => Control.Monad.Fail.MonadFail (Control.Monad.Trans.Maybe.MaybeT m)
instance GHC.Base.Monad m => GHC.Base.MonadPlus (Control.Monad.Trans.Maybe.MaybeT m)
instance Control.Monad.Fix.MonadFix m => Control.Monad.Fix.MonadFix (Control.Monad.Trans.Maybe.MaybeT m)
instance Control.Monad.Trans.Class.MonadTrans Control.Monad.Trans.Maybe.MaybeT
instance Control.Monad.IO.Class.MonadIO m => Control.Monad.IO.Class.MonadIO (Control.Monad.Trans.Maybe.MaybeT m)
instance Control.Monad.Zip.MonadZip m => Control.Monad.Zip.MonadZip (Control.Monad.Trans.Maybe.MaybeT m)


-- | A monad transformer that combines <tt>ReaderT</tt>, <tt>WriterT</tt>
°5uand <tt>StateT</tt>. This version is lazy; for a strict version with
°5uthe same interface, see <a>Control.Monad.Trans.RWS.Strict</a>.
module Control.Monad.Trans.RWS.Lazy

-- | A monad containing an environment of type <tt>r</tt>, output of type
°5u<tt>w</tt> and an updatable state of type <tt>s</tt>.
type RWS r w s = RWST r w s Identity

-- | Construct an RWS computation from a function. (The inverse of
°5u<a>runRWS</a>.)
rws :: (r -> s -> (a, s, w)) -> RWS r w s a

-- | Unwrap an RWS computation as a function. (The inverse of <a>rws</a>.)
runRWS :: RWS r w s a -> r -> s -> (a, s, w)

-- | Evaluate a computation with the given initial state and environment,
°5ureturning the final value and output, discarding the final state.
evalRWS :: RWS r w s a -> r -> s -> (a, w)

-- | Evaluate a computation with the given initial state and environment,
°5ureturning the final state and output, discarding the final value.
execRWS :: RWS r w s a -> r -> s -> (s, w)

-- | Map the return value, final state and output of a computation using
°5uthe given function.
°5u
°5u<ul>
°5u<li><pre><a>runRWS</a> (<a>mapRWS</a> f m) r s = f (<a>runRWS</a> m r
°5us)</pre></li>
°5u</ul>
mapRWS :: ((a, s, w) -> (b, s, w')) -> RWS r w s a -> RWS r w' s b

-- | <tt><a>withRWS</a> f m</tt> executes action <tt>m</tt> with an initial
°5uenvironment and state modified by applying <tt>f</tt>.
°5u
°5u<ul>
°5u<li><pre><a>runRWS</a> (<a>withRWS</a> f m) r s = <a>uncurry</a>
°5u(<a>runRWS</a> m) (f r s)</pre></li>
°5u</ul>
withRWS :: (r' -> s -> (r, s)) -> RWS r w s a -> RWS r' w s a

-- | A monad transformer adding reading an environment of type <tt>r</tt>,
°5ucollecting an output of type <tt>w</tt> and updating a state of type
°5u<tt>s</tt> to an inner monad <tt>m</tt>.
newtype RWST r w s m a
RWST :: r -> s -> m (a, s, w) -> RWST r w s m a
[runRWST] :: RWST r w s m a -> r -> s -> m (a, s, w)

-- | Evaluate a computation with the given initial state and environment,
°5ureturning the final value and output, discarding the final state.
evalRWST :: (Monad m) => RWST r w s m a -> r -> s -> m (a, w)

-- | Evaluate a computation with the given initial state and environment,
°5ureturning the final state and output, discarding the final value.
execRWST :: (Monad m) => RWST r w s m a -> r -> s -> m (s, w)

-- | Map the inner computation using the given function.
°5u
°5u<ul>
°5u<li><pre><a>runRWST</a> (<a>mapRWST</a> f m) r s = f (<a>runRWST</a> m
°5ur s)</pre></li>
°5u</ul>
mapRWST :: (m (a, s, w) -> n (b, s, w')) -> RWST r w s m a -> RWST r w' s n b

-- | <tt><a>withRWST</a> f m</tt> executes action <tt>m</tt> with an
°5uinitial environment and state modified by applying <tt>f</tt>.
°5u
°5u<ul>
°5u<li><pre><a>runRWST</a> (<a>withRWST</a> f m) r s = <a>uncurry</a>
°5u(<a>runRWST</a> m) (f r s)</pre></li>
°5u</ul>
withRWST :: (r' -> s -> (r, s)) -> RWST r w s m a -> RWST r' w s m a

-- | Constructor for computations in the reader monad (equivalent to
°5u<a>asks</a>).
reader :: (Monoid w, Monad m) => (r -> a) -> RWST r w s m a

-- | Fetch the value of the environment.
ask :: (Monoid w, Monad m) => RWST r w s m r

-- | Execute a computation in a modified environment
°5u
°5u<ul>
°5u<li><pre><a>runRWST</a> (<a>local</a> f m) r s = <a>runRWST</a> m (f
°5ur) s</pre></li>
°5u</ul>
local :: (r -> r) -> RWST r w s m a -> RWST r w s m a

-- | Retrieve a function of the current environment.
°5u
°5u<ul>
°5u<li><pre><a>asks</a> f = <a>liftM</a> f <a>ask</a></pre></li>
°5u</ul>
asks :: (Monoid w, Monad m) => (r -> a) -> RWST r w s m a

-- | Construct a writer computation from a (result, output) pair.
writer :: (Monad m) => (a, w) -> RWST r w s m a

-- | <tt><a>tell</a> w</tt> is an action that produces the output
°5u<tt>w</tt>.
tell :: (Monad m) => w -> RWST r w s m ()

-- | <tt><a>listen</a> m</tt> is an action that executes the action
°5u<tt>m</tt> and adds its output to the value of the computation.
°5u
°5u<ul>
°5u<li><pre><a>runRWST</a> (<a>listen</a> m) r s = <a>liftM</a> (\ (a, w)
°5u-&gt; ((a, w), w)) (<a>runRWST</a> m r s)</pre></li>
°5u</ul>
listen :: (Monad m) => RWST r w s m a -> RWST r w s m (a, w)

-- | <tt><a>listens</a> f m</tt> is an action that executes the action
°5u<tt>m</tt> and adds the result of applying <tt>f</tt> to the output to
°5uthe value of the computation.
°5u
°5u<ul>
°5u<li><pre><a>listens</a> f m = <a>liftM</a> (id *** f) (<a>listen</a>
°5um)</pre></li>
°5u<li><pre><a>runRWST</a> (<a>listens</a> f m) r s = <a>liftM</a> (\ (a,
°5uw) -&gt; ((a, f w), w)) (<a>runRWST</a> m r s)</pre></li>
°5u</ul>
listens :: (Monad m) => (w -> b) -> RWST r w s m a -> RWST r w s m (a, b)

-- | <tt><a>pass</a> m</tt> is an action that executes the action
°5u<tt>m</tt>, which returns a value and a function, and returns the
°5uvalue, applying the function to the output.
°5u
°5u<ul>
°5u<li><pre><a>runRWST</a> (<a>pass</a> m) r s = <a>liftM</a> (\ ((a, f),
°5uw) -&gt; (a, f w)) (<a>runRWST</a> m r s)</pre></li>
°5u</ul>
pass :: (Monad m) => RWST r w s m (a, w -> w) -> RWST r w s m a

-- | <tt><a>censor</a> f m</tt> is an action that executes the action
°5u<tt>m</tt> and applies the function <tt>f</tt> to its output, leaving
°5uthe return value unchanged.
°5u
°5u<ul>
°5u<li><pre><a>censor</a> f m = <a>pass</a> (<a>liftM</a> (\ x -&gt;
°5u(x,f)) m)</pre></li>
°5u<li><pre><a>runRWST</a> (<a>censor</a> f m) r s = <a>liftM</a> (\ (a,
°5uw) -&gt; (a, f w)) (<a>runRWST</a> m r s)</pre></li>
°5u</ul>
censor :: (Monad m) => (w -> w) -> RWST r w s m a -> RWST r w s m a

-- | Construct a state monad computation from a state transformer function.
state :: (Monoid w, Monad m) => (s -> (a, s)) -> RWST r w s m a

-- | Fetch the current value of the state within the monad.
get :: (Monoid w, Monad m) => RWST r w s m s

-- | <tt><a>put</a> s</tt> sets the state within the monad to <tt>s</tt>.
put :: (Monoid w, Monad m) => s -> RWST r w s m ()

-- | <tt><a>modify</a> f</tt> is an action that updates the state to the
°5uresult of applying <tt>f</tt> to the current state.
°5u
°5u<ul>
°5u<li><pre><a>modify</a> f = <a>get</a> &gt;&gt;= (<a>put</a> .
°5uf)</pre></li>
°5u</ul>
modify :: (Monoid w, Monad m) => (s -> s) -> RWST r w s m ()

-- | Get a specific component of the state, using a projection function
°5usupplied.
°5u
°5u<ul>
°5u<li><pre><a>gets</a> f = <a>liftM</a> f <a>get</a></pre></li>
°5u</ul>
gets :: (Monoid w, Monad m) => (s -> a) -> RWST r w s m a

-- | Uniform lifting of a <tt>callCC</tt> operation to the new monad. This
°5uversion rolls back to the original state on entering the continuation.
liftCallCC :: (Monoid w) => CallCC m (a, s, w) (b, s, w) -> CallCC (RWST r w s m) a b

-- | In-situ lifting of a <tt>callCC</tt> operation to the new monad. This
°5uversion uses the current state on entering the continuation.
liftCallCC' :: (Monoid w) => CallCC m (a, s, w) (b, s, w) -> CallCC (RWST r w s m) a b

-- | Lift a <tt>catchE</tt> operation to the new monad.
liftCatch :: Catch e m (a, s, w) -> Catch e (RWST r w s m) a
instance GHC.Base.Functor m => GHC.Base.Functor (Control.Monad.Trans.RWS.Lazy.RWST r w s m)
instance (GHC.Base.Monoid w, GHC.Base.Functor m, GHC.Base.Monad m) => GHC.Base.Applicative (Control.Monad.Trans.RWS.Lazy.RWST r w s m)
instance (GHC.Base.Monoid w, GHC.Base.Functor m, GHC.Base.MonadPlus m) => GHC.Base.Alternative (Control.Monad.Trans.RWS.Lazy.RWST r w s m)
instance (GHC.Base.Monoid w, GHC.Base.Monad m) => GHC.Base.Monad (Control.Monad.Trans.RWS.Lazy.RWST r w s m)
instance (GHC.Base.Monoid w, Control.Monad.Fail.MonadFail m) => Control.Monad.Fail.MonadFail (Control.Monad.Trans.RWS.Lazy.RWST r w s m)
instance (GHC.Base.Monoid w, GHC.Base.MonadPlus m) => GHC.Base.MonadPlus (Control.Monad.Trans.RWS.Lazy.RWST r w s m)
instance (GHC.Base.Monoid w, Control.Monad.Fix.MonadFix m) => Control.Monad.Fix.MonadFix (Control.Monad.Trans.RWS.Lazy.RWST r w s m)
instance GHC.Base.Monoid w => Control.Monad.Trans.Class.MonadTrans (Control.Monad.Trans.RWS.Lazy.RWST r w s)
instance (GHC.Base.Monoid w, Control.Monad.IO.Class.MonadIO m) => Control.Monad.IO.Class.MonadIO (Control.Monad.Trans.RWS.Lazy.RWST r w s m)


-- | A monad transformer that combines <tt>ReaderT</tt>, <tt>WriterT</tt>
°5uand <tt>StateT</tt>. This version is lazy; for a strict version, see
°5u<a>Control.Monad.Trans.RWS.Strict</a>, which has the same interface.
module Control.Monad.Trans.RWS


-- | A monad transformer that combines <tt>ReaderT</tt>, <tt>WriterT</tt>
°5uand <tt>StateT</tt>. This version is strict; for a lazy version with
°5uthe same interface, see <a>Control.Monad.Trans.RWS.Lazy</a>.
module Control.Monad.Trans.RWS.Strict

-- | A monad containing an environment of type <tt>r</tt>, output of type
°5u<tt>w</tt> and an updatable state of type <tt>s</tt>.
type RWS r w s = RWST r w s Identity

-- | Construct an RWS computation from a function. (The inverse of
°5u<a>runRWS</a>.)
rws :: (r -> s -> (a, s, w)) -> RWS r w s a

-- | Unwrap an RWS computation as a function. (The inverse of <a>rws</a>.)
runRWS :: RWS r w s a -> r -> s -> (a, s, w)

-- | Evaluate a computation with the given initial state and environment,
°5ureturning the final value and output, discarding the final state.
evalRWS :: RWS r w s a -> r -> s -> (a, w)

-- | Evaluate a computation with the given initial state and environment,
°5ureturning the final state and output, discarding the final value.
execRWS :: RWS r w s a -> r -> s -> (s, w)

-- | Map the return value, final state and output of a computation using
°5uthe given function.
°5u
°5u<ul>
°5u<li><pre><a>runRWS</a> (<a>mapRWS</a> f m) r s = f (<a>runRWS</a> m r
°5us)</pre></li>
°5u</ul>
mapRWS :: ((a, s, w) -> (b, s, w')) -> RWS r w s a -> RWS r w' s b

-- | <tt><a>withRWS</a> f m</tt> executes action <tt>m</tt> with an initial
°5uenvironment and state modified by applying <tt>f</tt>.
°5u
°5u<ul>
°5u<li><pre><a>runRWS</a> (<a>withRWS</a> f m) r s = <a>uncurry</a>
°5u(<a>runRWS</a> m) (f r s)</pre></li>
°5u</ul>
withRWS :: (r' -> s -> (r, s)) -> RWS r w s a -> RWS r' w s a

-- | A monad transformer adding reading an environment of type <tt>r</tt>,
°5ucollecting an output of type <tt>w</tt> and updating a state of type
°5u<tt>s</tt> to an inner monad <tt>m</tt>.
newtype RWST r w s m a
RWST :: r -> s -> m (a, s, w) -> RWST r w s m a
[runRWST] :: RWST r w s m a -> r -> s -> m (a, s, w)

-- | Evaluate a computation with the given initial state and environment,
°5ureturning the final value and output, discarding the final state.
evalRWST :: (Monad m) => RWST r w s m a -> r -> s -> m (a, w)

-- | Evaluate a computation with the given initial state and environment,
°5ureturning the final state and output, discarding the final value.
execRWST :: (Monad m) => RWST r w s m a -> r -> s -> m (s, w)

-- | Map the inner computation using the given function.
°5u
°5u<ul>
°5u<li><pre><a>runRWST</a> (<a>mapRWST</a> f m) r s = f (<a>runRWST</a> m
°5ur s)</pre></li>
°5u</ul>
mapRWST :: (m (a, s, w) -> n (b, s, w')) -> RWST r w s m a -> RWST r w' s n b

-- | <tt><a>withRWST</a> f m</tt> executes action <tt>m</tt> with an
°5uinitial environment and state modified by applying <tt>f</tt>.
°5u
°5u<ul>
°5u<li><pre><a>runRWST</a> (<a>withRWST</a> f m) r s = <a>uncurry</a>
°5u(<a>runRWST</a> m) (f r s)</pre></li>
°5u</ul>
withRWST :: (r' -> s -> (r, s)) -> RWST r w s m a -> RWST r' w s m a

-- | Constructor for computations in the reader monad (equivalent to
°5u<a>asks</a>).
reader :: (Monoid w, Monad m) => (r -> a) -> RWST r w s m a

-- | Fetch the value of the environment.
ask :: (Monoid w, Monad m) => RWST r w s m r

-- | Execute a computation in a modified environment
°5u
°5u<ul>
°5u<li><pre><a>runRWST</a> (<a>local</a> f m) r s = <a>runRWST</a> m (f
°5ur) s</pre></li>
°5u</ul>
local :: (r -> r) -> RWST r w s m a -> RWST r w s m a

-- | Retrieve a function of the current environment.
°5u
°5u<ul>
°5u<li><pre><a>asks</a> f = <a>liftM</a> f <a>ask</a></pre></li>
°5u</ul>
asks :: (Monoid w, Monad m) => (r -> a) -> RWST r w s m a

-- | Construct a writer computation from a (result, output) pair.
writer :: (Monad m) => (a, w) -> RWST r w s m a

-- | <tt><a>tell</a> w</tt> is an action that produces the output
°5u<tt>w</tt>.
tell :: (Monad m) => w -> RWST r w s m ()

-- | <tt><a>listen</a> m</tt> is an action that executes the action
°5u<tt>m</tt> and adds its output to the value of the computation.
°5u
°5u<ul>
°5u<li><pre><a>runRWST</a> (<a>listen</a> m) r s = <a>liftM</a> (\ (a, w)
°5u-&gt; ((a, w), w)) (<a>runRWST</a> m r s)</pre></li>
°5u</ul>
listen :: (Monad m) => RWST r w s m a -> RWST r w s m (a, w)

-- | <tt><a>listens</a> f m</tt> is an action that executes the action
°5u<tt>m</tt> and adds the result of applying <tt>f</tt> to the output to
°5uthe value of the computation.
°5u
°5u<ul>
°5u<li><pre><a>listens</a> f m = <a>liftM</a> (id *** f) (<a>listen</a>
°5um)</pre></li>
°5u<li><pre><a>runRWST</a> (<a>listens</a> f m) r s = <a>liftM</a> (\ (a,
°5uw) -&gt; ((a, f w), w)) (<a>runRWST</a> m r s)</pre></li>
°5u</ul>
listens :: (Monad m) => (w -> b) -> RWST r w s m a -> RWST r w s m (a, b)

-- | <tt><a>pass</a> m</tt> is an action that executes the action
°5u<tt>m</tt>, which returns a value and a function, and returns the
°5uvalue, applying the function to the output.
°5u
°5u<ul>
°5u<li><pre><a>runRWST</a> (<a>pass</a> m) r s = <a>liftM</a> (\ ((a, f),
°5uw) -&gt; (a, f w)) (<a>runRWST</a> m r s)</pre></li>
°5u</ul>
pass :: (Monad m) => RWST r w s m (a, w -> w) -> RWST r w s m a

-- | <tt><a>censor</a> f m</tt> is an action that executes the action
°5u<tt>m</tt> and applies the function <tt>f</tt> to its output, leaving
°5uthe return value unchanged.
°5u
°5u<ul>
°5u<li><pre><a>censor</a> f m = <a>pass</a> (<a>liftM</a> (\ x -&gt;
°5u(x,f)) m)</pre></li>
°5u<li><pre><a>runRWST</a> (<a>censor</a> f m) r s = <a>liftM</a> (\ (a,
°5uw) -&gt; (a, f w)) (<a>runRWST</a> m r s)</pre></li>
°5u</ul>
censor :: (Monad m) => (w -> w) -> RWST r w s m a -> RWST r w s m a

-- | Construct a state monad computation from a state transformer function.
state :: (Monoid w, Monad m) => (s -> (a, s)) -> RWST r w s m a

-- | Fetch the current value of the state within the monad.
get :: (Monoid w, Monad m) => RWST r w s m s

-- | <tt><a>put</a> s</tt> sets the state within the monad to <tt>s</tt>.
put :: (Monoid w, Monad m) => s -> RWST r w s m ()

-- | <tt><a>modify</a> f</tt> is an action that updates the state to the
°5uresult of applying <tt>f</tt> to the current state.
°5u
°5u<ul>
°5u<li><pre><a>modify</a> f = <a>get</a> &gt;&gt;= (<a>put</a> .
°5uf)</pre></li>
°5u</ul>
modify :: (Monoid w, Monad m) => (s -> s) -> RWST r w s m ()

-- | Get a specific component of the state, using a projection function
°5usupplied.
°5u
°5u<ul>
°5u<li><pre><a>gets</a> f = <a>liftM</a> f <a>get</a></pre></li>
°5u</ul>
gets :: (Monoid w, Monad m) => (s -> a) -> RWST r w s m a

-- | Uniform lifting of a <tt>callCC</tt> operation to the new monad. This
°5uversion rolls back to the original state on entering the continuation.
liftCallCC :: (Monoid w) => CallCC m (a, s, w) (b, s, w) -> CallCC (RWST r w s m) a b

-- | In-situ lifting of a <tt>callCC</tt> operation to the new monad. This
°5uversion uses the current state on entering the continuation.
liftCallCC' :: (Monoid w) => CallCC m (a, s, w) (b, s, w) -> CallCC (RWST r w s m) a b

-- | Lift a <tt>catchE</tt> operation to the new monad.
liftCatch :: Catch e m (a, s, w) -> Catch e (RWST r w s m) a
instance GHC.Base.Functor m => GHC.Base.Functor (Control.Monad.Trans.RWS.Strict.RWST r w s m)
instance (GHC.Base.Monoid w, GHC.Base.Functor m, GHC.Base.Monad m) => GHC.Base.Applicative (Control.Monad.Trans.RWS.Strict.RWST r w s m)
instance (GHC.Base.Monoid w, GHC.Base.Functor m, GHC.Base.MonadPlus m) => GHC.Base.Alternative (Control.Monad.Trans.RWS.Strict.RWST r w s m)
instance (GHC.Base.Monoid w, GHC.Base.Monad m) => GHC.Base.Monad (Control.Monad.Trans.RWS.Strict.RWST r w s m)
instance (GHC.Base.Monoid w, Control.Monad.Fail.MonadFail m) => Control.Monad.Fail.MonadFail (Control.Monad.Trans.RWS.Strict.RWST r w s m)
instance (GHC.Base.Monoid w, GHC.Base.MonadPlus m) => GHC.Base.MonadPlus (Control.Monad.Trans.RWS.Strict.RWST r w s m)
instance (GHC.Base.Monoid w, Control.Monad.Fix.MonadFix m) => Control.Monad.Fix.MonadFix (Control.Monad.Trans.RWS.Strict.RWST r w s m)
instance GHC.Base.Monoid w => Control.Monad.Trans.Class.MonadTrans (Control.Monad.Trans.RWS.Strict.RWST r w s)
instance (GHC.Base.Monoid w, Control.Monad.IO.Class.MonadIO m) => Control.Monad.IO.Class.MonadIO (Control.Monad.Trans.RWS.Strict.RWST r w s m)


-- | Declaration of the <a>ReaderT</a> monad transformer, which adds a
°5ustatic environment to a given monad.
°5u
°5uIf the computation is to modify the stored information, use
°5u<a>Control.Monad.Trans.State</a> instead.
module Control.Monad.Trans.Reader

-- | The parameterizable reader monad.
°5u
°5uComputations are functions of a shared environment.
°5u
°5uThe <a>return</a> function ignores the environment, while
°5u<tt>&gt;&gt;=</tt> passes the inherited environment to both
°5usubcomputations.
type Reader r = ReaderT r Identity

-- | Constructor for computations in the reader monad (equivalent to
°5u<a>asks</a>).
reader :: (Monad m) => (r -> a) -> ReaderT r m a

-- | Runs a <tt>Reader</tt> and extracts the final value from it. (The
°5uinverse of <a>reader</a>.)
runReader :: Reader r a -> r -> a

-- | Transform the value returned by a <tt>Reader</tt>.
°5u
°5u<ul>
°5u<li><pre><a>runReader</a> (<a>mapReader</a> f m) = f .
°5u<a>runReader</a> m</pre></li>
°5u</ul>
mapReader :: (a -> b) -> Reader r a -> Reader r b

-- | Execute a computation in a modified environment (a specialization of
°5u<a>withReaderT</a>).
°5u
°5u<ul>
°5u<li><pre><a>runReader</a> (<a>withReader</a> f m) = <a>runReader</a> m
°5u. f</pre></li>
°5u</ul>
withReader :: (r' -> r) -> Reader r a -> Reader r' a

-- | The reader monad transformer, which adds a read-only environment to
°5uthe given monad.
°5u
°5uThe <a>return</a> function ignores the environment, while
°5u<tt>&gt;&gt;=</tt> passes the inherited environment to both
°5usubcomputations.
newtype ReaderT r m a
ReaderT :: r -> m a -> ReaderT r m a
[runReaderT] :: ReaderT r m a -> r -> m a

-- | Transform the computation inside a <tt>ReaderT</tt>.
°5u
°5u<ul>
°5u<li><pre><a>runReaderT</a> (<a>mapReaderT</a> f m) = f .
°5u<a>runReaderT</a> m</pre></li>
°5u</ul>
mapReaderT :: (m a -> n b) -> ReaderT r m a -> ReaderT r n b

-- | Execute a computation in a modified environment (a more general
°5uversion of <a>local</a>).
°5u
°5u<ul>
°5u<li><pre><a>runReaderT</a> (<a>withReaderT</a> f m) =
°5u<a>runReaderT</a> m . f</pre></li>
°5u</ul>
withReaderT :: (r' -> r) -> ReaderT r m a -> ReaderT r' m a

-- | Fetch the value of the environment.
ask :: (Monad m) => ReaderT r m r

-- | Execute a computation in a modified environment (a specialization of
°5u<a>withReaderT</a>).
°5u
°5u<ul>
°5u<li><pre><a>runReaderT</a> (<a>local</a> f m) = <a>runReaderT</a> m .
°5uf</pre></li>
°5u</ul>
local :: (r -> r) -> ReaderT r m a -> ReaderT r m a

-- | Retrieve a function of the current environment.
°5u
°5u<ul>
°5u<li><pre><a>asks</a> f = <a>liftM</a> f <a>ask</a></pre></li>
°5u</ul>
asks :: (Monad m) => (r -> a) -> ReaderT r m a

-- | Lift a <tt>callCC</tt> operation to the new monad.
liftCallCC :: CallCC m a b -> CallCC (ReaderT r m) a b

-- | Lift a <tt>catchE</tt> operation to the new monad.
liftCatch :: Catch e m a -> Catch e (ReaderT r m) a
instance GHC.Base.Functor m => GHC.Base.Functor (Control.Monad.Trans.Reader.ReaderT r m)
instance GHC.Base.Applicative m => GHC.Base.Applicative (Control.Monad.Trans.Reader.ReaderT r m)
instance GHC.Base.Alternative m => GHC.Base.Alternative (Control.Monad.Trans.Reader.ReaderT r m)
instance GHC.Base.Monad m => GHC.Base.Monad (Control.Monad.Trans.Reader.ReaderT r m)
instance Control.Monad.Fail.MonadFail m => Control.Monad.Fail.MonadFail (Control.Monad.Trans.Reader.ReaderT r m)
instance GHC.Base.MonadPlus m => GHC.Base.MonadPlus (Control.Monad.Trans.Reader.ReaderT r m)
instance Control.Monad.Fix.MonadFix m => Control.Monad.Fix.MonadFix (Control.Monad.Trans.Reader.ReaderT r m)
instance Control.Monad.Trans.Class.MonadTrans (Control.Monad.Trans.Reader.ReaderT r)
instance Control.Monad.IO.Class.MonadIO m => Control.Monad.IO.Class.MonadIO (Control.Monad.Trans.Reader.ReaderT r m)
instance Control.Monad.Zip.MonadZip m => Control.Monad.Zip.MonadZip (Control.Monad.Trans.Reader.ReaderT r m)


-- | Selection monad transformer, modelling search algorithms.
°5u
°5u<ul>
°5u<li>Martin Escardo and Paulo Oliva. "Selection functions, bar
°5urecursion and backward induction", <i>Mathematical Structures in
°5uComputer Science</i> 20:2 (2010), pp. 127-168.
°5u<a>https://www.cs.bham.ac.uk/~mhe/papers/selection-escardo-oliva.pdf</a></li>
°5u<li>Jules Hedges. "Monad transformers for backtracking search". In
°5u<i>Proceedings of MSFP 2014</i>.
°5u<a>https://arxiv.org/abs/1406.2058</a></li>
°5u</ul>
module Control.Monad.Trans.Select

-- | Selection monad.
type Select r = SelectT r Identity

-- | Constructor for computations in the selection monad.
select :: ((a -> r) -> a) -> Select r a

-- | Runs a <tt>Select</tt> computation with a function for evaluating
°5uanswers to select a particular answer. (The inverse of <a>select</a>.)
runSelect :: Select r a -> (a -> r) -> a

-- | Apply a function to transform the result of a selection computation.
°5u
°5u<ul>
°5u<li><pre><a>runSelect</a> (<a>mapSelect</a> f m) = f .
°5u<a>runSelect</a> m</pre></li>
°5u</ul>
mapSelect :: (a -> a) -> Select r a -> Select r a

-- | Selection monad transformer.
°5u
°5u<a>SelectT</a> is not a functor on the category of monads, and many
°5uoperations cannot be lifted through it.
newtype SelectT r m a
SelectT :: ((a -> m r) -> m a) -> SelectT r m a

-- | Runs a <tt>SelectT</tt> computation with a function for evaluating
°5uanswers to select a particular answer. (The inverse of <a>select</a>.)
runSelectT :: SelectT r m a -> (a -> m r) -> m a

-- | Apply a function to transform the result of a selection computation.
°5uThis has a more restricted type than the <tt>map</tt> operations for
°5uother monad transformers, because <a>SelectT</a> does not define a
°5ufunctor in the category of monads.
°5u
°5u<ul>
°5u<li><pre><a>runSelectT</a> (<a>mapSelectT</a> f m) = f .
°5u<a>runSelectT</a> m</pre></li>
°5u</ul>
mapSelectT :: (m a -> m a) -> SelectT r m a -> SelectT r m a

-- | Convert a selection computation to a continuation-passing computation.
selectToContT :: (Monad m) => SelectT r m a -> ContT r m a

-- | Deprecated name for <a>selectToContT</a>.

-- | <i>Deprecated: Use selectToContT instead</i>
selectToCont :: (Monad m) => SelectT r m a -> ContT r m a
instance GHC.Base.Functor m => GHC.Base.Functor (Control.Monad.Trans.Select.SelectT r m)
instance (GHC.Base.Functor m, GHC.Base.Monad m) => GHC.Base.Applicative (Control.Monad.Trans.Select.SelectT r m)
instance (GHC.Base.Functor m, GHC.Base.MonadPlus m) => GHC.Base.Alternative (Control.Monad.Trans.Select.SelectT r m)
instance GHC.Base.Monad m => GHC.Base.Monad (Control.Monad.Trans.Select.SelectT r m)
instance Control.Monad.Fail.MonadFail m => Control.Monad.Fail.MonadFail (Control.Monad.Trans.Select.SelectT r m)
instance GHC.Base.MonadPlus m => GHC.Base.MonadPlus (Control.Monad.Trans.Select.SelectT r m)
instance Control.Monad.Trans.Class.MonadTrans (Control.Monad.Trans.Select.SelectT r)
instance Control.Monad.IO.Class.MonadIO m => Control.Monad.IO.Class.MonadIO (Control.Monad.Trans.Select.SelectT r m)


-- | Lazy state monads, passing an updatable state through a computation.
°5uSee below for examples.
°5u
°5uSome computations may not require the full power of state
°5utransformers:
°5u
°5u<ul>
°5u<li>For a read-only state, see <a>Control.Monad.Trans.Reader</a>.</li>
°5u<li>To accumulate a value without using it on the way, see
°5u<a>Control.Monad.Trans.Writer</a>.</li>
°5u</ul>
°5u
°5uIn this version, sequencing of computations is lazy, so that for
°5uexample the following produces a usable result:
°5u
°5u<pre>
°5uevalState (sequence $ repeat $ do { n &lt;- get; put (n*2); return n }) 1
°5u</pre>
°5u
°5uFor a strict version with the same interface, see
°5u<a>Control.Monad.Trans.State.Strict</a>.
module Control.Monad.Trans.State.Lazy

-- | A state monad parameterized by the type <tt>s</tt> of the state to
°5ucarry.
°5u
°5uThe <a>return</a> function leaves the state unchanged, while
°5u<tt>&gt;&gt;=</tt> uses the final state of the first computation as
°5uthe initial state of the second.
type State s = StateT s Identity

-- | Construct a state monad computation from a function. (The inverse of
°5u<a>runState</a>.)
state :: (Monad m) => (s -> (a, s)) -> StateT s m a

-- | Unwrap a state monad computation as a function. (The inverse of
°5u<a>state</a>.)
runState :: State s a -> s -> (a, s)

-- | Evaluate a state computation with the given initial state and return
°5uthe final value, discarding the final state.
°5u
°5u<ul>
°5u<li><pre><a>evalState</a> m s = <a>fst</a> (<a>runState</a> m
°5us)</pre></li>
°5u</ul>
evalState :: State s a -> s -> a

-- | Evaluate a state computation with the given initial state and return
°5uthe final state, discarding the final value.
°5u
°5u<ul>
°5u<li><pre><a>execState</a> m s = <a>snd</a> (<a>runState</a> m
°5us)</pre></li>
°5u</ul>
execState :: State s a -> s -> s

-- | Map both the return value and final state of a computation using the
°5ugiven function.
°5u
°5u<ul>
°5u<li><pre><a>runState</a> (<a>mapState</a> f m) = f . <a>runState</a>
°5um</pre></li>
°5u</ul>
mapState :: ((a, s) -> (b, s)) -> State s a -> State s b

-- | <tt><a>withState</a> f m</tt> executes action <tt>m</tt> on a state
°5umodified by applying <tt>f</tt>.
°5u
°5u<ul>
°5u<li><pre><a>withState</a> f m = <a>modify</a> f &gt;&gt; m</pre></li>
°5u</ul>
withState :: (s -> s) -> State s a -> State s a

-- | A state transformer monad parameterized by:
°5u
°5u<ul>
°5u<li><tt>s</tt> - The state.</li>
°5u<li><tt>m</tt> - The inner monad.</li>
°5u</ul>
°5u
°5uThe <a>return</a> function leaves the state unchanged, while
°5u<tt>&gt;&gt;=</tt> uses the final state of the first computation as
°5uthe initial state of the second.
newtype StateT s m a
StateT :: s -> m (a, s) -> StateT s m a
[runStateT] :: StateT s m a -> s -> m (a, s)

-- | Evaluate a state computation with the given initial state and return
°5uthe final value, discarding the final state.
°5u
°5u<ul>
°5u<li><pre><a>evalStateT</a> m s = <a>liftM</a> <a>fst</a>
°5u(<a>runStateT</a> m s)</pre></li>
°5u</ul>
evalStateT :: (Monad m) => StateT s m a -> s -> m a

-- | Evaluate a state computation with the given initial state and return
°5uthe final state, discarding the final value.
°5u
°5u<ul>
°5u<li><pre><a>execStateT</a> m s = <a>liftM</a> <a>snd</a>
°5u(<a>runStateT</a> m s)</pre></li>
°5u</ul>
execStateT :: (Monad m) => StateT s m a -> s -> m s

-- | Map both the return value and final state of a computation using the
°5ugiven function.
°5u
°5u<ul>
°5u<li><pre><a>runStateT</a> (<a>mapStateT</a> f m) = f .
°5u<a>runStateT</a> m</pre></li>
°5u</ul>
mapStateT :: (m (a, s) -> n (b, s)) -> StateT s m a -> StateT s n b

-- | <tt><a>withStateT</a> f m</tt> executes action <tt>m</tt> on a state
°5umodified by applying <tt>f</tt>.
°5u
°5u<ul>
°5u<li><pre><a>withStateT</a> f m = <a>modify</a> f &gt;&gt; m</pre></li>
°5u</ul>
withStateT :: (s -> s) -> StateT s m a -> StateT s m a

-- | Fetch the current value of the state within the monad.
get :: (Monad m) => StateT s m s

-- | <tt><a>put</a> s</tt> sets the state within the monad to <tt>s</tt>.
put :: (Monad m) => s -> StateT s m ()

-- | <tt><a>modify</a> f</tt> is an action that updates the state to the
°5uresult of applying <tt>f</tt> to the current state.
°5u
°5u<ul>
°5u<li><pre><a>modify</a> f = <a>get</a> &gt;&gt;= (<a>put</a> .
°5uf)</pre></li>
°5u</ul>
modify :: (Monad m) => (s -> s) -> StateT s m ()

-- | A variant of <a>modify</a> in which the computation is strict in the
°5unew state.
°5u
°5u<ul>
°5u<li><pre><a>modify'</a> f = <a>get</a> &gt;&gt;= ((<a>$!</a>)
°5u<a>put</a> . f)</pre></li>
°5u</ul>
modify' :: (Monad m) => (s -> s) -> StateT s m ()

-- | Get a specific component of the state, using a projection function
°5usupplied.
°5u
°5u<ul>
°5u<li><pre><a>gets</a> f = <a>liftM</a> f <a>get</a></pre></li>
°5u</ul>
gets :: (Monad m) => (s -> a) -> StateT s m a

-- | Uniform lifting of a <tt>callCC</tt> operation to the new monad. This
°5uversion rolls back to the original state on entering the continuation.
liftCallCC :: CallCC m (a, s) (b, s) -> CallCC (StateT s m) a b

-- | In-situ lifting of a <tt>callCC</tt> operation to the new monad. This
°5uversion uses the current state on entering the continuation. It does
°5unot satisfy the uniformity property (see
°5u<a>Control.Monad.Signatures</a>).
liftCallCC' :: CallCC m (a, s) (b, s) -> CallCC (StateT s m) a b

-- | Lift a <tt>catchE</tt> operation to the new monad.
liftCatch :: Catch e m (a, s) -> Catch e (StateT s m) a

-- | Lift a <tt>listen</tt> operation to the new monad.
liftListen :: (Monad m) => Listen w m (a, s) -> Listen w (StateT s m) a

-- | Lift a <tt>pass</tt> operation to the new monad.
liftPass :: (Monad m) => Pass w m (a, s) -> Pass w (StateT s m) a
instance GHC.Base.Functor m => GHC.Base.Functor (Control.Monad.Trans.State.Lazy.StateT s m)
instance (GHC.Base.Functor m, GHC.Base.Monad m) => GHC.Base.Applicative (Control.Monad.Trans.State.Lazy.StateT s m)
instance (GHC.Base.Functor m, GHC.Base.MonadPlus m) => GHC.Base.Alternative (Control.Monad.Trans.State.Lazy.StateT s m)
instance GHC.Base.Monad m => GHC.Base.Monad (Control.Monad.Trans.State.Lazy.StateT s m)
instance Control.Monad.Fail.MonadFail m => Control.Monad.Fail.MonadFail (Control.Monad.Trans.State.Lazy.StateT s m)
instance GHC.Base.MonadPlus m => GHC.Base.MonadPlus (Control.Monad.Trans.State.Lazy.StateT s m)
instance Control.Monad.Fix.MonadFix m => Control.Monad.Fix.MonadFix (Control.Monad.Trans.State.Lazy.StateT s m)
instance Control.Monad.Trans.Class.MonadTrans (Control.Monad.Trans.State.Lazy.StateT s)
instance Control.Monad.IO.Class.MonadIO m => Control.Monad.IO.Class.MonadIO (Control.Monad.Trans.State.Lazy.StateT s m)


-- | State monads, passing an updatable state through a computation.
°5u
°5uSome computations may not require the full power of state
°5utransformers:
°5u
°5u<ul>
°5u<li>For a read-only state, see <a>Control.Monad.Trans.Reader</a>.</li>
°5u<li>To accumulate a value without using it on the way, see
°5u<a>Control.Monad.Trans.Writer</a>.</li>
°5u</ul>
°5u
°5uThis version is lazy; for a strict version, see
°5u<a>Control.Monad.Trans.State.Strict</a>, which has the same interface.
module Control.Monad.Trans.State


-- | Strict state monads, passing an updatable state through a computation.
°5uSee below for examples.
°5u
°5uSome computations may not require the full power of state
°5utransformers:
°5u
°5u<ul>
°5u<li>For a read-only state, see <a>Control.Monad.Trans.Reader</a>.</li>
°5u<li>To accumulate a value without using it on the way, see
°5u<a>Control.Monad.Trans.Writer</a>.</li>
°5u</ul>
°5u
°5uIn this version, sequencing of computations is strict (but
°5ucomputations are not strict in the state unless you force it with
°5u<a>seq</a> or the like). For a lazy version with the same interface,
°5usee <a>Control.Monad.Trans.State.Lazy</a>.
module Control.Monad.Trans.State.Strict

-- | A state monad parameterized by the type <tt>s</tt> of the state to
°5ucarry.
°5u
°5uThe <a>return</a> function leaves the state unchanged, while
°5u<tt>&gt;&gt;=</tt> uses the final state of the first computation as
°5uthe initial state of the second.
type State s = StateT s Identity

-- | Construct a state monad computation from a function. (The inverse of
°5u<a>runState</a>.)
state :: (Monad m) => (s -> (a, s)) -> StateT s m a

-- | Unwrap a state monad computation as a function. (The inverse of
°5u<a>state</a>.)
runState :: State s a -> s -> (a, s)

-- | Evaluate a state computation with the given initial state and return
°5uthe final value, discarding the final state.
°5u
°5u<ul>
°5u<li><pre><a>evalState</a> m s = <a>fst</a> (<a>runState</a> m
°5us)</pre></li>
°5u</ul>
evalState :: State s a -> s -> a

-- | Evaluate a state computation with the given initial state and return
°5uthe final state, discarding the final value.
°5u
°5u<ul>
°5u<li><pre><a>execState</a> m s = <a>snd</a> (<a>runState</a> m
°5us)</pre></li>
°5u</ul>
execState :: State s a -> s -> s

-- | Map both the return value and final state of a computation using the
°5ugiven function.
°5u
°5u<ul>
°5u<li><pre><a>runState</a> (<a>mapState</a> f m) = f . <a>runState</a>
°5um</pre></li>
°5u</ul>
mapState :: ((a, s) -> (b, s)) -> State s a -> State s b

-- | <tt><a>withState</a> f m</tt> executes action <tt>m</tt> on a state
°5umodified by applying <tt>f</tt>.
°5u
°5u<ul>
°5u<li><pre><a>withState</a> f m = <a>modify</a> f &gt;&gt; m</pre></li>
°5u</ul>
withState :: (s -> s) -> State s a -> State s a

-- | A state transformer monad parameterized by:
°5u
°5u<ul>
°5u<li><tt>s</tt> - The state.</li>
°5u<li><tt>m</tt> - The inner monad.</li>
°5u</ul>
°5u
°5uThe <a>return</a> function leaves the state unchanged, while
°5u<tt>&gt;&gt;=</tt> uses the final state of the first computation as
°5uthe initial state of the second.
newtype StateT s m a
StateT :: s -> m (a, s) -> StateT s m a
[runStateT] :: StateT s m a -> s -> m (a, s)

-- | Evaluate a state computation with the given initial state and return
°5uthe final value, discarding the final state.
°5u
°5u<ul>
°5u<li><pre><a>evalStateT</a> m s = <a>liftM</a> <a>fst</a>
°5u(<a>runStateT</a> m s)</pre></li>
°5u</ul>
evalStateT :: (Monad m) => StateT s m a -> s -> m a

-- | Evaluate a state computation with the given initial state and return
°5uthe final state, discarding the final value.
°5u
°5u<ul>
°5u<li><pre><a>execStateT</a> m s = <a>liftM</a> <a>snd</a>
°5u(<a>runStateT</a> m s)</pre></li>
°5u</ul>
execStateT :: (Monad m) => StateT s m a -> s -> m s

-- | Map both the return value and final state of a computation using the
°5ugiven function.
°5u
°5u<ul>
°5u<li><pre><a>runStateT</a> (<a>mapStateT</a> f m) = f .
°5u<a>runStateT</a> m</pre></li>
°5u</ul>
mapStateT :: (m (a, s) -> n (b, s)) -> StateT s m a -> StateT s n b

-- | <tt><a>withStateT</a> f m</tt> executes action <tt>m</tt> on a state
°5umodified by applying <tt>f</tt>.
°5u
°5u<ul>
°5u<li><pre><a>withStateT</a> f m = <a>modify</a> f &gt;&gt; m</pre></li>
°5u</ul>
withStateT :: (s -> s) -> StateT s m a -> StateT s m a

-- | Fetch the current value of the state within the monad.
get :: (Monad m) => StateT s m s

-- | <tt><a>put</a> s</tt> sets the state within the monad to <tt>s</tt>.
put :: (Monad m) => s -> StateT s m ()

-- | <tt><a>modify</a> f</tt> is an action that updates the state to the
°5uresult of applying <tt>f</tt> to the current state.
°5u
°5u<ul>
°5u<li><pre><a>modify</a> f = <a>get</a> &gt;&gt;= (<a>put</a> .
°5uf)</pre></li>
°5u</ul>
modify :: (Monad m) => (s -> s) -> StateT s m ()

-- | A variant of <a>modify</a> in which the computation is strict in the
°5unew state.
°5u
°5u<ul>
°5u<li><pre><a>modify'</a> f = <a>get</a> &gt;&gt;= ((<a>$!</a>)
°5u<a>put</a> . f)</pre></li>
°5u</ul>
modify' :: (Monad m) => (s -> s) -> StateT s m ()

-- | Get a specific component of the state, using a projection function
°5usupplied.
°5u
°5u<ul>
°5u<li><pre><a>gets</a> f = <a>liftM</a> f <a>get</a></pre></li>
°5u</ul>
gets :: (Monad m) => (s -> a) -> StateT s m a

-- | Uniform lifting of a <tt>callCC</tt> operation to the new monad. This
°5uversion rolls back to the original state on entering the continuation.
liftCallCC :: CallCC m (a, s) (b, s) -> CallCC (StateT s m) a b

-- | In-situ lifting of a <tt>callCC</tt> operation to the new monad. This
°5uversion uses the current state on entering the continuation. It does
°5unot satisfy the uniformity property (see
°5u<a>Control.Monad.Signatures</a>).
liftCallCC' :: CallCC m (a, s) (b, s) -> CallCC (StateT s m) a b

-- | Lift a <tt>catchE</tt> operation to the new monad.
liftCatch :: Catch e m (a, s) -> Catch e (StateT s m) a

-- | Lift a <tt>listen</tt> operation to the new monad.
liftListen :: (Monad m) => Listen w m (a, s) -> Listen w (StateT s m) a

-- | Lift a <tt>pass</tt> operation to the new monad.
liftPass :: (Monad m) => Pass w m (a, s) -> Pass w (StateT s m) a
instance GHC.Base.Functor m => GHC.Base.Functor (Control.Monad.Trans.State.Strict.StateT s m)
instance (GHC.Base.Functor m, GHC.Base.Monad m) => GHC.Base.Applicative (Control.Monad.Trans.State.Strict.StateT s m)
instance (GHC.Base.Functor m, GHC.Base.MonadPlus m) => GHC.Base.Alternative (Control.Monad.Trans.State.Strict.StateT s m)
instance GHC.Base.Monad m => GHC.Base.Monad (Control.Monad.Trans.State.Strict.StateT s m)
instance Control.Monad.Fail.MonadFail m => Control.Monad.Fail.MonadFail (Control.Monad.Trans.State.Strict.StateT s m)
instance GHC.Base.MonadPlus m => GHC.Base.MonadPlus (Control.Monad.Trans.State.Strict.StateT s m)
instance Control.Monad.Fix.MonadFix m => Control.Monad.Fix.MonadFix (Control.Monad.Trans.State.Strict.StateT s m)
instance Control.Monad.Trans.Class.MonadTrans (Control.Monad.Trans.State.Strict.StateT s)
instance Control.Monad.IO.Class.MonadIO m => Control.Monad.IO.Class.MonadIO (Control.Monad.Trans.State.Strict.StateT s m)


-- | The lazy <a>WriterT</a> monad transformer, which adds collection of
°5uoutputs (such as a count or string output) to a given monad.
°5u
°5uThis monad transformer provides only limited access to the output
°5uduring the computation. For more general access, use
°5u<a>Control.Monad.Trans.State</a> instead.
°5u
°5uThis version builds its output lazily; for a strict version with the
°5usame interface, see <a>Control.Monad.Trans.Writer.Strict</a>.
module Control.Monad.Trans.Writer.Lazy

-- | A writer monad parameterized by the type <tt>w</tt> of output to
°5uaccumulate.
°5u
°5uThe <a>return</a> function produces the output <a>mempty</a>, while
°5u<tt>&gt;&gt;=</tt> combines the outputs of the subcomputations using
°5u<a>mappend</a>.
type Writer w = WriterT w Identity

-- | Construct a writer computation from a (result, output) pair. (The
°5uinverse of <a>runWriter</a>.)
writer :: (Monad m) => (a, w) -> WriterT w m a

-- | Unwrap a writer computation as a (result, output) pair. (The inverse
°5uof <a>writer</a>.)
runWriter :: Writer w a -> (a, w)

-- | Extract the output from a writer computation.
°5u
°5u<ul>
°5u<li><pre><a>execWriter</a> m = <a>snd</a> (<a>runWriter</a>
°5um)</pre></li>
°5u</ul>
execWriter :: Writer w a -> w

-- | Map both the return value and output of a computation using the given
°5ufunction.
°5u
°5u<ul>
°5u<li><pre><a>runWriter</a> (<a>mapWriter</a> f m) = f (<a>runWriter</a>
°5um)</pre></li>
°5u</ul>
mapWriter :: ((a, w) -> (b, w')) -> Writer w a -> Writer w' b

-- | A writer monad parameterized by:
°5u
°5u<ul>
°5u<li><tt>w</tt> - the output to accumulate.</li>
°5u<li><tt>m</tt> - The inner monad.</li>
°5u</ul>
°5u
°5uThe <a>return</a> function produces the output <a>mempty</a>, while
°5u<tt>&gt;&gt;=</tt> combines the outputs of the subcomputations using
°5u<a>mappend</a>.
newtype WriterT w m a
WriterT :: m (a, w) -> WriterT w m a
[runWriterT] :: WriterT w m a -> m (a, w)

-- | Extract the output from a writer computation.
°5u
°5u<ul>
°5u<li><pre><a>execWriterT</a> m = <a>liftM</a> <a>snd</a>
°5u(<a>runWriterT</a> m)</pre></li>
°5u</ul>
execWriterT :: (Monad m) => WriterT w m a -> m w

-- | Map both the return value and output of a computation using the given
°5ufunction.
°5u
°5u<ul>
°5u<li><pre><a>runWriterT</a> (<a>mapWriterT</a> f m) = f
°5u(<a>runWriterT</a> m)</pre></li>
°5u</ul>
mapWriterT :: (m (a, w) -> n (b, w')) -> WriterT w m a -> WriterT w' n b

-- | <tt><a>tell</a> w</tt> is an action that produces the output
°5u<tt>w</tt>.
tell :: (Monad m) => w -> WriterT w m ()

-- | <tt><a>listen</a> m</tt> is an action that executes the action
°5u<tt>m</tt> and adds its output to the value of the computation.
°5u
°5u<ul>
°5u<li><pre><a>runWriterT</a> (<a>listen</a> m) = <a>liftM</a> (\ (a, w)
°5u-&gt; ((a, w), w)) (<a>runWriterT</a> m)</pre></li>
°5u</ul>
listen :: (Monad m) => WriterT w m a -> WriterT w m (a, w)

-- | <tt><a>listens</a> f m</tt> is an action that executes the action
°5u<tt>m</tt> and adds the result of applying <tt>f</tt> to the output to
°5uthe value of the computation.
°5u
°5u<ul>
°5u<li><pre><a>listens</a> f m = <a>liftM</a> (id *** f) (<a>listen</a>
°5um)</pre></li>
°5u<li><pre><a>runWriterT</a> (<a>listens</a> f m) = <a>liftM</a> (\ (a,
°5uw) -&gt; ((a, f w), w)) (<a>runWriterT</a> m)</pre></li>
°5u</ul>
listens :: (Monad m) => (w -> b) -> WriterT w m a -> WriterT w m (a, b)

-- | <tt><a>pass</a> m</tt> is an action that executes the action
°5u<tt>m</tt>, which returns a value and a function, and returns the
°5uvalue, applying the function to the output.
°5u
°5u<ul>
°5u<li><pre><a>runWriterT</a> (<a>pass</a> m) = <a>liftM</a> (\ ((a, f),
°5uw) -&gt; (a, f w)) (<a>runWriterT</a> m)</pre></li>
°5u</ul>
pass :: (Monad m) => WriterT w m (a, w -> w) -> WriterT w m a

-- | <tt><a>censor</a> f m</tt> is an action that executes the action
°5u<tt>m</tt> and applies the function <tt>f</tt> to its output, leaving
°5uthe return value unchanged.
°5u
°5u<ul>
°5u<li><pre><a>censor</a> f m = <a>pass</a> (<a>liftM</a> (\ x -&gt;
°5u(x,f)) m)</pre></li>
°5u<li><pre><a>runWriterT</a> (<a>censor</a> f m) = <a>liftM</a> (\ (a,
°5uw) -&gt; (a, f w)) (<a>runWriterT</a> m)</pre></li>
°5u</ul>
censor :: (Monad m) => (w -> w) -> WriterT w m a -> WriterT w m a

-- | Lift a <tt>callCC</tt> operation to the new monad.
liftCallCC :: (Monoid w) => CallCC m (a, w) (b, w) -> CallCC (WriterT w m) a b

-- | Lift a <tt>catchE</tt> operation to the new monad.
liftCatch :: Catch e m (a, w) -> Catch e (WriterT w m) a
instance (GHC.Classes.Eq w, Data.Functor.Classes.Eq1 m) => Data.Functor.Classes.Eq1 (Control.Monad.Trans.Writer.Lazy.WriterT w m)
instance (GHC.Classes.Ord w, Data.Functor.Classes.Ord1 m) => Data.Functor.Classes.Ord1 (Control.Monad.Trans.Writer.Lazy.WriterT w m)
instance (GHC.Read.Read w, Data.Functor.Classes.Read1 m) => Data.Functor.Classes.Read1 (Control.Monad.Trans.Writer.Lazy.WriterT w m)
instance (GHC.Show.Show w, Data.Functor.Classes.Show1 m) => Data.Functor.Classes.Show1 (Control.Monad.Trans.Writer.Lazy.WriterT w m)
instance (GHC.Classes.Eq w, Data.Functor.Classes.Eq1 m, GHC.Classes.Eq a) => GHC.Classes.Eq (Control.Monad.Trans.Writer.Lazy.WriterT w m a)
instance (GHC.Classes.Ord w, Data.Functor.Classes.Ord1 m, GHC.Classes.Ord a) => GHC.Classes.Ord (Control.Monad.Trans.Writer.Lazy.WriterT w m a)
instance (GHC.Read.Read w, Data.Functor.Classes.Read1 m, GHC.Read.Read a) => GHC.Read.Read (Control.Monad.Trans.Writer.Lazy.WriterT w m a)
instance (GHC.Show.Show w, Data.Functor.Classes.Show1 m, GHC.Show.Show a) => GHC.Show.Show (Control.Monad.Trans.Writer.Lazy.WriterT w m a)
instance GHC.Base.Functor m => GHC.Base.Functor (Control.Monad.Trans.Writer.Lazy.WriterT w m)
instance Data.Foldable.Foldable f => Data.Foldable.Foldable (Control.Monad.Trans.Writer.Lazy.WriterT w f)
instance Data.Traversable.Traversable f => Data.Traversable.Traversable (Control.Monad.Trans.Writer.Lazy.WriterT w f)
instance (GHC.Base.Monoid w, GHC.Base.Applicative m) => GHC.Base.Applicative (Control.Monad.Trans.Writer.Lazy.WriterT w m)
instance (GHC.Base.Monoid w, GHC.Base.Alternative m) => GHC.Base.Alternative (Control.Monad.Trans.Writer.Lazy.WriterT w m)
instance (GHC.Base.Monoid w, GHC.Base.Monad m) => GHC.Base.Monad (Control.Monad.Trans.Writer.Lazy.WriterT w m)
instance (GHC.Base.Monoid w, Control.Monad.Fail.MonadFail m) => Control.Monad.Fail.MonadFail (Control.Monad.Trans.Writer.Lazy.WriterT w m)
instance (GHC.Base.Monoid w, GHC.Base.MonadPlus m) => GHC.Base.MonadPlus (Control.Monad.Trans.Writer.Lazy.WriterT w m)
instance (GHC.Base.Monoid w, Control.Monad.Fix.MonadFix m) => Control.Monad.Fix.MonadFix (Control.Monad.Trans.Writer.Lazy.WriterT w m)
instance GHC.Base.Monoid w => Control.Monad.Trans.Class.MonadTrans (Control.Monad.Trans.Writer.Lazy.WriterT w)
instance (GHC.Base.Monoid w, Control.Monad.IO.Class.MonadIO m) => Control.Monad.IO.Class.MonadIO (Control.Monad.Trans.Writer.Lazy.WriterT w m)
instance (GHC.Base.Monoid w, Control.Monad.Zip.MonadZip m) => Control.Monad.Zip.MonadZip (Control.Monad.Trans.Writer.Lazy.WriterT w m)


-- | The WriterT monad transformer. This version is lazy; for a strict
°5uversion, see <a>Control.Monad.Trans.Writer.Strict</a>, which has the
°5usame interface.
module Control.Monad.Trans.Writer


-- | The lazy <a>AccumT</a> monad transformer, which adds accumulation
°5ucapabilities (such as declarations or document patches) to a given
°5umonad.
°5u
°5uThis monad transformer provides append-only accumulation during the
°5ucomputation. For more general access, use
°5u<a>Control.Monad.Trans.State</a> instead.
module Control.Monad.Trans.Accum

-- | An accumulation monad parameterized by the type <tt>w</tt> of output
°5uto accumulate.
°5u
°5uThe <a>return</a> function produces the output <a>mempty</a>, while
°5u<tt>&gt;&gt;=</tt> combines the outputs of the subcomputations using
°5u<a>mappend</a>.
type Accum w = AccumT w Identity

-- | Construct an accumulation computation from a (result, output) pair.
°5u(The inverse of <a>runAccum</a>.)
accum :: (Monad m) => (w -> (a, w)) -> AccumT w m a

-- | Unwrap an accumulation computation as a (result, output) pair. (The
°5uinverse of <a>accum</a>.)
runAccum :: Accum w a -> w -> (a, w)

-- | Extract the output from an accumulation computation.
°5u
°5u<ul>
°5u<li><pre><a>execAccum</a> m w = <a>snd</a> (<a>runAccum</a> m
°5uw)</pre></li>
°5u</ul>
execAccum :: Accum w a -> w -> w

-- | Evaluate an accumulation computation with the given initial output
°5uhistory and return the final value, discarding the final output.
°5u
°5u<ul>
°5u<li><pre><a>evalAccum</a> m w = <a>fst</a> (<a>runAccum</a> m
°5uw)</pre></li>
°5u</ul>
evalAccum :: (Monoid w) => Accum w a -> w -> a

-- | Map both the return value and output of a computation using the given
°5ufunction.
°5u
°5u<ul>
°5u<li><pre><a>runAccum</a> (<a>mapAccum</a> f m) = f . <a>runAccum</a>
°5um</pre></li>
°5u</ul>
mapAccum :: ((a, w) -> (b, w)) -> Accum w a -> Accum w b

-- | An accumulation monad parameterized by:
°5u
°5u<ul>
°5u<li><tt>w</tt> - the output to accumulate.</li>
°5u<li><tt>m</tt> - The inner monad.</li>
°5u</ul>
°5u
°5uThe <a>return</a> function produces the output <a>mempty</a>, while
°5u<tt>&gt;&gt;=</tt> combines the outputs of the subcomputations using
°5u<a>mappend</a>.
°5u
°5uThis monad transformer is similar to both state and writer monad
°5utransformers. Thus it can be seen as
°5u
°5u<ul>
°5u<li>a restricted append-only version of a state monad transformer
°5uor</li>
°5u<li>a writer monad transformer with the extra ability to read all
°5uprevious output.</li>
°5u</ul>
newtype AccumT w m a
AccumT :: (w -> m (a, w)) -> AccumT w m a

-- | Unwrap an accumulation computation.
runAccumT :: AccumT w m a -> w -> m (a, w)

-- | Extract the output from an accumulation computation.
°5u
°5u<ul>
°5u<li><pre><a>execAccumT</a> m w = <a>liftM</a> <a>snd</a>
°5u(<a>runAccumT</a> m w)</pre></li>
°5u</ul>
execAccumT :: (Monad m) => AccumT w m a -> w -> m w

-- | Evaluate an accumulation computation with the given initial output
°5uhistory and return the final value, discarding the final output.
°5u
°5u<ul>
°5u<li><pre><a>evalAccumT</a> m w = <a>liftM</a> <a>fst</a>
°5u(<a>runAccumT</a> m w)</pre></li>
°5u</ul>
evalAccumT :: (Monad m, Monoid w) => AccumT w m a -> w -> m a

-- | Map both the return value and output of a computation using the given
°5ufunction.
°5u
°5u<ul>
°5u<li><pre><a>runAccumT</a> (<a>mapAccumT</a> f m) = f .
°5u<a>runAccumT</a> m</pre></li>
°5u</ul>
mapAccumT :: (m (a, w) -> n (b, w)) -> AccumT w m a -> AccumT w n b

-- | <tt><a>look</a></tt> is an action that fetches all the previously
°5uaccumulated output.
look :: (Monoid w, Monad m) => AccumT w m w

-- | <tt><a>look</a></tt> is an action that retrieves a function of the
°5upreviously accumulated output.
looks :: (Monoid w, Monad m) => (w -> a) -> AccumT w m a

-- | <tt><a>add</a> w</tt> is an action that produces the output
°5u<tt>w</tt>.
add :: (Monad m) => w -> AccumT w m ()

-- | Uniform lifting of a <tt>callCC</tt> operation to the new monad. This
°5uversion rolls back to the original output history on entering the
°5ucontinuation.
liftCallCC :: CallCC m (a, w) (b, w) -> CallCC (AccumT w m) a b

-- | In-situ lifting of a <tt>callCC</tt> operation to the new monad. This
°5uversion uses the current output history on entering the continuation.
°5uIt does not satisfy the uniformity property (see
°5u<a>Control.Monad.Signatures</a>).
liftCallCC' :: CallCC m (a, w) (b, w) -> CallCC (AccumT w m) a b

-- | Lift a <tt>catchE</tt> operation to the new monad.
liftCatch :: Catch e m (a, w) -> Catch e (AccumT w m) a

-- | Lift a <tt>listen</tt> operation to the new monad.
liftListen :: (Monad m) => Listen w m (a, s) -> Listen w (AccumT s m) a

-- | Lift a <tt>pass</tt> operation to the new monad.
liftPass :: (Monad m) => Pass w m (a, s) -> Pass w (AccumT s m) a

-- | Convert a read-only computation into an accumulation computation.
readerToAccumT :: (Functor m, Monoid w) => ReaderT w m a -> AccumT w m a

-- | Convert a writer computation into an accumulation computation.
writerToAccumT :: WriterT w m a -> AccumT w m a

-- | Convert an accumulation (append-only) computation into a fully
°5ustateful computation.
accumToStateT :: (Functor m, Monoid s) => AccumT s m a -> StateT s m a
instance GHC.Base.Functor m => GHC.Base.Functor (Control.Monad.Trans.Accum.AccumT w m)
instance (GHC.Base.Monoid w, GHC.Base.Functor m, GHC.Base.Monad m) => GHC.Base.Applicative (Control.Monad.Trans.Accum.AccumT w m)
instance (GHC.Base.Monoid w, GHC.Base.Functor m, GHC.Base.MonadPlus m) => GHC.Base.Alternative (Control.Monad.Trans.Accum.AccumT w m)
instance (GHC.Base.Monoid w, GHC.Base.Functor m, GHC.Base.Monad m) => GHC.Base.Monad (Control.Monad.Trans.Accum.AccumT w m)
instance (GHC.Base.Monoid w, Control.Monad.Fail.MonadFail m) => Control.Monad.Fail.MonadFail (Control.Monad.Trans.Accum.AccumT w m)
instance (GHC.Base.Monoid w, GHC.Base.Functor m, GHC.Base.MonadPlus m) => GHC.Base.MonadPlus (Control.Monad.Trans.Accum.AccumT w m)
instance (GHC.Base.Monoid w, GHC.Base.Functor m, Control.Monad.Fix.MonadFix m) => Control.Monad.Fix.MonadFix (Control.Monad.Trans.Accum.AccumT w m)
instance GHC.Base.Monoid w => Control.Monad.Trans.Class.MonadTrans (Control.Monad.Trans.Accum.AccumT w)
instance (GHC.Base.Monoid w, GHC.Base.Functor m, Control.Monad.IO.Class.MonadIO m) => Control.Monad.IO.Class.MonadIO (Control.Monad.Trans.Accum.AccumT w m)


-- | The strict <a>WriterT</a> monad transformer, which adds collection of
°5uoutputs (such as a count or string output) to a given monad.
°5u
°5uThis monad transformer provides only limited access to the output
°5uduring the computation. For more general access, use
°5u<a>Control.Monad.Trans.State</a> instead.
°5u
°5uThis version builds its output strictly; for a lazy version with the
°5usame interface, see <a>Control.Monad.Trans.Writer.Lazy</a>. Although
°5uthe output is built strictly, it is not possible to achieve constant
°5uspace behaviour with this transformer: for that, use
°5u<a>Control.Monad.Trans.State.Strict</a> instead.
module Control.Monad.Trans.Writer.Strict

-- | A writer monad parameterized by the type <tt>w</tt> of output to
°5uaccumulate.
°5u
°5uThe <a>return</a> function produces the output <a>mempty</a>, while
°5u<tt>&gt;&gt;=</tt> combines the outputs of the subcomputations using
°5u<a>mappend</a>.
type Writer w = WriterT w Identity

-- | Construct a writer computation from a (result, output) pair. (The
°5uinverse of <a>runWriter</a>.)
writer :: (Monad m) => (a, w) -> WriterT w m a

-- | Unwrap a writer computation as a (result, output) pair. (The inverse
°5uof <a>writer</a>.)
runWriter :: Writer w a -> (a, w)

-- | Extract the output from a writer computation.
°5u
°5u<ul>
°5u<li><pre><a>execWriter</a> m = <a>snd</a> (<a>runWriter</a>
°5um)</pre></li>
°5u</ul>
execWriter :: Writer w a -> w

-- | Map both the return value and output of a computation using the given
°5ufunction.
°5u
°5u<ul>
°5u<li><pre><a>runWriter</a> (<a>mapWriter</a> f m) = f (<a>runWriter</a>
°5um)</pre></li>
°5u</ul>
mapWriter :: ((a, w) -> (b, w')) -> Writer w a -> Writer w' b

-- | A writer monad parameterized by:
°5u
°5u<ul>
°5u<li><tt>w</tt> - the output to accumulate.</li>
°5u<li><tt>m</tt> - The inner monad.</li>
°5u</ul>
°5u
°5uThe <a>return</a> function produces the output <a>mempty</a>, while
°5u<tt>&gt;&gt;=</tt> combines the outputs of the subcomputations using
°5u<a>mappend</a>.
newtype WriterT w m a
WriterT :: m (a, w) -> WriterT w m a
[runWriterT] :: WriterT w m a -> m (a, w)

-- | Extract the output from a writer computation.
°5u
°5u<ul>
°5u<li><pre><a>execWriterT</a> m = <a>liftM</a> <a>snd</a>
°5u(<a>runWriterT</a> m)</pre></li>
°5u</ul>
execWriterT :: (Monad m) => WriterT w m a -> m w

-- | Map both the return value and output of a computation using the given
°5ufunction.
°5u
°5u<ul>
°5u<li><pre><a>runWriterT</a> (<a>mapWriterT</a> f m) = f
°5u(<a>runWriterT</a> m)</pre></li>
°5u</ul>
mapWriterT :: (m (a, w) -> n (b, w')) -> WriterT w m a -> WriterT w' n b

-- | <tt><a>tell</a> w</tt> is an action that produces the output
°5u<tt>w</tt>.
tell :: (Monad m) => w -> WriterT w m ()

-- | <tt><a>listen</a> m</tt> is an action that executes the action
°5u<tt>m</tt> and adds its output to the value of the computation.
°5u
°5u<ul>
°5u<li><pre><a>runWriterT</a> (<a>listen</a> m) = <a>liftM</a> (\ (a, w)
°5u-&gt; ((a, w), w)) (<a>runWriterT</a> m)</pre></li>
°5u</ul>
listen :: (Monad m) => WriterT w m a -> WriterT w m (a, w)

-- | <tt><a>listens</a> f m</tt> is an action that executes the action
°5u<tt>m</tt> and adds the result of applying <tt>f</tt> to the output to
°5uthe value of the computation.
°5u
°5u<ul>
°5u<li><pre><a>listens</a> f m = <a>liftM</a> (id *** f) (<a>listen</a>
°5um)</pre></li>
°5u<li><pre><a>runWriterT</a> (<a>listens</a> f m) = <a>liftM</a> (\ (a,
°5uw) -&gt; ((a, f w), w)) (<a>runWriterT</a> m)</pre></li>
°5u</ul>
listens :: (Monad m) => (w -> b) -> WriterT w m a -> WriterT w m (a, b)

-- | <tt><a>pass</a> m</tt> is an action that executes the action
°5u<tt>m</tt>, which returns a value and a function, and returns the
°5uvalue, applying the function to the output.
°5u
°5u<ul>
°5u<li><pre><a>runWriterT</a> (<a>pass</a> m) = <a>liftM</a> (\ ((a, f),
°5uw) -&gt; (a, f w)) (<a>runWriterT</a> m)</pre></li>
°5u</ul>
pass :: (Monad m) => WriterT w m (a, w -> w) -> WriterT w m a

-- | <tt><a>censor</a> f m</tt> is an action that executes the action
°5u<tt>m</tt> and applies the function <tt>f</tt> to its output, leaving
°5uthe return value unchanged.
°5u
°5u<ul>
°5u<li><pre><a>censor</a> f m = <a>pass</a> (<a>liftM</a> (\ x -&gt;
°5u(x,f)) m)</pre></li>
°5u<li><pre><a>runWriterT</a> (<a>censor</a> f m) = <a>liftM</a> (\ (a,
°5uw) -&gt; (a, f w)) (<a>runWriterT</a> m)</pre></li>
°5u</ul>
censor :: (Monad m) => (w -> w) -> WriterT w m a -> WriterT w m a

-- | Lift a <tt>callCC</tt> operation to the new monad.
liftCallCC :: (Monoid w) => CallCC m (a, w) (b, w) -> CallCC (WriterT w m) a b

-- | Lift a <tt>catchE</tt> operation to the new monad.
liftCatch :: Catch e m (a, w) -> Catch e (WriterT w m) a
instance (GHC.Classes.Eq w, Data.Functor.Classes.Eq1 m) => Data.Functor.Classes.Eq1 (Control.Monad.Trans.Writer.Strict.WriterT w m)
instance (GHC.Classes.Ord w, Data.Functor.Classes.Ord1 m) => Data.Functor.Classes.Ord1 (Control.Monad.Trans.Writer.Strict.WriterT w m)
instance (GHC.Read.Read w, Data.Functor.Classes.Read1 m) => Data.Functor.Classes.Read1 (Control.Monad.Trans.Writer.Strict.WriterT w m)
instance (GHC.Show.Show w, Data.Functor.Classes.Show1 m) => Data.Functor.Classes.Show1 (Control.Monad.Trans.Writer.Strict.WriterT w m)
instance (GHC.Classes.Eq w, Data.Functor.Classes.Eq1 m, GHC.Classes.Eq a) => GHC.Classes.Eq (Control.Monad.Trans.Writer.Strict.WriterT w m a)
instance (GHC.Classes.Ord w, Data.Functor.Classes.Ord1 m, GHC.Classes.Ord a) => GHC.Classes.Ord (Control.Monad.Trans.Writer.Strict.WriterT w m a)
instance (GHC.Read.Read w, Data.Functor.Classes.Read1 m, GHC.Read.Read a) => GHC.Read.Read (Control.Monad.Trans.Writer.Strict.WriterT w m a)
instance (GHC.Show.Show w, Data.Functor.Classes.Show1 m, GHC.Show.Show a) => GHC.Show.Show (Control.Monad.Trans.Writer.Strict.WriterT w m a)
instance GHC.Base.Functor m => GHC.Base.Functor (Control.Monad.Trans.Writer.Strict.WriterT w m)
instance Data.Foldable.Foldable f => Data.Foldable.Foldable (Control.Monad.Trans.Writer.Strict.WriterT w f)
instance Data.Traversable.Traversable f => Data.Traversable.Traversable (Control.Monad.Trans.Writer.Strict.WriterT w f)
instance (GHC.Base.Monoid w, GHC.Base.Applicative m) => GHC.Base.Applicative (Control.Monad.Trans.Writer.Strict.WriterT w m)
instance (GHC.Base.Monoid w, GHC.Base.Alternative m) => GHC.Base.Alternative (Control.Monad.Trans.Writer.Strict.WriterT w m)
instance (GHC.Base.Monoid w, GHC.Base.Monad m) => GHC.Base.Monad (Control.Monad.Trans.Writer.Strict.WriterT w m)
instance (GHC.Base.Monoid w, Control.Monad.Fail.MonadFail m) => Control.Monad.Fail.MonadFail (Control.Monad.Trans.Writer.Strict.WriterT w m)
instance (GHC.Base.Monoid w, GHC.Base.MonadPlus m) => GHC.Base.MonadPlus (Control.Monad.Trans.Writer.Strict.WriterT w m)
instance (GHC.Base.Monoid w, Control.Monad.Fix.MonadFix m) => Control.Monad.Fix.MonadFix (Control.Monad.Trans.Writer.Strict.WriterT w m)
instance GHC.Base.Monoid w => Control.Monad.Trans.Class.MonadTrans (Control.Monad.Trans.Writer.Strict.WriterT w)
instance (GHC.Base.Monoid w, Control.Monad.IO.Class.MonadIO m) => Control.Monad.IO.Class.MonadIO (Control.Monad.Trans.Writer.Strict.WriterT w m)
instance (GHC.Base.Monoid w, Control.Monad.Zip.MonadZip m) => Control.Monad.Zip.MonadZip (Control.Monad.Trans.Writer.Strict.WriterT w m)


-- | The constant functor.
module Data.Functor.Constant

-- | Constant functor.
newtype Constant a b
Constant :: a -> Constant a b
[getConstant] :: Constant a b -> a
instance forall a k (b :: k). GHC.Classes.Ord a => GHC.Classes.Ord (Data.Functor.Constant.Constant a b)
instance forall a k (b :: k). GHC.Classes.Eq a => GHC.Classes.Eq (Data.Functor.Constant.Constant a b)
instance forall k a (b :: k). GHC.Read.Read a => GHC.Read.Read (Data.Functor.Constant.Constant a b)
instance forall k a (b :: k). GHC.Show.Show a => GHC.Show.Show (Data.Functor.Constant.Constant a b)
instance Data.Functor.Classes.Eq2 Data.Functor.Constant.Constant
instance Data.Functor.Classes.Ord2 Data.Functor.Constant.Constant
instance Data.Functor.Classes.Read2 Data.Functor.Constant.Constant
instance Data.Functor.Classes.Show2 Data.Functor.Constant.Constant
instance GHC.Classes.Eq a => Data.Functor.Classes.Eq1 (Data.Functor.Constant.Constant a)
instance GHC.Classes.Ord a => Data.Functor.Classes.Ord1 (Data.Functor.Constant.Constant a)
instance GHC.Read.Read a => Data.Functor.Classes.Read1 (Data.Functor.Constant.Constant a)
instance GHC.Show.Show a => Data.Functor.Classes.Show1 (Data.Functor.Constant.Constant a)
instance GHC.Base.Functor (Data.Functor.Constant.Constant a)
instance Data.Foldable.Foldable (Data.Functor.Constant.Constant a)
instance Data.Traversable.Traversable (Data.Functor.Constant.Constant a)
instance forall k a (b :: k). GHC.Base.Semigroup a => GHC.Base.Semigroup (Data.Functor.Constant.Constant a b)
instance GHC.Base.Monoid a => GHC.Base.Applicative (Data.Functor.Constant.Constant a)
instance forall k a (b :: k). GHC.Base.Monoid a => GHC.Base.Monoid (Data.Functor.Constant.Constant a b)
instance Data.Bifunctor.Bifunctor Data.Functor.Constant.Constant
instance Data.Bifoldable.Bifoldable Data.Functor.Constant.Constant
instance Data.Bitraversable.Bitraversable Data.Functor.Constant.Constant


-- | Adding a new kind of pure computation to an applicative functor.
module Control.Applicative.Lift

-- | Applicative functor formed by adding pure computations to a given
°5uapplicative functor.
data Lift f a
Pure :: a -> Lift f a
Other :: (f a) -> Lift f a

-- | Projection to the other functor.
unLift :: (Applicative f) => Lift f a -> f a

-- | Apply a transformation to the other computation.
mapLift :: (f a -> g a) -> Lift f a -> Lift g a

-- | Eliminator for <a>Lift</a>.
°5u
°5u<ul>
°5u<li><pre><a>elimLift</a> f g . <a>pure</a> = f</pre></li>
°5u<li><pre><a>elimLift</a> f g . <a>Other</a> = g</pre></li>
°5u</ul>
elimLift :: (a -> r) -> (f a -> r) -> Lift f a -> r

-- | An applicative functor that collects a monoid (e.g. lists) of errors.
°5uA sequence of computations fails if any of its components do, but
°5uunlike monads made with <tt>ExceptT</tt> from
°5u<a>Control.Monad.Trans.Except</a>, these computations continue after
°5uan error, collecting all the errors.
°5u
°5u<ul>
°5u<li><pre><a>pure</a> f <a>&lt;*&gt;</a> <a>pure</a> x = <a>pure</a> (f
°5ux)</pre></li>
°5u<li><pre><a>pure</a> f <a>&lt;*&gt;</a> <a>failure</a> e =
°5u<a>failure</a> e</pre></li>
°5u<li><pre><a>failure</a> e <a>&lt;*&gt;</a> <a>pure</a> x =
°5u<a>failure</a> e</pre></li>
°5u<li><pre><a>failure</a> e1 <a>&lt;*&gt;</a> <a>failure</a> e2 =
°5u<a>failure</a> (e1 <a>&lt;&gt;</a> e2)</pre></li>
°5u</ul>
type Errors e = Lift (Constant e)

-- | Extractor for computations with accumulating errors.
°5u
°5u<ul>
°5u<li><pre><a>runErrors</a> (<a>pure</a> x) = <a>Right</a> x</pre></li>
°5u<li><pre><a>runErrors</a> (<a>failure</a> e) = <a>Left</a>
°5ue</pre></li>
°5u</ul>
runErrors :: Errors e a -> Either e a

-- | Report an error.
failure :: e -> Errors e a

-- | Convert from <a>Either</a> to <a>Errors</a> (inverse of
°5u<a>runErrors</a>).
eitherToErrors :: Either e a -> Errors e a
instance Data.Functor.Classes.Eq1 f => Data.Functor.Classes.Eq1 (Control.Applicative.Lift.Lift f)
instance Data.Functor.Classes.Ord1 f => Data.Functor.Classes.Ord1 (Control.Applicative.Lift.Lift f)
instance Data.Functor.Classes.Read1 f => Data.Functor.Classes.Read1 (Control.Applicative.Lift.Lift f)
instance Data.Functor.Classes.Show1 f => Data.Functor.Classes.Show1 (Control.Applicative.Lift.Lift f)
instance (Data.Functor.Classes.Eq1 f, GHC.Classes.Eq a) => GHC.Classes.Eq (Control.Applicative.Lift.Lift f a)
instance (Data.Functor.Classes.Ord1 f, GHC.Classes.Ord a) => GHC.Classes.Ord (Control.Applicative.Lift.Lift f a)
instance (Data.Functor.Classes.Read1 f, GHC.Read.Read a) => GHC.Read.Read (Control.Applicative.Lift.Lift f a)
instance (Data.Functor.Classes.Show1 f, GHC.Show.Show a) => GHC.Show.Show (Control.Applicative.Lift.Lift f a)
instance GHC.Base.Functor f => GHC.Base.Functor (Control.Applicative.Lift.Lift f)
instance Data.Foldable.Foldable f => Data.Foldable.Foldable (Control.Applicative.Lift.Lift f)
instance Data.Traversable.Traversable f => Data.Traversable.Traversable (Control.Applicative.Lift.Lift f)
instance GHC.Base.Applicative f => GHC.Base.Applicative (Control.Applicative.Lift.Lift f)
instance GHC.Base.Alternative f => GHC.Base.Alternative (Control.Applicative.Lift.Lift f)


-- | Making functors whose elements are notionally in the reverse order
°5ufrom the original functor.
module Data.Functor.Reverse

-- | The same functor, but with <a>Foldable</a> and <a>Traversable</a>
°5uinstances that process the elements in the reverse order.
newtype Reverse f a
Reverse :: f a -> Reverse f a
[getReverse] :: Reverse f a -> f a
instance Data.Functor.Classes.Eq1 f => Data.Functor.Classes.Eq1 (Data.Functor.Reverse.Reverse f)
instance Data.Functor.Classes.Ord1 f => Data.Functor.Classes.Ord1 (Data.Functor.Reverse.Reverse f)
instance Data.Functor.Classes.Read1 f => Data.Functor.Classes.Read1 (Data.Functor.Reverse.Reverse f)
instance Data.Functor.Classes.Show1 f => Data.Functor.Classes.Show1 (Data.Functor.Reverse.Reverse f)
instance (Data.Functor.Classes.Eq1 f, GHC.Classes.Eq a) => GHC.Classes.Eq (Data.Functor.Reverse.Reverse f a)
instance (Data.Functor.Classes.Ord1 f, GHC.Classes.Ord a) => GHC.Classes.Ord (Data.Functor.Reverse.Reverse f a)
instance (Data.Functor.Classes.Read1 f, GHC.Read.Read a) => GHC.Read.Read (Data.Functor.Reverse.Reverse f a)
instance (Data.Functor.Classes.Show1 f, GHC.Show.Show a) => GHC.Show.Show (Data.Functor.Reverse.Reverse f a)
instance GHC.Base.Functor f => GHC.Base.Functor (Data.Functor.Reverse.Reverse f)
instance GHC.Base.Applicative f => GHC.Base.Applicative (Data.Functor.Reverse.Reverse f)
instance GHC.Base.Alternative f => GHC.Base.Alternative (Data.Functor.Reverse.Reverse f)
instance GHC.Base.Monad m => GHC.Base.Monad (Data.Functor.Reverse.Reverse m)
instance Control.Monad.Fail.MonadFail m => Control.Monad.Fail.MonadFail (Data.Functor.Reverse.Reverse m)
instance GHC.Base.MonadPlus m => GHC.Base.MonadPlus (Data.Functor.Reverse.Reverse m)
instance Data.Foldable.Foldable f => Data.Foldable.Foldable (Data.Functor.Reverse.Reverse f)
instance Data.Traversable.Traversable f => Data.Traversable.Traversable (Data.Functor.Reverse.Reverse f)
