Copyright | (c) Galois Inc 2013-2014 |
---|---|
License | BSD3 |
Maintainer | Joe Hendrix <jhendrix@galois.com> |
Stability | provisional |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Lang.Crucible.Utils.StateContT
Contents
Description
This module defines a monad with continuations and state. By using this instead of a MTL StateT and ContT transformer stack, one can have a continuation that implements MonadCont and MonadState, yet never returns the final state. This also wraps MonadST.
Synopsis
- newtype StateContT s r m a = StateContT {
- runStateContT :: (a -> s -> m r) -> s -> m r
- class Monad m => MonadCont (m :: Type -> Type) where
- callCC :: ((a -> m b) -> m a) -> m a
- class Monad m => MonadState s (m :: Type -> Type) | m -> s where
Documentation
newtype StateContT s r m a Source #
A monad transformer that provides MonadCont
and MonadState
.
Constructors
StateContT | |
Fields
|
Instances
Re-exports
class Monad m => MonadCont (m :: Type -> Type) where #
Methods
callCC :: ((a -> m b) -> m a) -> m a #
callCC
(call-with-current-continuation)
calls a function with the current continuation as its argument.
Provides an escape continuation mechanism for use with Continuation monads.
Escape continuations allow to abort the current computation and return
a value immediately.
They achieve a similar effect to throwError
and catchError
within an Except
monad.
Advantage of this function over calling return
is that it makes
the continuation explicit,
allowing more flexibility and better control
(see examples in Control.Monad.Cont).
The standard idiom used with callCC
is to provide a lambda-expression
to name the continuation. Then calling the named continuation anywhere
within its scope will escape from the computation,
even if it is many layers deep within nested computations.
Instances
class Monad m => MonadState s (m :: Type -> Type) | m -> s where #
Minimal definition is either both of get
and put
or just state
Methods
Return the state from the internals of the monad.
Replace the state inside the monad.
state :: (s -> (a, s)) -> m a #
Embed a simple state action into the monad.
Instances
MonadState s m => MonadState s (Free m) | |
MonadState s m => MonadState s (MaybeT m) | |
(Functor f, MonadState s m) => MonadState s (FreeT f m) | |
(Monoid w, MonadState s m) => MonadState s (AccumT w m) | Since: mtl-2.3 |
MonadState s m => MonadState s (ExceptT e m) | Since: mtl-2.2 |
MonadState s m => MonadState s (IdentityT m) | |
MonadState s m => MonadState s (ReaderT r m) | |
MonadState s m => MonadState s (SelectT r m) | Since: mtl-2.3 |
Monad m => MonadState s (StateT s m) | |
Monad m => MonadState s (StateT s m) | |
(Monoid w, MonadState s m) => MonadState s (WriterT w m) | Since: mtl-2.3 |
(Monoid w, MonadState s m) => MonadState s (WriterT w m) | |
(Monoid w, MonadState s m) => MonadState s (WriterT w m) | |
MonadState s (StateContT s r m) Source # | |
Defined in Lang.Crucible.Utils.StateContT Methods get :: StateContT s r m s # put :: s -> StateContT s r m () # state :: (s -> (a, s)) -> StateContT s r m a # | |
MonadState s m => MonadState s (ContT r m) | |
(Monad m, Monoid w) => MonadState s (RWST r w s m) | Since: mtl-2.3 |
(Monad m, Monoid w) => MonadState s (RWST r w s m) | |
(Monad m, Monoid w) => MonadState s (RWST r w s m) | |
MonadState u (Rewriter ext h s ret u) Source # | |
Monad m => MonadState (t s) (Generator ext s t ret m) Source # | |
MonadState (SimState p sym ext rtp (OverrideLang ret) ('Just args)) (OverrideSim p sym ext rtp args ret) Source # | |
Defined in Lang.Crucible.Simulator.OverrideSim Methods get :: OverrideSim p sym ext rtp args ret (SimState p sym ext rtp (OverrideLang ret) ('Just args)) # put :: SimState p sym ext rtp (OverrideLang ret) ('Just args) -> OverrideSim p sym ext rtp args ret () # state :: (SimState p sym ext rtp (OverrideLang ret) ('Just args) -> (a, SimState p sym ext rtp (OverrideLang ret) ('Just args))) -> OverrideSim p sym ext rtp args ret a # |