monad-abort-fd-0.7.0.1: A better error monad transformer
Safe HaskellSafe-Inferred
LanguageHaskell2010

Control.Monad.Abort

Description

Error monad transformer and monad type classes for raising errors and recovering from them.

Synopsis

Documentation

class (Applicative μ, Monad μ) => MonadAbort e μ | μ -> e where Source #

Class of monads that support raising of errors.

Methods

abort :: e -> μ α Source #

Raise an error.

    abort e >>= rest = abort e

Instances

Instances details
MonadAbort SomeException STM Source # 
Instance details

Defined in Control.Monad.Abort.Class

Methods

abort :: SomeException -> STM α Source #

MonadAbort SomeException IO Source # 
Instance details

Defined in Control.Monad.Abort.Class

Methods

abort :: SomeException -> IO α Source #

MonadAbort e μ => MonadAbort e (ListT μ) Source # 
Instance details

Defined in Control.Monad.Abort.Class

Methods

abort :: e -> ListT μ α Source #

MonadAbort e μ => MonadAbort e (MaybeT μ) Source # 
Instance details

Defined in Control.Monad.Abort.Class

Methods

abort :: e -> MaybeT μ α Source #

(Monoid w, MonadAbort e μ) => MonadAbort e (AccumT w μ) Source # 
Instance details

Defined in Control.Monad.Abort.Class

Methods

abort :: e -> AccumT w μ α Source #

(Functor μ, Monad μ, Error e) => MonadAbort e (ErrorT e μ) Source # 
Instance details

Defined in Control.Monad.Abort.Class

Methods

abort :: e -> ErrorT e μ α Source #

(Functor μ, Monad μ) => MonadAbort e (ExceptT e μ) Source # 
Instance details

Defined in Control.Monad.Abort.Class

Methods

abort :: e -> ExceptT e μ α Source #

MonadAbort e μ => MonadAbort e (IdentityT μ) Source # 
Instance details

Defined in Control.Monad.Abort.Class

Methods

abort :: e -> IdentityT μ α Source #

MonadAbort e μ => MonadAbort e (ReaderT r μ) Source # 
Instance details

Defined in Control.Monad.Abort.Class

Methods

abort :: e -> ReaderT r μ α Source #

MonadAbort e μ => MonadAbort e (SelectT r μ) Source # 
Instance details

Defined in Control.Monad.Abort.Class

Methods

abort :: e -> SelectT r μ α Source #

MonadAbort e μ => MonadAbort e (StateT s μ) Source # 
Instance details

Defined in Control.Monad.Abort.Class

Methods

abort :: e -> StateT s μ α Source #

MonadAbort e μ => MonadAbort e (StateT s μ) Source # 
Instance details

Defined in Control.Monad.Abort.Class

Methods

abort :: e -> StateT s μ α Source #

(MonadAbort e μ, Monoid w) => MonadAbort e (WriterT w μ) Source # 
Instance details

Defined in Control.Monad.Abort.Class

Methods

abort :: e -> WriterT w μ α Source #

(MonadAbort e μ, Monoid w) => MonadAbort e (WriterT w μ) Source # 
Instance details

Defined in Control.Monad.Abort.Class

Methods

abort :: e -> WriterT w μ α Source #

(Functor μ, Monad μ) => MonadAbort e (AbortT e μ) Source # 
Instance details

Defined in Control.Monad.Abort.Class

Methods

abort :: e -> AbortT e μ α Source #

MonadAbort e μ => MonadAbort e (FinishT f μ) Source # 
Instance details

Defined in Control.Monad.Abort.Class

Methods

abort :: e -> FinishT f μ α Source #

MonadAbort e μ => MonadAbort e (ContT r μ) Source # 
Instance details

Defined in Control.Monad.Abort.Class

Methods

abort :: e -> ContT r μ α Source #

(MonadAbort e μ, Monoid w) => MonadAbort e (RWST r w s μ) Source # 
Instance details

Defined in Control.Monad.Abort.Class

Methods

abort :: e -> RWST r w s μ α Source #

(MonadAbort e μ, Monoid w) => MonadAbort e (RWST r w s μ) Source # 
Instance details

Defined in Control.Monad.Abort.Class

Methods

abort :: e -> RWST r w s μ α Source #

class MonadAbort e μ => MonadRecover e μ | μ -> e where Source #

Class of monads that support recovery from errors.

Minimal complete definition

recover | evaluate

Methods

recover :: μ α -> (e -> μ α) -> μ α Source #

recover m h recovers from errors raised in computation m using the provided error handler h. The default implementation is

  evaluate m >>= either h return

evaluate :: μ α -> μ (Either e α) Source #

evaluate m runs computation m, returning Left e if it raised an error e. The default implementation is

   recover (Right <$> m) (return . Left)

Instances

Instances details
MonadRecover SomeException STM Source # 
Instance details

Defined in Control.Monad.Abort.Class

Methods

recover :: STM α -> (SomeException -> STM α) -> STM α Source #

evaluate :: STM α -> STM (Either SomeException α) Source #

MonadRecover SomeException IO Source # 
Instance details

Defined in Control.Monad.Abort.Class

Methods

recover :: IO α -> (SomeException -> IO α) -> IO α Source #

evaluate :: IO α -> IO (Either SomeException α) Source #

MonadRecover e μ => MonadRecover e (ListT μ) Source # 
Instance details

Defined in Control.Monad.Abort.Class

Methods

recover :: ListT μ α -> (e -> ListT μ α) -> ListT μ α Source #

evaluate :: ListT μ α -> ListT μ (Either e α) Source #

MonadRecover e μ => MonadRecover e (MaybeT μ) Source # 
Instance details

Defined in Control.Monad.Abort.Class

Methods

recover :: MaybeT μ α -> (e -> MaybeT μ α) -> MaybeT μ α Source #

evaluate :: MaybeT μ α -> MaybeT μ (Either e α) Source #

(Monoid w, MonadRecover e μ) => MonadRecover e (AccumT w μ) Source # 
Instance details

Defined in Control.Monad.Abort.Class

Methods

recover :: AccumT w μ α -> (e -> AccumT w μ α) -> AccumT w μ α Source #

evaluate :: AccumT w μ α -> AccumT w μ (Either e α) Source #

(Functor μ, Monad μ, Error e) => MonadRecover e (ErrorT e μ) Source # 
Instance details

Defined in Control.Monad.Abort.Class

Methods

recover :: ErrorT e μ α -> (e -> ErrorT e μ α) -> ErrorT e μ α Source #

evaluate :: ErrorT e μ α -> ErrorT e μ (Either e α) Source #

(Functor μ, Monad μ) => MonadRecover e (ExceptT e μ) Source # 
Instance details

Defined in Control.Monad.Abort.Class

Methods

recover :: ExceptT e μ α -> (e -> ExceptT e μ α) -> ExceptT e μ α Source #

evaluate :: ExceptT e μ α -> ExceptT e μ (Either e α) Source #

MonadRecover e μ => MonadRecover e (IdentityT μ) Source # 
Instance details

Defined in Control.Monad.Abort.Class

Methods

recover :: IdentityT μ α -> (e -> IdentityT μ α) -> IdentityT μ α Source #

evaluate :: IdentityT μ α -> IdentityT μ (Either e α) Source #

MonadRecover e μ => MonadRecover e (ReaderT r μ) Source # 
Instance details

Defined in Control.Monad.Abort.Class

Methods

recover :: ReaderT r μ α -> (e -> ReaderT r μ α) -> ReaderT r μ α Source #

evaluate :: ReaderT r μ α -> ReaderT r μ (Either e α) Source #

MonadRecover e μ => MonadRecover e (StateT s μ) Source # 
Instance details

Defined in Control.Monad.Abort.Class

Methods

recover :: StateT s μ α -> (e -> StateT s μ α) -> StateT s μ α Source #

evaluate :: StateT s μ α -> StateT s μ (Either e α) Source #

MonadRecover e μ => MonadRecover e (StateT s μ) Source # 
Instance details

Defined in Control.Monad.Abort.Class

Methods

recover :: StateT s μ α -> (e -> StateT s μ α) -> StateT s μ α Source #

evaluate :: StateT s μ α -> StateT s μ (Either e α) Source #

(MonadRecover e μ, Monoid w) => MonadRecover e (WriterT w μ) Source # 
Instance details

Defined in Control.Monad.Abort.Class

Methods

recover :: WriterT w μ α -> (e -> WriterT w μ α) -> WriterT w μ α Source #

evaluate :: WriterT w μ α -> WriterT w μ (Either e α) Source #

(MonadRecover e μ, Monoid w) => MonadRecover e (WriterT w μ) Source # 
Instance details

Defined in Control.Monad.Abort.Class

Methods

recover :: WriterT w μ α -> (e -> WriterT w μ α) -> WriterT w μ α Source #

evaluate :: WriterT w μ α -> WriterT w μ (Either e α) Source #

(Functor μ, Monad μ) => MonadRecover e (AbortT e μ) Source # 
Instance details

Defined in Control.Monad.Abort.Class

Methods

recover :: AbortT e μ α -> (e -> AbortT e μ α) -> AbortT e μ α Source #

evaluate :: AbortT e μ α -> AbortT e μ (Either e α) Source #

MonadRecover e μ => MonadRecover e (FinishT f μ) Source # 
Instance details

Defined in Control.Monad.Abort.Class

Methods

recover :: FinishT f μ α -> (e -> FinishT f μ α) -> FinishT f μ α Source #

evaluate :: FinishT f μ α -> FinishT f μ (Either e α) Source #

(MonadRecover e μ, Monoid w) => MonadRecover e (RWST r w s μ) Source # 
Instance details

Defined in Control.Monad.Abort.Class

Methods

recover :: RWST r w s μ α -> (e -> RWST r w s μ α) -> RWST r w s μ α Source #

evaluate :: RWST r w s μ α -> RWST r w s μ (Either e α) Source #

(MonadRecover e μ, Monoid w) => MonadRecover e (RWST r w s μ) Source # 
Instance details

Defined in Control.Monad.Abort.Class

Methods

recover :: RWST r w s μ α -> (e -> RWST r w s μ α) -> RWST r w s μ α Source #

evaluate :: RWST r w s μ α -> RWST r w s μ (Either e α) Source #

onError :: MonadRecover e μ => μ α -> (e -> μ β) -> μ α Source #

Run an action on error, without recovering from it.

onError_ :: MonadRecover e μ => μ α -> μ β -> μ α Source #

Run an action on error (ignoring the error value), without recovering from it.

type Abort e α = AbortT e Identity α #

An alias for AbortT over Identity.

runAbort :: Abort e α -> Either e α #

runAbortT specialized for Abort.

newtype AbortT e (μ :: Type -> Type) α #

A monad transformer that extends monad μ with the ability to raise errors of type e and to recover from them.

Constructors

AbortT 

Fields

Instances

Instances details
MonadRWS r w s μ => MonadRWS r w s (AbortT e μ) Source # 
Instance details

Defined in Control.Monad.Abort.Class

(Functor μ, Monad μ) => MonadAbort e (AbortT e μ) Source # 
Instance details

Defined in Control.Monad.Abort.Class

Methods

abort :: e -> AbortT e μ α Source #

(Functor μ, Monad μ) => MonadRecover e (AbortT e μ) Source # 
Instance details

Defined in Control.Monad.Abort.Class

Methods

recover :: AbortT e μ α -> (e -> AbortT e μ α) -> AbortT e μ α Source #

evaluate :: AbortT e μ α -> AbortT e μ (Either e α) Source #

MonadFinish f μ => MonadFinish f (AbortT e μ) Source # 
Instance details

Defined in Control.Monad.Finish.Class

Methods

finish :: f -> AbortT e μ α Source #

MonadBaseControl η μ => MonadBaseControl η (AbortT e μ) 
Instance details

Defined in Control.Monad.Trans.Abort

Associated Types

type StM (AbortT e μ) a #

Methods

liftBaseWith :: (RunInBase (AbortT e μ) η -> η a) -> AbortT e μ a #

restoreM :: StM (AbortT e μ) a -> AbortT e μ a #

Monad μ => MonadError e (AbortT e μ) Source # 
Instance details

Defined in Control.Monad.Abort.Class

Methods

throwError :: e -> AbortT e μ a #

catchError :: AbortT e μ a -> (e -> AbortT e μ a) -> AbortT e μ a #

MonadReader r μ => MonadReader r (AbortT e μ) Source # 
Instance details

Defined in Control.Monad.Abort.Class

Methods

ask :: AbortT e μ r #

local :: (r -> r) -> AbortT e μ a -> AbortT e μ a #

reader :: (r -> a) -> AbortT e μ a #

MonadState s μ => MonadState s (AbortT e μ) Source # 
Instance details

Defined in Control.Monad.Abort.Class

Methods

get :: AbortT e μ s #

put :: s -> AbortT e μ () #

state :: (s -> (a, s)) -> AbortT e μ a #

MonadWriter w μ => MonadWriter w (AbortT e μ) Source # 
Instance details

Defined in Control.Monad.Abort.Class

Methods

writer :: (a, w) -> AbortT e μ a #

tell :: w -> AbortT e μ () #

listen :: AbortT e μ a -> AbortT e μ (a, w) #

pass :: AbortT e μ (a, w -> w) -> AbortT e μ a #

MonadBase η μ => MonadBase η (AbortT e μ) 
Instance details

Defined in Control.Monad.Trans.Abort

Methods

liftBase :: η α -> AbortT e μ α #

MonadTransControl (AbortT e) 
Instance details

Defined in Control.Monad.Trans.Abort

Associated Types

type StT (AbortT e) a #

Methods

liftWith :: Monad m => (Run (AbortT e) -> m a) -> AbortT e m a #

restoreT :: Monad m => m (StT (AbortT e) a) -> AbortT e m a #

BindTrans (AbortT e) 
Instance details

Defined in Control.Monad.Trans.Abort

Methods

liftB :: Bind b => b a -> AbortT e b a #

MonadTrans (AbortT e) 
Instance details

Defined in Control.Monad.Trans.Abort

Methods

lift :: Monad m => m a -> AbortT e m a #

MonadFail μ => MonadFail (AbortT f μ) 
Instance details

Defined in Control.Monad.Trans.Abort

Methods

fail :: String -> AbortT f μ a #

MonadFix μ => MonadFix (AbortT e μ) 
Instance details

Defined in Control.Monad.Trans.Abort

Methods

mfix :: (a -> AbortT e μ a) -> AbortT e μ a #

MonadIO μ => MonadIO (AbortT e μ) 
Instance details

Defined in Control.Monad.Trans.Abort

Methods

liftIO :: IO a -> AbortT e μ a #

MonadZip μ => MonadZip (AbortT f μ) 
Instance details

Defined in Control.Monad.Trans.Abort

Methods

mzip :: AbortT f μ a -> AbortT f μ b -> AbortT f μ (a, b) #

mzipWith :: (a -> b -> c) -> AbortT f μ a -> AbortT f μ b -> AbortT f μ c #

munzip :: AbortT f μ (a, b) -> (AbortT f μ a, AbortT f μ b) #

Foldable μ => Foldable (AbortT e μ) 
Instance details

Defined in Control.Monad.Trans.Abort

Methods

fold :: Monoid m => AbortT e μ m -> m #

foldMap :: Monoid m => (a -> m) -> AbortT e μ a -> m #

foldMap' :: Monoid m => (a -> m) -> AbortT e μ a -> m #

foldr :: (a -> b -> b) -> b -> AbortT e μ a -> b #

foldr' :: (a -> b -> b) -> b -> AbortT e μ a -> b #

foldl :: (b -> a -> b) -> b -> AbortT e μ a -> b #

foldl' :: (b -> a -> b) -> b -> AbortT e μ a -> b #

foldr1 :: (a -> a -> a) -> AbortT e μ a -> a #

foldl1 :: (a -> a -> a) -> AbortT e μ a -> a #

toList :: AbortT e μ a -> [a] #

null :: AbortT e μ a -> Bool #

length :: AbortT e μ a -> Int #

elem :: Eq a => a -> AbortT e μ a -> Bool #

maximum :: Ord a => AbortT e μ a -> a #

minimum :: Ord a => AbortT e μ a -> a #

sum :: Num a => AbortT e μ a -> a #

product :: Num a => AbortT e μ a -> a #

(Eq f, Eq1 μ) => Eq1 (AbortT f μ) 
Instance details

Defined in Control.Monad.Trans.Abort

Methods

liftEq :: (a -> b -> Bool) -> AbortT f μ a -> AbortT f μ b -> Bool #

(Ord f, Ord1 μ) => Ord1 (AbortT f μ) 
Instance details

Defined in Control.Monad.Trans.Abort

Methods

liftCompare :: (a -> b -> Ordering) -> AbortT f μ a -> AbortT f μ b -> Ordering #

(Read f, Read1 μ) => Read1 (AbortT f μ) 
Instance details

Defined in Control.Monad.Trans.Abort

Methods

liftReadsPrec :: (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (AbortT f μ a) #

liftReadList :: (Int -> ReadS a) -> ReadS [a] -> ReadS [AbortT f μ a] #

liftReadPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec (AbortT f μ a) #

liftReadListPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec [AbortT f μ a] #

(Show f, Show1 μ) => Show1 (AbortT f μ) 
Instance details

Defined in Control.Monad.Trans.Abort

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> AbortT f μ a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [AbortT f μ a] -> ShowS #

Traversable μ => Traversable (AbortT e μ) 
Instance details

Defined in Control.Monad.Trans.Abort

Methods

traverse :: Applicative f => (a -> f b) -> AbortT e μ a -> f (AbortT e μ b) #

sequenceA :: Applicative f => AbortT e μ (f a) -> f (AbortT e μ a) #

mapM :: Monad m => (a -> m b) -> AbortT e μ a -> m (AbortT e μ b) #

sequence :: Monad m => AbortT e μ (m a) -> m (AbortT e μ a) #

(Functor μ, Monad μ) => Applicative (AbortT e μ) 
Instance details

Defined in Control.Monad.Trans.Abort

Methods

pure :: a -> AbortT e μ a #

(<*>) :: AbortT e μ (a -> b) -> AbortT e μ a -> AbortT e μ b #

liftA2 :: (a -> b -> c) -> AbortT e μ a -> AbortT e μ b -> AbortT e μ c #

(*>) :: AbortT e μ a -> AbortT e μ b -> AbortT e μ b #

(<*) :: AbortT e μ a -> AbortT e μ b -> AbortT e μ a #

Functor μ => Functor (AbortT e μ) 
Instance details

Defined in Control.Monad.Trans.Abort

Methods

fmap :: (a -> b) -> AbortT e μ a -> AbortT e μ b #

(<$) :: a -> AbortT e μ b -> AbortT e μ a #

Monad μ => Monad (AbortT e μ) 
Instance details

Defined in Control.Monad.Trans.Abort

Methods

(>>=) :: AbortT e μ a -> (a -> AbortT e μ b) -> AbortT e μ b #

(>>) :: AbortT e μ a -> AbortT e μ b -> AbortT e μ b #

return :: a -> AbortT e μ a #

MonadCont μ => MonadCont (AbortT e μ) Source # 
Instance details

Defined in Control.Monad.Abort.Class

Methods

callCC :: ((a -> AbortT e μ b) -> AbortT e μ a) -> AbortT e μ a #

Pointed μ => Pointed (AbortT e μ) 
Instance details

Defined in Control.Monad.Trans.Abort

Methods

point :: a -> AbortT e μ a #

(Functor μ, Monad μ) => Apply (AbortT e μ) 
Instance details

Defined in Control.Monad.Trans.Abort

Methods

(<.>) :: AbortT e μ (a -> b) -> AbortT e μ a -> AbortT e μ b #

(.>) :: AbortT e μ a -> AbortT e μ b -> AbortT e μ b #

(<.) :: AbortT e μ a -> AbortT e μ b -> AbortT e μ a #

liftF2 :: (a -> b -> c) -> AbortT e μ a -> AbortT e μ b -> AbortT e μ c #

(Functor μ, Monad μ) => Bind (AbortT e μ) 
Instance details

Defined in Control.Monad.Trans.Abort

Methods

(>>-) :: AbortT e μ a -> (a -> AbortT e μ b) -> AbortT e μ b #

join :: AbortT e μ (AbortT e μ a) -> AbortT e μ a #

(Read f, Read1 μ, Read α) => Read (AbortT f μ α) 
Instance details

Defined in Control.Monad.Trans.Abort

Methods

readsPrec :: Int -> ReadS (AbortT f μ α) #

readList :: ReadS [AbortT f μ α] #

readPrec :: ReadPrec (AbortT f μ α) #

readListPrec :: ReadPrec [AbortT f μ α] #

(Show f, Show1 μ, Show α) => Show (AbortT f μ α) 
Instance details

Defined in Control.Monad.Trans.Abort

Methods

showsPrec :: Int -> AbortT f μ α -> ShowS #

show :: AbortT f μ α -> String #

showList :: [AbortT f μ α] -> ShowS #

(Eq f, Eq1 μ, Eq α) => Eq (AbortT f μ α) 
Instance details

Defined in Control.Monad.Trans.Abort

Methods

(==) :: AbortT f μ α -> AbortT f μ α -> Bool #

(/=) :: AbortT f μ α -> AbortT f μ α -> Bool #

(Ord f, Ord1 μ, Ord α) => Ord (AbortT f μ α) 
Instance details

Defined in Control.Monad.Trans.Abort

Methods

compare :: AbortT f μ α -> AbortT f μ α -> Ordering #

(<) :: AbortT f μ α -> AbortT f μ α -> Bool #

(<=) :: AbortT f μ α -> AbortT f μ α -> Bool #

(>) :: AbortT f μ α -> AbortT f μ α -> Bool #

(>=) :: AbortT f μ α -> AbortT f μ α -> Bool #

max :: AbortT f μ α -> AbortT f μ α -> AbortT f μ α #

min :: AbortT f μ α -> AbortT f μ α -> AbortT f μ α #

type StT (AbortT e) α 
Instance details

Defined in Control.Monad.Trans.Abort

type StT (AbortT e) α = Either e α
type StM (AbortT e μ) α 
Instance details

Defined in Control.Monad.Trans.Abort

type StM (AbortT e μ) α = ComposeSt (AbortT e) μ α