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 (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:

delay :: forall eff. Number -> ContT Unit (Eff (timeout :: Timeout | eff)) Unit
delay n = callCC \cont ->
  lift $ setTimeout n (runContT (cont unit) (\_ -> return 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