-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Error Continuations -- -- Error Continuations @package error-continuations @version 0.1.0.0 -- | The MaybeContT type and API provide an idiomatic way to handle -- possibly failing computations in continuation passing style over some -- base monad. module Control.Monad.Trans.MaybeCont -- | 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. newtype MaybeContT a m r -- | Construct a continuation-passing computation from a function. MaybeContT :: (m a -> (r -> m a) -> m a) -> MaybeContT a m r -- | The result of running a CPS computation with given nothing and just -- continuations. runMaybeContT :: MaybeContT a m r -> m a -> (r -> m a) -> m a -- | liftMaybeT embeds MaybeT in MaybeContT -- a. liftMaybeT :: Monad m => MaybeT m r -> MaybeContT a m r -- | nothingC is the CPS representation of Nothing. nothingC :: MaybeContT a m r -- | Apply a function to transform the result of a continuation-passing -- computation. mapMaybeContT :: (m a -> m a) -> MaybeContT a m r -> MaybeContT a m r -- | Apply a function to transform the just continuation passed to a -- continuation-passing computation. withMaybeContTJust :: ((r' -> m a) -> r -> m a) -> MaybeContT a m r -> MaybeContT a m r' -- | Apply a function to transform the nothing continuation passed to a -- continuation-passing computation. withMaybeContTNothing :: (m a -> m a) -> MaybeContT a m r -> MaybeContT a m r instance MonadCont (MaybeContT a m) instance MonadTrans (MaybeContT a) instance Monad (MaybeContT a m) instance Applicative (MaybeContT a m) instance Functor (MaybeContT a m) -- | The MaybeCont type and API provide an idiomatic way to handle -- possibly failing computations in continuation passing style. module Control.Monad.MaybeCont -- | 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. type MaybeCont a r = MaybeContT a Identity r -- | 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. data MaybeContT a m r -- | Construct a continuation-passing computation from a function. maybeCont :: (a -> (r -> a) -> a) -> MaybeCont a r -- | The result of running a CPS computation with given nothing and just -- continuations. -- --
-- runMaybeCont . maybeCont = id ---- --
-- maybeCont . runMaybeCont = id --runMaybeCont :: MaybeCont a r -> (a -> (r -> a) -> a) -- | liftMaybe embeds Maybe in MaybeCont a. liftMaybe :: Maybe r -> MaybeCont a r -- | nothingC is the CPS representation of Nothing. nothingC :: MaybeContT a m r -- | Apply a function to transform the result of a continuation-passing -- computation. mapMaybeCont :: (a -> a) -> MaybeCont a r -> MaybeCont a r -- | Apply a function to transform the just continuation passed to a -- continuation-passing computation. withMaybeContJust :: ((r' -> a) -> r -> a) -> MaybeCont a r -> MaybeCont a r' -- | Apply a function to transform the nothing continuation passed to an -- continuation-passing computation. withMaybeContNothing :: (a -> a) -> MaybeCont a r -> MaybeCont a r -- | The EitherContT type and API provide an idiomatic way to handle -- errors in continuation passing style over some base monad. module Control.Monad.Trans.EitherCont -- | The EitherContT a l m r -- type encodes a sum type monad transformer in continuation passing -- style which is separately monadic in both l and r. -- Interestingly, this property holds for any type constructor -- m. newtype EitherContT a l m r -- | Construct a continuation-passing computation from a function. EitherContT :: ((l -> m a) -> (r -> m a) -> m a) -> EitherContT a l m r -- | The result of running a CPS computation with given failure and success -- continuations. runEitherContT :: EitherContT a l m r -> (l -> m a) -> (r -> m a) -> m a -- | liftEitherT embeds EitherT in EitherContT -- a. liftEitherT :: Monad m => EitherT l m r -> EitherContT a l m r -- | fmapL encodes functoriality of EitherContT a -- l m r in l. fmapL :: (l -> l') -> EitherContT a l m r -> EitherContT a l' m r -- | bimapEC encodes bifunctoriality of EitherContT -- a l m r in l and -- r. -- --
-- bimapEC f id = fmapL f ---- --
-- bimapEC id f = fmap f --bimapEC :: (l -> l') -> (r -> r') -> EitherContT a l m r -> EitherContT a l' m r' -- | throwEC encodes the applicative/monadic unit of -- EitherContT a l m r in -- l. throwEC :: l -> EitherContT a l m r -- | apL encodes applicativity of EitherContT a -- l m r in l. apL :: EitherContT a (l -> l') m r -> EitherContT a l m r -> EitherContT a l' m r -- | throwEC and catchEC encode monadicity of -- EitherContT a l m r in -- l. The usual monad laws hold with throwEC taking the -- role of return and catchEC taking the role of -- >>=. -- --
-- throwEC l `catchEC` f = f l ---- --
-- ec `catchEC` throwEC = ec ---- --
-- (ec `catchEC` f) `catchEC` g = ec `catchEC` (\l -> f l `catchEC` g) --catchEC :: EitherContT a l m r -> (l -> EitherContT a l' m r) -> EitherContT a l' m r -- | handleEC is a flipped catchEC. handleEC :: (l -> EitherContT a l' m r) -> EitherContT a l m r -> EitherContT a l' m r -- | A right-to-left, point free way to compose handlers. The monad laws -- look more elegant, expressed in terms of <?<. -- --
-- throwEC <?< f = f = f <?< throwEC ---- --
-- (h <?< g) <?< f = h <?< (g <?< f) --(<) :: (l' -> EitherContT a l'' m r) -> (l -> EitherContT a l' m r) -> (l -> EitherContT a l'' m r) -- | A left-to-right, point free way to compose handlers. (>?>) :: (l -> EitherContT a l' m r) -> (l' -> EitherContT a l'' m r) -> (l -> EitherContT a l'' m r) -- | EitherContT a l m r is a -- monad transformer for m in l. liftL :: Monad m => m l -> EitherContT a l m r -- | flipEC encodes the symmetry of l and r in -- EitherContT a l m r. -- --
-- flipEC . flipEC = id --flipEC :: EitherContT a l m r -> EitherContT a r m l -- | Apply a function to transform the result of a continuation-passing -- computation. mapEitherContT :: (m a -> m a) -> EitherContT a l m r -> EitherContT a l m r -- | Apply a function to transform the success continuation passed to a -- continuation-passing computation. withEitherContTR :: ((r' -> m a) -> r -> m a) -> EitherContT a l m r -> EitherContT a l m r' -- | Apply a function to transform the failure continuation passed to an -- continuation-passing computation. withEitherContTL :: ((l' -> m a) -> l -> m a) -> EitherContT a l m r -> EitherContT a l' m r -- | Call with current failure continuation. callCCL :: ((l -> EitherContT a l' m r) -> EitherContT a l m r) -> EitherContT a l m r -- | lowerMonadError runs the continuation-passing computation, -- throwing on failure and returning on success. lowerMonadError :: MonadError l m => EitherContT r l m r -> m r -- | liftMonadError embeds a MonadError computation -- m r into EitherContT a l -- m r. -- -- liftMonadError and lowerMonadError are one-sided -- inverses, making MonadError l m => m r a retract of -- EitherContT r l m r. -- --
-- lowerMonadError . liftMonadError = id --liftMonadError :: MonadError l m => m r -> EitherContT a l m r instance MonadError l (EitherContT a l m) instance MonadCont (EitherContT a l m) instance MonadTrans (EitherContT a l) instance Monad (EitherContT a l m) instance Applicative (EitherContT a l m) instance Functor (EitherContT a l m) -- | The EitherCont type and API provide an idiomatic way to handle -- errors in continuation passing style. module Control.Monad.EitherCont -- | EitherCont a l r is a CPS -- computation that produces an intermediate result of type a -- within a CPS computation which produces either a success of type -- r or failure of type l. type EitherCont a l r = EitherContT a l Identity r -- | The EitherContT a l m r -- type encodes a sum type monad transformer in continuation passing -- style which is separately monadic in both l and r. -- Interestingly, this property holds for any type constructor -- m. data EitherContT a l m r -- | Construct a continuation-passing computation from a function. eitherCont :: ((l -> a) -> (r -> a) -> a) -> EitherCont a l r -- | The result of running a CPS computation with given failure and success -- continuations. -- --
-- runEitherCont . eitherCont = id ---- --
-- eitherCont . runEitherCont = id --runEitherCont :: EitherCont a l r -> (l -> a) -> (r -> a) -> a -- | liftEither embeds Either in EitherCont -- a. liftEither :: Either l r -> EitherCont a l r -- | fmapL encodes functoriality of EitherContT a -- l m r in l. fmapL :: (l -> l') -> EitherContT a l m r -> EitherContT a l' m r -- | bimapEC encodes bifunctoriality of EitherContT -- a l m r in l and -- r. -- --
-- bimapEC f id = fmapL f ---- --
-- bimapEC id f = fmap f --bimapEC :: (l -> l') -> (r -> r') -> EitherContT a l m r -> EitherContT a l' m r' -- | throwEC encodes the applicative/monadic unit of -- EitherContT a l m r in -- l. throwEC :: l -> EitherContT a l m r -- | apL encodes applicativity of EitherContT a -- l m r in l. apL :: EitherContT a (l -> l') m r -> EitherContT a l m r -> EitherContT a l' m r -- | throwEC and catchEC encode monadicity of -- EitherContT a l m r in -- l. The usual monad laws hold with throwEC taking the -- role of return and catchEC taking the role of -- >>=. -- --
-- throwEC l `catchEC` f = f l ---- --
-- ec `catchEC` throwEC = ec ---- --
-- (ec `catchEC` f) `catchEC` g = ec `catchEC` (\l -> f l `catchEC` g) --catchEC :: EitherContT a l m r -> (l -> EitherContT a l' m r) -> EitherContT a l' m r -- | EitherContT a l m r is a -- monad transformer for m in l. liftL :: Monad m => m l -> EitherContT a l m r -- | flipEC encodes the symmetry of l and r in -- EitherContT a l m r. -- --
-- flipEC . flipEC = id --flipEC :: EitherContT a l m r -> EitherContT a r m l -- | Apply a function to transform the result of a continuation-passing -- computation. mapEitherCont :: (a -> a) -> EitherCont a l r -> EitherCont a l r -- | Apply a function to transform the failure continuation passed to an -- continuation-passing computation. withEitherContL :: ((l' -> a) -> l -> a) -> EitherCont a l r -> EitherCont a l' r -- | Apply a function to transform the success continuation passed to a -- continuation-passing computation. withEitherContR :: ((r' -> a) -> r -> a) -> EitherCont a l r -> EitherCont a l r' -- | Call with current failure continuation. callCCL :: ((l -> EitherContT a l' m r) -> EitherContT a l m r) -> EitherContT a l m r -- | This module provides utility functions to convert between -- MaybeContT and EitherContT computations. module Control.Error.Cont.Util -- | Suppress the nothing continuation of an EitherContT hush :: EitherContT a l m r -> MaybeContT a m r -- | Tag the nothing continuation of a MaybeContT note :: l -> MaybeContT a m r -> EitherContT a l m r