SimpleH-1.2: A light, clean and powerful Haskell utility library

Safe HaskellNone

Algebra.Monad.State

Contents

Synopsis

The State Monad

class Monad m => MonadState s m | m -> s whereSource

Methods

get :: m sSource

put :: s -> m ()Source

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

Instances

MonadState s m => MonadState s (ListT m) 
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) 
(Monoid w, Monad m) => MonadState s (ParserT w s m) 
(Monad m, Monoid w) => MonadState s (RWST r w s m) 
MonadState (IO ()) IO 

data StateT s m a Source

Instances

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) 
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 aSource

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

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

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

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

(=~) :: MonadState s m => Lens' s s' -> (s' -> s') -> m ()Source

(=-) :: MonadState s m => Lens' s s' -> s' -> m ()Source

gets :: MonadState s m => Lens' s s' -> m s'Source

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

type Next a = aSource

type Prev a = aSource

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 bSource

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 bSource

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

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

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 => Arrow (StateA m) 

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