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

Safe HaskellSafe
LanguageHaskell2010

Control.Monad.Trans.MultiReader.Lazy

Contents

Description

The multi-valued version of mtl's Reader / ReaderT

Synopsis

MultiReaderT

newtype MultiReaderT x m a Source #

A Reader transformer monad patameterized by:

  • 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

MultiReaderT 

Fields

Instances

MonadBase b m => MonadBase b (MultiReaderT r m) Source # 

Methods

liftBase :: b α -> MultiReaderT r m α #

MonadBaseControl b m => MonadBaseControl b (MultiReaderT r m) Source # 

Associated Types

type StM (MultiReaderT r m :: * -> *) a :: * #

Methods

liftBaseWith :: (RunInBase (MultiReaderT r m) b -> b a) -> MultiReaderT r m a #

restoreM :: StM (MultiReaderT r m) a -> MultiReaderT r m a #

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

Methods

get :: MultiReaderT c m s #

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

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

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

Methods

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

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

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

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

(Monad m, ContainsType a c) => MonadMultiReader a (MultiReaderT c m) Source # 

Methods

mAsk :: MultiReaderT c m a Source #

(Monad m, ContainsType a c) => MonadMultiGet a (MultiReaderT c m) Source # 

Methods

mGet :: MultiReaderT c m a Source #

MonadTrans (MultiReaderT x) Source # 

Methods

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

MonadTransControl (MultiReaderT r) Source # 

Associated Types

type StT (MultiReaderT r :: (* -> *) -> * -> *) a :: * #

Methods

liftWith :: Monad m => (Run (MultiReaderT r) -> m a) -> MultiReaderT r m a #

restoreT :: Monad m => m (StT (MultiReaderT r) a) -> MultiReaderT r m a #

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

Methods

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

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

return :: a -> MultiReaderT x m a #

fail :: String -> MultiReaderT x m a #

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

Methods

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

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

MonadFix m => MonadFix (MultiReaderT r m) Source # 

Methods

mfix :: (a -> MultiReaderT r m a) -> MultiReaderT r m a #

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

Methods

pure :: a -> MultiReaderT x m a #

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

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

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

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

Methods

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

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

Methods

empty :: MultiReaderT c m a #

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

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

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

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

Methods

mzero :: MultiReaderT c m a #

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

type StT (MultiReaderT r) a Source # 
type StT (MultiReaderT r) a = (a, HList r)
type StM (MultiReaderT r m) a Source # 
type StM (MultiReaderT r m) a = ComposeSt (MultiReaderT r) m a

type MultiReaderTNull = MultiReaderT '[] Source #

A MultiReader transformer carrying an empty state.

type MultiReader x = MultiReaderT x Identity Source #

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

Similar to Reader r = ReaderT r Identity

MonadMultiReader class

class Monad m => MonadMultiReader a m where Source #

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

mAsk

Methods

mAsk :: m a Source #

Instances

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

Methods

mAsk :: t m a Source #

(Monad m, ContainsType a c) => MonadMultiReader a (MultiReaderT c m) Source # 

Methods

mAsk :: MultiReaderT c m a Source #

(Monad m, ContainsType a c) => MonadMultiReader a (MultiReaderT c m) Source # 

Methods

mAsk :: MultiReaderT c m a Source #

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

Methods

mAsk :: MultiRWST r w s m a Source #

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

Methods

mAsk :: MultiRWST r w s m a Source #

class Monad m => MonadMultiGet a m where Source #

In contrast to MonadMultiReader, MonadMultiGet is defined for State too, so it corresponds to read-access of any kind.

Note however that for MultiRWS, only the values from the state part can be accessed via MonadMultiGet, due to limitations of the design of MultiRWS and of the type system. This is issue is resolved in the MultiGST type.

Minimal complete definition

mGet

Methods

mGet :: m a Source #

Instances

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

Methods

mGet :: t m a Source #

(Monad m, ContainsType a c) => MonadMultiGet a (MultiReaderT c m) Source # 

Methods

mGet :: MultiReaderT c m a Source #

(Monad m, ContainsType a c) => MonadMultiGet a (MultiReaderT c m) Source # 

Methods

mGet :: MultiReaderT c m a Source #

(Monad m, ContainsType a c) => MonadMultiGet a (MultiStateT c m) Source # 

Methods

mGet :: MultiStateT c m a Source #

(Monad m, ContainsType a c) => MonadMultiGet a (MultiStateT c m) Source # 

Methods

mGet :: MultiStateT c m a Source #

(Monad m, HListMContains GettableFlag a cts) => MonadMultiGet a (MultiGSTT cts m) Source # 

Methods

mGet :: MultiGSTT cts m a Source #

(Monad m, HListMContains GettableFlag a cts) => MonadMultiGet a (MultiGSTT cts m) Source # 

Methods

mGet :: MultiGSTT cts m a Source #

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

Methods

mGet :: MultiRWST r w s m a Source #

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

Methods

mGet :: MultiRWST r w s m a Source #

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 #

with-functions (single reader)

withMultiReader :: Monad m => r -> MultiReaderT (r ': rs) m a -> MultiReaderT rs m a Source #

withMultiReader_ :: (Functor m, Monad m) => r -> MultiReaderT (r ': rs) m a -> MultiReaderT rs m () Source #

with-functions (multiple readers)

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

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

without-function (single reader)

withoutMultiReader :: Monad m => MultiReaderT rs m a -> MultiReaderT (r ': rs) m a Source #

inflate-function (run ReaderT in MultiReaderT)

inflateReader :: (Monad m, ContainsType r rs) => ReaderT r m a -> MultiReaderT rs m a 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 #