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

Safe Haskell | Safe
Language | Haskell2010

Control.Monad.Trans.MultiWriter.Lazy

Contents

- MultiWriterT
- MonadMultiWriter class
- run-functions
- with-functions (single Writer)
- with-functions (multiple Writers)
- inflate-function (run WriterT in MultiWriterT)
- other functions

Description

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

Synopsis

- newtype MultiWriterT x m a = MultiWriterT {
  - runMultiWriterTRaw :: StateT (HList x) m a
  }
- type MultiWriterTNull = MultiWriterT '[]
- type MultiWriter x a = MultiWriterT x Identity a
- class (Monad m, Monoid a) => MonadMultiWriter a m where
  - mTell :: a -> m ()
- runMultiWriterT :: (Monoid (HList w), Functor m) => MultiWriterT w m a -> m (a, HList w)
- runMultiWriterTAW :: (Monoid (HList w), Functor m) => MultiWriterT w m a -> m (a, HList w)
- runMultiWriterTWA :: (Monoid (HList w), Monad m) => MultiWriterT w m a -> m (HList w, a)
- runMultiWriterTW :: (Monoid (HList w), Monad m) => MultiWriterT w m a -> m (HList w)
- runMultiWriterTNil :: Monad m => MultiWriterT '[] m a -> m a
- runMultiWriterTNil_ :: Functor m => MultiWriterT '[] m a -> m ()
- withMultiWriter :: (Monoid w, Monad m) => MultiWriterT (w ': ws) m a -> MultiWriterT ws m (a, w)
- withMultiWriterAW :: (Monoid w, Monad m) => MultiWriterT (w ': ws) m a -> MultiWriterT ws m (a, w)
- withMultiWriterWA :: (Monoid w, Monad m) => MultiWriterT (w ': ws) m a -> MultiWriterT ws m (w, a)
- withMultiWriterW :: (Monoid w, Monad m) => MultiWriterT (w ': ws) m a -> MultiWriterT ws m w
- 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)
- 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)
- 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)
- withMultiWritersW :: forall w1 w2 m a. (Monoid (HList w1), Monad m, HInit w1) => MultiWriterT (Append w1 w2) m a -> MultiWriterT w2 m (HList w1)
- inflateWriter :: (Monad m, Monoid w, ContainsType w ws) => WriterT w m a -> MultiWriterT ws m a
- mapMultiWriterT :: (m (a, HList w) -> m' (a', HList w)) -> MultiWriterT w m a -> MultiWriterT w m' a'
- mGetRaw :: Monad m => MultiWriterT a m (HList a)
- mPutRaw :: Monad m => HList s -> MultiWriterT s m ()

# 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

Instances details

MonadBase b m => MonadBase b (MultiWriterT c m) Source # |
Instance details Defined in Control.Monad.Trans.MultiWriter.Lazy Methods liftBase :: b α -> MultiWriterT c m α Source #
MonadBaseControl b m => MonadBaseControl b (MultiWriterT c m) Source # |
Instance details Defined in Control.Monad.Trans.MultiWriter.Lazy Associated Types type StM (MultiWriterT c m) a Source # Methods liftBaseWith :: (RunInBase (MultiWriterT c m) b -> b a) -> MultiWriterT c m a Source # restoreM :: StM (MultiWriterT c m) a -> MultiWriterT c m a Source #
(Monad m, ContainsType a c, Monoid a) => MonadMultiWriter a (MultiWriterT c m) Source # |
Instance details Defined in Control.Monad.Trans.MultiWriter.Lazy Methods mTell :: a -> MultiWriterT c m () Source #
MonadState s m => MonadState s (MultiWriterT c m) Source # |
Instance details Defined in Control.Monad.Trans.MultiWriter.Lazy 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 # |
Instance details Defined in Control.Monad.Trans.MultiWriter.Lazy 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
MonadTrans (MultiWriterT x) Source # |
Instance details Defined in Control.Monad.Trans.MultiWriter.Lazy Methods lift :: Monad m => m a -> MultiWriterT x m a
MonadTransControl (MultiWriterT c) Source # |
Instance details Defined in Control.Monad.Trans.MultiWriter.Lazy Associated Types type StT (MultiWriterT c) a Source # Methods liftWith :: Monad m => (Run (MultiWriterT c) -> m a) -> MultiWriterT c m a Source # restoreT :: Monad m => m (StT (MultiWriterT c) a) -> MultiWriterT c m a Source #
Monad m => Monad (MultiWriterT x m) Source # |
Instance details Defined in Control.Monad.Trans.MultiWriter.Lazy 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
Functor f => Functor (MultiWriterT x f) Source # |
Instance details Defined in Control.Monad.Trans.MultiWriter.Lazy 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 # |
Instance details Defined in Control.Monad.Trans.MultiWriter.Lazy Methods mfix :: (a -> MultiWriterT w m a) -> MultiWriterT w m a
(Applicative m, Monad m) => Applicative (MultiWriterT x m) Source # |

Instance details

Defined in Control.Monad.Trans.MultiWriter.Lazy

Methods

pure :: a -> MultiWriterT x m a

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

liftA2 :: (a -> b -> c) -> MultiWriterT x m a -> MultiWriterT x m b -> MultiWriterT x m c

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

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

(Functor m, Applicative m, MonadPlus m) => Alternative (MultiWriterT c m) Source # |
Instance details Defined in Control.Monad.Trans.MultiWriter.Lazy 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 # |
Instance details Defined in Control.Monad.Trans.MultiWriter.Lazy Methods mzero :: MultiWriterT c m a mplus :: MultiWriterT c m a -> MultiWriterT c m a -> MultiWriterT c m a
MonadIO m => MonadIO (MultiWriterT c m) Source # |
Instance details Defined in Control.Monad.Trans.MultiWriter.Lazy Methods liftIO :: IO a -> MultiWriterT c m a
type StT (MultiWriterT c) a Source # |
Instance details Defined in Control.Monad.Trans.MultiWriter.Lazy type StT (MultiWriterT c) a = (a, HList c)
type StM (MultiWriterT c m) a Source # |
Instance details Defined in Control.Monad.Trans.MultiWriter.Lazy type StM (MultiWriterT c m) a = ComposeSt (MultiWriterT c) m a

type MultiWriterTNull = MultiWriterT '[] Source #

A MultiWriter transformer carrying an empty state.

type MultiWriter x a = MultiWriterT x Identity a Source #

# MonadMultiWriter class

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

Methods

mTell :: a -> m () Source #

#### Instances

Instances details

(MonadTrans t, Monad (t m), MonadMultiWriter a m) => MonadMultiWriter a (t m) Source # |
Instance details Defined in Control.Monad.Trans.MultiWriter.Class Methods mTell :: a -> t m () Source #
(Monad m, ContainsType a c, Monoid a) => MonadMultiWriter a (MultiWriterT c m) Source # |
Instance details Defined in Control.Monad.Trans.MultiWriter.Strict Methods mTell :: a -> MultiWriterT c m () Source #
(Monad m, ContainsType a c, Monoid a) => MonadMultiWriter a (MultiWriterT c m) Source # |
Instance details Defined in Control.Monad.Trans.MultiWriter.Lazy Methods mTell :: a -> MultiWriterT c m () Source #
(Monad m, Monoid a, HListMContains 'TellableFlag a cts) => MonadMultiWriter a (MultiGSTT cts m) Source # |
Instance details Defined in Control.Monad.Trans.MultiGST.Strict Methods mTell :: a -> MultiGSTT cts m () Source #
(Monad m, Monoid a, HListMContains 'TellableFlag a cts) => MonadMultiWriter a (MultiGSTT cts m) Source # |
Instance details Defined in Control.Monad.Trans.MultiGST.Lazy Methods mTell :: a -> MultiGSTT cts m () Source #
(Monad m, ContainsType a w, Monoid a) => MonadMultiWriter a (MultiRWST r w s m) Source # |
Instance details Defined in Control.Monad.Trans.MultiRWS.Strict Methods mTell :: a -> MultiRWST r w s m () Source #
(Monad m, ContainsType a w, Monoid a) => MonadMultiWriter a (MultiRWST r w s m) Source # |
Instance details Defined in Control.Monad.Trans.MultiRWS.Lazy 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 #

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

runMultiWriterTNil :: Monad m => MultiWriterT '[] m a -> m a Source #

runMultiWriterTNil_ :: Functor m => MultiWriterT '[] m a -> m () 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 #