Safe Haskell | None |
---|---|
Language | Haskell2010 |
Control.Monad.Trans.StateBag.Primitive
Description
State bag monad transformer which runs on a PrimMonad stack.
- data StateBaggerT full bag m a
- runBagger :: forall full m a. (PrimMonad m, ElementCount full) => StateBaggerT full '[] m a -> m a
- addItem :: forall item full bag m a. (PrimMonad m, ElementIndex item full) => item -> StateBaggerT full (item ': bag) m a -> StateBaggerT full bag m a
- topItem :: forall item full bag m. (PrimMonad m, ElementIndex item full) => StateBaggerT full (item ': bag) m item
- stackItem :: forall item full bag m a. (PrimMonad m, ElementIndex item full) => item -> StateBaggerT full (item ': bag) m a -> StateBaggerT full bag m (a, item)
- data StateBagT bag m a
- makeBag :: forall bag m a. (PrimMonad m, ElementCount bag) => StateBagT bag m a -> StateBaggerT bag bag m a
- getItem :: forall m item bag. (PrimMonad m, ElementIndex item bag) => StateBagT bag m item
- putItem :: forall m item bag. (PrimMonad m, ElementIndex item bag) => item -> StateBagT bag m ()
- modifyItemM :: forall m item bag. (PrimMonad m, ElementIndex item bag) => (item -> StateBagT bag m item) -> StateBagT bag m ()
- class ElementCount a
- class ElementIndex x xs
Documentation
data StateBaggerT full bag m a Source #
Monad transformer for building state bags.
Instances
MonadTrans (StateBaggerT full bag) Source # | |
Monad m => Monad (StateBaggerT full bag m) Source # | |
Functor m => Functor (StateBaggerT full bag m) Source # | |
Applicative m => Applicative (StateBaggerT full bag m) Source # | |
MonadIO m => MonadIO (StateBaggerT full bag m) Source # | |
PrimMonad m => PrimMonad (StateBaggerT full bag m) Source # | |
type PrimState (StateBaggerT full bag m) Source # | |
runBagger :: forall full m a. (PrimMonad m, ElementCount full) => StateBaggerT full '[] m a -> m a Source #
Run an empty state bagger on top of a monad stack.
addItem :: forall item full bag m a. (PrimMonad m, ElementIndex item full) => item -> StateBaggerT full (item ': bag) m a -> StateBaggerT full bag m a Source #
Run a state bagger with one additional item.
topItem :: forall item full bag m. (PrimMonad m, ElementIndex item full) => StateBaggerT full (item ': bag) m item Source #
Get the value of the top item in a state bagger.
stackItem :: forall item full bag m a. (PrimMonad m, ElementIndex item full) => item -> StateBaggerT full (item ': bag) m a -> StateBaggerT full bag m (a, item) Source #
Run a state bagger with one additional item and capture the final value of that item on return.
data StateBagT bag m a Source #
State bag monad transformer where the state items are represented by the
type-level list bag
.
Instances
MonadTrans (StateBagT bag) Source # | |
Monad m => Monad (StateBagT bag m) Source # | |
Functor m => Functor (StateBagT bag m) Source # | |
Applicative m => Applicative (StateBagT bag m) Source # | |
MonadIO m => MonadIO (StateBagT bag m) Source # | |
PrimMonad m => PrimMonad (StateBagT bag m) Source # | |
PrimMonad m => StateBagMonad (StateBagT bag m) Source # | |
type PrimState (StateBagT bag m) Source # | |
type Bag (StateBagT bag m) Source # | |
type BagBase (StateBagT bag m) Source # | |
makeBag :: forall bag m a. (PrimMonad m, ElementCount bag) => StateBagT bag m a -> StateBaggerT bag bag m a Source #
Runs a state bag with the items prepared in a state bagger.
getItem :: forall m item bag. (PrimMonad m, ElementIndex item bag) => StateBagT bag m item Source #
Gets the current value of item
from the bag.
putItem :: forall m item bag. (PrimMonad m, ElementIndex item bag) => item -> StateBagT bag m () Source #
Stores a new value of item
in the bag.
modifyItemM :: forall m item bag. (PrimMonad m, ElementIndex item bag) => (item -> StateBagT bag m item) -> StateBagT bag m () Source #
Applies a monadic function to an item in the bag and stores the result.
class ElementCount a Source #
Type-class for counting the number of elements in a type-level list.
Minimal complete definition
elemCount
Instances
ElementCount ([] *) Source # | |
ElementCount xs => ElementCount ((:) * x xs) Source # | |
class ElementIndex x xs Source #
Type-class for finding the index of an element in a type-level list.
Minimal complete definition
elemIndex
Instances
ElementIndex x xs => ElementIndex x ((:) * y xs) Source # | |
ElementIndex x ((:) * x xs) Source # | |