-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | like mtl's ReaderT/StateT, but more than one contained value/type. -- @package multistate @version 0.2.0.0 -- | A GADT HList implementation -- -- Probably exists somewhere else already, but why add a dependency for -- something so simple. module Data.HList.HList data HList :: [*] -> * HNil :: HList [] (:+:) :: x -> HList xs -> HList (x : xs) instance [overlap ok] (Monoid x, Monoid (HList xs)) => Monoid (HList (x : xs)) instance [overlap ok] Monoid (HList '[]) instance [overlap ok] (Show a, Show (HList b)) => Show (HList (a : b)) instance [overlap ok] Show (HList '[]) -- | The multi-valued version of mtl's State / StateT / MonadState module Control.Monad.MultiState -- | A State transformer monad patameterized by: -- -- -- -- 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: -- -- -- -- For example, -- --
--   MultiStateT (Cons Int (Cons Bool Null)) :: (* -> *) -> (* -> *)
--   
-- -- is a State wrapper containing the types [Int,Bool]. newtype MultiStateT x m a MultiStateT :: StateT (HList x) m a -> MultiStateT x m a runMultiStateTRaw :: MultiStateT x m a -> StateT (HList x) m a -- | A MultiState transformer carrying an empty state. type MultiStateTNull = MultiStateT [] -- | A state monad parameterized by the list of types x of the state to -- carry. -- -- Similar to State s = StateT s Identity type MultiState x = MultiStateT x Identity -- | All methods must be defined. -- -- The idea is: Any monad stack is instance of MonadMultiState -- a, iff the stack contains a MultiStateT x with a -- element of x. class Monad m => MonadMultiState a m mSet :: MonadMultiState a m => a -> m () mGet :: MonadMultiState a m => m a -- | A raw extractor of the contained HList (i.e. the complete state). -- -- For a possible usecase, see withMultiStates. mGetRaw :: Monad m => MultiStateT a m (HList a) -- | Adds an element to the state, thereby transforming a MultiStateT over -- values with types (x:xs) to a MultiStateT over xs. -- -- Think "Execute this computation with this additional value as state". withMultiState :: Monad m => x -> MultiStateT (x : xs) m a -> MultiStateT xs m a -- | Adds a heterogenous list of elements to the state, thereby -- transforming a MultiStateT over values with types xs++ys to a -- MultiStateT over ys. -- -- Similar to recursively adding single values with -- withMultiState. -- -- Note that ys can be Null; in that case the return value can be -- evaluated further using evalMultiStateT. withMultiStates :: Monad m => HList xs -> MultiStateT (Append xs ys) m a -> MultiStateT ys m a -- | Evaluate an empty state computation. -- -- Because the state is empty, no initial state must be provided. -- -- Currently it is not directly possible to extract the final state of a -- computation (similar to execStateT and runStateT for -- mtl's StateT), but you can use mGetRaw if you need such -- functionality. -- -- If you want to evaluate a computation over any non-Null state, either -- use -- -- evalMultiStateT :: Monad m => MultiStateT [] m a -> m a -- | Evaluate a state computation with the given initial state. evalMultiStateTWithInitial :: Monad m => HList a -> MultiStateT a m b -> m b -- | Map both the return value and the state of a computation using the -- given function. mapMultiStateT :: (m (a, HList w) -> m' (a', HList w)) -> MultiStateT w m a -> MultiStateT w m' a' instance [overlap ok] MonadWriter w m => MonadWriter w (MultiStateT c m) instance [overlap ok] MonadState s m => MonadState s (MultiStateT c m) instance [overlap ok] (MonadTrans t, Monad (t m), MonadMultiState a m) => MonadMultiState a (t m) instance [overlap ok] (Monad m, ContainsType a c) => MonadMultiState a (MultiStateT c m) instance [overlap ok] MonadTrans (MultiStateT x) instance [overlap ok] Monad m => Monad (MultiStateT x m) instance [overlap ok] (Applicative m, Monad m) => Applicative (MultiStateT x m) instance [overlap ok] Functor f => Functor (MultiStateT x f) instance [overlap ok] ContainsType a xs => ContainsType a (x : xs) instance [overlap ok] ContainsType a (a : xs) -- | The multi-valued version of mtl's Reader / ReaderT / MonadReader module Control.Monad.MultiReader -- | A Reader transformer monad patameterized by: -- -- -- -- 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: -- -- -- -- For example, -- --
--   MultiReaderT (Cons Int (Cons Bool Null)) :: (* -> *) -> (* -> *)
--   
-- -- is a Reader wrapper containing the types [Int,Bool]. newtype MultiReaderT x m a MultiReaderT :: StateT (HList x) m a -> MultiReaderT x m a runMultiReaderTRaw :: MultiReaderT x m a -> StateT (HList x) m a -- | A MultiReader transformer carrying an empty state. type MultiReaderTNull = MultiReaderT [] -- | A reader monad parameterized by the list of types x of the environment -- / input to carry. -- -- Similar to Reader r = ReaderT r Identity type MultiReader x = MultiReaderT x 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. class Monad m => MonadMultiReader a m mAsk :: MonadMultiReader a m => m a -- | A raw extractor of the contained HList (i.e. the complete -- environment). -- -- For a possible usecase, see withMultiReaders. mAskRaw :: Monad m => MultiReaderT a m (HList a) -- | Adds an element to the environment, thereby transforming a -- MultiReaderT carrying an environment with types (x:xs) to a a -- MultiReaderT with xs. -- -- Think "Execute this computation with this additional value as -- environment". withMultiReader :: Monad m => x -> MultiReaderT (x : xs) m a -> MultiReaderT xs m a -- | Adds a heterogenous list of elements to the environment, thereby -- transforming a MultiReaderT carrying an environment with values over -- types xs++ys to a MultiReaderT over ys. -- -- Similar to recursively adding single values with -- withMultiReader. -- -- Note that ys can be Null; in that case the return value can be -- evaluated further using evalMultiReaderT. withMultiReaders :: Monad m => HList xs -> MultiReaderT (Append xs ys) m a -> MultiReaderT ys m a -- | Evaluate a computation over an empty environment. -- -- Because the environment is empty, it does not need to be provided. -- -- If you want to evaluate a computation over any non-Null environment, -- either use -- -- evalMultiReaderT :: Monad m => MultiReaderT [] m a -> m a -- | Evaluate a reader computation with the given environment. evalMultiReaderTWithInitial :: Monad m => HList a -> MultiReaderT a m b -> m b -- | 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. mapMultiReaderT :: (m (a, HList w) -> m' (a', HList w)) -> MultiReaderT w m a -> MultiReaderT w m' a' instance [overlap ok] MonadWriter w m => MonadWriter w (MultiReaderT c m) instance [overlap ok] MonadState s m => MonadState s (MultiReaderT c m) instance [overlap ok] (MonadTrans t, Monad (t m), MonadMultiReader a m) => MonadMultiReader a (t m) instance [overlap ok] (Monad m, ContainsType a c) => MonadMultiReader a (MultiReaderT c m) instance [overlap ok] MonadTrans (MultiReaderT x) instance [overlap ok] Monad m => Monad (MultiReaderT x m) instance [overlap ok] (Applicative m, Monad m) => Applicative (MultiReaderT x m) instance [overlap ok] Functor f => Functor (MultiReaderT x f) instance [overlap ok] ContainsType a xs => ContainsType a (x : xs) instance [overlap ok] ContainsType a (a : xs)