Methods
callCC :: ((a -> m b) -> m a) -> m acallCC(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 callingreturnis that it makes the continuation explicit, allowing more flexibility and better control (see examples in Control.Monad.Cont).The standard idiom used with
callCCis 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.
Instances14MonadCont, …
MonadCont m => MonadCont (MaybeT m)Defined in mtl-2.3.1 · Control.Monad.Cont.ClassMonadCont m => MonadCont (ExceptT e m)Defined in mtl-2.3.1 · Control.Monad.Cont.ClassMonadCont m => MonadCont (IdentityT m)Defined in mtl-2.3.1 · Control.Monad.Cont.ClassMonadCont m => MonadCont (ReaderT r m)Defined in mtl-2.3.1 · Control.Monad.Cont.ClassMonadCont m => MonadCont (StateT s m)Defined in mtl-2.3.1 · Control.Monad.Cont.ClassMonadCont m => MonadCont (StateT s m)Defined in mtl-2.3.1 · Control.Monad.Cont.Class(Monoid w, MonadCont m) => MonadCont (AccumT w m)Defined in mtl-2.3.1 · Control.Monad.Cont.Class(Monoid w, MonadCont m) => MonadCont (WriterT w m)Defined in mtl-2.3.1 · Control.Monad.Cont.Class(Monoid w, MonadCont m) => MonadCont (WriterT w m)Defined in mtl-2.3.1 · Control.Monad.Cont.Class(Monoid w, MonadCont m) => MonadCont (WriterT w m)Defined in mtl-2.3.1 · Control.Monad.Cont.ClassMonadCont (ContT r m)Defined in mtl-2.3.1 · Control.Monad.Cont.Class(Monoid w, MonadCont m) => MonadCont (RWST r w s m)Defined in mtl-2.3.1 · Control.Monad.Cont.Class(Monoid w, MonadCont m) => MonadCont (RWST r w s m)Defined in mtl-2.3.1 · Control.Monad.Cont.Class(Monoid w, MonadCont m) => MonadCont (RWST r w s m)Defined in mtl-2.3.1 · Control.Monad.Cont.Class