| Copyright | (c) Ivan Perez and Manuel Baerenz 2016 |
|---|---|
| License | BSD3 |
| Maintainer | ivan.perez@keera.co.uk |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
Control.Monad.Trans.MSF.Except
Description
Synopsis
- newtype MSFExcept m a b e = MSFExcept {
- runMSFExcept :: MSF (ExceptT e m) a b
- throw :: Monad m => e -> MSF (ExceptT e m) a b
- try :: MSF (ExceptT e m) a b -> MSFExcept m a b e
- step :: Monad m => (a -> m (b, e)) -> MSFExcept m a b e
- pass :: Monad m => MSF (ExceptT e m) a a
- safe :: Monad m => MSF m a b -> MSFExcept m a b e
- throwOnCond :: Monad m => (a -> Bool) -> e -> MSF (ExceptT e m) a a
- maybeToExceptS :: (Functor m, Monad m) => MSF (MaybeT m) a b -> MSF (ExceptT () m) a b
- exceptS :: (Functor m, Monad m) => MSF (ExceptT e m) a b -> MSF m a (Either e b)
- listToMSFExcept :: Monad m => [b] -> MSFExcept m a b ()
- reactimateExcept :: Monad m => MSFExcept m () () e -> m e
- safely :: Monad m => MSFExcept m a b Void -> MSF m a b
- reactimateB :: Monad m => MSF m () Bool -> m ()
- throwS :: Monad m => MSF (ExceptT e m) e a
- throwOnCondM :: Monad m => (a -> m Bool) -> e -> MSF (ExceptT e m) a a
- throwOn :: Monad m => e -> MSF (ExceptT e m) Bool ()
- throwOn' :: Monad m => MSF (ExceptT e m) (Bool, e) ()
- throwMaybe :: Monad m => MSF (ExceptT e m) (Maybe e) (Maybe a)
- catchS :: Monad m => MSF (ExceptT e m) a b -> (e -> MSF m a b) -> MSF m a b
- untilE :: Monad m => MSF m a b -> MSF m b (Maybe e) -> MSF (ExceptT e m) a b
- inExceptT :: Monad m => MSF (ExceptT e m) (ExceptT e m a) a
- transG :: (Monad m1, Monad m2) => (a2 -> m1 a1) -> (forall c. a2 -> m1 (b1, c) -> m2 (b2, Maybe c)) -> MSF m1 a1 b1 -> MSF m2 a2 b2
- tagged :: Monad m => MSF (ExceptT e1 m) a b -> MSF (ExceptT e2 m) (a, e2) b
- currentInput :: Monad m => MSFExcept m e b e
- handleExceptT :: Monad m => MSF (ExceptT e1 m) a b -> (e1 -> MSF (ExceptT e2 m) a b) -> MSF (ExceptT e2 m) a b
- handleGen :: (a -> m1 (b1, MSF m1 a b1) -> m2 (b2, MSF m2 a b2)) -> MSF m1 a b1 -> MSF m2 a b2
- once :: Monad m => (a -> m e) -> MSFExcept m a b e
- once_ :: Monad m => m e -> MSFExcept m a b e
- step_ :: Monad m => b -> MSFExcept m a b ()
- performOnFirstSample :: Monad m => m (MSF m a b) -> MSF m a b
- switch :: Monad m => MSF m a (b, Maybe c) -> (c -> MSF m a b) -> MSF m a b
- dSwitch :: Monad m => MSF m a (b, Maybe c) -> (c -> MSF m a b) -> MSF m a b
- type Except e = ExceptT e Identity
- newtype ExceptT e (m :: Type -> Type) a = ExceptT (m (Either e a))
- runExcept :: Except e a -> Either e a
- mapExcept :: (Either e a -> Either e' b) -> Except e a -> Except e' b
- withExcept :: (e -> e') -> Except e a -> Except e' a
- runExceptT :: ExceptT e m a -> m (Either e a)
- mapExceptT :: (m (Either e a) -> n (Either e' b)) -> ExceptT e m a -> ExceptT e' n b
- withExceptT :: forall (m :: Type -> Type) e e' a. Functor m => (e -> e') -> ExceptT e m a -> ExceptT e' m a
- throwE :: forall (m :: Type -> Type) e a. Monad m => e -> ExceptT e m a
- catchE :: forall (m :: Type -> Type) e a e'. Monad m => ExceptT e m a -> (e -> ExceptT e' m a) -> ExceptT e' m a
- except :: forall (m :: Type -> Type) e a. Monad m => Either e a -> ExceptT e m a
- handleE :: forall (m :: Type -> Type) e e' a. Monad m => (e -> ExceptT e' m a) -> ExceptT e m a -> ExceptT e' m a
- tryE :: forall (m :: Type -> Type) e a. Monad m => ExceptT e m a -> ExceptT e m (Either e a)
- finallyE :: forall (m :: Type -> Type) e a. Monad m => ExceptT e m a -> ExceptT e m () -> ExceptT e m a
Documentation
newtype MSFExcept m a b e Source #
MSFs with an ExceptT transformer layer are in fact monads /in the
exception type/.
returncorresponds to throwing an exception immediately.>>=is exception handling: The first value throws an exception, while the Kleisli arrow handles the exception and produces a new signal function, which can throw exceptions in a different type.m: The monad that theMSFmay take side effects in.a: The input typeb: The output typee: The type of exceptions that can be thrown
Constructors
| MSFExcept | |
Fields
| |
Instances
| Monad m => Applicative (MSFExcept m a b) Source # | Applicative instance for MSFs on the |
Defined in Control.Monad.Trans.MSF.Except Methods pure :: a0 -> MSFExcept m a b a0 # (<*>) :: MSFExcept m a b (a0 -> b0) -> MSFExcept m a b a0 -> MSFExcept m a b b0 # liftA2 :: (a0 -> b0 -> c) -> MSFExcept m a b a0 -> MSFExcept m a b b0 -> MSFExcept m a b c # (*>) :: MSFExcept m a b a0 -> MSFExcept m a b b0 -> MSFExcept m a b b0 # (<*) :: MSFExcept m a b a0 -> MSFExcept m a b b0 -> MSFExcept m a b a0 # | |
| Monad m => Functor (MSFExcept m a b) Source # | Functor instance for MSFs on the |
| Monad m => Monad (MSFExcept m a b) Source # | Monad instance for |
step :: Monad m => (a -> m (b, e)) -> MSFExcept m a b e Source #
Advances a single tick with the given Kleisli arrow, and then throws an exception.
throwOnCond :: Monad m => (a -> Bool) -> e -> MSF (ExceptT e m) a a Source #
Throw the exception e whenever the function evaluates to True.
listToMSFExcept :: Monad m => [b] -> MSFExcept m a b () Source #
Converts a list to an MSFExcept, which outputs an element of the list at
each step, throwing () when the list ends.
reactimateExcept :: Monad m => MSFExcept m () () e -> m e Source #
Reactimates an MSFExcept until it throws an exception.
throwOnCondM :: Monad m => (a -> m Bool) -> e -> MSF (ExceptT e m) a a Source #
Throws the exception when the input is True. Variant of throwOnCond
for Kleisli arrows.
throwOn :: Monad m => e -> MSF (ExceptT e m) Bool () Source #
Throw the exception when the input is True.
throwOn' :: Monad m => MSF (ExceptT e m) (Bool, e) () Source #
Variant of throwOn, where the exception may change every tick.
throwMaybe :: Monad m => MSF (ExceptT e m) (Maybe e) (Maybe a) Source #
When the input is Just e, throw the exception e. (Does not output any
actual data.)
untilE :: Monad m => MSF m a b -> MSF m b (Maybe e) -> MSF (ExceptT e m) a b Source #
Similar to Yampa's delayed switching. Loses a b in case of an exception.
transG :: (Monad m1, Monad m2) => (a2 -> m1 a1) -> (forall c. a2 -> m1 (b1, c) -> m2 (b2, Maybe c)) -> MSF m1 a1 b1 -> MSF m2 a2 b2 Source #
More general lifting combinator that enables recovery. Note that, unlike a
polymorphic lifting function forall a . m a -> m1 a, this auxiliary
function needs to be a bit more structured, and produces a Maybe value. The
previous MSF is used if a new one is not produced.
tagged :: Monad m => MSF (ExceptT e1 m) a b -> MSF (ExceptT e2 m) (a, e2) b Source #
In case an exception occurs in the first argument, replace the exception by the second component of the tuple.
currentInput :: Monad m => MSFExcept m e b e Source #
Immediately throw the current input as an exception.
handleExceptT :: Monad m => MSF (ExceptT e1 m) a b -> (e1 -> MSF (ExceptT e2 m) a b) -> MSF (ExceptT e2 m) a b Source #
Execute an MSF and, if it throws an exception, recover by switching to a second MSF.
handleGen :: (a -> m1 (b1, MSF m1 a b1) -> m2 (b2, MSF m2 a b2)) -> MSF m1 a b1 -> MSF m2 a b2 Source #
Use a generic handler to handle exceptions in MSF processing actions.
once :: Monad m => (a -> m e) -> MSFExcept m a b e Source #
Inside the MSFExcept monad, execute an action of the wrapped monad.
This passes the last input value to the action, but doesn't advance a tick.
step_ :: Monad m => b -> MSFExcept m a b () Source #
Advances a single tick outputting the value, and then throws ().
newtype ExceptT e (m :: Type -> Type) a #
A monad transformer that adds exceptions to other monads.
ExceptT constructs a monad parameterized over two things:
- e - The exception type.
- m - The inner monad.
The return function yields a computation that produces the given
value, while >>= sequences two subcomputations, exiting on the
first exception.
Instances
runExcept :: Except e a -> Either e a #
Extractor for computations in the exception monad.
(The inverse of except).
withExcept :: (e -> e') -> Except e a -> Except e' a #
Transform any exceptions thrown by the computation using the given
function (a specialization of withExceptT).
runExceptT :: ExceptT e m a -> m (Either e a) #
The inverse of ExceptT.
mapExceptT :: (m (Either e a) -> n (Either e' b)) -> ExceptT e m a -> ExceptT e' n b #
Map the unwrapped computation using the given function.
runExceptT(mapExceptTf m) = f (runExceptTm)
withExceptT :: forall (m :: Type -> Type) e e' a. Functor m => (e -> e') -> ExceptT e m a -> ExceptT e' m a #
Transform any exceptions thrown by the computation using the given function.
except :: forall (m :: Type -> Type) e a. Monad m => Either e a -> ExceptT e m a #
Constructor for computations in the exception monad.
(The inverse of runExcept).
handleE :: forall (m :: Type -> Type) e e' a. Monad m => (e -> ExceptT e' m a) -> ExceptT e m a -> ExceptT e' m a #