Module

Control.Monad.Cont.Class

Package
purescript-transformers
Repository
purescript/purescript-transformers

This module defines the MonadCont type class and its instances.

#MonadCont Source

class MonadCont :: (Type -> Type) -> Constraintclass (Monad m) <= MonadCont m  where

The MonadCont type class represents those monads which support the callCC, or call-with-current-continuation operation.

This action makes the current continuation available to the caller.

For example:

-- setTimeout :: Number -> Effect Unit -> Effect Unit

delay :: Number -> ContT Unit Effect Unit
delay n = callCC \cont ->
  lift $ setTimeout n (runContT (cont unit) (\_ -> pure unit))

An implementation is provided for ContT, and for other monad transformers defined in this library.

Members

  • callCC :: forall a. ((forall b. a -> m b) -> m a) -> m a