monad-abort-fd-0.7: A better error monad transformer

Safe HaskellNone
LanguageHaskell98

Control.Monad.Finish

Description

Short-circuiting monad transformer and the corresponding generalizing monad type class.

Synopsis

Documentation

class Monad μ => MonadFinish f μ | μ -> f where Source #

Class of monads that support short-circuiting.

Minimal complete definition

finish

Methods

finish :: f -> μ α Source #

Short-circuit the computation with the provided value.

    finish f >>= rest = finish f

Instances

MonadFinish f μ => MonadFinish f (ListT μ) Source # 

Methods

finish :: f -> ListT μ α Source #

MonadFinish f μ => MonadFinish f (MaybeT μ) Source # 

Methods

finish :: f -> MaybeT μ α Source #

(MonadFinish f μ, Monoid w) => MonadFinish f (WriterT w μ) Source # 

Methods

finish :: f -> WriterT w μ α Source #

(MonadFinish f μ, Monoid w) => MonadFinish f (WriterT w μ) Source # 

Methods

finish :: f -> WriterT w μ α Source #

MonadFinish f μ => MonadFinish f (StateT s μ) Source # 

Methods

finish :: f -> StateT s μ α Source #

MonadFinish f μ => MonadFinish f (StateT s μ) Source # 

Methods

finish :: f -> StateT s μ α Source #

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

Methods

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

MonadFinish f μ => MonadFinish f (ExceptT e μ) Source # 

Methods

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

(MonadFinish f μ, Error e) => MonadFinish f (ErrorT e μ) Source # 

Methods

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

MonadFinish f μ => MonadFinish f (IdentityT * μ) Source # 

Methods

finish :: f -> IdentityT * μ α Source #

Monad μ => MonadFinish f (FinishT f μ) Source # 

Methods

finish :: f -> FinishT f μ α Source #

MonadFinish f μ => MonadFinish f (ReaderT * r μ) Source # 

Methods

finish :: f -> ReaderT * r μ α Source #

MonadFinish f μ => MonadFinish f (ContT * r μ) Source # 

Methods

finish :: f -> ContT * r μ α Source #

(MonadFinish f μ, Monoid w) => MonadFinish f (RWST r w s μ) Source # 

Methods

finish :: f -> RWST r w s μ α Source #

(MonadFinish f μ, Monoid w) => MonadFinish f (RWST r w s μ) Source # 

Methods

finish :: f -> RWST r w s μ α Source #

type Finish f α = FinishT f Identity α #

An alias for FinishT over Identity.

runFinish :: Finish f α -> Either f α #

runFinishT specialized for Finish.

runFinish' :: Finish α α -> α #

runFinishT' specialized to Finish.

newtype FinishT f (μ :: * -> *) α :: * -> (* -> *) -> * -> * #

A monad transformer that extends monad μ with the ability to short-circuit computations with a value of type f.

  runFinishT $ do someStuff
                  when condition $ finish reason
                  otherwiseContinue

Constructors

FinishT 

Fields

Instances

MonadBase η μ => MonadBase η (FinishT f μ) 

Methods

liftBase :: η α -> FinishT f μ α #

MonadBaseControl η μ => MonadBaseControl η (FinishT e μ) 

Associated Types

type StM (FinishT e μ :: * -> *) a :: * #

Methods

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

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

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

Methods

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

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

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

Methods

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

Monad μ => MonadFinish f (FinishT f μ) Source # 

Methods

finish :: f -> FinishT f μ α Source #

MonadTrans (FinishT f) 

Methods

lift :: Monad m => m a -> FinishT f m a #

MonadTransControl (FinishT f) 

Associated Types

type StT (FinishT f :: (* -> *) -> * -> *) a :: * #

Methods

liftWith :: Monad m => (Run (FinishT f) -> m a) -> FinishT f m a #

restoreT :: Monad m => m (StT (FinishT f) a) -> FinishT f m a #

BindTrans (FinishT f) 

Methods

liftB :: Bind b => b a -> FinishT f b a #

Monad μ => Monad (FinishT f μ) 

Methods

(>>=) :: FinishT f μ a -> (a -> FinishT f μ b) -> FinishT f μ b #

(>>) :: FinishT f μ a -> FinishT f μ b -> FinishT f μ b #

return :: a -> FinishT f μ a #

fail :: String -> FinishT f μ a #

Functor μ => Functor (FinishT f μ) 

Methods

fmap :: (a -> b) -> FinishT f μ a -> FinishT f μ b #

(<$) :: a -> FinishT f μ b -> FinishT f μ a #

MonadFix μ => MonadFix (FinishT f μ) 

Methods

mfix :: (a -> FinishT f μ a) -> FinishT f μ a #

MonadFail μ => MonadFail (FinishT f μ) 

Methods

fail :: String -> FinishT f μ a #

(Functor μ, Monad μ) => Applicative (FinishT f μ) 

Methods

pure :: a -> FinishT f μ a #

(<*>) :: FinishT f μ (a -> b) -> FinishT f μ a -> FinishT f μ b #

liftA2 :: (a -> b -> c) -> FinishT f μ a -> FinishT f μ b -> FinishT f μ c #

(*>) :: FinishT f μ a -> FinishT f μ b -> FinishT f μ b #

(<*) :: FinishT f μ a -> FinishT f μ b -> FinishT f μ a #

(Eq f, Eq1 μ) => Eq1 (FinishT f μ) 

Methods

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

(Ord f, Ord1 μ) => Ord1 (FinishT f μ) 

Methods

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

(Read f, Read1 μ) => Read1 (FinishT f μ) 

Methods

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

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

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

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

(Show f, Show1 μ) => Show1 (FinishT f μ) 

Methods

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

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

MonadZip μ => MonadZip (FinishT f μ) 

Methods

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

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

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

MonadIO μ => MonadIO (FinishT f μ) 

Methods

liftIO :: IO a -> FinishT f μ a #

Pointed μ => Pointed (FinishT f μ) 

Methods

point :: a -> FinishT f μ a #

(Functor μ, Monad μ) => Apply (FinishT f μ) 

Methods

(<.>) :: FinishT f μ (a -> b) -> FinishT f μ a -> FinishT f μ b #

(.>) :: FinishT f μ a -> FinishT f μ b -> FinishT f μ b #

(<.) :: FinishT f μ a -> FinishT f μ b -> FinishT f μ a #

liftF2 :: (a -> b -> c) -> FinishT f μ a -> FinishT f μ b -> FinishT f μ c #

(Functor μ, Monad μ) => Bind (FinishT f μ) 

Methods

(>>-) :: FinishT f μ a -> (a -> FinishT f μ b) -> FinishT f μ b #

join :: FinishT f μ (FinishT f μ a) -> FinishT f μ a #

(Eq f, Eq1 μ, Eq α) => Eq (FinishT f μ α) 

Methods

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

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

(Ord f, Ord1 μ, Ord α) => Ord (FinishT f μ α) 

Methods

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

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

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

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

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

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

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

(Read f, Read1 μ, Read α) => Read (FinishT f μ α) 

Methods

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

readList :: ReadS [FinishT f μ α] #

readPrec :: ReadPrec (FinishT f μ α) #

readListPrec :: ReadPrec [FinishT f μ α] #

(Show f, Show1 μ, Show α) => Show (FinishT f μ α) 

Methods

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

show :: FinishT f μ α -> String #

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

type StT (FinishT f) α 
type StT (FinishT f) α = Either f α
type StM (FinishT e μ) α 
type StM (FinishT e μ) α = ComposeSt (FinishT e) μ α

runFinishT' :: Monad μ => FinishT α μ α -> μ α #

A version of runFinishT for the cases where you don't need to distinguish between short-circuits and regular computation results.