definitive-base-2.6.3: A small Prelude wrapper to simplify my own Haskell developments

Safe HaskellNone
LanguageHaskell2010

Algebra.Monad.Writer

Contents

Synopsis

The Writer monad

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

Minimal complete definition

tell, listen, censor

Methods

tell :: w -> m () Source #

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

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

Instances

MonadWriter w m => MonadWriter w (Free m) Source # 

Methods

tell :: w -> Free m () Source #

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

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

MonadWriter w m => MonadWriter w (ListT m) Source # 

Methods

tell :: w -> ListT m () Source #

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

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

MonadWriter w m => MonadWriter w (TreeT m) Source # 

Methods

tell :: w -> TreeT m () Source #

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

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

MonadWriter w m => MonadWriter w (MaybeT m) Source # 

Methods

tell :: w -> MaybeT m () Source #

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

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

MonadWriter w m => MonadWriter w (StrictT m) Source # 

Methods

tell :: w -> StrictT m () Source #

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

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

MonadWriter w m => MonadWriter w (LogicT m) Source # 

Methods

tell :: w -> LogicT m () Source #

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

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

(Traversable f, Monad f, MonadWriter w g) => MonadWriter w (Compose' f g) Source # 

Methods

tell :: w -> Compose' f g () Source #

listen :: Compose' f g a -> Compose' f g (w, a) Source #

censor :: Compose' f g (a, w -> w) -> Compose' f g a Source #

MonadWriter w m => MonadWriter w (ReaderT r m) Source # 

Methods

tell :: w -> ReaderT r m () Source #

listen :: ReaderT r m a -> ReaderT r m (w, a) Source #

censor :: ReaderT r m (a, w -> w) -> ReaderT r m a Source #

MonadWriter w m => MonadWriter w (StateT s m) Source # 

Methods

tell :: w -> StateT s m () Source #

listen :: StateT s m a -> StateT s m (w, a) Source #

censor :: StateT s m (a, w -> w) -> StateT s m a Source #

(Monoid w, Monad m) => MonadWriter w (WriterT w m) Source # 

Methods

tell :: w -> WriterT w m () Source #

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

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

(Monad m, SubSemi acc w, Monoid w) => MonadWriter w (CounterT w acc m) Source # 

Methods

tell :: w -> CounterT w acc m () Source #

listen :: CounterT w acc m a -> CounterT w acc m (w, a) Source #

censor :: CounterT w acc m (a, w -> w) -> CounterT w acc m a Source #

(Monad m, Monoid w) => MonadWriter w (RWST r w s m) Source # 

Methods

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

listen :: RWST r w s m a -> RWST r w s m (w, a) Source #

censor :: RWST r w s m (a, w -> w) -> RWST r w s m a Source #

Ring t => MonadWriter (Product t) (ProbT t m) Source # 

Methods

tell :: Product t -> ProbT t m () Source #

listen :: ProbT t m a -> ProbT t m (Product t, a) Source #

censor :: ProbT t m (a, Product t -> Product t) -> ProbT t m a Source #

mute :: MonadWriter w m => m a -> m a Source #

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

intercept' :: MonadWriter w m => m a -> m w Source #

eavesdrop :: MonadWriter w m => 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) Source # 

Methods

future :: n a -> WriterT w m a Source #

(Monoid w, Monad m) => MonadWriter w (WriterT w m) Source # 

Methods

tell :: w -> WriterT w m () Source #

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

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

(Monoid w, MonadReader r m) => MonadReader r (WriterT w m) Source # 

Methods

ask :: WriterT w m r Source #

local :: (r -> r) -> WriterT w m a -> WriterT w m a Source #

(Monoid w, MonadState r m) => MonadState r (WriterT w m) Source # 

Methods

get :: WriterT w m r Source #

put :: r -> WriterT w m () Source #

modify :: (r -> r) -> WriterT w m () Source #

Monoid w => ConcreteMonad (WriterT w) Source # 

Methods

generalize :: Monad m => WriterT w Id a -> WriterT w m a Source #

Monoid w => MonadTrans (WriterT w) Source # 

Methods

lift :: Monad m => m a -> WriterT w m a Source #

Monoid w => MonadInternal (WriterT w) Source # 

Methods

internal :: Monad m => (forall c. m (c, a) -> m (c, b)) -> WriterT w m a -> WriterT w m b Source #

(Monoid w, Unit m) => Unit (WriterT w m) Source # 

Methods

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

(MonadCont m, Monoid w) => MonadCont (WriterT w m) Source # 

Methods

callCC :: (forall b. (a -> WriterT w m b) -> WriterT w m b) -> WriterT w m a Source #

(MonadList m, Monoid w) => MonadList (WriterT w m) Source # 

Methods

choose :: [a] -> WriterT w m a Source #

(MonadFix m, Monoid w) => MonadFix (WriterT w m) Source # 

Methods

mfix :: (a -> WriterT w m a) -> WriterT w m a Source #

Traversable m => Traversable (WriterT e m) Source # 

Methods

sequence :: Applicative f => WriterT e m (f a) -> f (WriterT e m a) Source #

Foldable m => Foldable (WriterT w m) Source # 

Methods

fold :: Monoid m => WriterT w m m -> m Source #

(Monoid w, Monad m) => Monad (WriterT w m) Source # 

Methods

join :: WriterT w m (WriterT w m a) -> WriterT w m a Source #

(>>=) :: WriterT w m a -> (a -> WriterT w m b) -> WriterT w m b Source #

(Monad m, Monoid w) => Applicative (WriterT w m) Source # 
(Monad m, Monoid w) => SemiApplicative (WriterT w m) Source # 

Methods

(<*>) :: WriterT w m (a -> b) -> WriterT w m a -> WriterT w m b Source #

Functor m => Functor (WriterT w m) Source # 

Methods

map :: (a -> b) -> WriterT w m a -> WriterT w m b Source #

(Monoid w, MonadLogic m l) => MonadLogic (WriterT w m) (WriterT w l) Source # 

Methods

deduce :: WriterT w l a -> WriterT w m (Maybe (a, WriterT w l a)) Source #

induce :: WriterT w m (Maybe (a, WriterT w l a)) -> WriterT w l a Source #

Ring (m (a, Void, w)) => Ring (WriterT w m a) Source # 

Methods

one :: WriterT w m a Source #

Semiring (m (a, Void, w)) => Semiring (WriterT w m a) Source # 

Methods

(*) :: WriterT w m a -> WriterT w m a -> WriterT w m a Source #

Monoid (m (a, Void, w)) => Monoid (WriterT w m a) Source # 

Methods

zero :: WriterT w m a Source #

Semigroup (m (a, Void, w)) => Semigroup (WriterT w m a) Source # 

Methods

(+) :: WriterT w m a -> WriterT w m a -> WriterT w m a Source #

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 #

Minimal complete definition

getCounter, setCounter

Methods

getCounter :: m acc Source #

setCounter :: acc -> m () Source #

Instances

MonadCounter w a m => MonadCounter w a (Free m) Source # 

Methods

getCounter :: Free m a Source #

setCounter :: a -> Free m () Source #

MonadCounter w acc m => MonadCounter w acc (ReaderT r m) Source # 

Methods

getCounter :: ReaderT r m acc Source #

setCounter :: acc -> ReaderT r m () Source #

MonadCounter w acc m => MonadCounter w acc (StateT s m) Source # 

Methods

getCounter :: StateT s m acc Source #

setCounter :: acc -> StateT s m () Source #

(Monad m, Monoid w, SubSemi acc w) => MonadCounter w acc (CounterT w acc m) Source # 

Methods

getCounter :: CounterT w acc m acc Source #

setCounter :: acc -> CounterT w acc m () Source #

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) Source # 

Methods

getCounter :: CounterT w acc m acc Source #

setCounter :: acc -> CounterT w acc m () Source #

(Monad m, Monoid w, MonadFuture n m) => MonadFuture n (CounterT w acc m) Source # 

Methods

future :: n a -> CounterT w acc m a Source #

(Monad m, SubSemi acc w, Monoid w) => MonadWriter w (CounterT w acc m) Source # 

Methods

tell :: w -> CounterT w acc m () Source #

listen :: CounterT w acc m a -> CounterT w acc m (w, a) Source #

censor :: CounterT w acc m (a, w -> w) -> CounterT w acc m a Source #

(MonadState s m, Monoid w) => MonadState s (CounterT w acc m) Source # 

Methods

get :: CounterT w acc m s Source #

put :: s -> CounterT w acc m () Source #

modify :: (s -> s) -> CounterT w acc m () Source #

Monoid w => ConcreteMonad (CounterT w acc) Source # 

Methods

generalize :: Monad m => CounterT w acc Id a -> CounterT w acc m a Source #

Monoid w => MonadTrans (CounterT w acc) Source # 

Methods

lift :: Monad m => m a -> CounterT w acc m a Source #

(Monoid w, Unit m) => Unit (CounterT w acc m) Source # 

Methods

pure :: a -> CounterT w acc m a Source #

(MonadFix m, Monoid w) => MonadFix (CounterT w acc m) Source # 

Methods

mfix :: (a -> CounterT w acc m a) -> CounterT w acc m a Source #

(Monoid w, Monad m) => Monad (CounterT w a m) Source # 

Methods

join :: CounterT w a m (CounterT w a m a) -> CounterT w a m a Source #

(>>=) :: CounterT w a m a -> (a -> CounterT w a m b) -> CounterT w a m b Source #

(Monad m, Monoid w) => Applicative (CounterT w acc m) Source # 
(Monad m, Monoid w) => SemiApplicative (CounterT w acc m) Source # 

Methods

(<*>) :: CounterT w acc m (a -> b) -> CounterT w acc m a -> CounterT w acc m b Source #

Functor m => Functor (CounterT w acc m) Source # 

Methods

map :: (a -> b) -> CounterT w acc m a -> CounterT w acc m b Source #

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

i'counterT :: (SubSemi acc w, 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, Monoid acc') => Iso (Counter w acc a) (Counter w' acc' a') (a, acc, w) (a', acc', w') Source #

Orphan instances

Monoid w => MonadWriter w ((,) w) Source # 

Methods

tell :: w -> (w, ()) Source #

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

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