Safe Haskell | None |
---|

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.

# Documentation

class Monad m => MonadChronicle c m | m -> c whereSource

is an action that ends with a final output `confess`

c`c`

.

Equivalent to `throwError`

for the `Error`

monad.

memento :: m a -> m (Either c a)Source

is an action that executes the action `memento`

m`m`

, 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 m`m`

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`

m`m`

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 m`m`

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`

m`MonadChronicle`

instance.

(Monad (MaybeT m), MonadChronicle c m) => MonadChronicle c (MaybeT m) | |

(Monad (IdentityT m), MonadChronicle c m) => MonadChronicle c (IdentityT m) | |

(Monad (These c), Monoid c) => MonadChronicle c (These c) | |

(Monad (WriterT w m), Monoid w, MonadChronicle c m) => MonadChronicle c (WriterT w m) | |

(Monad (WriterT w m), Monoid w, MonadChronicle c m) => MonadChronicle c (WriterT w m) | |

(Monad (StateT s m), Monoid s, MonadChronicle c m) => MonadChronicle c (StateT s m) | |

(Monad (StateT s m), Monoid s, MonadChronicle c m) => MonadChronicle c (StateT s m) | |

(Monad (ReaderT r m), MonadChronicle c m) => MonadChronicle c (ReaderT r m) | |

(Monad (ErrorT e m), Error e, MonadChronicle c m) => MonadChronicle c (ErrorT e m) | |

(Monad (ChronicleT c m), Monoid c, Monad m) => MonadChronicle c (ChronicleT c m) |