| Copyright | (c) Eitan Chatav, 2015 |
|---|---|
| License | PublicDomain |
| Maintainer | eitan.chatav@gmail.com |
| Stability | experimental |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
Control.Monad.MaybeCont
Description
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
- data MaybeContT a m r
- maybeCont :: (a -> (r -> a) -> a) -> MaybeCont a r
- runMaybeCont :: MaybeCont a r -> a -> (r -> a) -> a
- liftMaybe :: Maybe r -> MaybeCont a r
- nothingC :: MaybeContT a m r
- mapMaybeCont :: (a -> a) -> MaybeCont a r -> MaybeCont a r
- withMaybeContJust :: ((r' -> a) -> r -> a) -> MaybeCont a r -> MaybeCont a r'
- withMaybeContNothing :: (a -> a) -> MaybeCont a r -> MaybeCont a r
Documentation
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.
Instances
| MonadTrans (MaybeContT a) |
|
| Monad (MaybeContT a m) | The |
| Functor (MaybeContT a m) | The |
| Applicative (MaybeContT a m) | The |
| 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
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.