Introduces a recursive binding to the continuation.
Due to the use of callCC, calling the continuation will interrupt execution
of the current block creating an effect similar to goto/setjmp in C.
Modulererebase-1.21.2Haskell2010
Control.Monad.Cont.Class
- 1 class
- 3 values
- Packagererebase-1.21.2
- Exports4
- LanguageHaskell2010
- LicenceMIT
- SourceClass.hs
Simplified version of label without arguments.
Lift a callCC-style function through any MonadTrans.
Note
For any function f, 'liftCallCC f' satisfies the uniformity
condition
provided that f is quasi-algebraic. More specifically, for any g, we must have:
'join' '$' f (\exit -> 'pure' '$' g (exit '.' 'pure') = f gcallCC is quasi-algebraic; furthermore, for any quasi-algebraic f,
liftCallCC f is also quasi-algebraic.
See also
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.
Instances22MonadCont, …
MonadCont m => MonadCont (Free m)Defined in free-5.2 · Control.Monad.FreeMonadCont m => MonadCont (Free m)Defined in free-5.2 · Control.Monad.Free.ApMonadCont m => MonadCont (F m)Defined in free-5.2 · Control.Monad.Free.ChurchMonadCont m => MonadCont (IterT m)Defined in free-5.2 · Control.Monad.Trans.IterMonadCont m => MonadCont (MaybeT m)Defined in mtl-2.3.1 · Control.Monad.Cont.ClassMonadCont m => MonadCont (FT f m)Defined in free-5.2 · Control.Monad.Trans.Free.ChurchMonadCont 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(Representable g, MonadCont m) => MonadCont (StateT g m)Defined in adjunctions-4.4.3 · Control.Monad.Representable.State(Applicative f, MonadCont m) => MonadCont (FreeT f m)Defined in free-5.2 · Control.Monad.Trans.Free.Ap(Functor f, MonadCont m) => MonadCont (FreeT f m)Defined in free-5.2 · Control.Monad.Trans.Free(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