| Safe Haskell | Safe-Inferred |
|---|
Control.Monad.Chronicle.Class
Description
Hybrid error/writer monad class that allows both accumulating outputs and aborting computation with a final output.
The expected use case is for computations with a notion of fatal vs. non-fatal errors.
- class Monad m => MonadChronicle c m | m -> c where
- newtype ChronicleT c m a = ChronicleT {
- runChronicleT :: m (These c a)
- runChronicle :: Chronicle c a -> These c a
Documentation
class Monad m => MonadChronicle c m | m -> c whereSource
Methods
is an action that ends with a final output confess cc.
Equivalent to throwError for the Error monad.
memento :: m a -> m (Either c a)Source
is an action that executes the action memento mm, returning either
its record if it ended with confess, or its final value otherwise, with
any record added to the current record.
Similar to catchError in the Error monad, but with a notion of
non-fatal errors (which are accumulated) vs. fatal errors (which are caught
without accumulating).
absolve :: a -> m a -> m aSource
is an action that executes the action absolve x mm and discards any
record it had. The default value x will be used if m ended via
confess.
is an action that executes the action condemn mm and keeps its value
only if it had no record. Otherwise, the value (if any) will be discarded
and only the record kept.
This can be seen as converting non-fatal errors into fatal ones.
retcon :: (c -> c) -> m a -> m aSource
is an action that executes the action retcon f mm and applies the
function f to its output, leaving the return value unchanged.
chronicle :: These c a -> m aSource
lifts a plain 'These c a' value into a chronicle mMonadChronicle instance.
Instances
| MonadChronicle c m => MonadChronicle c (MaybeT m) | |
| MonadChronicle c m => MonadChronicle c (IdentityT m) | |
| Monoid c => MonadChronicle c (These c) | |
| (Monoid w, MonadChronicle c m) => MonadChronicle c (WriterT w m) | |
| (Monoid w, MonadChronicle c m) => MonadChronicle c (WriterT w m) | |
| MonadChronicle c m => MonadChronicle c (StateT s m) | |
| MonadChronicle c m => MonadChronicle c (StateT s m) | |
| MonadChronicle c m => MonadChronicle c (ReaderT r m) | |
| (Error e, MonadChronicle c m) => MonadChronicle c (ErrorT e m) | |
| (Monoid c, Monad m) => MonadChronicle c (ChronicleT c m) | |
| (Monoid w, MonadChronicle c m) => MonadChronicle c (RWST r w s m) | |
| (Monoid w, MonadChronicle c m) => MonadChronicle c (RWST r w s m) |
newtype ChronicleT c m a Source
The ChronicleT monad transformer.
The return function produces a computation with no output, and >>=
combines multiple outputs with mappend.
Constructors
| ChronicleT | |
Fields
| |
Instances
| (Monoid c, MonadRWS r w s m) => MonadRWS r w s (ChronicleT c m) | |
| (Monoid c, MonadError e m) => MonadError e (ChronicleT c m) | |
| (Monoid c, MonadReader r m) => MonadReader r (ChronicleT c m) | |
| (Monoid c, MonadState s m) => MonadState s (ChronicleT c m) | |
| (Monoid c, MonadWriter w m) => MonadWriter w (ChronicleT c m) | |
| (Monoid c, Monad m) => MonadChronicle c (ChronicleT c m) | |
| Monoid c => MonadTrans (ChronicleT c) | |
| (Monoid c, Monad m) => Monad (ChronicleT c m) | |
| Functor m => Functor (ChronicleT c m) | |
| (Monoid c, Monad m) => MonadPlus (ChronicleT c m) | |
| (Monoid c, Applicative m) => Applicative (ChronicleT c m) | |
| (Monoid c, Applicative m, Monad m) => Alternative (ChronicleT c m) | |
| (Monoid c, MonadIO m) => MonadIO (ChronicleT c m) | |
| (Monoid c, Apply m) => Apply (ChronicleT c m) | |
| (Monoid c, Apply m, Monad m) => Bind (ChronicleT c m) |
runChronicle :: Chronicle c a -> These c aSource