monad-levels- Specific levels of monad transformers

Copyright(c) Ivan Lazar Miljenovic
License3-Clause BSD-style
Safe HaskellNone



This module allows inclusion of ContT into your monad stack so as to represent continuation-passing style (CPS) computations.

Note that the behaviour of some monad transformers and how they deal with continuations differs from how mtl handles them. For example, with a lazy state transformer, using this module results in liftCallCC, whereas mtl uses liftCallCC'.



callCC :: forall m a b. HasCont m a b => ((a -> m b) -> m a) -> m a Source

callCC (call-with-current-continuation) calls a function with the current continuation as its argument.

newtype ContT r m a :: * -> (* -> *) -> * -> *

The continuation monad transformer. Can be used to add continuation handling to other monads.




runContT :: (a -> m r) -> m r

type HasCont m a b = SatisfyConstraintF IsCont m a (ContFn b) Source

Represents monad stacks that can successfully pass callCC down to a ContT transformer.

class MonadLevel m => IsCont m Source

A simple class just to match up with the ContT monad transformer.

type ContFn b = MkVarFn (Func (Func ValueOnly (MonadicOther b)) MonadicValue) Source

This corresponds to CallCC in transformers.