| Safe Haskell | Trustworthy | 
|---|---|
| Language | Haskell2010 | 
Control.Monad.Trans.Chronicle
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.
Synopsis
- type Chronicle c = ChronicleT c Identity
- chronicle :: Monad m => These c a -> ChronicleT c m a
- runChronicle :: Chronicle c a -> These c a
- newtype ChronicleT c m a = ChronicleT {- runChronicleT :: m (These c a)
 
- dictate :: (Semigroup c, Monad m) => c -> ChronicleT c m ()
- disclose :: (Default a, Semigroup c, Monad m) => c -> ChronicleT c m a
- confess :: (Semigroup c, Monad m) => c -> ChronicleT c m a
- memento :: (Semigroup c, Monad m) => ChronicleT c m a -> ChronicleT c m (Either c a)
- absolve :: (Semigroup c, Monad m) => a -> ChronicleT c m a -> ChronicleT c m a
- condemn :: (Semigroup c, Monad m) => ChronicleT c m a -> ChronicleT c m a
- retcon :: (Semigroup 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 <>.
Constructors
| ChronicleT | |
| Fields 
 | |
Instances
Chronicle operations
confess :: (Semigroup c, Monad m) => c -> ChronicleT c m a Source #
confess cc.
Equivalent to throwError for the Error monad.
memento :: (Semigroup c, Monad m) => ChronicleT c m a -> ChronicleT c m (Either c a) Source #
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 :: (Semigroup c, Monad m) => a -> ChronicleT c m a -> ChronicleT c m a Source #
condemn :: (Semigroup c, Monad m) => ChronicleT c m a -> ChronicleT c m a Source #
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 :: (Semigroup c, Monad m) => (c -> c) -> ChronicleT c m a -> ChronicleT c m a Source #