definitive-base-2.3: The base modules of the Definitive framework.

Safe HaskellNone
LanguageHaskell2010

Algebra.Monad.State

Contents

Synopsis

The State Monad

class Monad m => MonadState s m | m -> s where Source

Minimal complete definition

get

Methods

get :: m s Source

put :: s -> m () Source

modify :: (s -> s) -> m () Source

Instances

MonadState s m => MonadState s (ListT m) 
MonadState s m => MonadState s (Free m) 
MonadState s m => MonadState s (LogicT m) 
(Traversable g, Monad g, MonadState s f) => MonadState s ((:.:) f g) 
(Traversable f, Monad f, MonadState s g) => MonadState s (Compose' f g) 
Monad m => MonadState s (StateT s m) 
MonadState s m => MonadState s (ReaderT r m) 
(Monoid w, MonadState r m) => MonadState r (WriterT w m) 
(MonadState s m, Monoid w, SubSemi acc w) => MonadState s (CounterT w acc m) 
(Monad m, Monoid w) => MonadState s (RWST r w s m) 
MonadState (IO ()) IO 

data StateT s m a Source

Instances

MonadCounter w acc m => MonadCounter w acc (StateT s m) 
(Monad m, MonadFuture n m) => MonadFuture n (StateT s m) 
MonadError e m => MonadError e (StateT s m) 
MonadWriter w m => MonadWriter w (StateT s m) 
MonadReader r m => MonadReader r (StateT s m) 
Monad m => MonadState s (StateT s m) 
MonadTrans (StateT s) 
MonadInternal (StateT s) 
Unit m => Unit (StateT s m) 
MonadCont m => MonadCont (StateT s m) 
MonadList m => MonadList (StateT s m) 
MonadFix m => MonadFix (StateT s m) 
Monad m => Monad (StateT s m) 
Monad m => Applicative (StateT s m) 
Functor m => Functor (StateT s m) 
Ring (m (a, s, Void)) => Ring (StateT s m a) 
Semiring (m (a, s, Void)) => Semiring (StateT s m a) 
Monoid (m (a, s, Void)) => Monoid (StateT s m a) 
Semigroup (m (a, s, Void)) => Semigroup (StateT s m a) 

type State s a = StateT s Id a Source

stateT :: (Functor m, Functor n) => Iso (StateT s m a) (StateT t n b) (s -> m (s, a)) (t -> n (t, b)) Source

eval :: (s -> (a, b)) -> s -> b Source

exec :: Functor f => f (a, b) -> f a Source

state :: Iso (State s a) (State t b) (s -> (s, a)) (t -> (t, b)) Source

(=~) :: MonadState s m => Traversal' s a -> (a -> a) -> m () infixl 0 Source

(=-) :: MonadState s m => Traversal' s s' -> s' -> m () infixl 0 Source

(^>=) :: MonadState s m => LensLike m a a s s -> (a -> m ()) -> m () Source

gets :: MonadState s m => (s -> a) -> m a Source

use :: MonadState s m => Getter' s a -> m a Source

saving :: MonadState s m => Lens' s s' -> m a -> m a Source

type Next a = a Source

type Prev a = a Source

mapAccum :: Traversable t => (a -> s -> (s, b)) -> t a -> s -> (s, t b) Source

mapAccum_ :: Traversable t => (a -> s -> (s, b)) -> t a -> s -> t b Source

mapAccumR :: Traversable t => (a -> s -> (s, b)) -> t a -> s -> (s, t b) Source

mapAccumR_ :: Traversable t => (a -> s -> (s, b)) -> t a -> s -> t b Source

push :: Traversable t => t a -> a -> t a Source

pop :: Traversable t => t a -> a -> t a Source

withPrev :: Traversable t => a -> t a -> t (Prev a, a) Source

withNext :: Traversable t => t a -> a -> t (a, Next a) Source

The State Arrow

newtype StateA m s a Source

Constructors

StateA (StateT s m a) 

Instances

Monad m => Split (StateA m) 
Monad m => Choice (StateA m) 
Monad m => Category (StateA m) 
Monad m => Deductive (StateA m) 
Monad m => Arrow (StateA m) 

stateA :: Iso (StateA m s a) (StateA m' s' a') (StateT s m a) (StateT s' m' a') Source