Safe Haskell | None |
---|---|
Language | Haskell2010 |
- MonadState class
- The State monad
- The StateT monad transformer
- The State monad (lazy)
- The StateT monad transformer (lazy)
- The State monad (flattened)
- The StateT monad transformer (flattened)
- MonadState class (implicit)
- The State monad (implicit)
- The StateT monad transformer (implicit)
- The State monad (lazy, implicit)
- The StateT monad transformer (lazy, implicit)
- Zoom
- Internal labels
- class Monad m => MonadState tag s m | m tag -> s where
- get :: MonadState tag s m => m s
- put :: MonadState tag s m => s -> m ()
- state :: MonadState tag s m => (s -> (a, s)) -> m a
- modify :: forall tag s m. MonadState tag s m => (s -> s) -> m ()
- gets :: forall tag s m a. MonadState tag s m => (s -> a) -> m a
- type State tag r = StateT tag r Identity
- runState :: forall tag s a. State tag s a -> s -> (a, s)
- evalState :: forall tag s a. State tag s a -> s -> a
- execState :: forall tag s a. State tag s a -> s -> s
- type StateT tag s = TaggedTrans (TAGGED STATE tag) (StateT s)
- stateT :: forall tag s m a. (s -> m (a, s)) -> StateT tag s m a
- runStateT :: forall tag s m a. StateT tag s m a -> s -> m (a, s)
- evalStateT :: forall tag s m a. Monad m => StateT tag s m a -> s -> m a
- execStateT :: forall tag s m a. Monad m => StateT tag s m a -> s -> m s
- type LazyState tag r = LazyStateT tag r Identity
- runLazyState :: forall tag s a. LazyState tag s a -> s -> (a, s)
- evalLazyState :: forall tag s a. LazyState tag s a -> s -> a
- execLazyState :: forall tag s a. LazyState tag s a -> s -> s
- type LazyStateT tag s = TaggedTrans (TAGGED STATE tag) (StateT s)
- lazyStateT :: forall tag s m a. (s -> m (a, s)) -> LazyStateT tag s m a
- runLazyStateT :: forall tag s m a. LazyStateT tag s m a -> s -> m (a, s)
- evalLazyStateT :: forall tag s m a. Monad m => LazyStateT tag s m a -> s -> m a
- execLazyStateT :: forall tag s m a. Monad m => LazyStateT tag s m a -> s -> m s
- type States s = StatesT s Identity
- runStates :: forall p a. States p a -> p -> (a, p)
- type StatesT s = TaggedTrans (STATES (Tags s)) (StateT s)
- runStatesT :: forall p m a. StatesT p m a -> p -> m (a, p)
- type MonadState' s = MonadState s s
- get' :: forall s m. MonadState' s m => m s
- put' :: forall s m. MonadState' s m => s -> m ()
- state' :: forall s m a. MonadState' s m => (s -> (a, s)) -> m a
- modify' :: forall s m. MonadState' s m => (s -> s) -> m ()
- gets' :: forall s m a. MonadState' s m => (s -> a) -> m a
- type State' s = State s s
- runState' :: State' s a -> s -> (a, s)
- evalState' :: State' s a -> s -> a
- execState' :: State' s a -> s -> s
- type StateT' s = StateT s s
- stateT' :: (s -> m (a, s)) -> StateT' s m a
- runStateT' :: StateT' s m a -> s -> m (a, s)
- evalStateT' :: Monad m => StateT' s m a -> s -> m a
- execStateT' :: Monad m => StateT' s m a -> s -> m s
- type LazyState' s = LazyState s s
- runLazyState' :: LazyState' s a -> s -> (a, s)
- evalLazyState' :: LazyState' s a -> s -> a
- execLazyState' :: LazyState' s a -> s -> s
- type LazyStateT' s = LazyStateT s s
- lazyStateT' :: (s -> m (a, s)) -> LazyStateT' s m a
- runLazyStateT' :: LazyStateT' s m a -> s -> m (a, s)
- evalLazyStateT' :: Monad m => LazyStateT' s m a -> s -> m a
- execLazyStateT' :: Monad m => LazyStateT' s m a -> s -> m s
- type ZoomT t z = TaggedTrans (ZOOM t z) IdentityT
- zoom :: forall tag sOuter sInner m a. Lens' sOuter sInner -> (forall z. Reifies z (ReifiedLens' sOuter sInner) => ZoomT tag z m a) -> m a
- data TAGGED e t
- data STATE
- type family STATES (ts :: HList xs) :: [Type] where ...
- data ZOOM t z
MonadState class
class Monad m => MonadState tag s m | m tag -> s where Source #
Return the state from the internals of the monad.
Replace the state inside the monad.
state :: (s -> (a, s)) -> m a Source #
Embed a simple state action into the monad.
(MonadTrans t, Monad (t m), MonadState k tag s m) => MonadState k tag s (t m) Source # | |
(MonadState k1 tag sOuter m, Reifies k z (ReifiedLens' sOuter sInner), (~) ((* -> *) -> * -> *) trans (IdentityT *)) => MonadState k1 tag sInner (TaggedTrans * (* -> *) * (ZOOM k k1 tag z) trans m) Source # | |
(Monad (trans m), MonadState k tag s (TaggedTrans * (Type -> Type) [a] effs trans m)) => MonadState k tag s (TaggedTrans * (Type -> Type) [a] ((:) a eff effs) trans m) Source # | |
(MonadState k1 tNew s m, (~) ((* -> *) -> * -> *) trans (IdentityT *)) => MonadState k tOld s (TaggedTrans * (* -> *) * (TAG_REPLACE k1 k tOld tNew) trans m) Source # | |
get :: MonadState tag s m => m s Source #
Return the state from the internals of the monad.
put :: MonadState tag s m => s -> m () Source #
Replace the state inside the monad.
state :: MonadState tag s m => (s -> (a, s)) -> m a Source #
Embed a simple state action into the monad.
modify :: forall tag s m. MonadState tag s m => (s -> s) -> m () Source #
Modifies the state inside a state monad.
gets :: forall tag s m a. MonadState tag s m => (s -> a) -> m a Source #
Gets specific component of the state, using a projection function supplied.
The State monad
runState :: forall tag s a. State tag s a -> s -> (a, s) Source #
Runs a State
with the given initial state
and returns both the final value and the final state.
evalState :: forall tag s a. State tag s a -> s -> a Source #
Runs a State
with the given initial state
and returns the final value, discarding the final state.
execState :: forall tag s a. State tag s a -> s -> s Source #
Runs a State
with the given initial state
and returns the final state, discarding the final value.
The StateT monad transformer
stateT :: forall tag s m a. (s -> m (a, s)) -> StateT tag s m a Source #
Constructor for computations in the state monad transformer.
runStateT :: forall tag s m a. StateT tag s m a -> s -> m (a, s) Source #
Runs a StateT
with the given initial state
and returns both the final value and the final state.
evalStateT :: forall tag s m a. Monad m => StateT tag s m a -> s -> m a Source #
Runs a StateT
with the given initial state
and returns the final value, discarding the final state.
execStateT :: forall tag s m a. Monad m => StateT tag s m a -> s -> m s Source #
Runs a StateT
with the given initial state
and returns the final state, discarding the final value.
The State monad (lazy)
type LazyState tag r = LazyStateT tag r Identity Source #
runLazyState :: forall tag s a. LazyState tag s a -> s -> (a, s) Source #
Runs a State
with the given initial state
and returns both the final value and the final state.
evalLazyState :: forall tag s a. LazyState tag s a -> s -> a Source #
Runs a State
with the given initial state
and returns the final value, discarding the final state.
execLazyState :: forall tag s a. LazyState tag s a -> s -> s Source #
Runs a State
with the given initial state
and returns the final state, discarding the final value.
The StateT monad transformer (lazy)
type LazyStateT tag s = TaggedTrans (TAGGED STATE tag) (StateT s) Source #
lazyStateT :: forall tag s m a. (s -> m (a, s)) -> LazyStateT tag s m a Source #
Constructor for computations in the state monad transformer.
runLazyStateT :: forall tag s m a. LazyStateT tag s m a -> s -> m (a, s) Source #
Runs a StateT
with the given initial state
and returns both the final value and the final state.
evalLazyStateT :: forall tag s m a. Monad m => LazyStateT tag s m a -> s -> m a Source #
Runs a StateT
with the given initial state
and returns the final value, discarding the final state.
execLazyStateT :: forall tag s m a. Monad m => LazyStateT tag s m a -> s -> m s Source #
Runs a StateT
with the given initial state
and returns the final state, discarding the final value.
The State monad (flattened)
The StateT monad transformer (flattened)
runStatesT :: forall p m a. StatesT p m a -> p -> m (a, p) Source #
MonadState class (implicit)
type MonadState' s = MonadState s s Source #
get' :: forall s m. MonadState' s m => m s Source #
put' :: forall s m. MonadState' s m => s -> m () Source #
state' :: forall s m a. MonadState' s m => (s -> (a, s)) -> m a Source #
modify' :: forall s m. MonadState' s m => (s -> s) -> m () Source #
gets' :: forall s m a. MonadState' s m => (s -> a) -> m a Source #
The State monad (implicit)
evalState' :: State' s a -> s -> a Source #
execState' :: State' s a -> s -> s Source #
The StateT monad transformer (implicit)
runStateT' :: StateT' s m a -> s -> m (a, s) Source #
evalStateT' :: Monad m => StateT' s m a -> s -> m a Source #
execStateT' :: Monad m => StateT' s m a -> s -> m s Source #
The State monad (lazy, implicit)
type LazyState' s = LazyState s s Source #
runLazyState' :: LazyState' s a -> s -> (a, s) Source #
evalLazyState' :: LazyState' s a -> s -> a Source #
execLazyState' :: LazyState' s a -> s -> s Source #
The StateT monad transformer (lazy, implicit)
type LazyStateT' s = LazyStateT s s Source #
lazyStateT' :: (s -> m (a, s)) -> LazyStateT' s m a Source #
runLazyStateT' :: LazyStateT' s m a -> s -> m (a, s) Source #
evalLazyStateT' :: Monad m => LazyStateT' s m a -> s -> m a Source #
execLazyStateT' :: Monad m => LazyStateT' s m a -> s -> m s Source #
Zoom
zoom :: forall tag sOuter sInner m a. Lens' sOuter sInner -> (forall z. Reifies z (ReifiedLens' sOuter sInner) => ZoomT tag z m a) -> m a Source #
Zoom into a part of a state using a lens.
Internal labels
Encode type-level information for StateT
.