-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Control flow data type and monad transformer. -- -- Control flow abstraction for short-circuiting on success and failure -- as well as continuing with a value. @package transformers-continue @version 0.0.1 -- | Continue type. module Data.Continue -- | The Continue type represents values with three possibilities: a -- value of type Continue a b is one of -- Stop , Failure x or -- Continue a. data Continue x a Stop :: Continue x a Failure :: x -> Continue x a Continue :: a -> Continue x a instance Data.Traversable.Traversable (Data.Continue.Continue x) instance Data.Foldable.Foldable (Data.Continue.Continue x) instance GHC.Base.Functor (Data.Continue.Continue x) instance (GHC.Show.Show a, GHC.Show.Show x) => GHC.Show.Show (Data.Continue.Continue x a) instance (GHC.Classes.Eq a, GHC.Classes.Eq x) => GHC.Classes.Eq (Data.Continue.Continue x a) instance GHC.Base.Applicative (Data.Continue.Continue x) instance Data.Bifunctor.Bifunctor Data.Continue.Continue instance GHC.Base.Monad (Data.Continue.Continue x) -- | This monad transformer extends a monad with the ability to handle -- multiple terminating cases. -- -- A sequence of actions terminates normally, producing a value, only if -- none of the actions in the sequence are Stop or Failure. -- If one action is Stop or Failure, the rest of the -- sequence is skipped and the composite action exits with that result. module Control.Monad.Trans.Continue -- | A monad transfomer that extends the Continue monad. -- -- Computations are stopes, failures or normal values. -- -- The return function returns a normal value, while -- >>= exits on the first stop or failure. newtype ContinueT x m a ContinueT :: m (Continue x a) -> ContinueT x m a [runContinueT] :: ContinueT x m a -> m (Continue x a) -- | Singal a stop. -- --
runContinueT stop = return -- Stop
runContinueT (failure x) = return -- (Failure x)
runContinueT (continue x) = return -- (Continue x)
-- runContinueT (mapContinueT f m) = f (runContinueT m) --mapContinueT :: (m (Continue x a) -> n (Continue y b)) -> ContinueT x m a -> ContinueT y n b -- | Map over both failure and continue. bimapContinueT :: Functor m => (x -> y) -> (a -> b) -> ContinueT x m a -> ContinueT y m b -- | Map over failure. firstContinueT :: Functor m => (x -> y) -> ContinueT x m a -> ContinueT y m a -- | Map over continue. secondContinueT :: Functor m => (a -> b) -> ContinueT x m a -> ContinueT x m b -- | Map over failure. mapFailure :: Functor m => (x -> y) -> ContinueT x m a -> ContinueT y m a -- | Lift an Maybe into an ContinueT -- --
runContinueT (stopFromNothing Nothing) = -- return Stop
runContinueT (stopFromNothing (Just a)) -- = return (Continue a)
runContinueT (hoistEither (Left x)) = -- return (Failure x)
runContinueT (hoistEither (Right a)) = -- return (Continue a)
runExceptT (runToExceptT (continue a)) -- = return (Right a)
runExceptT (runToExceptT (failure x)) -- = return (Left x)
runExceptT (runToExceptT stop) = -- return (Right ())