error-continuations- Error Continuations

Copyright(c) Eitan Chatav, 2015
Safe HaskellSafe-Inferred



The MaybeCont type and API provide an idiomatic way to handle possibly failing computations in continuation passing style.



type MaybeCont a r = MaybeContT a Identity r Source

MaybeCont a r is a CPS computation that produces an intermediate result of type a within a CPS computation which produces either a just or nothing.

data MaybeContT a m r Source

The MaybeContT a l m r type encodes a nullable monad transformer in continuation passing style which is monadic in r. This property holds for any type constructor m.


MonadTrans (MaybeContT a)

MaybeContT a is a monad transformer.

Monad (MaybeContT a m)

The Monad instance encodes monadicity of MaybeContT a m.

Functor (MaybeContT a m)

The Functor instance encodes functoriality of MaybeContT a m.

Applicative (MaybeContT a m)

The Applicative instance encodes applicativity of MaybeContT a m.

MonadCont (MaybeContT a m)

Call with current just continuation.

maybeCont :: (a -> (r -> a) -> a) -> MaybeCont a r Source

Construct a continuation-passing computation from a function.

runMaybeCont :: MaybeCont a r -> a -> (r -> a) -> a Source

The result of running a CPS computation with given nothing and just continuations.

runMaybeCont . maybeCont = id
maybeCont . runMaybeCont = id

nothingC :: MaybeContT a m r Source

nothingC is the CPS representation of Nothing.

mapMaybeCont :: (a -> a) -> MaybeCont a r -> MaybeCont a r Source

Apply a function to transform the result of a continuation-passing computation.

withMaybeContJust :: ((r' -> a) -> r -> a) -> MaybeCont a r -> MaybeCont a r' Source

Apply a function to transform the just continuation passed to a continuation-passing computation.

withMaybeContNothing :: (a -> a) -> MaybeCont a r -> MaybeCont a r Source

Apply a function to transform the nothing continuation passed to an continuation-passing computation.