{-# LANGUAGE CPP #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE Trustworthy #-}
{-# LANGUAGE UndecidableInstances #-}
{-# OPTIONS_GHC -fno-warn-warnings-deprecations #-}
module Control.Monad.Chronicle.Class (
MonadChronicle(..),
) where
import Control.Applicative
import Control.Monad.Trans.Chronicle (ChronicleT)
import qualified Control.Monad.Trans.Chronicle as Ch
import Data.These
import Data.These.Combinators
import Control.Monad.Trans.Except as Except
import Control.Monad.Trans.Identity as Identity
import Control.Monad.Trans.Maybe as Maybe
import Control.Monad.Trans.RWS.Lazy as LazyRWS
import Control.Monad.Trans.RWS.Strict as StrictRWS
import Control.Monad.Trans.Reader as Reader
import Control.Monad.Trans.State.Lazy as LazyState
import Control.Monad.Trans.State.Strict as StrictState
import Control.Monad.Trans.Writer.Lazy as LazyWriter
import Control.Monad.Trans.Writer.Strict as StrictWriter
#if !(MIN_VERSION_transformers(0,6,0))
import Control.Monad.Trans.Error as Error
#endif
import Control.Monad (liftM)
import Control.Monad.Trans.Class (lift)
import Data.Default.Class
import Data.Semigroup
import Prelude
class (Monad m) => MonadChronicle c m | m -> c where
dictate :: c -> m ()
disclose :: (Default a) => c -> m a
disclose c
c = c -> m ()
forall c (m :: * -> *). MonadChronicle c m => c -> m ()
dictate c
c m () -> m a -> m a
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return a
forall a. Default a => a
def
confess :: c -> m a
memento :: m a -> m (Either c a)
absolve :: a -> m a -> m a
condemn :: m a -> m a
retcon :: (c -> c) -> m a -> m a
chronicle :: These c a -> m a
instance (Semigroup c) => MonadChronicle c (These c) where
dictate :: c -> These c ()
dictate c
c = c -> () -> These c ()
forall a b. a -> b -> These a b
These c
c ()
confess :: c -> These c a
confess c
c = c -> These c a
forall a b. a -> These a b
This c
c
memento :: These c a -> These c (Either c a)
memento (This c
c) = Either c a -> These c (Either c a)
forall a b. b -> These a b
That (c -> Either c a
forall a b. a -> Either a b
Left c
c)
memento These c a
m = (a -> Either c a) -> These c a -> These c (Either c a)
forall b d a. (b -> d) -> These a b -> These a d
mapThere a -> Either c a
forall a b. b -> Either a b
Right These c a
m
absolve :: a -> These c a -> These c a
absolve a
x (This c
_) = a -> These c a
forall a b. b -> These a b
That a
x
absolve a
_ (That a
x) = a -> These c a
forall a b. b -> These a b
That a
x
absolve a
_ (These c
_ a
x) = a -> These c a
forall a b. b -> These a b
That a
x
condemn :: These c a -> These c a
condemn (These c
c a
_) = c -> These c a
forall a b. a -> These a b
This c
c
condemn These c a
m = These c a
m
retcon :: (c -> c) -> These c a -> These c a
retcon = (c -> c) -> These c a -> These c a
forall a c b. (a -> c) -> These a b -> These c b
mapHere
chronicle :: These c a -> These c a
chronicle = These c a -> These c a
forall a. a -> a
id
instance (Semigroup c, Monad m) => MonadChronicle c (ChronicleT c m) where
dictate :: c -> ChronicleT c m ()
dictate = c -> ChronicleT c m ()
forall c (m :: * -> *).
(Semigroup c, Monad m) =>
c -> ChronicleT c m ()
Ch.dictate
confess :: c -> ChronicleT c m a
confess = c -> ChronicleT c m a
forall c (m :: * -> *) a.
(Semigroup c, Monad m) =>
c -> ChronicleT c m a
Ch.confess
memento :: ChronicleT c m a -> ChronicleT c m (Either c a)
memento = ChronicleT c m a -> ChronicleT c m (Either c a)
forall c (m :: * -> *) a.
(Semigroup c, Monad m) =>
ChronicleT c m a -> ChronicleT c m (Either c a)
Ch.memento
absolve :: a -> ChronicleT c m a -> ChronicleT c m a
absolve = a -> ChronicleT c m a -> ChronicleT c m a
forall c (m :: * -> *) a.
(Semigroup c, Monad m) =>
a -> ChronicleT c m a -> ChronicleT c m a
Ch.absolve
condemn :: ChronicleT c m a -> ChronicleT c m a
condemn = ChronicleT c m a -> ChronicleT c m a
forall c (m :: * -> *) a.
(Semigroup c, Monad m) =>
ChronicleT c m a -> ChronicleT c m a
Ch.condemn
retcon :: (c -> c) -> ChronicleT c m a -> ChronicleT c m a
retcon = (c -> c) -> ChronicleT c m a -> ChronicleT c m a
forall c (m :: * -> *) a.
(Semigroup c, Monad m) =>
(c -> c) -> ChronicleT c m a -> ChronicleT c m a
Ch.retcon
chronicle :: These c a -> ChronicleT c m a
chronicle = m (These c a) -> ChronicleT c m a
forall c (m :: * -> *) a. m (These c a) -> ChronicleT c m a
Ch.ChronicleT (m (These c a) -> ChronicleT c m a)
-> (These c a -> m (These c a)) -> These c a -> ChronicleT c m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. These c a -> m (These c a)
forall (m :: * -> *) a. Monad m => a -> m a
return
instance (MonadChronicle c m) => MonadChronicle c (IdentityT m) where
dictate :: c -> IdentityT m ()
dictate = m () -> IdentityT m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> IdentityT m ()) -> (c -> m ()) -> c -> IdentityT m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. c -> m ()
forall c (m :: * -> *). MonadChronicle c m => c -> m ()
dictate
confess :: c -> IdentityT m a
confess = m a -> IdentityT m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> IdentityT m a) -> (c -> m a) -> c -> IdentityT m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. c -> m a
forall c (m :: * -> *) a. MonadChronicle c m => c -> m a
confess
memento :: IdentityT m a -> IdentityT m (Either c a)
memento (IdentityT m a
m) = m (Either c a) -> IdentityT m (Either c a)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Either c a) -> IdentityT m (Either c a))
-> m (Either c a) -> IdentityT m (Either c a)
forall a b. (a -> b) -> a -> b
$ m a -> m (Either c a)
forall c (m :: * -> *) a.
MonadChronicle c m =>
m a -> m (Either c a)
memento m a
m
absolve :: a -> IdentityT m a -> IdentityT m a
absolve a
x (IdentityT m a
m) = m a -> IdentityT m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> IdentityT m a) -> m a -> IdentityT m a
forall a b. (a -> b) -> a -> b
$ a -> m a -> m a
forall c (m :: * -> *) a. MonadChronicle c m => a -> m a -> m a
absolve a
x m a
m
condemn :: IdentityT m a -> IdentityT m a
condemn (IdentityT m a
m) = m a -> IdentityT m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> IdentityT m a) -> m a -> IdentityT m a
forall a b. (a -> b) -> a -> b
$ m a -> m a
forall c (m :: * -> *) a. MonadChronicle c m => m a -> m a
condemn m a
m
retcon :: (c -> c) -> IdentityT m a -> IdentityT m a
retcon c -> c
f (IdentityT m a
m) = m a -> IdentityT m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> IdentityT m a) -> m a -> IdentityT m a
forall a b. (a -> b) -> a -> b
$ (c -> c) -> m a -> m a
forall c (m :: * -> *) a.
MonadChronicle c m =>
(c -> c) -> m a -> m a
retcon c -> c
f m a
m
chronicle :: These c a -> IdentityT m a
chronicle = m a -> IdentityT m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> IdentityT m a)
-> (These c a -> m a) -> These c a -> IdentityT m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. These c a -> m a
forall c (m :: * -> *) a. MonadChronicle c m => These c a -> m a
chronicle
instance (MonadChronicle c m) => MonadChronicle c (MaybeT m) where
dictate :: c -> MaybeT m ()
dictate = m () -> MaybeT m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> MaybeT m ()) -> (c -> m ()) -> c -> MaybeT m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. c -> m ()
forall c (m :: * -> *). MonadChronicle c m => c -> m ()
dictate
confess :: c -> MaybeT m a
confess = m a -> MaybeT m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> MaybeT m a) -> (c -> m a) -> c -> MaybeT m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. c -> m a
forall c (m :: * -> *) a. MonadChronicle c m => c -> m a
confess
memento :: MaybeT m a -> MaybeT m (Either c a)
memento (MaybeT m (Maybe a)
m) = m (Maybe (Either c a)) -> MaybeT m (Either c a)
forall (m :: * -> *) a. m (Maybe a) -> MaybeT m a
MaybeT (m (Maybe (Either c a)) -> MaybeT m (Either c a))
-> m (Maybe (Either c a)) -> MaybeT m (Either c a)
forall a b. (a -> b) -> a -> b
$ (c -> Maybe (Either c a))
-> (Maybe a -> Maybe (Either c a))
-> Either c (Maybe a)
-> Maybe (Either c a)
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (Either c a -> Maybe (Either c a)
forall a. a -> Maybe a
Just (Either c a -> Maybe (Either c a))
-> (c -> Either c a) -> c -> Maybe (Either c a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. c -> Either c a
forall a b. a -> Either a b
Left) (a -> Either c a
forall a b. b -> Either a b
Right (a -> Either c a) -> Maybe a -> Maybe (Either c a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>) (Either c (Maybe a) -> Maybe (Either c a))
-> m (Either c (Maybe a)) -> m (Maybe (Either c a))
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
`liftM` m (Maybe a) -> m (Either c (Maybe a))
forall c (m :: * -> *) a.
MonadChronicle c m =>
m a -> m (Either c a)
memento m (Maybe a)
m
absolve :: a -> MaybeT m a -> MaybeT m a
absolve a
x (MaybeT m (Maybe a)
m) = m (Maybe a) -> MaybeT m a
forall (m :: * -> *) a. m (Maybe a) -> MaybeT m a
MaybeT (m (Maybe a) -> MaybeT m a) -> m (Maybe a) -> MaybeT m a
forall a b. (a -> b) -> a -> b
$ Maybe a -> m (Maybe a) -> m (Maybe a)
forall c (m :: * -> *) a. MonadChronicle c m => a -> m a -> m a
absolve (a -> Maybe a
forall a. a -> Maybe a
Just a
x) m (Maybe a)
m
condemn :: MaybeT m a -> MaybeT m a
condemn (MaybeT m (Maybe a)
m) = m (Maybe a) -> MaybeT m a
forall (m :: * -> *) a. m (Maybe a) -> MaybeT m a
MaybeT (m (Maybe a) -> MaybeT m a) -> m (Maybe a) -> MaybeT m a
forall a b. (a -> b) -> a -> b
$ m (Maybe a) -> m (Maybe a)
forall c (m :: * -> *) a. MonadChronicle c m => m a -> m a
condemn m (Maybe a)
m
retcon :: (c -> c) -> MaybeT m a -> MaybeT m a
retcon c -> c
f (MaybeT m (Maybe a)
m) = m (Maybe a) -> MaybeT m a
forall (m :: * -> *) a. m (Maybe a) -> MaybeT m a
MaybeT (m (Maybe a) -> MaybeT m a) -> m (Maybe a) -> MaybeT m a
forall a b. (a -> b) -> a -> b
$ (c -> c) -> m (Maybe a) -> m (Maybe a)
forall c (m :: * -> *) a.
MonadChronicle c m =>
(c -> c) -> m a -> m a
retcon c -> c
f m (Maybe a)
m
chronicle :: These c a -> MaybeT m a
chronicle = m a -> MaybeT m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> MaybeT m a)
-> (These c a -> m a) -> These c a -> MaybeT m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. These c a -> m a
forall c (m :: * -> *) a. MonadChronicle c m => These c a -> m a
chronicle
#if !(MIN_VERSION_transformers(0,6,0))
instance (Error e, MonadChronicle c m) => MonadChronicle c (ErrorT e m) where
dictate :: c -> ErrorT e m ()
dictate = m () -> ErrorT e m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> ErrorT e m ()) -> (c -> m ()) -> c -> ErrorT e m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. c -> m ()
forall c (m :: * -> *). MonadChronicle c m => c -> m ()
dictate
confess :: c -> ErrorT e m a
confess = m a -> ErrorT e m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> ErrorT e m a) -> (c -> m a) -> c -> ErrorT e m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. c -> m a
forall c (m :: * -> *) a. MonadChronicle c m => c -> m a
confess
memento :: ErrorT e m a -> ErrorT e m (Either c a)
memento (ErrorT m (Either e a)
m) = m (Either e (Either c a)) -> ErrorT e m (Either c a)
forall e (m :: * -> *) a. m (Either e a) -> ErrorT e m a
ErrorT (m (Either e (Either c a)) -> ErrorT e m (Either c a))
-> m (Either e (Either c a)) -> ErrorT e m (Either c a)
forall a b. (a -> b) -> a -> b
$ (c -> Either e (Either c a))
-> (Either e a -> Either e (Either c a))
-> Either c (Either e a)
-> Either e (Either c a)
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (Either c a -> Either e (Either c a)
forall a b. b -> Either a b
Right (Either c a -> Either e (Either c a))
-> (c -> Either c a) -> c -> Either e (Either c a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. c -> Either c a
forall a b. a -> Either a b
Left) (a -> Either c a
forall a b. b -> Either a b
Right (a -> Either c a) -> Either e a -> Either e (Either c a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>) (Either c (Either e a) -> Either e (Either c a))
-> m (Either c (Either e a)) -> m (Either e (Either c a))
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
`liftM` m (Either e a) -> m (Either c (Either e a))
forall c (m :: * -> *) a.
MonadChronicle c m =>
m a -> m (Either c a)
memento m (Either e a)
m
absolve :: a -> ErrorT e m a -> ErrorT e m a
absolve a
x (ErrorT m (Either e a)
m) = m (Either e a) -> ErrorT e m a
forall e (m :: * -> *) a. m (Either e a) -> ErrorT e m a
ErrorT (m (Either e a) -> ErrorT e m a) -> m (Either e a) -> ErrorT e m a
forall a b. (a -> b) -> a -> b
$ Either e a -> m (Either e a) -> m (Either e a)
forall c (m :: * -> *) a. MonadChronicle c m => a -> m a -> m a
absolve (a -> Either e a
forall a b. b -> Either a b
Right a
x) m (Either e a)
m
condemn :: ErrorT e m a -> ErrorT e m a
condemn (ErrorT m (Either e a)
m) = m (Either e a) -> ErrorT e m a
forall e (m :: * -> *) a. m (Either e a) -> ErrorT e m a
ErrorT (m (Either e a) -> ErrorT e m a) -> m (Either e a) -> ErrorT e m a
forall a b. (a -> b) -> a -> b
$ m (Either e a) -> m (Either e a)
forall c (m :: * -> *) a. MonadChronicle c m => m a -> m a
condemn m (Either e a)
m
retcon :: (c -> c) -> ErrorT e m a -> ErrorT e m a
retcon c -> c
f (ErrorT m (Either e a)
m) = m (Either e a) -> ErrorT e m a
forall e (m :: * -> *) a. m (Either e a) -> ErrorT e m a
ErrorT (m (Either e a) -> ErrorT e m a) -> m (Either e a) -> ErrorT e m a
forall a b. (a -> b) -> a -> b
$ (c -> c) -> m (Either e a) -> m (Either e a)
forall c (m :: * -> *) a.
MonadChronicle c m =>
(c -> c) -> m a -> m a
retcon c -> c
f m (Either e a)
m
chronicle :: These c a -> ErrorT e m a
chronicle = m a -> ErrorT e m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> ErrorT e m a)
-> (These c a -> m a) -> These c a -> ErrorT e m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. These c a -> m a
forall c (m :: * -> *) a. MonadChronicle c m => These c a -> m a
chronicle
#endif
instance (MonadChronicle c m) => MonadChronicle c (ExceptT e m) where
dictate :: c -> ExceptT e m ()
dictate = m () -> ExceptT e m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> ExceptT e m ()) -> (c -> m ()) -> c -> ExceptT e m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. c -> m ()
forall c (m :: * -> *). MonadChronicle c m => c -> m ()
dictate
confess :: c -> ExceptT e m a
confess = m a -> ExceptT e m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> ExceptT e m a) -> (c -> m a) -> c -> ExceptT e m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. c -> m a
forall c (m :: * -> *) a. MonadChronicle c m => c -> m a
confess
memento :: ExceptT e m a -> ExceptT e m (Either c a)
memento (ExceptT m (Either e a)
m) = m (Either e (Either c a)) -> ExceptT e m (Either c a)
forall e (m :: * -> *) a. m (Either e a) -> ExceptT e m a
ExceptT (m (Either e (Either c a)) -> ExceptT e m (Either c a))
-> m (Either e (Either c a)) -> ExceptT e m (Either c a)
forall a b. (a -> b) -> a -> b
$ (c -> Either e (Either c a))
-> (Either e a -> Either e (Either c a))
-> Either c (Either e a)
-> Either e (Either c a)
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (Either c a -> Either e (Either c a)
forall a b. b -> Either a b
Right (Either c a -> Either e (Either c a))
-> (c -> Either c a) -> c -> Either e (Either c a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. c -> Either c a
forall a b. a -> Either a b
Left) (a -> Either c a
forall a b. b -> Either a b
Right (a -> Either c a) -> Either e a -> Either e (Either c a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>) (Either c (Either e a) -> Either e (Either c a))
-> m (Either c (Either e a)) -> m (Either e (Either c a))
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
`liftM` m (Either e a) -> m (Either c (Either e a))
forall c (m :: * -> *) a.
MonadChronicle c m =>
m a -> m (Either c a)
memento m (Either e a)
m
absolve :: a -> ExceptT e m a -> ExceptT e m a
absolve a
x (ExceptT m (Either e a)
m) = m (Either e a) -> ExceptT e m a
forall e (m :: * -> *) a. m (Either e a) -> ExceptT e m a
ExceptT (m (Either e a) -> ExceptT e m a)
-> m (Either e a) -> ExceptT e m a
forall a b. (a -> b) -> a -> b
$ Either e a -> m (Either e a) -> m (Either e a)
forall c (m :: * -> *) a. MonadChronicle c m => a -> m a -> m a
absolve (a -> Either e a
forall a b. b -> Either a b
Right a
x) m (Either e a)
m
condemn :: ExceptT e m a -> ExceptT e m a
condemn (ExceptT m (Either e a)
m) = m (Either e a) -> ExceptT e m a
forall e (m :: * -> *) a. m (Either e a) -> ExceptT e m a
ExceptT (m (Either e a) -> ExceptT e m a)
-> m (Either e a) -> ExceptT e m a
forall a b. (a -> b) -> a -> b
$ m (Either e a) -> m (Either e a)
forall c (m :: * -> *) a. MonadChronicle c m => m a -> m a
condemn m (Either e a)
m
retcon :: (c -> c) -> ExceptT e m a -> ExceptT e m a
retcon c -> c
f (ExceptT m (Either e a)
m) = m (Either e a) -> ExceptT e m a
forall e (m :: * -> *) a. m (Either e a) -> ExceptT e m a
ExceptT (m (Either e a) -> ExceptT e m a)
-> m (Either e a) -> ExceptT e m a
forall a b. (a -> b) -> a -> b
$ (c -> c) -> m (Either e a) -> m (Either e a)
forall c (m :: * -> *) a.
MonadChronicle c m =>
(c -> c) -> m a -> m a
retcon c -> c
f m (Either e a)
m
chronicle :: These c a -> ExceptT e m a
chronicle = m a -> ExceptT e m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> ExceptT e m a)
-> (These c a -> m a) -> These c a -> ExceptT e m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. These c a -> m a
forall c (m :: * -> *) a. MonadChronicle c m => These c a -> m a
chronicle
instance (MonadChronicle c m) => MonadChronicle c (ReaderT r m) where
dictate :: c -> ReaderT r m ()
dictate = m () -> ReaderT r m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> ReaderT r m ()) -> (c -> m ()) -> c -> ReaderT r m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. c -> m ()
forall c (m :: * -> *). MonadChronicle c m => c -> m ()
dictate
confess :: c -> ReaderT r m a
confess = m a -> ReaderT r m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> ReaderT r m a) -> (c -> m a) -> c -> ReaderT r m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. c -> m a
forall c (m :: * -> *) a. MonadChronicle c m => c -> m a
confess
memento :: ReaderT r m a -> ReaderT r m (Either c a)
memento (ReaderT r -> m a
m) = (r -> m (Either c a)) -> ReaderT r m (Either c a)
forall r (m :: * -> *) a. (r -> m a) -> ReaderT r m a
ReaderT ((r -> m (Either c a)) -> ReaderT r m (Either c a))
-> (r -> m (Either c a)) -> ReaderT r m (Either c a)
forall a b. (a -> b) -> a -> b
$ m a -> m (Either c a)
forall c (m :: * -> *) a.
MonadChronicle c m =>
m a -> m (Either c a)
memento (m a -> m (Either c a)) -> (r -> m a) -> r -> m (Either c a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. r -> m a
m
absolve :: a -> ReaderT r m a -> ReaderT r m a
absolve a
x (ReaderT r -> m a
m) = (r -> m a) -> ReaderT r m a
forall r (m :: * -> *) a. (r -> m a) -> ReaderT r m a
ReaderT ((r -> m a) -> ReaderT r m a) -> (r -> m a) -> ReaderT r m a
forall a b. (a -> b) -> a -> b
$ a -> m a -> m a
forall c (m :: * -> *) a. MonadChronicle c m => a -> m a -> m a
absolve a
x (m a -> m a) -> (r -> m a) -> r -> m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. r -> m a
m
condemn :: ReaderT r m a -> ReaderT r m a
condemn (ReaderT r -> m a
m) = (r -> m a) -> ReaderT r m a
forall r (m :: * -> *) a. (r -> m a) -> ReaderT r m a
ReaderT ((r -> m a) -> ReaderT r m a) -> (r -> m a) -> ReaderT r m a
forall a b. (a -> b) -> a -> b
$ m a -> m a
forall c (m :: * -> *) a. MonadChronicle c m => m a -> m a
condemn (m a -> m a) -> (r -> m a) -> r -> m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. r -> m a
m
retcon :: (c -> c) -> ReaderT r m a -> ReaderT r m a
retcon c -> c
f (ReaderT r -> m a
m) = (r -> m a) -> ReaderT r m a
forall r (m :: * -> *) a. (r -> m a) -> ReaderT r m a
ReaderT ((r -> m a) -> ReaderT r m a) -> (r -> m a) -> ReaderT r m a
forall a b. (a -> b) -> a -> b
$ (c -> c) -> m a -> m a
forall c (m :: * -> *) a.
MonadChronicle c m =>
(c -> c) -> m a -> m a
retcon c -> c
f (m a -> m a) -> (r -> m a) -> r -> m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. r -> m a
m
chronicle :: These c a -> ReaderT r m a
chronicle = m a -> ReaderT r m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> ReaderT r m a)
-> (These c a -> m a) -> These c a -> ReaderT r m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. These c a -> m a
forall c (m :: * -> *) a. MonadChronicle c m => These c a -> m a
chronicle
instance (MonadChronicle c m) => MonadChronicle c (LazyState.StateT s m) where
dictate :: c -> StateT s m ()
dictate = m () -> StateT s m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> StateT s m ()) -> (c -> m ()) -> c -> StateT s m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. c -> m ()
forall c (m :: * -> *). MonadChronicle c m => c -> m ()
dictate
confess :: c -> StateT s m a
confess = m a -> StateT s m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> StateT s m a) -> (c -> m a) -> c -> StateT s m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. c -> m a
forall c (m :: * -> *) a. MonadChronicle c m => c -> m a
confess
memento :: StateT s m a -> StateT s m (Either c a)
memento (LazyState.StateT s -> m (a, s)
m) = (s -> m (Either c a, s)) -> StateT s m (Either c a)
forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
LazyState.StateT ((s -> m (Either c a, s)) -> StateT s m (Either c a))
-> (s -> m (Either c a, s)) -> StateT s m (Either c a)
forall a b. (a -> b) -> a -> b
$ \s
s -> do
(c -> (Either c a, s))
-> ((a, s) -> (Either c a, s))
-> Either c (a, s)
-> (Either c a, s)
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (\c
c -> (c -> Either c a
forall a b. a -> Either a b
Left c
c, s
s)) (\(a
a, s
s') -> (a -> Either c a
forall a b. b -> Either a b
Right a
a, s
s')) (Either c (a, s) -> (Either c a, s))
-> m (Either c (a, s)) -> m (Either c a, s)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
`liftM` m (a, s) -> m (Either c (a, s))
forall c (m :: * -> *) a.
MonadChronicle c m =>
m a -> m (Either c a)
memento (s -> m (a, s)
m s
s)
absolve :: a -> StateT s m a -> StateT s m a
absolve a
x (LazyState.StateT s -> m (a, s)
m) = (s -> m (a, s)) -> StateT s m a
forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
LazyState.StateT ((s -> m (a, s)) -> StateT s m a)
-> (s -> m (a, s)) -> StateT s m a
forall a b. (a -> b) -> a -> b
$ \s
s -> (a, s) -> m (a, s) -> m (a, s)
forall c (m :: * -> *) a. MonadChronicle c m => a -> m a -> m a
absolve (a
x, s
s) (m (a, s) -> m (a, s)) -> m (a, s) -> m (a, s)
forall a b. (a -> b) -> a -> b
$ s -> m (a, s)
m s
s
condemn :: StateT s m a -> StateT s m a
condemn (LazyState.StateT s -> m (a, s)
m) = (s -> m (a, s)) -> StateT s m a
forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
LazyState.StateT ((s -> m (a, s)) -> StateT s m a)
-> (s -> m (a, s)) -> StateT s m a
forall a b. (a -> b) -> a -> b
$ m (a, s) -> m (a, s)
forall c (m :: * -> *) a. MonadChronicle c m => m a -> m a
condemn (m (a, s) -> m (a, s)) -> (s -> m (a, s)) -> s -> m (a, s)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. s -> m (a, s)
m
retcon :: (c -> c) -> StateT s m a -> StateT s m a
retcon c -> c
f (LazyState.StateT s -> m (a, s)
m) = (s -> m (a, s)) -> StateT s m a
forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
LazyState.StateT ((s -> m (a, s)) -> StateT s m a)
-> (s -> m (a, s)) -> StateT s m a
forall a b. (a -> b) -> a -> b
$ (c -> c) -> m (a, s) -> m (a, s)
forall c (m :: * -> *) a.
MonadChronicle c m =>
(c -> c) -> m a -> m a
retcon c -> c
f (m (a, s) -> m (a, s)) -> (s -> m (a, s)) -> s -> m (a, s)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. s -> m (a, s)
m
chronicle :: These c a -> StateT s m a
chronicle = m a -> StateT s m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> StateT s m a)
-> (These c a -> m a) -> These c a -> StateT s m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. These c a -> m a
forall c (m :: * -> *) a. MonadChronicle c m => These c a -> m a
chronicle
instance (MonadChronicle c m) => MonadChronicle c (StrictState.StateT s m) where
dictate :: c -> StateT s m ()
dictate = m () -> StateT s m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> StateT s m ()) -> (c -> m ()) -> c -> StateT s m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. c -> m ()
forall c (m :: * -> *). MonadChronicle c m => c -> m ()
dictate
confess :: c -> StateT s m a
confess = m a -> StateT s m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> StateT s m a) -> (c -> m a) -> c -> StateT s m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. c -> m a
forall c (m :: * -> *) a. MonadChronicle c m => c -> m a
confess
memento :: StateT s m a -> StateT s m (Either c a)
memento (StrictState.StateT s -> m (a, s)
m) = (s -> m (Either c a, s)) -> StateT s m (Either c a)
forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
StrictState.StateT ((s -> m (Either c a, s)) -> StateT s m (Either c a))
-> (s -> m (Either c a, s)) -> StateT s m (Either c a)
forall a b. (a -> b) -> a -> b
$ \s
s -> do
(c -> (Either c a, s))
-> ((a, s) -> (Either c a, s))
-> Either c (a, s)
-> (Either c a, s)
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (\c
c -> (c -> Either c a
forall a b. a -> Either a b
Left c
c, s
s)) (\(a
a, s
s') -> (a -> Either c a
forall a b. b -> Either a b
Right a
a, s
s')) (Either c (a, s) -> (Either c a, s))
-> m (Either c (a, s)) -> m (Either c a, s)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
`liftM` m (a, s) -> m (Either c (a, s))
forall c (m :: * -> *) a.
MonadChronicle c m =>
m a -> m (Either c a)
memento (s -> m (a, s)
m s
s)
absolve :: a -> StateT s m a -> StateT s m a
absolve a
x (StrictState.StateT s -> m (a, s)
m) = (s -> m (a, s)) -> StateT s m a
forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
StrictState.StateT ((s -> m (a, s)) -> StateT s m a)
-> (s -> m (a, s)) -> StateT s m a
forall a b. (a -> b) -> a -> b
$ \s
s -> (a, s) -> m (a, s) -> m (a, s)
forall c (m :: * -> *) a. MonadChronicle c m => a -> m a -> m a
absolve (a
x, s
s) (m (a, s) -> m (a, s)) -> m (a, s) -> m (a, s)
forall a b. (a -> b) -> a -> b
$ s -> m (a, s)
m s
s
condemn :: StateT s m a -> StateT s m a
condemn (StrictState.StateT s -> m (a, s)
m) = (s -> m (a, s)) -> StateT s m a
forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
StrictState.StateT ((s -> m (a, s)) -> StateT s m a)
-> (s -> m (a, s)) -> StateT s m a
forall a b. (a -> b) -> a -> b
$ m (a, s) -> m (a, s)
forall c (m :: * -> *) a. MonadChronicle c m => m a -> m a
condemn (m (a, s) -> m (a, s)) -> (s -> m (a, s)) -> s -> m (a, s)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. s -> m (a, s)
m
retcon :: (c -> c) -> StateT s m a -> StateT s m a
retcon c -> c
f (StrictState.StateT s -> m (a, s)
m) = (s -> m (a, s)) -> StateT s m a
forall s (m :: * -> *) a. (s -> m (a, s)) -> StateT s m a
StrictState.StateT ((s -> m (a, s)) -> StateT s m a)
-> (s -> m (a, s)) -> StateT s m a
forall a b. (a -> b) -> a -> b
$ (c -> c) -> m (a, s) -> m (a, s)
forall c (m :: * -> *) a.
MonadChronicle c m =>
(c -> c) -> m a -> m a
retcon c -> c
f (m (a, s) -> m (a, s)) -> (s -> m (a, s)) -> s -> m (a, s)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. s -> m (a, s)
m
chronicle :: These c a -> StateT s m a
chronicle = m a -> StateT s m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> StateT s m a)
-> (These c a -> m a) -> These c a -> StateT s m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. These c a -> m a
forall c (m :: * -> *) a. MonadChronicle c m => These c a -> m a
chronicle
instance (Monoid w, MonadChronicle c m) => MonadChronicle c (LazyWriter.WriterT w m) where
dictate :: c -> WriterT w m ()
dictate = m () -> WriterT w m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> WriterT w m ()) -> (c -> m ()) -> c -> WriterT w m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. c -> m ()
forall c (m :: * -> *). MonadChronicle c m => c -> m ()
dictate
confess :: c -> WriterT w m a
confess = m a -> WriterT w m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> WriterT w m a) -> (c -> m a) -> c -> WriterT w m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. c -> m a
forall c (m :: * -> *) a. MonadChronicle c m => c -> m a
confess
memento :: WriterT w m a -> WriterT w m (Either c a)
memento (LazyWriter.WriterT m (a, w)
m) = m (Either c a, w) -> WriterT w m (Either c a)
forall w (m :: * -> *) a. m (a, w) -> WriterT w m a
LazyWriter.WriterT (m (Either c a, w) -> WriterT w m (Either c a))
-> m (Either c a, w) -> WriterT w m (Either c a)
forall a b. (a -> b) -> a -> b
$
(c -> (Either c a, w))
-> ((a, w) -> (Either c a, w))
-> Either c (a, w)
-> (Either c a, w)
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (\c
c -> (c -> Either c a
forall a b. a -> Either a b
Left c
c, w
forall a. Monoid a => a
mempty)) (\(a
a, w
w) -> (a -> Either c a
forall a b. b -> Either a b
Right a
a, w
w)) (Either c (a, w) -> (Either c a, w))
-> m (Either c (a, w)) -> m (Either c a, w)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
`liftM` m (a, w) -> m (Either c (a, w))
forall c (m :: * -> *) a.
MonadChronicle c m =>
m a -> m (Either c a)
memento m (a, w)
m
absolve :: a -> WriterT w m a -> WriterT w m a
absolve a
x (LazyWriter.WriterT m (a, w)
m) = m (a, w) -> WriterT w m a
forall w (m :: * -> *) a. m (a, w) -> WriterT w m a
LazyWriter.WriterT (m (a, w) -> WriterT w m a) -> m (a, w) -> WriterT w m a
forall a b. (a -> b) -> a -> b
$ (a, w) -> m (a, w) -> m (a, w)
forall c (m :: * -> *) a. MonadChronicle c m => a -> m a -> m a
absolve (a
x, w
forall a. Monoid a => a
mempty) m (a, w)
m
condemn :: WriterT w m a -> WriterT w m a
condemn (LazyWriter.WriterT m (a, w)
m) = m (a, w) -> WriterT w m a
forall w (m :: * -> *) a. m (a, w) -> WriterT w m a
LazyWriter.WriterT (m (a, w) -> WriterT w m a) -> m (a, w) -> WriterT w m a
forall a b. (a -> b) -> a -> b
$ m (a, w) -> m (a, w)
forall c (m :: * -> *) a. MonadChronicle c m => m a -> m a
condemn m (a, w)
m
retcon :: (c -> c) -> WriterT w m a -> WriterT w m a
retcon c -> c
f (LazyWriter.WriterT m (a, w)
m) = m (a, w) -> WriterT w m a
forall w (m :: * -> *) a. m (a, w) -> WriterT w m a
LazyWriter.WriterT (m (a, w) -> WriterT w m a) -> m (a, w) -> WriterT w m a
forall a b. (a -> b) -> a -> b
$ (c -> c) -> m (a, w) -> m (a, w)
forall c (m :: * -> *) a.
MonadChronicle c m =>
(c -> c) -> m a -> m a
retcon c -> c
f m (a, w)
m
chronicle :: These c a -> WriterT w m a
chronicle = m a -> WriterT w m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> WriterT w m a)
-> (These c a -> m a) -> These c a -> WriterT w m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. These c a -> m a
forall c (m :: * -> *) a. MonadChronicle c m => These c a -> m a
chronicle
instance (Monoid w, MonadChronicle c m) => MonadChronicle c (StrictWriter.WriterT w m) where
dictate :: c -> WriterT w m ()
dictate = m () -> WriterT w m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> WriterT w m ()) -> (c -> m ()) -> c -> WriterT w m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. c -> m ()
forall c (m :: * -> *). MonadChronicle c m => c -> m ()
dictate
confess :: c -> WriterT w m a
confess = m a -> WriterT w m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> WriterT w m a) -> (c -> m a) -> c -> WriterT w m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. c -> m a
forall c (m :: * -> *) a. MonadChronicle c m => c -> m a
confess
memento :: WriterT w m a -> WriterT w m (Either c a)
memento (StrictWriter.WriterT m (a, w)
m) = m (Either c a, w) -> WriterT w m (Either c a)
forall w (m :: * -> *) a. m (a, w) -> WriterT w m a
StrictWriter.WriterT (m (Either c a, w) -> WriterT w m (Either c a))
-> m (Either c a, w) -> WriterT w m (Either c a)
forall a b. (a -> b) -> a -> b
$
(c -> (Either c a, w))
-> ((a, w) -> (Either c a, w))
-> Either c (a, w)
-> (Either c a, w)
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (\c
c -> (c -> Either c a
forall a b. a -> Either a b
Left c
c, w
forall a. Monoid a => a
mempty)) (\(a
a, w
w) -> (a -> Either c a
forall a b. b -> Either a b
Right a
a, w
w)) (Either c (a, w) -> (Either c a, w))
-> m (Either c (a, w)) -> m (Either c a, w)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
`liftM` m (a, w) -> m (Either c (a, w))
forall c (m :: * -> *) a.
MonadChronicle c m =>
m a -> m (Either c a)
memento m (a, w)
m
absolve :: a -> WriterT w m a -> WriterT w m a
absolve a
x (StrictWriter.WriterT m (a, w)
m) = m (a, w) -> WriterT w m a
forall w (m :: * -> *) a. m (a, w) -> WriterT w m a
StrictWriter.WriterT (m (a, w) -> WriterT w m a) -> m (a, w) -> WriterT w m a
forall a b. (a -> b) -> a -> b
$ (a, w) -> m (a, w) -> m (a, w)
forall c (m :: * -> *) a. MonadChronicle c m => a -> m a -> m a
absolve (a
x, w
forall a. Monoid a => a
mempty) m (a, w)
m
condemn :: WriterT w m a -> WriterT w m a
condemn (StrictWriter.WriterT m (a, w)
m) = m (a, w) -> WriterT w m a
forall w (m :: * -> *) a. m (a, w) -> WriterT w m a
StrictWriter.WriterT (m (a, w) -> WriterT w m a) -> m (a, w) -> WriterT w m a
forall a b. (a -> b) -> a -> b
$ m (a, w) -> m (a, w)
forall c (m :: * -> *) a. MonadChronicle c m => m a -> m a
condemn m (a, w)
m
retcon :: (c -> c) -> WriterT w m a -> WriterT w m a
retcon c -> c
f (StrictWriter.WriterT m (a, w)
m) = m (a, w) -> WriterT w m a
forall w (m :: * -> *) a. m (a, w) -> WriterT w m a
StrictWriter.WriterT (m (a, w) -> WriterT w m a) -> m (a, w) -> WriterT w m a
forall a b. (a -> b) -> a -> b
$ (c -> c) -> m (a, w) -> m (a, w)
forall c (m :: * -> *) a.
MonadChronicle c m =>
(c -> c) -> m a -> m a
retcon c -> c
f m (a, w)
m
chronicle :: These c a -> WriterT w m a
chronicle = m a -> WriterT w m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> WriterT w m a)
-> (These c a -> m a) -> These c a -> WriterT w m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. These c a -> m a
forall c (m :: * -> *) a. MonadChronicle c m => These c a -> m a
chronicle
instance (Monoid w, MonadChronicle c m) => MonadChronicle c (LazyRWS.RWST r w s m) where
dictate :: c -> RWST r w s m ()
dictate = m () -> RWST r w s m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> RWST r w s m ()) -> (c -> m ()) -> c -> RWST r w s m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. c -> m ()
forall c (m :: * -> *). MonadChronicle c m => c -> m ()
dictate
confess :: c -> RWST r w s m a
confess = m a -> RWST r w s m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> RWST r w s m a) -> (c -> m a) -> c -> RWST r w s m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. c -> m a
forall c (m :: * -> *) a. MonadChronicle c m => c -> m a
confess
memento :: RWST r w s m a -> RWST r w s m (Either c a)
memento (LazyRWS.RWST r -> s -> m (a, s, w)
m) = (r -> s -> m (Either c a, s, w)) -> RWST r w s m (Either c a)
forall r w s (m :: * -> *) a.
(r -> s -> m (a, s, w)) -> RWST r w s m a
LazyRWS.RWST ((r -> s -> m (Either c a, s, w)) -> RWST r w s m (Either c a))
-> (r -> s -> m (Either c a, s, w)) -> RWST r w s m (Either c a)
forall a b. (a -> b) -> a -> b
$ \r
r s
s ->
(c -> (Either c a, s, w))
-> ((a, s, w) -> (Either c a, s, w))
-> Either c (a, s, w)
-> (Either c a, s, w)
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (\c
c -> (c -> Either c a
forall a b. a -> Either a b
Left c
c, s
s, w
forall a. Monoid a => a
mempty)) (\(a
a, s
s', w
w) -> (a -> Either c a
forall a b. b -> Either a b
Right a
a, s
s', w
w)) (Either c (a, s, w) -> (Either c a, s, w))
-> m (Either c (a, s, w)) -> m (Either c a, s, w)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
`liftM` m (a, s, w) -> m (Either c (a, s, w))
forall c (m :: * -> *) a.
MonadChronicle c m =>
m a -> m (Either c a)
memento (r -> s -> m (a, s, w)
m r
r s
s)
absolve :: a -> RWST r w s m a -> RWST r w s m a
absolve a
x (LazyRWS.RWST r -> s -> m (a, s, w)
m) = (r -> s -> m (a, s, w)) -> RWST r w s m a
forall r w s (m :: * -> *) a.
(r -> s -> m (a, s, w)) -> RWST r w s m a
LazyRWS.RWST ((r -> s -> m (a, s, w)) -> RWST r w s m a)
-> (r -> s -> m (a, s, w)) -> RWST r w s m a
forall a b. (a -> b) -> a -> b
$ \r
r s
s -> (a, s, w) -> m (a, s, w) -> m (a, s, w)
forall c (m :: * -> *) a. MonadChronicle c m => a -> m a -> m a
absolve (a
x, s
s, w
forall a. Monoid a => a
mempty) (m (a, s, w) -> m (a, s, w)) -> m (a, s, w) -> m (a, s, w)
forall a b. (a -> b) -> a -> b
$ r -> s -> m (a, s, w)
m r
r s
s
condemn :: RWST r w s m a -> RWST r w s m a
condemn (LazyRWS.RWST r -> s -> m (a, s, w)
m) = (r -> s -> m (a, s, w)) -> RWST r w s m a
forall r w s (m :: * -> *) a.
(r -> s -> m (a, s, w)) -> RWST r w s m a
LazyRWS.RWST ((r -> s -> m (a, s, w)) -> RWST r w s m a)
-> (r -> s -> m (a, s, w)) -> RWST r w s m a
forall a b. (a -> b) -> a -> b
$ \r
r s
s -> m (a, s, w) -> m (a, s, w)
forall c (m :: * -> *) a. MonadChronicle c m => m a -> m a
condemn (m (a, s, w) -> m (a, s, w)) -> m (a, s, w) -> m (a, s, w)
forall a b. (a -> b) -> a -> b
$ r -> s -> m (a, s, w)
m r
r s
s
retcon :: (c -> c) -> RWST r w s m a -> RWST r w s m a
retcon c -> c
f (LazyRWS.RWST r -> s -> m (a, s, w)
m) = (r -> s -> m (a, s, w)) -> RWST r w s m a
forall r w s (m :: * -> *) a.
(r -> s -> m (a, s, w)) -> RWST r w s m a
LazyRWS.RWST ((r -> s -> m (a, s, w)) -> RWST r w s m a)
-> (r -> s -> m (a, s, w)) -> RWST r w s m a
forall a b. (a -> b) -> a -> b
$ \r
r s
s -> (c -> c) -> m (a, s, w) -> m (a, s, w)
forall c (m :: * -> *) a.
MonadChronicle c m =>
(c -> c) -> m a -> m a
retcon c -> c
f (m (a, s, w) -> m (a, s, w)) -> m (a, s, w) -> m (a, s, w)
forall a b. (a -> b) -> a -> b
$ r -> s -> m (a, s, w)
m r
r s
s
chronicle :: These c a -> RWST r w s m a
chronicle = m a -> RWST r w s m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> RWST r w s m a)
-> (These c a -> m a) -> These c a -> RWST r w s m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. These c a -> m a
forall c (m :: * -> *) a. MonadChronicle c m => These c a -> m a
chronicle
instance (Monoid w, MonadChronicle c m) => MonadChronicle c (StrictRWS.RWST r w s m) where
dictate :: c -> RWST r w s m ()
dictate = m () -> RWST r w s m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> RWST r w s m ()) -> (c -> m ()) -> c -> RWST r w s m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. c -> m ()
forall c (m :: * -> *). MonadChronicle c m => c -> m ()
dictate
confess :: c -> RWST r w s m a
confess = m a -> RWST r w s m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> RWST r w s m a) -> (c -> m a) -> c -> RWST r w s m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. c -> m a
forall c (m :: * -> *) a. MonadChronicle c m => c -> m a
confess
memento :: RWST r w s m a -> RWST r w s m (Either c a)
memento (StrictRWS.RWST r -> s -> m (a, s, w)
m) = (r -> s -> m (Either c a, s, w)) -> RWST r w s m (Either c a)
forall r w s (m :: * -> *) a.
(r -> s -> m (a, s, w)) -> RWST r w s m a
StrictRWS.RWST ((r -> s -> m (Either c a, s, w)) -> RWST r w s m (Either c a))
-> (r -> s -> m (Either c a, s, w)) -> RWST r w s m (Either c a)
forall a b. (a -> b) -> a -> b
$ \r
r s
s ->
(c -> (Either c a, s, w))
-> ((a, s, w) -> (Either c a, s, w))
-> Either c (a, s, w)
-> (Either c a, s, w)
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (\c
c -> (c -> Either c a
forall a b. a -> Either a b
Left c
c, s
s, w
forall a. Monoid a => a
mempty)) (\(a
a, s
s', w
w) -> (a -> Either c a
forall a b. b -> Either a b
Right a
a, s
s', w
w)) (Either c (a, s, w) -> (Either c a, s, w))
-> m (Either c (a, s, w)) -> m (Either c a, s, w)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
`liftM` m (a, s, w) -> m (Either c (a, s, w))
forall c (m :: * -> *) a.
MonadChronicle c m =>
m a -> m (Either c a)
memento (r -> s -> m (a, s, w)
m r
r s
s)
absolve :: a -> RWST r w s m a -> RWST r w s m a
absolve a
x (StrictRWS.RWST r -> s -> m (a, s, w)
m) = (r -> s -> m (a, s, w)) -> RWST r w s m a
forall r w s (m :: * -> *) a.
(r -> s -> m (a, s, w)) -> RWST r w s m a
StrictRWS.RWST ((r -> s -> m (a, s, w)) -> RWST r w s m a)
-> (r -> s -> m (a, s, w)) -> RWST r w s m a
forall a b. (a -> b) -> a -> b
$ \r
r s
s -> (a, s, w) -> m (a, s, w) -> m (a, s, w)
forall c (m :: * -> *) a. MonadChronicle c m => a -> m a -> m a
absolve (a
x, s
s, w
forall a. Monoid a => a
mempty) (m (a, s, w) -> m (a, s, w)) -> m (a, s, w) -> m (a, s, w)
forall a b. (a -> b) -> a -> b
$ r -> s -> m (a, s, w)
m r
r s
s
condemn :: RWST r w s m a -> RWST r w s m a
condemn (StrictRWS.RWST r -> s -> m (a, s, w)
m) = (r -> s -> m (a, s, w)) -> RWST r w s m a
forall r w s (m :: * -> *) a.
(r -> s -> m (a, s, w)) -> RWST r w s m a
StrictRWS.RWST ((r -> s -> m (a, s, w)) -> RWST r w s m a)
-> (r -> s -> m (a, s, w)) -> RWST r w s m a
forall a b. (a -> b) -> a -> b
$ \r
r s
s -> m (a, s, w) -> m (a, s, w)
forall c (m :: * -> *) a. MonadChronicle c m => m a -> m a
condemn (m (a, s, w) -> m (a, s, w)) -> m (a, s, w) -> m (a, s, w)
forall a b. (a -> b) -> a -> b
$ r -> s -> m (a, s, w)
m r
r s
s
retcon :: (c -> c) -> RWST r w s m a -> RWST r w s m a
retcon c -> c
f (StrictRWS.RWST r -> s -> m (a, s, w)
m) = (r -> s -> m (a, s, w)) -> RWST r w s m a
forall r w s (m :: * -> *) a.
(r -> s -> m (a, s, w)) -> RWST r w s m a
StrictRWS.RWST ((r -> s -> m (a, s, w)) -> RWST r w s m a)
-> (r -> s -> m (a, s, w)) -> RWST r w s m a
forall a b. (a -> b) -> a -> b
$ \r
r s
s -> (c -> c) -> m (a, s, w) -> m (a, s, w)
forall c (m :: * -> *) a.
MonadChronicle c m =>
(c -> c) -> m a -> m a
retcon c -> c
f (m (a, s, w) -> m (a, s, w)) -> m (a, s, w) -> m (a, s, w)
forall a b. (a -> b) -> a -> b
$ r -> s -> m (a, s, w)
m r
r s
s
chronicle :: These c a -> RWST r w s m a
chronicle = m a -> RWST r w s m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> RWST r w s m a)
-> (These c a -> m a) -> These c a -> RWST r w s m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. These c a -> m a
forall c (m :: * -> *) a. MonadChronicle c m => These c a -> m a
chronicle