Safe Haskell | Safe |
---|---|
Language | Haskell98 |
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.
- type Chronicle c = ChronicleT c Identity
- chronicle :: These c a -> Chronicle c a
- runChronicle :: Chronicle c a -> These c a
- newtype ChronicleT c m a = ChronicleT {
- runChronicleT :: m (These c a)
- dictate :: (Monoid c, Monad m) => c -> ChronicleT c m ()
- disclose :: (Default a, Monoid c, Monad m) => c -> ChronicleT c m a
- confess :: (Monoid c, Monad m) => c -> ChronicleT c m a
- memento :: (Monoid c, Monad m) => ChronicleT c m a -> ChronicleT c m (Either c a)
- absolve :: (Monoid c, Monad m) => a -> ChronicleT c m a -> ChronicleT c m a
- condemn :: (Monoid c, Monad m) => ChronicleT c m a -> ChronicleT c m a
- retcon :: (Monoid c, Monad m) => (c -> c) -> ChronicleT c m a -> ChronicleT c m a
The Chronicle monad
type Chronicle c = ChronicleT c Identity Source
runChronicle :: Chronicle c a -> These c a Source
The ChronicleT monad transformer
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
.
ChronicleT | |
|
(Monoid c, MonadRWS r w s m) => MonadRWS r w s (ChronicleT c m) Source | |
(Monoid c, MonadError e m) => MonadError e (ChronicleT c m) Source | |
(Monoid c, MonadReader r m) => MonadReader r (ChronicleT c m) Source | |
(Monoid c, MonadState s m) => MonadState s (ChronicleT c m) Source | |
(Monoid c, MonadWriter w m) => MonadWriter w (ChronicleT c m) Source | |
(Monoid c, Monad m) => MonadChronicle c (ChronicleT c m) Source | |
Monoid c => MonadTrans (ChronicleT c) Source | |
(Monoid c, Monad m) => Monad (ChronicleT c m) Source | |
Functor m => Functor (ChronicleT c m) Source | |
(Monoid c, MonadFix m) => MonadFix (ChronicleT c m) Source | |
(Monoid c, Applicative m) => Applicative (ChronicleT c m) Source | |
(Monoid c, Applicative m, Monad m) => Alternative (ChronicleT c m) Source | |
(Monoid c, Monad m) => MonadPlus (ChronicleT c m) Source | |
(Monoid c, MonadIO m) => MonadIO (ChronicleT c m) Source | |
(Monoid c, Apply m) => Apply (ChronicleT c m) Source | |
(Monoid c, Apply m, Monad m) => Bind (ChronicleT c m) Source |
Chronicle operations
dictate :: (Monoid c, Monad m) => c -> ChronicleT c m () Source
confess :: (Monoid c, Monad m) => c -> ChronicleT c m a Source
is an action that ends with a final output confess
cc
.
Equivalent to throwError
for the Error
monad.
memento :: (Monoid c, Monad m) => ChronicleT c m a -> ChronicleT c 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 :: (Monoid c, Monad m) => a -> ChronicleT c m a -> ChronicleT c m a Source
condemn :: (Monoid c, Monad m) => ChronicleT c m a -> ChronicleT c m a Source
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 :: (Monoid c, Monad m) => (c -> c) -> ChronicleT c m a -> ChronicleT c m a Source