@@ -1,6 +1,6 @@
11module Control.Monad.State
22
3−import Control.Monad.Identity
3+import public Control.Monad.Identity
44import Control.Monad.Trans
55
66%access public
@@ -55,3 +55,15 @@ gets f = do s <- get
5555||| The State monad. See the MonadState class
5656State : Type -> Type -> Type
5757State s a = StateT s Identity a
58+
59+||| Unwrap a State monad computation.
60+runState : State s a -> s -> (a,s)
61+runState m = runIdentity . runStateT m
62+
63+||| Unwrap a State monad computation, but discard the final state.
64+evalState : State s a -> s -> a
65+evalState m = fst . runState m
66+
67+||| Unwrap a State monad computation, but discard the resulting value.
68+execState : State s a -> s -> s
69+execState m = snd . runState m