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

-- | Monad morphisms
--   
--   This library provides monad morphism utilities, most commonly used for
--   manipulating monad transformer stacks.
@package mmorph
@version 1.2.0

-- | A monad morphism is a natural transformation:
--   
--   
--   morph :: forall a . m a -> n a
--   
--   
--   ... that obeys the following two laws:
--   
--   
--   morph $ do x <- m  =  do x <- morph m
--              f x           morph (f x)
--   
--   morph (return x) = return x
--   
--   
--   ... which are equivalent to the following two functor laws:
--   
--   
--   morph . (f >=> g) = morph . f >=> morph . g
--   
--   morph . return = return
--   
--   
--   Examples of monad morphisms include:
--   
--   
--   
- lift (from MonadTrans)
--   
- squash (See below)
--   
- hoist f (See below), if f is a monad
--   morphism
--   
- (f . g), if f and g are both monad
--   morphisms
--   
- id
--   
--   
--   Monad morphisms commonly arise when manipulating existing monad
--   transformer code for compatibility purposes. The MFunctor,
--   MonadTrans, and MMonad classes define standard ways to
--   change monad transformer stacks:
--   
--   
--   
- lift introduces a new monad transformer layer of any
--   type.
--   
- squash flattens two identical monad transformer layers into
--   a single layer of the same type.
--   
- hoist maps monad morphisms to modify deeper layers of the
--   monad transformer stack.
--   
module Control.Monad.Morph

-- | A functor in the category of monads, using hoist as the analog
--   of fmap:
--   
--   
--   hoist (f . g) = hoist f . hoist g
--   
--   hoist id = id
--   
class MFunctor t

-- | Lift a monad morphism from m to n into a monad
--   morphism from (t m) to (t n)
--   
--   The first argument to hoist must be a monad morphism, even
--   though the type system does not enforce this
hoist :: (MFunctor t, Monad m) => (forall a. m a -> n a) -> t m b -> t n b

-- | A function that generalizes the Identity base monad to
--   be any monad.
generalize :: Monad m => Identity a -> m a

-- | A monad in the category of monads, using lift from
--   MonadTrans as the analog of return and embed as
--   the analog of (=<<):
--   
--   
--   embed lift = id
--   
--   embed f (lift m) = f m
--   
--   embed g (embed f t) = embed (\m -> embed g (f m)) t
--   
class (MFunctor t, MonadTrans t) => MMonad t

-- | Embed a newly created MMonad layer within an existing layer
--   
--   embed is analogous to (=<<)
embed :: (MMonad t, Monad n) => (forall a. m a -> t n a) -> t m b -> t n b

-- | The class of monad transformers. Instances should satisfy the
--   following laws, which state that lift is a monad
--   transformation:
--   
--   
--   
- 
lift . return = return

--   
- 
lift (m >>= f) = lift m >>=
--   (lift . f)

--   
class () => MonadTrans (t :: Type -> Type -> Type -> Type)

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

-- | Squash two MMonad layers into a single layer
--   
--   squash is analogous to join
squash :: (Monad m, MMonad t) => t (t m) a -> t m a

-- | Compose two MMonad layer-building functions
--   
--   (>|>) is analogous to (>=>)
(>|>) :: (Monad m3, MMonad t) => (forall a. m1 a -> t m2 a) -> (forall b. m2 b -> t m3 b) -> m1 c -> t m3 c
infixr 2 >|>

-- | Equivalent to (>|>) with the arguments flipped
--   
--   (<|<) is analogous to (<=<)
(<|<) :: (Monad m3, MMonad t) => (forall b. m2 b -> t m3 b) -> (forall a. m1 a -> t m2 a) -> m1 c -> t m3 c
infixl 2 <|<

-- | An infix operator equivalent to embed
--   
--   (=<|) is analogous to (=<<)
(=<|) :: (Monad n, MMonad t) => (forall a. m a -> t n a) -> t m b -> t n b
infixr 2 =<|

-- | Equivalent to (=<|) with the arguments flipped
--   
--   (|>=) is analogous to (>>=)
(|>=) :: (Monad n, MMonad t) => t m b -> (forall a. m a -> t n a) -> t n b
infixl 2 |>=
instance Control.Monad.Morph.MMonad (Control.Monad.Trans.Except.ExceptT e)
instance Control.Monad.Morph.MMonad Control.Monad.Trans.Identity.IdentityT
instance Control.Monad.Morph.MMonad Control.Monad.Trans.Maybe.MaybeT
instance Control.Monad.Morph.MMonad (Control.Monad.Trans.Reader.ReaderT r)
instance GHC.Base.Monoid w => Control.Monad.Morph.MMonad (Control.Monad.Trans.Writer.Strict.WriterT w)
instance GHC.Base.Monoid w => Control.Monad.Morph.MMonad (Control.Monad.Trans.Writer.Lazy.WriterT w)
instance Control.Monad.Morph.MFunctor (Control.Monad.Trans.Except.ExceptT e)
instance Control.Monad.Morph.MFunctor Control.Monad.Trans.Identity.IdentityT
instance Control.Monad.Morph.MFunctor Control.Monad.Trans.Maybe.MaybeT
instance Control.Monad.Morph.MFunctor (Control.Monad.Trans.Reader.ReaderT r)
instance Control.Monad.Morph.MFunctor (Control.Monad.Trans.RWS.Lazy.RWST r w s)
instance Control.Monad.Morph.MFunctor (Control.Monad.Trans.RWS.Strict.RWST r w s)
instance Control.Monad.Morph.MFunctor (Control.Monad.Trans.State.Lazy.StateT s)
instance Control.Monad.Morph.MFunctor (Control.Monad.Trans.State.Strict.StateT s)
instance Control.Monad.Morph.MFunctor (Control.Monad.Trans.Writer.Strict.WriterT w)
instance Control.Monad.Morph.MFunctor (Control.Monad.Trans.Writer.Lazy.WriterT w)
instance GHC.Base.Functor f => Control.Monad.Morph.MFunctor (Data.Functor.Compose.Compose f)
instance Control.Monad.Morph.MFunctor (Data.Functor.Product.Product f)
instance Control.Monad.Morph.MFunctor Control.Applicative.Backwards.Backwards
instance Control.Monad.Morph.MFunctor Control.Applicative.Lift.Lift

-- | Composition of monad transformers. A higher-order version of
--   Data.Functor.Compose.
module Control.Monad.Trans.Compose

-- | Composition of monad transformers.
newtype ComposeT (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *) m a
ComposeT :: f (g m) a -> ComposeT (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *) m a
[getComposeT] :: ComposeT (f :: (* -> *) -> * -> *) (g :: (* -> *) -> * -> *) m a -> f (g m) a
infixr 9 `ComposeT`
infixr 9 `ComposeT`

-- | Transform the computation inside a ComposeT.
mapComposeT :: (f (g m) a -> p (q n) b) -> ComposeT f g m a -> ComposeT p q n b
instance Control.Monad.Writer.Class.MonadWriter w (f (g m)) => Control.Monad.Writer.Class.MonadWriter w (Control.Monad.Trans.Compose.ComposeT f g m)
instance Control.Monad.State.Class.MonadState s (f (g m)) => Control.Monad.State.Class.MonadState s (Control.Monad.Trans.Compose.ComposeT f g m)
instance (Control.Monad.Reader.Class.MonadReader r (f (g m)), Control.Monad.Writer.Class.MonadWriter w (f (g m)), Control.Monad.State.Class.MonadState s (f (g m))) => Control.Monad.RWS.Class.MonadRWS r w s (Control.Monad.Trans.Compose.ComposeT f g m)
instance Control.Monad.Reader.Class.MonadReader r (f (g m)) => Control.Monad.Reader.Class.MonadReader r (Control.Monad.Trans.Compose.ComposeT f g m)
instance GHC.Base.MonadPlus (f (g m)) => GHC.Base.MonadPlus (Control.Monad.Trans.Compose.ComposeT f g m)
instance Control.Monad.IO.Class.MonadIO (f (g m)) => Control.Monad.IO.Class.MonadIO (Control.Monad.Trans.Compose.ComposeT f g m)
instance Control.Monad.Fail.MonadFail (f (g m)) => Control.Monad.Fail.MonadFail (Control.Monad.Trans.Compose.ComposeT f g m)
instance Control.Monad.Error.Class.MonadError e (f (g m)) => Control.Monad.Error.Class.MonadError e (Control.Monad.Trans.Compose.ComposeT f g m)
instance Control.Monad.Cont.Class.MonadCont (f (g m)) => Control.Monad.Cont.Class.MonadCont (Control.Monad.Trans.Compose.ComposeT f g m)
instance GHC.Base.Monad (f (g m)) => GHC.Base.Monad (Control.Monad.Trans.Compose.ComposeT f g m)
instance Data.Traversable.Traversable (f (g m)) => Data.Traversable.Traversable (Control.Monad.Trans.Compose.ComposeT f g m)
instance GHC.Show.Show (f (g m) a) => GHC.Show.Show (Control.Monad.Trans.Compose.ComposeT f g m a)
instance GHC.Read.Read (f (g m) a) => GHC.Read.Read (Control.Monad.Trans.Compose.ComposeT f g m a)
instance GHC.Classes.Ord (f (g m) a) => GHC.Classes.Ord (Control.Monad.Trans.Compose.ComposeT f g m a)
instance GHC.Base.Functor (f (g m)) => GHC.Base.Functor (Control.Monad.Trans.Compose.ComposeT f g m)
instance Data.Foldable.Foldable (f (g m)) => Data.Foldable.Foldable (Control.Monad.Trans.Compose.ComposeT f g m)
instance GHC.Classes.Eq (f (g m) a) => GHC.Classes.Eq (Control.Monad.Trans.Compose.ComposeT f g m a)
instance GHC.Base.Applicative (f (g m)) => GHC.Base.Applicative (Control.Monad.Trans.Compose.ComposeT f g m)
instance GHC.Base.Alternative (f (g m)) => GHC.Base.Alternative (Control.Monad.Trans.Compose.ComposeT f g m)
instance (Control.Monad.Morph.MFunctor f, Control.Monad.Trans.Class.MonadTrans f, Control.Monad.Trans.Class.MonadTrans g) => Control.Monad.Trans.Class.MonadTrans (Control.Monad.Trans.Compose.ComposeT f g)
instance (Control.Monad.Morph.MFunctor f, Control.Monad.Morph.MFunctor g, forall (m :: * -> *). GHC.Base.Monad m => GHC.Base.Monad (g m)) => Control.Monad.Morph.MFunctor (Control.Monad.Trans.Compose.ComposeT f g)
