| Safe Haskell | Safe |
|---|---|
| Language | Haskell98 |
Control.Monad.Trans.Continue
Description
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.
Constructors
| ContinueT | |
Fields
| |
Instances
| 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(failurex) =return(Failurex)
continue :: Applicative m => a -> ContinueT x m a Source #
Singal a continue value x.
runContinueT(continuex) =return(Continuex)
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(mapContinueTf m) = f (runContinueTm)
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(stopFromNothingNothing) =returnStoprunContinueT(stopFromNothing(Justa)) =return(Continuea)
hoistEither :: Applicative m => Either x a -> ContinueT x m a Source #
Lift an Either into an ContinueT
runContinueT(hoistEither(Leftx)) =return(Failurex)runContinueT(hoistEither(Righta)) =return(Continuea)
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(continuea)) =return(Righta)runExceptT(runToExceptT(failurex)) =return(Leftx)runExceptT(runToExceptTstop) =return(Right())