HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Moduletransformers-except-0.1.4Haskell98

Control.Monad.Trans.Except.Extra

This monad transformer extends Control.Monad.Trans.Except with a few more conveniences.

  • 25 values

Control.Monad.Trans.Except.Extra

8 declarations
valueexceptT :: Monad m => (x -> m b) -> (a -> m b) -> ExceptT x m a -> m b
#

Map over both arguments at the same time.

Specialised version of bimap for ExceptT.

Extensions

17 declarations
valuehandleExceptT
  1. :: (MonadCatch m, Exception e)
  2. => e -> x
  3. -> m a
  4. -> 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.

  • Warning*: This function should be used with caution! In particular, it is bad practice to catch SomeException because that includes asynchronous exceptions like stack/heap overflow, thread killed and user interrupt. Trying to handle StackOverflow, HeapOverflow and ThreadKilled exceptions could cause your program to crash or behave in unexpected ways.

valuehandlesExceptT
  1. :: (Foldable f, MonadCatch m)
  2. => f (Handler m x)
  3. -> m a
  4. -> 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.

valuebracketExceptionT
  1. :: MonadMask m
  2. => ExceptT e m a
  3. -> a -> ExceptT e m c
  4. -> a -> ExceptT e m b
  5. -> ExceptT e m b
#

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.

valuehushM :: Monad m => Either e a -> (e -> m ()) -> m (Maybe a)
#

Convert an Either to a Maybe and execute the supplied handler in the Left case.