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


-- | An either monad transformer
--   
--   An either monad transformer
@package either
@version 3.4


-- | This module provides a minimalist <a>Either</a> monad transformer.
module Control.Monad.Trans.Either

-- | <a>EitherT</a> is a version of <a>ErrorT</a> that does not require a
--   spurious <a>Error</a> instance for the <a>Left</a> case.
--   
--   <a>Either</a> is a perfectly usable <a>Monad</a> without such a
--   constraint. <tt>ErrorT</tt> is not the generalization of the current
--   <a>Either</a> monad, it is something else.
--   
--   This is necessary for both theoretical and practical reasons. For
--   instance an apomorphism is the generalized anamorphism for this Monad,
--   but it cannot be written with <tt>ErrorT</tt>.
--   
--   In addition to the combinators here, the <tt>errors</tt> package
--   provides a large number of combinators for working with this type.
newtype EitherT e m a
EitherT :: m (Either e a) -> EitherT e m a
runEitherT :: EitherT e m a -> m (Either e a)

-- | Given a pair of actions, one to perform in case of failure, and one to
--   perform in case of success, run an <a>EitherT</a> and get back a
--   monadic result.
eitherT :: Monad m => (a -> m c) -> (b -> m c) -> EitherT a m b -> m c

-- | Map over both failure and success.
bimapEitherT :: Functor m => (e -> f) -> (a -> b) -> EitherT e m a -> EitherT f m b

-- | Map the unwrapped computation using the given function.
--   
--   <pre>
--   <a>runEitherT</a> (<a>mapEitherT</a> f m) = f (<a>runEitherT</a> m)
--   </pre>
mapEitherT :: (m (Either e a) -> n (Either e' b)) -> EitherT e m a -> EitherT e' n b

-- | Lift an <a>Either</a> into an <a>EitherT</a>
hoistEither :: Monad m => Either e a -> EitherT e m a

-- | Analogous to <a>Left</a>. Equivalent to <a>throwError</a>.
left :: Monad m => e -> EitherT e m a

-- | Analogous to <a>Right</a>. Equivalent to <a>return</a>.
right :: Monad m => a -> EitherT e m a
instance (Monad f, Traversable f) => Traversable (EitherT e f)
instance Foldable m => Foldable (EitherT e m)
instance MonadRandom m => MonadRandom (EitherT e m)
instance MonadWriter s m => MonadWriter s (EitherT e m)
instance MonadState s m => MonadState s (EitherT e m)
instance MonadReader r m => MonadReader r (EitherT e m)
instance MonadCont m => MonadCont (EitherT e m)
instance MonadIO m => MonadIO (EitherT e m)
instance MonadTrans (EitherT e)
instance MonadFix m => MonadFix (EitherT e m)
instance Monad m => MonadError e (EitherT e m)
instance Monad m => Monad (EitherT e m)
instance Monad m => Bind (EitherT e m)
instance (Monad m, Semigroup e) => Alt (EitherT e m)
instance Monad m => Semigroup (EitherT e m a)
instance (Monad m, Monoid e) => MonadPlus (EitherT e m)
instance (Monad m, Monoid e) => Alternative (EitherT e m)
instance Monad m => Applicative (EitherT e m)
instance Monad m => Apply (EitherT e m)
instance Monad m => Functor (EitherT e m)
instance Ord (m (Either e a)) => Ord (EitherT e m a)
instance Eq (m (Either e a)) => Eq (EitherT e m a)
instance Read (m (Either e a)) => Read (EitherT e m a)
instance Show (m (Either e a)) => Show (EitherT e m a)
