multistate-0.3.0.0: like mtl's ReaderT/WriterT/StateT, but more than one contained value/type.

Safe HaskellNone
LanguageHaskell2010

Control.Monad.MultiWriter

Contents

Description

The multi-valued version of mtl's Writer / WriterT / MonadWriter

Synopsis

MultiWriterT

newtype MultiWriterT x m a Source

A Writer transformer monad patameterized by:

  • x - The list of types that can be written (Monoid instances).
  • m - The inner monad.

MultiWriterT corresponds to mtl's WriterT, but can contain a heterogenous list of types.

This heterogenous list is represented using Types.Data.List, i.e:

  • '[] - The empty list,
  • a ': b - A list where a is an arbitrary type and b is the rest list.

For example,

MultiWriterT '[Int, Bool] :: (* -> *) -> (* -> *)

is a Writer transformer containing the types [Int, Bool].

Constructors

MultiWriterT 

Fields

runMultiWriterTRaw :: StateT (HList x) m a
 

Instances

type MultiWriterTNull = MultiWriterT [] Source

A MultiWriter transformer carrying an empty state.

MonadMultiWriter class

class (Monad m, Monoid a) => MonadMultiWriter a m where Source

Methods

mTell :: a -> m () Source

Instances

(MonadTrans t, Monad (t m), MonadMultiWriter a m) => MonadMultiWriter a (t m) 
(Monad m, ContainsType a c, Monoid a) => MonadMultiWriter a (MultiWriterT c m) 

functions

withMultiWriter :: Monad m => x -> MultiWriterT (x : xs) m a -> MultiWriterT xs m a Source

withMultiWriters :: Monad m => HList xs -> MultiWriterT (Append xs ys) m a -> MultiWriterT ys m a Source

runMultiWriterT :: (Monad m, Monoid (HList l)) => MultiWriterT l m a -> m (a, HList l) Source

mapMultiWriterT :: (m (a, HList w) -> m' (a', HList w)) -> MultiWriterT w m a -> MultiWriterT w m' a' Source