monad-chronicle-1.0.0.1: These as a transformer, ChronicleT

Safe HaskellTrustworthy
LanguageHaskell2010

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.

Documentation

class Monad m => MonadChronicle c m | m -> c where Source #

Minimal complete definition

dictate, confess, memento, absolve, condemn, retcon, chronicle

Methods

dictate :: c -> m () Source #

dictate c is an action that records the output c.

Equivalent to tell for the Writer monad.

disclose :: Default a => c -> m a Source #

disclose c is an action that records the output c and returns a Default value.

This is a convenience function for reporting non-fatal errors in one branch a case, or similar scenarios when there is no meaningful result but a placeholder of sorts is needed in order to continue.

confess :: c -> m a Source #

confess c is an action that ends with a final record c.

Equivalent to throwError for the Error monad.

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

memento m is an action that executes the action 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 a Source #

absolve x m is an action that executes the action m and discards any record it had. The default value x will be used if m ended via confess.

condemn :: m a -> m a Source #

condemn m is an action that executes the action 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 a Source #

retcon f m is an action that executes the action m and applies the function f to its output, leaving the return value unchanged.

Equivalent to censor for the Writer monad.

chronicle :: These c a -> m a Source #

chronicle m lifts a plain These c a value into a MonadChronicle instance.

Instances
MonadChronicle c m => MonadChronicle c (MaybeT m) Source # 
Instance details

Defined in Control.Monad.Chronicle.Class

Methods

dictate :: c -> MaybeT m () Source #

disclose :: Default a => c -> MaybeT m a Source #

confess :: c -> MaybeT m a Source #

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

absolve :: a -> MaybeT m a -> MaybeT m a Source #

condemn :: MaybeT m a -> MaybeT m a Source #

retcon :: (c -> c) -> MaybeT m a -> MaybeT m a Source #

chronicle :: These c a -> MaybeT m a Source #

Semigroup c => MonadChronicle c (These c) Source # 
Instance details

Defined in Control.Monad.Chronicle.Class

Methods

dictate :: c -> These c () Source #

disclose :: Default a => c -> These c a Source #

confess :: c -> These c a Source #

memento :: These c a -> These c (Either c a) Source #

absolve :: a -> These c a -> These c a Source #

condemn :: These c a -> These c a Source #

retcon :: (c -> c) -> These c a -> These c a Source #

chronicle :: These c a -> These c a Source #

(Monoid w, MonadChronicle c m) => MonadChronicle c (WriterT w m) Source # 
Instance details

Defined in Control.Monad.Chronicle.Class

Methods

dictate :: c -> WriterT w m () Source #

disclose :: Default a => c -> WriterT w m a Source #

confess :: c -> WriterT w m a Source #

memento :: WriterT w m a -> WriterT w m (Either c a) Source #

absolve :: a -> WriterT w m a -> WriterT w m a Source #

condemn :: WriterT w m a -> WriterT w m a Source #

retcon :: (c -> c) -> WriterT w m a -> WriterT w m a Source #

chronicle :: These c a -> WriterT w m a Source #

(Monoid w, MonadChronicle c m) => MonadChronicle c (WriterT w m) Source # 
Instance details

Defined in Control.Monad.Chronicle.Class

Methods

dictate :: c -> WriterT w m () Source #

disclose :: Default a => c -> WriterT w m a Source #

confess :: c -> WriterT w m a Source #

memento :: WriterT w m a -> WriterT w m (Either c a) Source #

absolve :: a -> WriterT w m a -> WriterT w m a Source #

condemn :: WriterT w m a -> WriterT w m a Source #

retcon :: (c -> c) -> WriterT w m a -> WriterT w m a Source #

chronicle :: These c a -> WriterT w m a Source #

MonadChronicle c m => MonadChronicle c (StateT s m) Source # 
Instance details

Defined in Control.Monad.Chronicle.Class

Methods

dictate :: c -> StateT s m () Source #

disclose :: Default a => c -> StateT s m a Source #

confess :: c -> StateT s m a Source #

memento :: StateT s m a -> StateT s m (Either c a) Source #

absolve :: a -> StateT s m a -> StateT s m a Source #

condemn :: StateT s m a -> StateT s m a Source #

retcon :: (c -> c) -> StateT s m a -> StateT s m a Source #

chronicle :: These c a -> StateT s m a Source #

MonadChronicle c m => MonadChronicle c (StateT s m) Source # 
Instance details

Defined in Control.Monad.Chronicle.Class

Methods

dictate :: c -> StateT s m () Source #

disclose :: Default a => c -> StateT s m a Source #

confess :: c -> StateT s m a Source #

memento :: StateT s m a -> StateT s m (Either c a) Source #

absolve :: a -> StateT s m a -> StateT s m a Source #

condemn :: StateT s m a -> StateT s m a Source #

retcon :: (c -> c) -> StateT s m a -> StateT s m a Source #

chronicle :: These c a -> StateT s m a Source #

MonadChronicle c m => MonadChronicle c (ExceptT e m) Source # 
Instance details

Defined in Control.Monad.Chronicle.Class

Methods

dictate :: c -> ExceptT e m () Source #

disclose :: Default a => c -> ExceptT e m a Source #

confess :: c -> ExceptT e m a Source #

memento :: ExceptT e m a -> ExceptT e m (Either c a) Source #

absolve :: a -> ExceptT e m a -> ExceptT e m a Source #

condemn :: ExceptT e m a -> ExceptT e m a Source #

retcon :: (c -> c) -> ExceptT e m a -> ExceptT e m a Source #

chronicle :: These c a -> ExceptT e m a Source #

(Error e, MonadChronicle c m) => MonadChronicle c (ErrorT e m) Source # 
Instance details

Defined in Control.Monad.Chronicle.Class

Methods

dictate :: c -> ErrorT e m () Source #

disclose :: Default a => c -> ErrorT e m a Source #

confess :: c -> ErrorT e m a Source #

memento :: ErrorT e m a -> ErrorT e m (Either c a) Source #

absolve :: a -> ErrorT e m a -> ErrorT e m a Source #

condemn :: ErrorT e m a -> ErrorT e m a Source #

retcon :: (c -> c) -> ErrorT e m a -> ErrorT e m a Source #

chronicle :: These c a -> ErrorT e m a Source #

MonadChronicle c m => MonadChronicle c (IdentityT m) Source # 
Instance details

Defined in Control.Monad.Chronicle.Class

Methods

dictate :: c -> IdentityT m () Source #

disclose :: Default a => c -> IdentityT m a Source #

confess :: c -> IdentityT m a Source #

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

absolve :: a -> IdentityT m a -> IdentityT m a Source #

condemn :: IdentityT m a -> IdentityT m a Source #

retcon :: (c -> c) -> IdentityT m a -> IdentityT m a Source #

chronicle :: These c a -> IdentityT m a Source #

(Semigroup c, Monad m) => MonadChronicle c (ChronicleT c m) Source # 
Instance details

Defined in Control.Monad.Chronicle.Class

Methods

dictate :: c -> ChronicleT c m () Source #

disclose :: Default a => c -> ChronicleT c m a Source #

confess :: c -> ChronicleT c m a Source #

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

absolve :: a -> ChronicleT c m a -> ChronicleT c m a Source #

condemn :: ChronicleT c m a -> ChronicleT c m a Source #

retcon :: (c -> c) -> ChronicleT c m a -> ChronicleT c m a Source #

chronicle :: These c a -> ChronicleT c m a Source #

MonadChronicle c m => MonadChronicle c (ReaderT r m) Source # 
Instance details

Defined in Control.Monad.Chronicle.Class

Methods

dictate :: c -> ReaderT r m () Source #

disclose :: Default a => c -> ReaderT r m a Source #

confess :: c -> ReaderT r m a Source #

memento :: ReaderT r m a -> ReaderT r m (Either c a) Source #

absolve :: a -> ReaderT r m a -> ReaderT r m a Source #

condemn :: ReaderT r m a -> ReaderT r m a Source #

retcon :: (c -> c) -> ReaderT r m a -> ReaderT r m a Source #

chronicle :: These c a -> ReaderT r m a Source #

(Monoid w, MonadChronicle c m) => MonadChronicle c (RWST r w s m) Source # 
Instance details

Defined in Control.Monad.Chronicle.Class

Methods

dictate :: c -> RWST r w s m () Source #

disclose :: Default a => c -> RWST r w s m a Source #

confess :: c -> RWST r w s m a Source #

memento :: RWST r w s m a -> RWST r w s m (Either c a) Source #

absolve :: a -> RWST r w s m a -> RWST r w s m a Source #

condemn :: RWST r w s m a -> RWST r w s m a Source #

retcon :: (c -> c) -> RWST r w s m a -> RWST r w s m a Source #

chronicle :: These c a -> RWST r w s m a Source #

(Monoid w, MonadChronicle c m) => MonadChronicle c (RWST r w s m) Source # 
Instance details

Defined in Control.Monad.Chronicle.Class

Methods

dictate :: c -> RWST r w s m () Source #

disclose :: Default a => c -> RWST r w s m a Source #

confess :: c -> RWST r w s m a Source #

memento :: RWST r w s m a -> RWST r w s m (Either c a) Source #

absolve :: a -> RWST r w s m a -> RWST r w s m a Source #

condemn :: RWST r w s m a -> RWST r w s m a Source #

retcon :: (c -> c) -> RWST r w s m a -> RWST r w s m a Source #

chronicle :: These c a -> RWST r w s m a Source #