|Portability||semi-portable (Rank2Types, MPTCs)|
A continuation-passing variant of
Maybe for short-circuiting
at failure. This is based largely on code from the Haskell Wiki
was released under a simple permissive license
However, various changes and extensions have been made, which
are subject to the BSD license of this package.
- data MaybeK a
- runMaybeK :: MaybeK a -> Maybe a
- toMaybeK :: Maybe a -> MaybeK a
- maybeK :: b -> (a -> b) -> MaybeK a -> b
- data MaybeKT m a
- runMaybeKT :: Monad m => MaybeKT m a -> m (Maybe a)
- toMaybeKT :: Monad m => Maybe a -> MaybeKT m a
- liftMaybeK :: Monad m => MaybeK a -> MaybeKT m a
- lowerMaybeK :: Monad m => MaybeKT m a -> m (MaybeK a)
The partiality monad
A continuation-passing encoding of
Maybe; also known as
Codensity Maybe, if you're familiar with that terminology.
N.B., this is not the 2-continuation implementation based on the
Church encoding of
Maybe. The latter tends to have worse
performance than non-continuation based implementations.
This is generally more efficient than using
Maybe for two
reasons. First is that it right associates all binds, ensuring
that bad associativity doesn't artificially introduce midpoints
in short-circuiting to the nearest handler. Second is that it
removes the need for intermediate case expressions.
The partiality monad transformer
A monad transformer version of
MaybeKT and return the concrete