Copyright | (c) Ivan Perez and Manuel Baerenz 2016 |
---|---|
License | BSD3 |
Maintainer | ivan.perez@keera.co.uk |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Synopsis
- newtype MSFExcept m a b e = MSFExcept {
- runMSFExcept :: MSF (ExceptT e m) a b
- throwOnCond :: Monad m => (a -> Bool) -> e -> MSF (ExceptT e m) a 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)
- throwS :: Monad m => MSF (ExceptT e m) e a
- throw :: Monad m => e -> MSF (ExceptT e m) a b
- pass :: Monad m => MSF (ExceptT e m) a a
- maybeToExceptS :: (Functor m, Monad m) => MSF (MaybeT m) a b -> MSF (ExceptT () m) a b
- 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
- exceptS :: (Functor m, Monad m) => MSF (ExceptT e m) a b -> MSF m a (Either e b)
- inExceptT :: Monad m => MSF (ExceptT e m) (ExceptT e m a) a
- tagged :: Monad m => MSF (ExceptT e1 m) a b -> MSF (ExceptT e2 m) (a, e2) b
- try :: MSF (ExceptT e m) a b -> MSFExcept m a b e
- 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
- safely :: Monad m => MSFExcept m a b Void -> MSF m a b
- safe :: Monad m => MSF m a b -> MSFExcept m a b e
- once :: Monad m => (a -> m e) -> MSFExcept m a b e
- once_ :: Monad m => m e -> MSFExcept m a b e
- step :: Monad m => (a -> m (b, e)) -> MSFExcept m a b e
- step_ :: Monad m => b -> MSFExcept m a b ()
- listToMSFExcept :: Monad m => [b] -> MSFExcept m a b ()
- performOnFirstSample :: Monad m => m (MSF m a b) -> MSF m a b
- reactimateExcept :: Monad m => MSFExcept m () () e -> m e
- reactimateB :: Monad m => MSF m () Bool -> m ()
- 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
- 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
- handleGen :: (a -> m1 (b1, MSF m1 a b1) -> m2 (b2, MSF m2 a b2)) -> MSF m1 a b1 -> MSF m2 a b2
- mapExcept :: (Either e a -> Either e' b) -> Except e a -> Except e' b
- mapExceptT :: (m (Either e a) -> n (Either e' b)) -> ExceptT e m a -> ExceptT e' n b
- runExcept :: Except e a -> Either e a
- runExceptT :: ExceptT e m a -> m (Either e a)
- withExcept :: (e -> e') -> Except e a -> Except e' a
- withExceptT :: forall (m :: Type -> Type) e e' a. Functor m => (e -> e') -> ExceptT e m a -> ExceptT e' m a
- type Except e = ExceptT e Identity
- newtype ExceptT e (m :: Type -> Type) a = ExceptT (m (Either e a))
- throwE :: forall (m :: Type -> Type) e a. Monad m => e -> ExceptT e m a
- except :: forall (m :: Type -> Type) e a. Monad m => Either e a -> 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
Documentation
newtype MSFExcept m a b e Source #
MSF
s with an ExceptT
transformer layer are in fact monads /in the
exception type/.
return
corresponds 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 theMSF
may take side effects in.a
: The input typeb
: The output typee
: The type of exceptions that can be thrown
MSFExcept | |
|
Instances
Monad m => Applicative (MSFExcept m a b) Source # | Applicative instance for MSFs on the |
Defined in Control.Monad.Trans.MSF.Except 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 |
throwOnCond :: Monad m => (a -> Bool) -> e -> MSF (ExceptT e m) a a Source #
Throw the exception e
whenever the function evaluates to True
.
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.
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.
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 => (a -> m (b, e)) -> MSFExcept m a b e Source #
Advances a single tick with the given Kleisli arrow, and then throws an exception.
step_ :: Monad m => b -> MSFExcept m a b () Source #
Advances a single tick outputting the value, and then throws ()
.
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.
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.
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.
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
(mapExceptT
f m) = f (runExceptT
m)
runExcept :: Except e a -> Either e a #
Extractor for computations in the exception monad.
(The inverse of except
).
runExceptT :: ExceptT e m a -> m (Either e a) #
The inverse of ExceptT
.
withExcept :: (e -> e') -> Except e a -> Except e' a #
Transform any exceptions thrown by the computation using the given
function (a specialization of withExceptT
).
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.
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.