monads-tf-0.3.0.1: Monad classes, using type families
Copyright(c) Andy Gill 2001
(c) Oregon Graduate Institute of Science and Technology 2001
LicenseBSD-style (see the file LICENSE)
Maintainerross@soi.city.ac.uk
Stabilityexperimental
Portabilitynon-portable (type families)
Safe HaskellSafe-Inferred
LanguageGHC2021

Control.Monad.Writer.Class

Description

The MonadWriter class.

Inspired by the paper /Functional Programming with Overloading and Higher-Order Polymorphism/, Mark P Jones (http://web.cecs.pdx.edu/~mpj/pubs/springschool.html) Advanced School of Functional Programming, 1995.

Synopsis

Documentation

class (Monoid (WriterType m), Monad m) => MonadWriter m where Source #

Associated Types

type WriterType m Source #

Methods

tell :: WriterType m -> m () Source #

Shout to the monad what you want to be heard. The monad carries this packet upwards, merging it if needed (hence the Monoid requirement).

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

Listen to a monad acting, and return what the monad "said".

pass :: m (a, WriterType m -> WriterType m) -> m a Source #

Provide a writer transformer which changes internals of the written object.

Instances

Instances details
MonadWriter m => MonadWriter (MaybeT m) Source # 
Instance details

Defined in Control.Monad.Writer.Class

Associated Types

type WriterType (MaybeT m) Source #

Methods

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

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

pass :: MaybeT m (a, WriterType (MaybeT m) -> WriterType (MaybeT m)) -> MaybeT m a Source #

MonadWriter m => MonadWriter (ExceptT e m) Source # 
Instance details

Defined in Control.Monad.Writer.Class

Associated Types

type WriterType (ExceptT e m) Source #

Methods

tell :: WriterType (ExceptT e m) -> ExceptT e m () Source #

listen :: ExceptT e m a -> ExceptT e m (a, WriterType (ExceptT e m)) Source #

pass :: ExceptT e m (a, WriterType (ExceptT e m) -> WriterType (ExceptT e m)) -> ExceptT e m a Source #

MonadWriter m => MonadWriter (IdentityT m) Source # 
Instance details

Defined in Control.Monad.Writer.Class

Associated Types

type WriterType (IdentityT m) Source #

MonadWriter m => MonadWriter (ReaderT r m) Source # 
Instance details

Defined in Control.Monad.Writer.Class

Associated Types

type WriterType (ReaderT r m) Source #

Methods

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

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

pass :: ReaderT r m (a, WriterType (ReaderT r m) -> WriterType (ReaderT r m)) -> ReaderT r m a Source #

MonadWriter m => MonadWriter (StateT s m) Source # 
Instance details

Defined in Control.Monad.Writer.Class

Associated Types

type WriterType (StateT s m) Source #

Methods

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

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

pass :: StateT s m (a, WriterType (StateT s m) -> WriterType (StateT s m)) -> StateT s m a Source #

MonadWriter m => MonadWriter (StateT s m) Source # 
Instance details

Defined in Control.Monad.Writer.Class

Associated Types

type WriterType (StateT s m) Source #

Methods

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

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

pass :: StateT s m (a, WriterType (StateT s m) -> WriterType (StateT s m)) -> StateT s m a Source #

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

Defined in Control.Monad.Writer.Class

Associated Types

type WriterType (WriterT w m) Source #

Methods

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

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

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

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

Defined in Control.Monad.Writer.Class

Associated Types

type WriterType (WriterT w m) Source #

Methods

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

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

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

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

Defined in Control.Monad.Writer.Class

Associated Types

type WriterType (RWST r w s m) Source #

Methods

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

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

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

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

Defined in Control.Monad.Writer.Class

Associated Types

type WriterType (RWST r w s m) Source #

Methods

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

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

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

listens :: MonadWriter m => (WriterType m -> b) -> m a -> m (a, b) Source #

listens f m is an action that executes the action m and adds the result of applying f to the output to the value of the computation.

censor :: MonadWriter m => (WriterType m -> WriterType m) -> m a -> m a Source #

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