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


-- | A collection of monad transformers.
--   
--   A collection of monad transformers.
@package monadLib
@version 3.10.1


-- | This library provides a collection of monad transformers that can be
--   combined to produce various monads.
module MonadLib

-- | Computations with no effects.
data Id a

-- | Computation with no effects (strict).
data Lift a

-- | Adds no new features. Useful as a placeholder.
data IdT m a

-- | Add support for propagating a context of type <tt>i</tt>.
data ReaderT i m a

-- | Add support for collecting values of type <tt>i</tt>. The type
--   <tt>i</tt> should be a monoid, whose unit is used to represent a lack
--   of a value, and whose binary operation is used to combine multiple
--   values. This transformer is strict in its output component.
data WriterT i m a

-- | Add support for threading state of type <tt>i</tt>.
data StateT i m a

-- | Add support for exceptions of type <tt>i</tt>.
data ExceptionT i m a

-- | Add support for multiple answers.
data ChoiceT m a

-- | Add support for continuations within a prompt of type <tt>i</tt>.
data ContT i m a
class MonadT t

-- | Promote a computation from the underlying monad.
lift :: (MonadT t, Monad m) => m a -> t m a
class (Monad m, Monad n) => BaseM m n | m -> n

-- | Promote a computation from the base monad.
inBase :: BaseM m n => n a -> m a

-- | Classifies monads that provide access to a context of type <tt>i</tt>.
class (Monad m) => ReaderM m i | m -> i

-- | Get the context.
ask :: ReaderM m i => m i

-- | Classifies monads that can collect values of type <tt>i</tt>.
class (Monad m) => WriterM m i | m -> i

-- | Add a value to the collection.
put :: WriterM m i => i -> m ()

-- | Classifies monads that propagate a state component of type <tt>i</tt>.
class (Monad m) => StateM m i | m -> i

-- | Get the state.
get :: StateM m i => m i

-- | Set the state.
set :: StateM m i => i -> m ()

-- | Classifies monads that support raising exceptions of type <tt>i</tt>.
class (Monad m) => ExceptionM m i | m -> i

-- | Raise an exception.
raise :: ExceptionM m i => i -> m a

-- | Classifies monads that provide access to a computation's continuation.
class Monad m => ContM m

-- | Capture the current continuation.
callWithCC :: ContM m => ((a -> Label m) -> m a) -> m a

-- | Classifies monads that support aborting the program and returning a
--   given final result of type <tt>i</tt>.
class Monad m => AbortM m i

-- | Abort the program with the given value as final result.
abort :: AbortM m i => i -> m a

-- | An explicit representation for monadic continuations.
data Label m

-- | Capture the current continuation. This function is like <a>return</a>,
--   except that it also captures the current continuation. Later, we can
--   use <a>jump</a> to repeat the computation from this point onwards but
--   with a possibly different value.
labelCC :: ContM m => a -> m (a, a -> Label m)

-- | Capture the current continuation. Later we can use <a>jump</a> to
--   restart the program from this point.
labelCC_ :: forall m. ContM m => m (Label m)

-- | Restart a previously captured computation.
jump :: Label m -> m a

-- | Label a given continuation.
labelC :: (forall b. m b) -> Label m

-- | A version of <a>callWithCC</a> that avoids the need for an explicit
--   use of the <a>jump</a> function.
callCC :: ContM m => ((a -> m b) -> m a) -> m a

-- | Get the result of a pure computation.
runId :: Id a -> a

-- | Get the result of a pure strict computation.
runLift :: Lift a -> a

-- | Remove an identity layer.
runIdT :: IdT m a -> m a

-- | Execute a reader computation in the given context.
runReaderT :: i -> ReaderT i m a -> m a

-- | Execute a writer computation. Returns the result and the collected
--   output.
runWriterT :: Monad m => WriterT i m a -> m (a, i)

-- | Execute a stateful computation in the given initial state. The second
--   component of the result is the final state.
runStateT :: i -> StateT i m a -> m (a, i)

-- | Execute a computation with exceptions. Successful results are tagged
--   with <a>Right</a>, exceptional results are tagged with <a>Left</a>.
runExceptionT :: ExceptionT i m a -> m (Either i a)

-- | Execute a computation with the given continuation.
runContT :: (a -> m i) -> ContT i m a -> m i

-- | Execute a computation that may return multiple answers. The resulting
--   computation returns <a>Nothing</a> if no answers were found, or
--   <tt>Just (answer,new_comp)</tt>, where <tt>answer</tt> is an answer,
--   and <tt>new_comp</tt> is a computation that may produce more answers.
--   The search is depth-first and left-biased with respect to the
--   <a>mplus</a> operation.
runChoiceT :: Monad m => ChoiceT m a -> m (Maybe (a, ChoiceT m a))

-- | Execute a computation that may return multiple answers, returning at
--   most one answer.
findOne :: Monad m => ChoiceT m a -> m (Maybe a)

-- | Execute a computation that may return multiple answers, collecting all
--   possible answers.
findAll :: Monad m => ChoiceT m a -> m [a]

-- | Generalized running.
class Monad m => RunM m a r | m a -> r
runM :: RunM m a r => m a -> r

-- | Classifies monads that support changing the context for a
--   sub-computation.
class (ReaderM m i) => RunReaderM m i | m -> i

-- | Change the context for the duration of a sub-computation.
local :: RunReaderM m i => i -> m a -> m a

-- | Classifies monads that support collecting the output of a
--   sub-computation.
class WriterM m i => RunWriterM m i | m -> i

-- | Collect the output from a sub-computation.
collect :: RunWriterM m i => m a -> m (a, i)

-- | Classifies monads that support handling of exceptions.
class ExceptionM m i => RunExceptionM m i | m -> i

-- | Convert computations that may raise an exception into computations
--   that do not raise exception but instead, yield a tagged results.
--   Exceptions are tagged with <a>Left</a>, successful computations are
--   tagged with <a>Right</a>.
try :: RunExceptionM m i => m a -> m (Either i a)

-- | Apply a function to the environment. Useful for accessing environmnt
--   components.
asks :: ReaderM m r => (r -> a) -> m a

-- | Add content the output and return a result.
puts :: WriterM m w => (a, w) -> m a

-- | Update the state and return a result.
sets :: StateM m s => (s -> (a, s)) -> m a

-- | Updates the state with the given function.
sets_ :: StateM m s => (s -> s) -> m ()

-- | Either raise an exception or return a value. <a>Left</a> values
--   signify the we should raise an exception, <a>Right</a> values indicate
--   success.
raises :: ExceptionM m x => Either x a -> m a

-- | Modify the environment for the duration of a computation.
mapReader :: RunReaderM m r => (r -> r) -> m a -> m a

-- | Modify the output of a computation.
mapWriter :: RunWriterM m w => (w -> w) -> m a -> m a

-- | Modify the exception that was risen by a computation.
mapException :: RunExceptionM m x => (x -> x) -> m a -> m a

-- | Apply the given exception handler, if a computation raises an
--   exception.
handle :: RunExceptionM m x => m a -> (x -> m a) -> m a

-- | A convenience type family for defining stacks of monads. The first
--   entry in the list is the top-most layer of the monad stack (i.e., the
--   one that is furtherest from the base). For example:
--   
--   <pre>
--   newtype M a = M { unM ::
--     WithBase IO
--       '[ ReaderT    Int
--        , StateT     Char
--        , ExceptionT String
--        ] a
--     }
--   </pre>
--   
--   is equivalent to:
--   
--   <pre>
--   newtype M a = M { unM ::
--     ReaderT    Int      (
--     StateT     Char     (
--     ExceptionT String
--     IO                  )) a
--     }
--   </pre>
type family WithBase base layers :: Type -> Type
instance MonadLib.ContM m => MonadLib.ContM (MonadLib.IdT m)
instance MonadLib.ContM m => MonadLib.ContM (MonadLib.ReaderT i m)
instance MonadLib.ContM m => MonadLib.ContM (MonadLib.StateT i m)
instance (MonadLib.ContM m, GHC.Base.Monoid i) => MonadLib.ContM (MonadLib.WriterT i m)
instance MonadLib.ContM m => MonadLib.ContM (MonadLib.ExceptionT i m)
instance MonadLib.ContM m => MonadLib.ContM (MonadLib.ChoiceT m)
instance GHC.Base.Monad m => MonadLib.ContM (MonadLib.ContT i m)
instance GHC.Base.Monad m => MonadLib.AbortM (MonadLib.ContT i m) i
instance MonadLib.AbortM GHC.Types.IO GHC.IO.Exception.ExitCode
instance MonadLib.AbortM m i => MonadLib.AbortM (MonadLib.IdT m) i
instance MonadLib.AbortM m i => MonadLib.AbortM (MonadLib.ReaderT j m) i
instance (MonadLib.AbortM m i, GHC.Base.Monoid j) => MonadLib.AbortM (MonadLib.WriterT j m) i
instance MonadLib.AbortM m i => MonadLib.AbortM (MonadLib.StateT j m) i
instance MonadLib.AbortM m i => MonadLib.AbortM (MonadLib.ExceptionT j m) i
instance MonadLib.AbortM m i => MonadLib.AbortM (MonadLib.ChoiceT m) i
instance MonadLib.RunExceptionM GHC.Types.IO GHC.Exception.Type.SomeException
instance GHC.Base.Monad m => MonadLib.RunExceptionM (MonadLib.ExceptionT i m) i
instance MonadLib.RunExceptionM m i => MonadLib.RunExceptionM (MonadLib.IdT m) i
instance MonadLib.RunExceptionM m i => MonadLib.RunExceptionM (MonadLib.ReaderT j m) i
instance (MonadLib.RunExceptionM m i, GHC.Base.Monoid j) => MonadLib.RunExceptionM (MonadLib.WriterT j m) i
instance MonadLib.RunExceptionM m i => MonadLib.RunExceptionM (MonadLib.StateT j m) i
instance (GHC.Base.Monad m, GHC.Base.Monoid i) => MonadLib.RunWriterM (MonadLib.WriterT i m) i
instance MonadLib.RunWriterM m j => MonadLib.RunWriterM (MonadLib.IdT m) j
instance MonadLib.RunWriterM m j => MonadLib.RunWriterM (MonadLib.ReaderT i m) j
instance MonadLib.RunWriterM m j => MonadLib.RunWriterM (MonadLib.StateT i m) j
instance MonadLib.RunWriterM m j => MonadLib.RunWriterM (MonadLib.ExceptionT i m) j
instance (MonadLib.RunWriterM m j, Control.Monad.Fix.MonadFix m) => MonadLib.RunWriterM (MonadLib.ContT i m) j
instance GHC.Base.Monad m => MonadLib.RunReaderM (MonadLib.ReaderT i m) i
instance MonadLib.RunReaderM m j => MonadLib.RunReaderM (MonadLib.IdT m) j
instance (MonadLib.RunReaderM m j, GHC.Base.Monoid i) => MonadLib.RunReaderM (MonadLib.WriterT i m) j
instance MonadLib.RunReaderM m j => MonadLib.RunReaderM (MonadLib.StateT i m) j
instance MonadLib.RunReaderM m j => MonadLib.RunReaderM (MonadLib.ExceptionT i m) j
instance MonadLib.RunReaderM m j => MonadLib.RunReaderM (MonadLib.ContT i m) j
instance MonadLib.ExceptionM GHC.Types.IO GHC.Exception.Type.SomeException
instance GHC.Base.Monad m => MonadLib.ExceptionM (MonadLib.ExceptionT i m) i
instance MonadLib.ExceptionM m j => MonadLib.ExceptionM (MonadLib.IdT m) j
instance MonadLib.ExceptionM m j => MonadLib.ExceptionM (MonadLib.ReaderT i m) j
instance (MonadLib.ExceptionM m j, GHC.Base.Monoid i) => MonadLib.ExceptionM (MonadLib.WriterT i m) j
instance MonadLib.ExceptionM m j => MonadLib.ExceptionM (MonadLib.StateT i m) j
instance MonadLib.ExceptionM m j => MonadLib.ExceptionM (MonadLib.ChoiceT m) j
instance MonadLib.ExceptionM m j => MonadLib.ExceptionM (MonadLib.ContT i m) j
instance GHC.Base.Monad m => MonadLib.StateM (MonadLib.StateT i m) i
instance MonadLib.StateM m j => MonadLib.StateM (MonadLib.IdT m) j
instance MonadLib.StateM m j => MonadLib.StateM (MonadLib.ReaderT i m) j
instance (MonadLib.StateM m j, GHC.Base.Monoid i) => MonadLib.StateM (MonadLib.WriterT i m) j
instance MonadLib.StateM m j => MonadLib.StateM (MonadLib.ExceptionT i m) j
instance MonadLib.StateM m j => MonadLib.StateM (MonadLib.ChoiceT m) j
instance MonadLib.StateM m j => MonadLib.StateM (MonadLib.ContT i m) j
instance (GHC.Base.Monad m, GHC.Base.Monoid i) => MonadLib.WriterM (MonadLib.WriterT i m) i
instance MonadLib.WriterM m j => MonadLib.WriterM (MonadLib.IdT m) j
instance MonadLib.WriterM m j => MonadLib.WriterM (MonadLib.ReaderT i m) j
instance MonadLib.WriterM m j => MonadLib.WriterM (MonadLib.StateT i m) j
instance MonadLib.WriterM m j => MonadLib.WriterM (MonadLib.ExceptionT i m) j
instance MonadLib.WriterM m j => MonadLib.WriterM (MonadLib.ChoiceT m) j
instance MonadLib.WriterM m j => MonadLib.WriterM (MonadLib.ContT i m) j
instance GHC.Base.Monad m => MonadLib.ReaderM (MonadLib.ReaderT i m) i
instance MonadLib.ReaderM m j => MonadLib.ReaderM (MonadLib.IdT m) j
instance (MonadLib.ReaderM m j, GHC.Base.Monoid i) => MonadLib.ReaderM (MonadLib.WriterT i m) j
instance MonadLib.ReaderM m j => MonadLib.ReaderM (MonadLib.StateT i m) j
instance MonadLib.ReaderM m j => MonadLib.ReaderM (MonadLib.ExceptionT i m) j
instance MonadLib.ReaderM m j => MonadLib.ReaderM (MonadLib.ChoiceT m) j
instance MonadLib.ReaderM m j => MonadLib.ReaderM (MonadLib.ContT i m) j
instance MonadLib.BaseM GHC.Types.IO GHC.Types.IO
instance MonadLib.BaseM GHC.Maybe.Maybe GHC.Maybe.Maybe
instance MonadLib.BaseM [] []
instance MonadLib.BaseM MonadLib.Id MonadLib.Id
instance MonadLib.BaseM MonadLib.Lift MonadLib.Lift
instance MonadLib.BaseM (GHC.ST.ST s) (GHC.ST.ST s)
instance MonadLib.BaseM m n => MonadLib.BaseM (MonadLib.IdT m) n
instance MonadLib.BaseM m n => MonadLib.BaseM (MonadLib.ReaderT i m) n
instance MonadLib.BaseM m n => MonadLib.BaseM (MonadLib.StateT i m) n
instance (MonadLib.BaseM m n, GHC.Base.Monoid i) => MonadLib.BaseM (MonadLib.WriterT i m) n
instance MonadLib.BaseM m n => MonadLib.BaseM (MonadLib.ExceptionT i m) n
instance MonadLib.BaseM m n => MonadLib.BaseM (MonadLib.ChoiceT m) n
instance MonadLib.BaseM m n => MonadLib.BaseM (MonadLib.ContT i m) n
instance MonadLib.MonadT MonadLib.IdT
instance MonadLib.MonadT (MonadLib.ReaderT i)
instance MonadLib.MonadT (MonadLib.StateT i)
instance GHC.Base.Monoid i => MonadLib.MonadT (MonadLib.WriterT i)
instance MonadLib.MonadT (MonadLib.ExceptionT i)
instance MonadLib.MonadT MonadLib.ChoiceT
instance MonadLib.MonadT (MonadLib.ContT i)
instance MonadLib.RunM MonadLib.Id a a
instance MonadLib.RunM MonadLib.Lift a a
instance MonadLib.RunM GHC.Types.IO a (GHC.Types.IO a)
instance MonadLib.RunM m a r => MonadLib.RunM (MonadLib.IdT m) a r
instance MonadLib.RunM m a r => MonadLib.RunM (MonadLib.ReaderT i m) a (i -> r)
instance (GHC.Base.Monoid i, MonadLib.RunM m (a, i) r) => MonadLib.RunM (MonadLib.WriterT i m) a r
instance MonadLib.RunM m (a, i) r => MonadLib.RunM (MonadLib.StateT i m) a (i -> r)
instance MonadLib.RunM m (Data.Either.Either i a) r => MonadLib.RunM (MonadLib.ExceptionT i m) a r
instance MonadLib.RunM m i r => MonadLib.RunM (MonadLib.ContT i m) a ((a -> m i) -> r)
instance MonadLib.RunM m (GHC.Maybe.Maybe (a, MonadLib.ChoiceT m a)) r => MonadLib.RunM (MonadLib.ChoiceT m) a r
instance GHC.Base.Monad m => GHC.Base.Monad (MonadLib.ContT i m)
instance GHC.Base.Monad m => GHC.Base.Functor (MonadLib.ContT i m)
instance GHC.Base.Monad m => GHC.Base.Applicative (MonadLib.ContT i m)
instance GHC.Base.MonadPlus m => GHC.Base.Alternative (MonadLib.ContT i m)
instance GHC.Base.MonadPlus m => GHC.Base.MonadPlus (MonadLib.ContT i m)
instance Control.Monad.Fail.MonadFail m => Control.Monad.Fail.MonadFail (MonadLib.ContT i m)
instance GHC.Base.Monad m => GHC.Base.Monad (MonadLib.ChoiceT m)
instance GHC.Base.Monad m => GHC.Base.Functor (MonadLib.ChoiceT m)
instance GHC.Base.Monad m => GHC.Base.Applicative (MonadLib.ChoiceT m)
instance GHC.Base.Monad m => GHC.Base.Alternative (MonadLib.ChoiceT m)
instance GHC.Base.Monad m => GHC.Base.MonadPlus (MonadLib.ChoiceT m)
instance Control.Monad.Fail.MonadFail m => Control.Monad.Fail.MonadFail (MonadLib.ChoiceT m)
instance GHC.Base.Monad m => GHC.Base.Monad (MonadLib.ExceptionT i m)
instance GHC.Base.Monad m => GHC.Base.Functor (MonadLib.ExceptionT i m)
instance GHC.Base.Monad m => GHC.Base.Applicative (MonadLib.ExceptionT i m)
instance GHC.Base.MonadPlus m => GHC.Base.Alternative (MonadLib.ExceptionT i m)
instance Control.Monad.Fix.MonadFix m => Control.Monad.Fix.MonadFix (MonadLib.ExceptionT i m)
instance GHC.Base.MonadPlus m => GHC.Base.MonadPlus (MonadLib.ExceptionT i m)
instance Control.Monad.Fail.MonadFail m => Control.Monad.Fail.MonadFail (MonadLib.ExceptionT i m)
instance GHC.Base.Monad m => GHC.Base.Monad (MonadLib.StateT i m)
instance GHC.Base.Monad m => GHC.Base.Functor (MonadLib.StateT i m)
instance GHC.Base.Monad m => GHC.Base.Applicative (MonadLib.StateT i m)
instance GHC.Base.MonadPlus m => GHC.Base.Alternative (MonadLib.StateT i m)
instance Control.Monad.Fix.MonadFix m => Control.Monad.Fix.MonadFix (MonadLib.StateT i m)
instance GHC.Base.MonadPlus m => GHC.Base.MonadPlus (MonadLib.StateT i m)
instance Control.Monad.Fail.MonadFail m => Control.Monad.Fail.MonadFail (MonadLib.StateT i m)
instance (GHC.Base.Monad m, GHC.Base.Monoid i) => GHC.Base.Monad (MonadLib.WriterT i m)
instance (GHC.Base.Monad m, GHC.Base.Monoid i) => GHC.Base.Functor (MonadLib.WriterT i m)
instance (GHC.Base.Monad m, GHC.Base.Monoid i) => GHC.Base.Applicative (MonadLib.WriterT i m)
instance (GHC.Base.MonadPlus m, GHC.Base.Monoid i) => GHC.Base.Alternative (MonadLib.WriterT i m)
instance (Control.Monad.Fix.MonadFix m, GHC.Base.Monoid i) => Control.Monad.Fix.MonadFix (MonadLib.WriterT i m)
instance (GHC.Base.MonadPlus m, GHC.Base.Monoid i) => GHC.Base.MonadPlus (MonadLib.WriterT i m)
instance (GHC.Base.Monoid i, Control.Monad.Fail.MonadFail m) => Control.Monad.Fail.MonadFail (MonadLib.WriterT i m)
instance GHC.Base.Monad m => GHC.Base.Monad (MonadLib.ReaderT i m)
instance GHC.Base.Monad m => GHC.Base.Functor (MonadLib.ReaderT i m)
instance GHC.Base.Monad m => GHC.Base.Applicative (MonadLib.ReaderT i m)
instance GHC.Base.MonadPlus m => GHC.Base.Alternative (MonadLib.ReaderT i m)
instance Control.Monad.Fix.MonadFix m => Control.Monad.Fix.MonadFix (MonadLib.ReaderT i m)
instance GHC.Base.MonadPlus m => GHC.Base.MonadPlus (MonadLib.ReaderT i m)
instance Control.Monad.Fail.MonadFail m => Control.Monad.Fail.MonadFail (MonadLib.ReaderT i m)
instance GHC.Base.Monad m => GHC.Base.Monad (MonadLib.IdT m)
instance GHC.Base.Monad m => GHC.Base.Functor (MonadLib.IdT m)
instance GHC.Base.Monad m => GHC.Base.Applicative (MonadLib.IdT m)
instance GHC.Base.MonadPlus m => GHC.Base.Alternative (MonadLib.IdT m)
instance Control.Monad.Fix.MonadFix m => Control.Monad.Fix.MonadFix (MonadLib.IdT m)
instance GHC.Base.MonadPlus m => GHC.Base.MonadPlus (MonadLib.IdT m)
instance Control.Monad.Fail.MonadFail m => Control.Monad.Fail.MonadFail (MonadLib.IdT m)
instance GHC.Base.Monad MonadLib.Lift
instance GHC.Base.Functor MonadLib.Lift
instance GHC.Base.Applicative MonadLib.Lift
instance Control.Monad.Fix.MonadFix MonadLib.Lift
instance GHC.Base.Monad MonadLib.Id
instance GHC.Base.Functor MonadLib.Id
instance GHC.Base.Applicative MonadLib.Id
instance Control.Monad.Fix.MonadFix MonadLib.Id


-- | This module defines a number of functions that make it easy to get the
--   functionality of MonadLib for user-defined newtypes.
module MonadLib.Derive

-- | An isomorphism between (usually) monads. Typically the constructor and
--   selector of a newtype delcaration.
data Iso m n
Iso :: (forall a. m a -> n a) -> (forall a. n a -> m a) -> Iso m n

-- | Derive the implementation of <a>fmap</a> from <a>Functor</a>.
derive_fmap :: Functor m => Iso m n -> (a -> b) -> n a -> n b

-- | Derive the implementation of <a>pure</a> from <a>Applicative</a>.
derive_pure :: Applicative m => Iso m n -> a -> n a

-- | Derive the implementation of <a>&lt;*&gt;</a> from <a>Applicative</a>.
derive_apply :: Applicative m => Iso m n -> n (a -> b) -> n a -> n b

-- | Derive the implementation of <a>empty</a> from <a>Alternative</a>.
derive_empty :: Alternative m => Iso m n -> n a

-- | Derive the implementation of <a>&lt;|&gt;</a> from <a>Alternative</a>.
derive_or :: Alternative m => Iso m n -> n a -> n a -> n a

-- | Derive the implementation of <a>return</a> from <a>Monad</a>.
derive_return :: Monad m => Iso m n -> a -> n a

-- | Derive the implementation of <a>&gt;&gt;=</a> from <a>Monad</a>.
derive_bind :: Monad m => Iso m n -> n a -> (a -> n b) -> n b
derive_fail :: MonadFail m => Iso m n -> String -> n a

-- | Derive the implementation of <a>mzero</a> from <a>MonadPlus</a>.
derive_mzero :: MonadPlus m => Iso m n -> n a

-- | Derive the implementation of <a>mplus</a> from <a>MonadPlus</a>.
derive_mplus :: MonadPlus m => Iso m n -> n a -> n a -> n a

-- | Derive the implementation of <a>mfix</a> from <a>MonadFix</a>.
derive_mfix :: MonadFix m => Iso m n -> (a -> n a) -> n a

-- | Derive the implementation of <a>ask</a> from <a>ReaderM</a>.
derive_ask :: ReaderM m i => Iso m n -> n i

-- | Derive the implementation of <a>local</a> from <a>RunReaderM</a>.
derive_local :: RunReaderM m i => Iso m n -> i -> n a -> n a

-- | Derive the implementation of <a>put</a> from <a>WriterM</a>.
derive_put :: WriterM m i => Iso m n -> i -> n ()

-- | Derive the implementation of <a>collect</a> from <a>RunWriterM</a>.
derive_collect :: RunWriterM m i => Iso m n -> n a -> n (a, i)

-- | Derive the implementation of <a>get</a> from <a>StateM</a>.
derive_get :: StateM m i => Iso m n -> n i

-- | Derive the implementation of <a>set</a> from <a>StateM</a>.
derive_set :: StateM m i => Iso m n -> i -> n ()

-- | Derive the implementation of <a>raise</a> from <a>ExceptionM</a>.
derive_raise :: ExceptionM m i => Iso m n -> i -> n a

-- | Derive the implementation of <a>try</a> from <a>RunExceptionM</a>.
derive_try :: RunExceptionM m i => Iso m n -> n a -> n (Either i a)

-- | Derive the implementation of <a>callWithCC</a> from <a>ContM</a>.
derive_callWithCC :: ContM m => Iso m n -> ((a -> Label n) -> n a) -> n a
derive_abort :: AbortM m i => Iso m n -> i -> n a

-- | Derive the implementation of <a>lift</a> from <a>MonadT</a>.
derive_lift :: (MonadT t, Monad m) => Iso (t m) n -> m a -> n a

-- | Derive the implementation of <a>inBase</a> from <a>BaseM</a>.
derive_inBase :: BaseM m x => Iso m n -> x a -> n a

-- | Derive the implementation of the <a>runM</a> function from
--   <a>RunM</a>.
derive_runM :: RunM m a r => Iso m n -> n a -> r


-- | This module contains a collection of monads that are defined in terms
--   of the monad transformers from <a>MonadLib</a>. The definitions in
--   this module are completely mechanical and so this module may become
--   obsolete if support for automated derivations for instances becomes
--   well supported across implementations.
module MonadLib.Monads
data Reader i a
data Writer i a
data State i a
data Exception i a
data Cont i a
runReader :: i -> Reader i a -> a
runWriter :: Writer i a -> (a, i)
runState :: i -> State i a -> (a, i)
runException :: Exception i a -> Either i a
runCont :: (a -> i) -> Cont i a -> i
instance MonadLib.BaseM (MonadLib.Monads.Cont i) (MonadLib.Monads.Cont i)
instance GHC.Base.Monad (MonadLib.Monads.Cont i)
instance GHC.Base.Functor (MonadLib.Monads.Cont i)
instance GHC.Base.Applicative (MonadLib.Monads.Cont i)
instance MonadLib.ContM (MonadLib.Monads.Cont i)
instance MonadLib.BaseM (MonadLib.Monads.Exception i) (MonadLib.Monads.Exception i)
instance GHC.Base.Monad (MonadLib.Monads.Exception i)
instance GHC.Base.Functor (MonadLib.Monads.Exception i)
instance GHC.Base.Applicative (MonadLib.Monads.Exception i)
instance Control.Monad.Fix.MonadFix (MonadLib.Monads.Exception i)
instance MonadLib.ExceptionM (MonadLib.Monads.Exception i) i
instance MonadLib.RunExceptionM (MonadLib.Monads.Exception i) i
instance MonadLib.BaseM (MonadLib.Monads.State i) (MonadLib.Monads.State i)
instance GHC.Base.Monad (MonadLib.Monads.State i)
instance GHC.Base.Functor (MonadLib.Monads.State i)
instance GHC.Base.Applicative (MonadLib.Monads.State i)
instance Control.Monad.Fix.MonadFix (MonadLib.Monads.State i)
instance MonadLib.StateM (MonadLib.Monads.State i) i
instance GHC.Base.Monoid i => MonadLib.BaseM (MonadLib.Monads.Writer i) (MonadLib.Monads.Writer i)
instance GHC.Base.Monoid i => GHC.Base.Monad (MonadLib.Monads.Writer i)
instance GHC.Base.Monoid i => GHC.Base.Functor (MonadLib.Monads.Writer i)
instance GHC.Base.Monoid i => GHC.Base.Applicative (MonadLib.Monads.Writer i)
instance GHC.Base.Monoid i => Control.Monad.Fix.MonadFix (MonadLib.Monads.Writer i)
instance GHC.Base.Monoid i => MonadLib.WriterM (MonadLib.Monads.Writer i) i
instance GHC.Base.Monoid i => MonadLib.RunWriterM (MonadLib.Monads.Writer i) i
instance MonadLib.BaseM (MonadLib.Monads.Reader i) (MonadLib.Monads.Reader i)
instance GHC.Base.Monad (MonadLib.Monads.Reader i)
instance GHC.Base.Functor (MonadLib.Monads.Reader i)
instance GHC.Base.Applicative (MonadLib.Monads.Reader i)
instance Control.Monad.Fix.MonadFix (MonadLib.Monads.Reader i)
instance MonadLib.ReaderM (MonadLib.Monads.Reader i) i
instance MonadLib.RunReaderM (MonadLib.Monads.Reader i) i
