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


-- | An Either monad transformer
--   
--   Drop in alternative to ExceptT. Uses a pattern synonym to maintain
--   compatibility with the old EitherT types but is actually ExceptT under
--   the covers.
@package transformers-either
@version 0.0.2


-- | This monad transformer extends <a>Control.Monad.Trans.Except</a> with
--   a more familar <a>Either</a> naming.
module Control.Monad.Trans.Either

-- | Type alias for <a>ExceptT</a>
type EitherT = ExceptT

-- | Constructor for computations in the either monad. (The inverse of
--   <a>runEitherT</a>).
newEitherT :: m (Either x a) -> EitherT x m a

-- | Extractor for computations in the either monad. (The inverse of
--   <a>newEitherT</a>).
runEitherT :: EitherT x m a -> m (Either x a)
eitherT :: Monad m => (x -> m b) -> (a -> m b) -> EitherT x m a -> m b

-- | Constructor for left computations.
left :: Monad m => x -> EitherT x m a

-- | Constructor for right computations.
right :: Monad m => a -> EitherT x m a
mapEitherT :: (m (Either x a) -> n (Either y b)) -> EitherT x m a -> EitherT y n b

-- | Hoist an <a>Either</a> into an "EitherT m"
hoistEither :: Monad m => Either x a -> EitherT x m a

-- | Map the unwrapped computation using the given function.
bimapEitherT :: Functor m => (x -> y) -> (a -> b) -> EitherT x m a -> EitherT y m b

-- | Map the <a>Left</a> unwrapped computation using the given function.
firstEitherT :: Functor m => (x -> y) -> EitherT x m a -> EitherT y m a

-- | Map the <a>Right</a> unwrapped computation using the given function.
secondEitherT :: Functor m => (a -> b) -> EitherT x m a -> EitherT x m b

-- | Hoist a 'Maybe a' into a 'Right a'
hoistMaybe :: Monad m => x -> Maybe a -> EitherT x m a

-- | Hoist
hoistEitherT :: (forall b. m b -> n b) -> EitherT x m a -> EitherT x n a

module Control.Monad.Trans.Either.Exit

-- | orDieWithCode with an exit code of 1 in case of an error
orDie :: (e -> Text) -> EitherT e IO a -> IO a

-- | An idiom for failing hard on EitherT errors.
--   
--   <ul>
--   <li>This really dies*. There is no other way to say it.</li>
--   </ul>
--   
--   The reason it lives with command line parser tooling, is that it is
--   the only valid place to actually exit like this. Be appropriately
--   wary.
orDieWithCode :: Int -> (e -> Text) -> EitherT e IO a -> IO a
