HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Modulererebase-1.21.2Haskell2010

Control.Monad.Cont.Class

  • 1 class
  • 3 values
valuelabel :: MonadCont m => a -> m (a -> m b, a)
#

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.

valueliftCallCC
  1. :: (MonadTrans t, Monad m, forall (m' :: Type -> Type). Monad m' => Monad (t m'))
  2. => CallCC m (t m a) b
  3. -> CallCC (t m) a b
#

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 g

callCC is quasi-algebraic; furthermore, for any quasi-algebraic f, liftCallCC f is also quasi-algebraic.

See also

classclass 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.

Instances22MonadCont, …