-- 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 (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 -- --
-- 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 -- --