-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | An Except monad transformer with -- -- Extra pieces for working with Except @package transformers-except @version 0.1.4 module Control.Monad.Trans.Except.Exit -- | orDieWithCode with an exit code of 1 in case of an error orDie :: (e -> Text) -> ExceptT e IO a -> IO a -- | An idiom for failing hard on EitherT errors. -- -- -- -- 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) -> ExceptT e IO a -> IO a -- | This monad transformer extends Control.Monad.Trans.Except with -- a few more conveniences. module Control.Monad.Trans.Except.Extra -- | Constructor for computations in the ExceptT monad. (The inverse of -- runExceptT). newExceptT :: m (Either x a) -> ExceptT x m a -- | The inverse of ExceptT. runExceptT :: ExceptT e m a -> m (Either e a) -- | Map over both arguments at the same time. -- -- Specialised version of bimap for ExceptT. exceptT :: Monad m => (x -> m b) -> (a -> m b) -> ExceptT x m a -> m b -- | Constructor for left computations. left :: Monad m => x -> ExceptT x m a -- | Constructor for right computations. right :: Monad m => a -> ExceptT x m a -- | Map the unwrapped computation using the given function. -- -- mapExceptT :: (m (Either e a) -> n (Either e' b)) -> ExceptT e m a -> ExceptT e' n b -- | Hoist an Either into an ExceptT m. hoistEither :: Monad m => Either x a -> ExceptT x m a -- | Map the unwrapped computation using the given function. bimapExceptT :: Functor m => (x -> y) -> (a -> b) -> ExceptT x m a -> ExceptT y m b -- | Map the Left unwrapped computation using the given function. firstExceptT :: Functor m => (x -> y) -> ExceptT x m a -> ExceptT y m a -- | Map the Right unwrapped computation using the given function. secondExceptT :: Functor m => (a -> b) -> ExceptT x m a -> ExceptT x m b -- | Hoist Maybe a into Right a. hoistMaybe :: Monad m => x -> Maybe a -> ExceptT x m a -- | Hoist Except m into an Except n. hoistExceptT :: (forall b. m b -> n b) -> ExceptT x m a -> ExceptT x n a -- | Try an IO action inside an ExceptT. If the IO -- action throws an IOException, catch it and wrap it with the -- provided handler to convert it to the error type of the ExceptT -- transformer. Exceptions other than IOException will escape the -- ExceptT transformer. -- -- Note: IOError is a type synonym for IOException. handleIOExceptT :: MonadIO m => (IOException -> x) -> IO a -> ExceptT x m a -- | Try any monad action and catch the specified exception, wrapping it to -- convert it to the error type of the ExceptT transformer. -- Exceptions other that the specified exception type will escape the -- ExceptT transformer. -- -- handleExceptT :: (MonadCatch m, Exception e) => (e -> x) -> m a -> ExceptT x m a -- | Try a monad action and catch any of the exceptions caught by the -- provided handlers. The handler for each exception type needs to wrap -- it to convert it to the error type of the ExceptT transformer. -- Exceptions not explicitly handled by the provided handlers will escape -- the ExceptT transformer. handlesExceptT :: (Foldable f, MonadCatch m) => f (Handler m x) -> m a -> ExceptT x m a -- | Handle an error. Equivalent to handleError in mtl package. handleLeftT :: Monad m => (e -> ExceptT e m a) -> ExceptT e m a -> ExceptT e m a -- | Flipped handleIOExceptT. catchIOExceptT :: MonadIO m => IO a -> (IOException -> x) -> ExceptT x m a -- | Flipped handleExceptT. catchExceptT :: (MonadCatch m, Exception e) => m a -> (e -> x) -> ExceptT x m a -- | Flipped handlesExceptT. catchesExceptT :: (Foldable f, MonadCatch m) => m a -> f (Handler m x) -> ExceptT x m a -- | Flipped handleLeftT. catchLeftT :: Monad m => ExceptT e m a -> (e -> ExceptT e m a) -> ExceptT e m a -- | Acquire a resource in ExceptT and then perform an action with -- it, cleaning up afterwards regardless of left. -- -- This function does not clean up in the event of an exception. Prefer -- bracketExceptionT in any impure setting. bracketExceptT :: Monad m => ExceptT e m a -> (a -> ExceptT e m b) -> (a -> ExceptT e m c) -> ExceptT e m c -- | Acquire a resource in ExceptT and then perform an action with it, -- cleaning up afterwards regardless of left or exception. -- -- Like bracketExceptT, but the cleanup is called even when the -- bracketed function throws an exception. Exceptions in the bracketed -- function are caught to allow the cleanup to run and then rethrown. bracketExceptionT :: MonadMask m => ExceptT e m a -> (a -> ExceptT e m c) -> (a -> ExceptT e m b) -> ExceptT e m b -- | Convert an Either to a Maybe and execute the supplied handler in the -- Left case. hushM :: Monad m => Either e a -> (e -> m ()) -> m (Maybe a) -- | Handle the Left constructor in returned Either. onLeft :: forall e x m a. Monad m => (e -> ExceptT x m a) -> ExceptT x m (Either e a) -> ExceptT x m a -- | Handle the Nothing constructor in returned Maybe. onNothing :: forall x m a. Monad m => ExceptT x m a -> ExceptT x m (Maybe a) -> ExceptT x m a