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

Description

Synopsis

newtype MultiReaderT x m a Source #

• x - The list of types constituting the environment / input (to be read),
• m - The inner monad.

MultiReaderT corresponds to mtl's ReaderT, 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,

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

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

Constructors

Instances

A MultiReader transformer carrying an empty state.

A reader monad parameterized by the list of types x of the environment / input to carry.

Similar to Reader r = ReaderT r Identity

All methods must be defined.

The idea is: Any monad stack is instance of MonadMultiReader a, iff the stack contains a MultiReaderT x with a element of x.

Minimal complete definition

Methods

mAsk :: m a Source #

Instances

# run-functions

runMultiReaderT :: Monad m => HList r -> MultiReaderT r m a -> m a Source #

runMultiReaderT_ :: Functor m => HList r -> MultiReaderT r m a -> m () Source #

withMultiReaders_ :: (Functor m, Monad m) => HList r1 -> MultiReaderT (Append r1 r2) m a -> MultiReaderT r2 m () Source #

# other functions

mapMultiReaderT :: (m (a, HList w) -> m' (a', HList w)) -> MultiReaderT w m a -> MultiReaderT w m' a' Source #

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

Note that there is a difference to mtl's ReaderT, where it is not possible to modify the environment.

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

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

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