definitive-base-2.3: The base modules of the Definitive framework.

Safe HaskellNone
LanguageHaskell2010

Algebra.Monad.Writer

Contents

Synopsis

The Writer monad

class (Monad m, Monoid w) => MonadWriter w m | m -> w where Source

Methods

tell :: w -> m () Source

listen :: m a -> m (w, a) Source

censor :: m (a, w -> w) -> m a Source

Instances

Monoid w => MonadWriter w ((,) w) 
MonadWriter w m => MonadWriter w (ListT m) 
MonadWriter w m => MonadWriter w (Free m) 
(Traversable g, Monad g, MonadWriter w f) => MonadWriter w ((:.:) f g) 
(Traversable f, Monad f, MonadWriter w g) => MonadWriter w (Compose' f g) 
MonadWriter w m => MonadWriter w (StateT s m) 
MonadWriter w m => MonadWriter w (ReaderT r m) 
(Monoid w, Monad m) => MonadWriter w (WriterT w m) 
(Monad m, SubSemi acc w, Monoid w) => MonadWriter w (CounterT w acc m) 
(Monad m, Monoid w) => MonadWriter w (RWST r w s m) 
(Ring t, Monad m) => MonadWriter (Product t) (ProbT t m) 

mute :: (MonadWriter w m, Monoid w) => m a -> m a Source

intercept :: (MonadWriter w m, Monoid w) => m a -> m (w, a) Source

intercept' :: (MonadWriter w m, Monoid w) => m a -> m w Source

eavesdrop :: (MonadWriter w m, Monoid w) => m a -> m w Source

The Writer transformer

data WriterT w m a Source

A simple Writer monad

Instances

(Monad m, Monoid w, MonadFuture n m) => MonadFuture n (WriterT w m) 
(Monoid w, Monad m) => MonadWriter w (WriterT w m) 
(Monoid w, MonadReader r m) => MonadReader r (WriterT w m) 
(Monoid w, MonadState r m) => MonadState r (WriterT w m) 
Monoid w => MonadTrans (WriterT w) 
Monoid w => MonadInternal (WriterT w) 
(Unit m, Monoid w) => Unit (WriterT w m) 
(Monoid w, MonadCont m) => MonadCont (WriterT w m) 
(Monoid w, MonadList m) => MonadList (WriterT w m) 
(Monoid w, MonadFix m) => MonadFix (WriterT w m) 
Traversable m => Traversable (WriterT e m) 
Foldable m => Foldable (WriterT w m) 
(Monoid w, Monad m) => Monad (WriterT w m) 
(Monoid w, Monad m) => Applicative (WriterT w m) 
Functor m => Functor (WriterT w m) 
Ring (m (a, Void, w)) => Ring (WriterT w m a) 
Semiring (m (a, Void, w)) => Semiring (WriterT w m a) 
Monoid (m (a, Void, w)) => Monoid (WriterT w m a) 
Semigroup (m (a, Void, w)) => Semigroup (WriterT w m a) 

type Writer w a = WriterT w Id a Source

writerT :: (Functor m, Functor m') => Iso (WriterT w m a) (WriterT w' m' b) (m (w, a)) (m' (w', b)) Source

writer :: Iso (Writer w a) (Writer w' b) (w, a) (w', b) Source

pureWriter :: Monoid w => Iso (w, a) (w', b) a b Source

Keeping track of where we are

class (SubSemi acc w, MonadWriter w m) => MonadCounter w acc m | m -> acc where Source

Methods

getCounter :: m acc Source

Instances

MonadCounter w a m => MonadCounter w a (Free m) 
MonadCounter w acc m => MonadCounter w acc (StateT s m) 
MonadCounter w acc m => MonadCounter w acc (ReaderT r m) 
(Monad m, Monoid w, SubSemi acc w) => MonadCounter w acc (CounterT w acc m) 

Implementation

data CounterT w acc m a Source

The canonical representsation of a WriterAcc Monad

Instances

(Monad m, Monoid w, SubSemi acc w) => MonadCounter w acc (CounterT w acc m) 
(Monad m, Monoid w, SubSemi acc w, MonadFuture n m) => MonadFuture n (CounterT w acc m) 
(Monad m, SubSemi acc w, Monoid w) => MonadWriter w (CounterT w acc m) 
(MonadState s m, Monoid w, SubSemi acc w) => MonadState s (CounterT w acc m) 
Monoid w => MonadTrans (CounterT w acc) 
(Unit m, Monoid w) => Unit (CounterT w acc m) 
(SubSemi acc w, Monoid w, MonadFix m) => MonadFix (CounterT w acc m) 
(Monoid w, SubSemi a w, Monad m) => Monad (CounterT w a m) 
(Monoid w, Monad m) => Applicative (CounterT w acc m) 
Functor m => Functor (CounterT w acc m) 

type Counter w acc a = CounterT w acc Id a Source

i'counterT :: (SubSemi acc w, SubSemi acc' w', Monoid acc, Monoid acc', Functor m) => Iso (CounterT w acc m a) (CounterT w' acc' m' a') (m (a, acc, w)) (m' (a', acc', w')) Source

i'counter :: (SubSemi acc w, SubSemi acc' w', Monoid acc, Monoid acc', Functor m) => Iso (Counter w acc a) (Counter w' acc' a') (a, acc, w) (a', acc', w') Source