A state monad parameterized by the type s of the state to carry.
The return function leaves the state unchanged, while >>= uses
the final state of the first computation as the initial state of
the second.
:: a typeCtrl KGHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05
Modulerebase-1.21.2Haskell2010
A state monad parameterized by the type s of the state to carry.
The return function leaves the state unchanged, while >>= uses
the final state of the first computation as the initial state of
the second.
A state transformer monad parameterized by:
s - The state.
m - The inner monad.
The return function leaves the state unchanged, while >>= uses
the final state of the first computation as the initial state of
the second.
MonadAccum w m => MonadAccum w (StateT s m)Defined in mtl-2.3.1 · Control.Monad.AccumMonadError e m => MonadError e (StateT s m)Defined in mtl-2.3.1 · Control.Monad.Error.ClassMonadReader r m => MonadReader r (StateT s m)Defined in mtl-2.3.1 · Control.Monad.Reader.ClassMonad m => MonadState s (StateT s m)Defined in mtl-2.3.1 · Control.Monad.State.ClassMonadWriter w m => MonadWriter w (StateT s m)Defined in mtl-2.3.1 · Control.Monad.Writer.ClassMonadSelect w m => MonadSelect w (StateT s m)Defined in mtl-2.3.1 · Control.Monad.Select'Readerizes' the state: the 'ranking' function can see a value of
type s, but not modify it. Effectively, can be thought of as 'extending'
the 'ranking' by all values in s, but which s gets given to any rank
calls is predetermined by the 'outer state' (and cannot change).
MonadBase b m => MonadBase b (StateT s m)Defined in transformers-base-0.4.6 · Control.Monad.Base(Functor f, MonadFree f m) => MonadFree f (StateT s m)Defined in free-5.2 · Control.Monad.Free.ClassMonadTrans (StateT s)Defined in transformers-0.6.1.1 · Control.Monad.Trans.State.StrictBindTrans (StateT s)Defined in semigroupoids-6.0.1 · Data.Functor.Bind.TransMonad m => Monad (StateT s m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.State.StrictFunctor m => Functor (StateT s m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.State.StrictMonadFix m => MonadFix (StateT s m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.State.StrictMonadFail m => MonadFail (StateT s m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.State.Strict(Functor m, Monad m) => Applicative (StateT s m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.State.Strict(Functor m, MonadPlus m) => Alternative (StateT s m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.State.StrictMonadPlus m => MonadPlus (StateT s m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.State.StrictMonadIO m => MonadIO (StateT s m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.State.StrictContravariant m => Contravariant (StateT s m)Defined in transformers-0.6.1.1 · Control.Monad.Trans.State.StrictMonadCont m => MonadCont (StateT s m)Defined in mtl-2.3.1 · Control.Monad.Cont.ClassMonadCatch m => MonadCatch (StateT s m)Defined in exceptions-0.10.9 · Control.Monad.CatchMonadMask m => MonadMask (StateT s m)Defined in exceptions-0.10.9 · Control.Monad.CatchMonadThrow m => MonadThrow (StateT s m)Defined in exceptions-0.10.9 · Control.Monad.CatchPrimMonad m => PrimMonad (StateT s m)Defined in primitive-0.9.1.0 · Control.Monad.PrimitiveDecidable m => Decidable (StateT s m)Defined in contravariant-1.5.5 · Data.Functor.Contravariant.DivisibleDivisible m => Divisible (StateT s m)Defined in contravariant-1.5.5 · Data.Functor.Contravariant.DivisibleAlt f => Alt (StateT e f)Defined in semigroupoids-6.0.1 · Data.Functor.AltBind m => Apply (StateT s m)Defined in semigroupoids-6.0.1 · Data.Functor.Bind.ClassBind m => Bind (StateT s m)Defined in semigroupoids-6.0.1 · Data.Functor.Bind.ClassConclude m => Conclude (StateT s m)Defined in semigroupoids-6.0.1 · Data.Functor.Contravariant.ConcludeDecide m => Decide (StateT s m)Defined in semigroupoids-6.0.1 · Data.Functor.Contravariant.DecideDivise m => Divise (StateT s m)Defined in semigroupoids-6.0.1 · Data.Functor.Contravariant.DivisePlus f => Plus (StateT e f)Defined in semigroupoids-6.0.1 · Data.Functor.PlusInvariant m => Invariant (StateT s m)Defined in invariant-0.6.4 · Data.Functor.Invariantfrom the transformers package
Monad m => Selective (StateT s m)Defined in selective-0.7.0.1 · Control.SelectivePointed m => Pointed (StateT s m)Defined in pointed-5.0.4 · Data.PointedGeneric (StateT s m a)Defined in transformers-0.6.1.1 · Control.Monad.Trans.State.Stricttype Rep (StateT s m a) = D1 ('MetaData "StateT"
"Control.Monad.Trans.State.Strict"
"transformers-0.6.1.1-a11a"
'True) (C1 ('MetaCons "StateT"
'PrefixI 'True) (S1 ('MetaSel ('Just "runStateT"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (s -> m (a, s)))))Defined in transformers-0.6.1.1 · Control.Monad.Trans.State.Stricttype PrimState (StateT s m) = PrimState mDefined in primitive-0.9.1.0 · Control.Monad.PrimitiveEvaluate a state computation with the given initial state and return the final value, discarding the final state.
evalStateT m s = liftM fst (runStateT m s)Evaluate a state computation with the given initial state and return the final state, discarding the final value.
execStateT m s = liftM snd (runStateT m s)runState :: State s astate-passing computation to execute
-> sinitial state
-> (a, s)return value and final state
Unwrap a state monad computation as a function. (The inverse of state.)
withStateT f m executes action m on a state modified by
applying f.
withStateT f m = modify f >> mUniform lifting of a callCC operation to the new monad.
This version rolls back to the original state on entering the
continuation.
Fetch the current value of the state within the monad.
put s sets the state within the monad to s.
state Construct a state monad computation from a function. (The inverse of runState.)
Lift a catchE operation to the new monad.
In-situ lifting of a callCC operation to the new monad.
This version uses the current state on entering the continuation.
It does not satisfy the uniformity property (see Control.Monad.Signatures).
Lift a listen operation to the new monad.
Lift a pass operation to the new monad.
A variant of modify in which the new state is generated by a monadic action.