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

Safe HaskellSafe
LanguageHaskell2010

Control.Monad.Trans.MultiWriter.Lazy

Contents

Description

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

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

Instances

MonadBase b m => MonadBase b (MultiWriterT c m) Source # 

Methods

liftBase :: b α -> MultiWriterT c m α #

MonadBaseControl b m => MonadBaseControl b (MultiWriterT c m) Source # 

Associated Types

type StM (MultiWriterT c m :: * -> *) a :: * #

Methods

liftBaseWith :: (RunInBase (MultiWriterT c m) b -> b a) -> MultiWriterT c m a #

restoreM :: StM (MultiWriterT c m) a -> MultiWriterT c m a #

MonadState s m => MonadState s (MultiWriterT c m) Source # 

Methods

get :: MultiWriterT c m s #

put :: s -> MultiWriterT c m () #

state :: (s -> (a, s)) -> MultiWriterT c m a #

MonadWriter w m => MonadWriter w (MultiWriterT c m) Source # 

Methods

writer :: (a, w) -> MultiWriterT c m a #

tell :: w -> MultiWriterT c m () #

listen :: MultiWriterT c m a -> MultiWriterT c m (a, w) #

pass :: MultiWriterT c m (a, w -> w) -> MultiWriterT c m a #

(Monad m, ContainsType a c, Monoid a) => MonadMultiWriter a (MultiWriterT c m) Source # 

Methods

mTell :: a -> MultiWriterT c m () Source #

MonadTrans (MultiWriterT x) Source # 

Methods

lift :: Monad m => m a -> MultiWriterT x m a #

MonadTransControl (MultiWriterT c) Source # 

Associated Types

type StT (MultiWriterT c :: (* -> *) -> * -> *) a :: * #

Methods

liftWith :: Monad m => (Run (MultiWriterT c) -> m a) -> MultiWriterT c m a #

restoreT :: Monad m => m (StT (MultiWriterT c) a) -> MultiWriterT c m a #

Monad m => Monad (MultiWriterT x m) Source # 

Methods

(>>=) :: MultiWriterT x m a -> (a -> MultiWriterT x m b) -> MultiWriterT x m b #

(>>) :: MultiWriterT x m a -> MultiWriterT x m b -> MultiWriterT x m b #

return :: a -> MultiWriterT x m a #

fail :: String -> MultiWriterT x m a #

Functor f => Functor (MultiWriterT x f) Source # 

Methods

fmap :: (a -> b) -> MultiWriterT x f a -> MultiWriterT x f b #

(<$) :: a -> MultiWriterT x f b -> MultiWriterT x f a #

MonadFix m => MonadFix (MultiWriterT w m) Source # 

Methods

mfix :: (a -> MultiWriterT w m a) -> MultiWriterT w m a #

(Applicative m, Monad m) => Applicative (MultiWriterT x m) Source # 

Methods

pure :: a -> MultiWriterT x m a #

(<*>) :: MultiWriterT x m (a -> b) -> MultiWriterT x m a -> MultiWriterT x m b #

(*>) :: MultiWriterT x m a -> MultiWriterT x m b -> MultiWriterT x m b #

(<*) :: MultiWriterT x m a -> MultiWriterT x m b -> MultiWriterT x m a #

MonadIO m => MonadIO (MultiWriterT c m) Source # 

Methods

liftIO :: IO a -> MultiWriterT c m a #

(Functor m, Applicative m, MonadPlus m) => Alternative (MultiWriterT c m) Source # 

Methods

empty :: MultiWriterT c m a #

(<|>) :: MultiWriterT c m a -> MultiWriterT c m a -> MultiWriterT c m a #

some :: MultiWriterT c m a -> MultiWriterT c m [a] #

many :: MultiWriterT c m a -> MultiWriterT c m [a] #

MonadPlus m => MonadPlus (MultiWriterT c m) Source # 

Methods

mzero :: MultiWriterT c m a #

mplus :: MultiWriterT c m a -> MultiWriterT c m a -> MultiWriterT c m a #

type StT (MultiWriterT c) a Source # 
type StT (MultiWriterT c) a = (a, HList c)
type StM (MultiWriterT c m) a Source # 
type StM (MultiWriterT c m) a = ComposeSt (MultiWriterT c) m a

type MultiWriterTNull = MultiWriterT '[] Source #

A MultiWriter transformer carrying an empty state.

MonadMultiWriter class

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

Minimal complete definition

mTell

Methods

mTell :: a -> m () Source #

Instances

(MonadTrans t, Monad (t m), MonadMultiWriter a m) => MonadMultiWriter a (t m) Source # 

Methods

mTell :: a -> t m () Source #

(Monad m, ContainsType a c, Monoid a) => MonadMultiWriter a (MultiWriterT c m) Source # 

Methods

mTell :: a -> MultiWriterT c m () Source #

(Monad m, ContainsType a c, Monoid a) => MonadMultiWriter a (MultiWriterT c m) Source # 

Methods

mTell :: a -> MultiWriterT c m () Source #

(Monad m, Monoid a, HListMContains TellableFlag a cts) => MonadMultiWriter a (MultiGSTT cts m) Source # 

Methods

mTell :: a -> MultiGSTT cts m () Source #

(Monad m, Monoid a, HListMContains TellableFlag a cts) => MonadMultiWriter a (MultiGSTT cts m) Source # 

Methods

mTell :: a -> MultiGSTT cts m () Source #

(Monad m, ContainsType a w, Monoid a) => MonadMultiWriter a (MultiRWST r w s m) Source # 

Methods

mTell :: a -> MultiRWST r w s m () Source #

(Monad m, ContainsType a w, Monoid a) => MonadMultiWriter a (MultiRWST r w s m) Source # 

Methods

mTell :: a -> MultiRWST r w s m () Source #

run-functions

runMultiWriterT :: (Monoid (HList w), Functor m) => MultiWriterT w m a -> m (a, HList w) Source #

runMultiWriterTAW :: (Monoid (HList w), Functor m) => MultiWriterT w m a -> m (a, HList w) Source #

runMultiWriterTWA :: (Monoid (HList w), Monad m) => MultiWriterT w m a -> m (HList w, a) Source #

with-functions (single Writer)

withMultiWriter :: (Monoid w, Monad m) => MultiWriterT (w ': ws) m a -> MultiWriterT ws m (a, w) Source #

withMultiWriterAW :: (Monoid w, Monad m) => MultiWriterT (w ': ws) m a -> MultiWriterT ws m (a, w) Source #

withMultiWriterWA :: (Monoid w, Monad m) => MultiWriterT (w ': ws) m a -> MultiWriterT ws m (w, a) Source #

withMultiWriterW :: (Monoid w, Monad m) => MultiWriterT (w ': ws) m a -> MultiWriterT ws m w Source #

with-functions (multiple Writers)

withMultiWriters :: forall w1 w2 m a. (Monoid (HList w1), Monad m, HInit w1) => MultiWriterT (Append w1 w2) m a -> MultiWriterT w2 m (a, HList w1) Source #

withMultiWritersAW :: forall w1 w2 m a. (Monoid (HList w1), Monad m, HInit w1) => MultiWriterT (Append w1 w2) m a -> MultiWriterT w2 m (a, HList w1) Source #

withMultiWritersWA :: forall w1 w2 m a. (Monoid (HList w1), Monad m, HInit w1) => MultiWriterT (Append w1 w2) m a -> MultiWriterT w2 m (HList w1, a) Source #

withMultiWritersW :: forall w1 w2 m a. (Monoid (HList w1), Monad m, HInit w1) => MultiWriterT (Append w1 w2) m a -> MultiWriterT w2 m (HList w1) Source #

inflate-function (run WriterT in MultiWriterT)

inflateWriter :: (Monad m, Monoid w, ContainsType w ws) => WriterT w m a -> MultiWriterT ws m a Source #

other functions

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

Map both the return value and the state of a computation using the given function.

mGetRaw :: Monad m => MultiWriterT a m (HList a) Source #

A raw extractor of the contained HList (i.e. the complete state).

mPutRaw :: Monad m => HList s -> MultiWriterT s m () Source #