Safe Haskell | Safe |
---|---|
Language | Haskell98 |
This monad transformer extends a monad with the ability to handle multiple terminating cases.
A sequence of actions terminates normally, producing a value, only
if none of the actions in the sequence are Stop
or Failure
. If
one action is Stop
or Failure
, the rest of the sequence is
skipped and the composite action exits with that result.
- newtype ContinueT x m a = ContinueT {
- runContinueT :: m (Continue x a)
- stop :: Applicative m => ContinueT x m a
- failure :: Applicative m => x -> ContinueT x m a
- continue :: Applicative m => a -> ContinueT x m a
- hoistContinue :: Monad m => Continue x a -> ContinueT x m a
- mapContinueT :: (m (Continue x a) -> n (Continue y b)) -> ContinueT x m a -> ContinueT y n b
- bimapContinueT :: Functor m => (x -> y) -> (a -> b) -> ContinueT x m a -> ContinueT y m b
- firstContinueT :: Functor m => (x -> y) -> ContinueT x m a -> ContinueT y m a
- secondContinueT :: Functor m => (a -> b) -> ContinueT x m a -> ContinueT x m b
- mapFailure :: Functor m => (x -> y) -> ContinueT x m a -> ContinueT y m a
- stopFromNothing :: Applicative m => Maybe a -> ContinueT x m a
- hoistEither :: Applicative m => Either x a -> ContinueT x m a
- liftEitherT :: Monad m => ExceptT x m a -> ContinueT x m a
- liftExceptT :: Monad m => ExceptT x m a -> ContinueT x m a
- runToEitherT :: Monad m => ContinueT x m () -> ExceptT x m ()
- runToExceptT :: Monad m => ContinueT x m () -> ExceptT x m ()
ContinueT
newtype ContinueT x m a Source #
A monad transfomer that extends the Continue
monad.
Computations are stopes, failures or normal values.
The return
function returns a normal value, while >>=
exits on
the first stop or failure.
ContinueT | |
|
MonadTrans (ContinueT x) Source # | |
Monad m => Monad (ContinueT x m) Source # | |
Functor m => Functor (ContinueT x m) Source # | |
(Applicative m, Monad m) => Applicative (ContinueT x m) Source # | |
Foldable m => Foldable (ContinueT x m) Source # | |
Traversable m => Traversable (ContinueT x m) Source # | |
MonadIO m => MonadIO (ContinueT x m) Source # | |
stop :: Applicative m => ContinueT x m a Source #
Singal a stop.
failure :: Applicative m => x -> ContinueT x m a Source #
Singal a failure value x
.
runContinueT
(failure
x) =return
(Failure
x)
continue :: Applicative m => a -> ContinueT x m a Source #
Singal a continue value x
.
runContinueT
(continue
x) =return
(Continue
x)
mapContinueT :: (m (Continue x a) -> n (Continue y b)) -> ContinueT x m a -> ContinueT y n b Source #
Map the unwrapped computation using the given function.
runContinueT
(mapContinueT
f m) = f (runContinueT
m)
bimapContinueT :: Functor m => (x -> y) -> (a -> b) -> ContinueT x m a -> ContinueT y m b Source #
Map over both failure and continue.
firstContinueT :: Functor m => (x -> y) -> ContinueT x m a -> ContinueT y m a Source #
Map over failure.
secondContinueT :: Functor m => (a -> b) -> ContinueT x m a -> ContinueT x m b Source #
Map over continue.
stopFromNothing :: Applicative m => Maybe a -> ContinueT x m a Source #
Lift an Maybe
into an ContinueT
runContinueT
(stopFromNothing
Nothing
) =return
Stop
runContinueT
(stopFromNothing
(Just
a)) =return
(Continue
a)
hoistEither :: Applicative m => Either x a -> ContinueT x m a Source #
Lift an Either
into an ContinueT
runContinueT
(hoistEither
(Left
x)) =return
(Failure
x)runContinueT
(hoistEither
(Right
a)) =return
(Continue
a)
EitherT / ExceptT extensions
liftEitherT :: Monad m => ExceptT x m a -> ContinueT x m a Source #
Utility function for EitherT pattern synonym over ExceptT
runToEitherT :: Monad m => ContinueT x m () -> ExceptT x m () Source #
Utility function for EitherT pattern synonym over ExceptT
runToExceptT :: Monad m => ContinueT x m () -> ExceptT x m () Source #
Convert an ContinueT
into an ExceptT
runExceptT
(runToExceptT
(continue
a)) =return
(Right
a)runExceptT
(runToExceptT
(failure
x)) =return
(Left
x)runExceptT
(runToExceptT
stop
) =return
(Right
())