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

Safe HaskellSafe
LanguageHaskell2010

Control.Monad.Trans.MultiState.Lazy

Contents

Description

The multi-valued version of mtl's State / StateT

Synopsis

MultiStateT

newtype MultiStateT x m a Source #

A State transformer monad patameterized by:

  • x - The list of types constituting the state,
  • m - The inner monad.

MultiStateT corresponds to mtl's StateT, 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,

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

is a State wrapper containing the types [Int, Bool].

Constructors

MultiStateT 

Fields

Instances

MonadBase b m => MonadBase b (MultiStateT s m) Source # 

Methods

liftBase :: b α -> MultiStateT s m α #

MonadBaseControl b m => MonadBaseControl b (MultiStateT s m) Source # 

Associated Types

type StM (MultiStateT s m :: * -> *) a :: * #

Methods

liftBaseWith :: (RunInBase (MultiStateT s m) b -> b a) -> MultiStateT s m a #

restoreM :: StM (MultiStateT s m) a -> MultiStateT s m a #

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

Methods

get :: MultiStateT c m s #

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

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

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

Methods

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

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

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

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

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

Methods

mGet :: MultiStateT c m a Source #

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

Methods

mSet :: a -> MultiStateT c m () Source #

MonadTrans (MultiStateT x) Source # 

Methods

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

MonadTransControl (MultiStateT s) Source # 

Associated Types

type StT (MultiStateT s :: (* -> *) -> * -> *) a :: * #

Methods

liftWith :: Monad m => (Run (MultiStateT s) -> m a) -> MultiStateT s m a #

restoreT :: Monad m => m (StT (MultiStateT s) a) -> MultiStateT s m a #

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

Methods

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

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

return :: a -> MultiStateT x m a #

fail :: String -> MultiStateT x m a #

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

Methods

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

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

MonadFix m => MonadFix (MultiStateT s m) Source # 

Methods

mfix :: (a -> MultiStateT s m a) -> MultiStateT s m a #

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

Methods

pure :: a -> MultiStateT x m a #

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

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

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

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

Methods

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

(Functor m, Applicative m, MonadPlus m) => Alternative (MultiStateT s m) Source # 

Methods

empty :: MultiStateT s m a #

(<|>) :: MultiStateT s m a -> MultiStateT s m a -> MultiStateT s m a #

some :: MultiStateT s m a -> MultiStateT s m [a] #

many :: MultiStateT s m a -> MultiStateT s m [a] #

MonadPlus m => MonadPlus (MultiStateT s m) Source # 

Methods

mzero :: MultiStateT s m a #

mplus :: MultiStateT s m a -> MultiStateT s m a -> MultiStateT s m a #

type StT (MultiStateT s) a Source # 
type StT (MultiStateT s) a = (a, HList s)
type StM (MultiStateT s m) a Source # 
type StM (MultiStateT s m) a = ComposeSt (MultiStateT s) m a

type MultiStateTNull = MultiStateT '[] Source #

A MultiState transformer carrying an empty state.

type MultiState x = MultiStateT x Identity Source #

A state monad parameterized by the list of types x of the state to carry.

Similar to State s = StateT s Identity

MonadMultiState class

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 #

class MonadMultiGet a m => MonadMultiState a m where Source #

Minimal complete definition

mSet

Methods

mSet :: a -> m () Source #

Instances

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

Methods

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

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

Methods

mSet :: a -> MultiStateT c m () Source #

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

Methods

mSet :: a -> MultiStateT c m () Source #

(Monad m, HListMContains SettableFlag a cts) => MonadMultiState a (MultiGSTT cts m) Source # 

Methods

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

(Monad m, HListMContains SettableFlag a cts) => MonadMultiState a (MultiGSTT cts m) Source # 

Methods

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

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

Methods

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

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

Methods

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

run-functions

runMultiStateT :: Functor m => HList s -> MultiStateT s m a -> m (a, HList s) Source #

runMultiStateTAS :: Functor m => HList s -> MultiStateT s m a -> m (a, HList s) Source #

runMultiStateTSA :: Monad m => HList s -> MultiStateT s m a -> m (HList s, a) Source #

runMultiStateTA :: Monad m => HList s -> MultiStateT s m a -> m a Source #

runMultiStateTS :: Monad m => HList s -> MultiStateT s m a -> m (HList s) Source #

runMultiStateT_ :: Functor m => HList s -> MultiStateT s m a -> m () Source #

runMultiStateTNil :: Monad m => MultiStateT '[] m a -> m a Source #

with-functions (single state)

withMultiState :: Monad m => s -> MultiStateT (s ': ss) m a -> MultiStateT ss m (a, s) Source #

withMultiStateAS :: Monad m => s -> MultiStateT (s ': ss) m a -> MultiStateT ss m (a, s) Source #

withMultiStateSA :: Monad m => s -> MultiStateT (s ': ss) m a -> MultiStateT ss m (s, a) Source #

withMultiStateA :: Monad m => s -> MultiStateT (s ': ss) m a -> MultiStateT ss m a Source #

withMultiStateS :: Monad m => s -> MultiStateT (s ': ss) m a -> MultiStateT ss m s Source #

withMultiState_ :: (Functor m, Monad m) => s -> MultiStateT (s ': ss) m a -> MultiStateT ss m () Source #

with-functions (multiple states)

withMultiStates :: Monad m => HList s1 -> MultiStateT (Append s1 s2) m a -> MultiStateT s2 m (a, HList s1) Source #

withMultiStatesAS :: Monad m => HList s1 -> MultiStateT (Append s1 s2) m a -> MultiStateT s2 m (a, HList s1) Source #

withMultiStatesSA :: Monad m => HList s1 -> MultiStateT (Append s1 s2) m a -> MultiStateT s2 m (HList s1, a) Source #

withMultiStatesA :: Monad m => HList s1 -> MultiStateT (Append s1 s2) m a -> MultiStateT s2 m a Source #

withMultiStatesS :: Monad m => HList s1 -> MultiStateT (Append s1 s2) m a -> MultiStateT s2 m (HList s1) Source #

withMultiStates_ :: (Functor m, Monad m) => HList s1 -> MultiStateT (Append s1 s2) m a -> MultiStateT s2 m () Source #

without-function (single state)

withoutMultiState :: (Functor m, Monad m) => MultiStateT ss m a -> MultiStateT (s ': ss) m a Source #

inflate-functions (run single state in multiple states)

inflateState :: (Monad m, ContainsType s ss) => StateT s m a -> MultiStateT ss m a Source #

inflateReader :: (Monad m, ContainsType r ss) => ReaderT r m a -> MultiStateT ss m a Source #

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

other functions

mapMultiStateT :: (m (a, HList w) -> m' (a', HList w)) -> MultiStateT w m a -> MultiStateT w m' a' Source #

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

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

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

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