definitive-base-2.6.3: A small Prelude wrapper to simplify my own Haskell developments

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 (Free m) Source # 

Methods

get :: Free m s Source #

put :: s -> Free m () Source #

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

MonadState s m => MonadState s (ListT m) Source # 

Methods

get :: ListT m s Source #

put :: s -> ListT m () Source #

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

MonadState s m => MonadState s (TreeT m) Source # 

Methods

get :: TreeT m s Source #

put :: s -> TreeT m () Source #

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

MonadState s m => MonadState s (MaybeT m) Source # 

Methods

get :: MaybeT m s Source #

put :: s -> MaybeT m () Source #

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

MonadState s m => MonadState s (StrictT m) Source # 

Methods

get :: StrictT m s Source #

put :: s -> StrictT m () Source #

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

MonadState s m => MonadState s (LogicT m) Source # 

Methods

get :: LogicT m s Source #

put :: s -> LogicT m () Source #

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

(Traversable f, Monad f, MonadState s g) => MonadState s (Compose' f g) Source # 

Methods

get :: Compose' f g s Source #

put :: s -> Compose' f g () Source #

modify :: (s -> s) -> Compose' f g () Source #

MonadState s m => MonadState s (ReaderT r m) Source # 

Methods

get :: ReaderT r m s Source #

put :: s -> ReaderT r m () Source #

modify :: (s -> s) -> ReaderT r m () Source #

Monad m => MonadState s (StateT s m) Source # 

Methods

get :: StateT s m s Source #

put :: s -> StateT s m () Source #

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

(Monoid w, MonadState r m) => MonadState r (WriterT w m) Source # 

Methods

get :: WriterT w m r Source #

put :: r -> WriterT w m () Source #

modify :: (r -> r) -> WriterT w m () Source #

(MonadState s m, Monoid w) => MonadState s (CounterT w acc m) Source # 

Methods

get :: CounterT w acc m s Source #

put :: s -> CounterT w acc m () Source #

modify :: (s -> s) -> CounterT w acc m () Source #

(Monad m, Monoid w) => MonadState s (RWST r w s m) Source # 

Methods

get :: RWST r w s m s Source #

put :: s -> RWST r w s m () Source #

modify :: (s -> s) -> RWST r w s m () Source #

data StateT s m a Source #

Instances

MonadCounter w acc m => MonadCounter w acc (StateT s m) Source # 

Methods

getCounter :: StateT s m acc Source #

setCounter :: acc -> StateT s m () Source #

(Monad m, MonadFuture n m) => MonadFuture n (StateT s m) Source # 

Methods

future :: n a -> StateT s m a Source #

MonadError e m => MonadError e (StateT s m) Source # 

Methods

throw :: e -> StateT s m a Source #

catch :: (e -> StateT s m a) -> StateT s m a -> StateT s m a Source #

MonadWriter w m => MonadWriter w (StateT s m) Source # 

Methods

tell :: w -> StateT s m () Source #

listen :: StateT s m a -> StateT s m (w, a) Source #

censor :: StateT s m (a, w -> w) -> StateT s m a Source #

MonadReader r m => MonadReader r (StateT s m) Source # 

Methods

ask :: StateT s m r Source #

local :: (r -> r) -> StateT s m a -> StateT s m a Source #

Monad m => MonadState s (StateT s m) Source # 

Methods

get :: StateT s m s Source #

put :: s -> StateT s m () Source #

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

ConcreteMonad (StateT s) Source # 

Methods

generalize :: Monad m => StateT s Id a -> StateT s m a Source #

MonadTrans (StateT s) Source # 

Methods

lift :: Monad m => m a -> StateT s m a Source #

MonadInternal (StateT s) Source # 

Methods

internal :: Monad m => (forall c. m (c, a) -> m (c, b)) -> StateT s m a -> StateT s m b Source #

Unit m => Unit (StateT s m) Source # 

Methods

pure :: a -> StateT s m a Source #

MonadCont m => MonadCont (StateT s m) Source # 

Methods

callCC :: (forall b. (a -> StateT s m b) -> StateT s m b) -> StateT s m a Source #

MonadList m => MonadList (StateT s m) Source # 

Methods

choose :: [a] -> StateT s m a Source #

MonadFix m => MonadFix (StateT s m) Source # 

Methods

mfix :: (a -> StateT s m a) -> StateT s m a Source #

Monad m => Monad (StateT s m) Source # 

Methods

join :: StateT s m (StateT s m a) -> StateT s m a Source #

(>>=) :: StateT s m a -> (a -> StateT s m b) -> StateT s m b Source #

Monad m => Applicative (StateT s m) Source # 
Monad m => SemiApplicative (StateT s m) Source # 

Methods

(<*>) :: StateT s m (a -> b) -> StateT s m a -> StateT s m b Source #

Functor m => Functor (StateT s m) Source # 

Methods

map :: (a -> b) -> StateT s m a -> StateT s m b Source #

MonadLogic l m => MonadLogic (StateT s l) (StateT s m) Source # 

Methods

deduce :: StateT s m a -> StateT s l (Maybe (a, StateT s m a)) Source #

induce :: StateT s l (Maybe (a, StateT s m a)) -> StateT s m a Source #

Ring (m (a, s, Void)) => Ring (StateT s m a) Source # 

Methods

one :: StateT s m a Source #

Semiring (m (a, s, Void)) => Semiring (StateT s m a) Source # 

Methods

(*) :: StateT s m a -> StateT s m a -> StateT s m a Source #

Monoid (m (a, s, Void)) => Monoid (StateT s m a) Source # 

Methods

zero :: StateT s m a Source #

Semigroup (m (a, s, Void)) => Semigroup (StateT s m a) Source # 

Methods

(+) :: StateT s m a -> StateT s m a -> StateT s m a Source #

Functor m => StateRes (StateT s m a) (s -> m s) (s -> m a) Source # 

Methods

evalS :: StateT s m a -> s -> m a Source #

execS :: StateT s m a -> s -> m s Source #

type State s a = StateT s Id a Source #

class StateRes t s a | t -> s a where Source #

Minimal complete definition

evalS, execS

Methods

evalS :: t -> a Source #

execS :: t -> s Source #

Instances

StateRes r a b => StateRes (Id r) a b Source # 

Methods

evalS :: Id r -> b Source #

execS :: Id r -> a Source #

StateRes (s, a) s a Source # 

Methods

evalS :: (s, a) -> a Source #

execS :: (s, a) -> s Source #

StateRes r a b => StateRes (s -> r) (s -> a) (s -> b) Source # 

Methods

evalS :: (s -> r) -> s -> b Source #

execS :: (s -> r) -> s -> a Source #

Functor m => StateRes (StateT s m a) (s -> m s) (s -> m a) Source # 

Methods

evalS :: StateT s m a -> s -> m a Source #

execS :: StateT s m a -> s -> m s Source #

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

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

(<~) :: MonadState s m => Lens' s a -> (a -> (a, b)) -> m b infixl 1 Source #

(=~) :: MonadState s m => FixFold' s a -> (a -> a) -> m () infixl 1 Source #

(=-) :: MonadState s m => FixFold' s s' -> s' -> m () infixl 1 Source #

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

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

getl :: MonadState s m => Lens' s a -> m a Source #

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

swapWith :: MonadState s m => Lens' s a -> (a -> 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 #

scanl :: Traversable t => (a -> b -> a) -> a -> t b -> t a Source #

scanr :: Traversable t => (a -> b -> a) -> a -> t b -> t a 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) Source # 

Methods

(<#>) :: StateA m a c -> StateA m b d -> StateA m (a, b) (c, d) Source #

Monad m => Choice (StateA m) Source # 

Methods

(<|>) :: StateA m a c -> StateA m b c -> StateA m (a :+: b) c Source #

Monad m => Category (StateA m) Source # 

Methods

id :: StateA m a a Source #

Monad m => Deductive (StateA m) Source # 

Methods

(.) :: StateA m b c -> StateA m a b -> StateA m a c Source #

Monad m => Arrow (StateA m) Source # 

Methods

arr :: (a -> b) -> StateA m a b Source #

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

Atomic IO state

runAtomic :: IORef s -> State s a -> IO a Source #

Orphan instances

MonadState (IO ()) IO Source # 

Methods

get :: IO (IO ()) Source #

put :: IO () -> IO () Source #

modify :: (IO () -> IO ()) -> IO () Source #