Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Control.Eff.Exception
Description
Exception-producing and exception-handling effects
Synopsis
- newtype Exc e (v :: k) = Exc e
- exc :: Monad m => e -> m (Either e a)
- withException :: Monad m => a -> m (Either e a)
- type Fail = Exc () :: k -> Type
- throwError :: forall e (r :: [Type -> Type]) a. Member (Exc e :: Type -> Type) r => e -> Eff r a
- throwError_ :: forall e (r :: [Type -> Type]). Member (Exc e :: Type -> Type) r => e -> Eff r ()
- die :: forall (r :: [Type -> Type]) a. Member (Fail :: Type -> Type) r => Eff r a
- runError :: forall e (r :: [Type -> Type]) a. Eff ((Exc e :: Type -> Type) ': r) a -> Eff r (Either e a)
- runFail :: forall (r :: [Type -> Type]) a. Eff ((Fail :: Type -> Type) ': r) a -> Eff r (Maybe a)
- catchError :: forall e (r :: [Type -> Type]) a. Member (Exc e :: Type -> Type) r => Eff r a -> (e -> Eff r a) -> Eff r a
- onFail :: forall (r :: [Type -> Type]) a. Eff ((Fail :: Type -> Type) ': r) a -> Eff r a -> Eff r a
- rethrowError :: forall e' (r :: [Type -> Type]) e a. Member (Exc e' :: Type -> Type) r => (e -> e') -> Eff ((Exc e :: Type -> Type) ': r) a -> Eff r a
- liftEither :: forall e (r :: [Type -> Type]) a. Member (Exc e :: Type -> Type) r => Either e a -> Eff r a
- liftEitherM :: forall e (r :: [Type -> Type]) m a. (Member (Exc e :: Type -> Type) r, Lifted m r) => m (Either e a) -> Eff r a
- liftMaybe :: forall (r :: [Type -> Type]) a. Member (Fail :: Type -> Type) r => Maybe a -> Eff r a
- liftMaybeM :: forall (r :: [Type -> Type]) m a. (Member (Fail :: Type -> Type) r, Lifted m r) => m (Maybe a) -> Eff r a
- ignoreFail :: forall (r :: [Type -> Type]) a. Eff ((Fail :: Type -> Type) ': r) a -> Eff r ()
Documentation
newtype Exc e (v :: k) Source #
Exceptions
exceptions of the type e; no resumption
Constructors
Exc e |
Instances
(MonadBase m m, LiftedBase m r) => MonadBaseControl m (Eff ((Exc e :: Type -> Type) ': r)) Source # | |
Monad m => Handle (Exc e :: Type -> Type) r a (m (Either e a)) Source # | Given a callback, and an |
Defined in Control.Eff.Exception Methods handle :: (Eff r a -> m (Either e a)) -> Arrs r v a -> Exc e v -> m (Either e a) Source # handle_relay :: forall (r' :: [Type -> Type]). (r ~ ((Exc e :: Type -> Type) ': r'), Relay (m (Either e a)) r') => (a -> m (Either e a)) -> (Eff r a -> m (Either e a)) -> Eff r a -> m (Either e a) Source # respond_relay :: (a -> m (Either e a)) -> (Eff r a -> m (Either e a)) -> Eff r a -> m (Either e a) Source # | |
type StM (Eff ((Exc e :: Type -> Type) ': r)) a Source # | |
withException :: Monad m => a -> m (Either e a) Source #
Embed a pure value
throwError :: forall e (r :: [Type -> Type]) a. Member (Exc e :: Type -> Type) r => e -> Eff r a Source #
Throw an exception in an effectful computation. The type is inferred.
throwError_ :: forall e (r :: [Type -> Type]). Member (Exc e :: Type -> Type) r => e -> Eff r () Source #
Throw an exception in an effectful computation. The type is unit, which suppresses the ghc-mod warning "A do-notation statement discarded a result of type"
die :: forall (r :: [Type -> Type]) a. Member (Fail :: Type -> Type) r => Eff r a Source #
Makes an effect fail, preventing future effects from happening.
runError :: forall e (r :: [Type -> Type]) a. Eff ((Exc e :: Type -> Type) ': r) a -> Eff r (Either e a) Source #
Run a computation that might produce an exception.
runFail :: forall (r :: [Type -> Type]) a. Eff ((Fail :: Type -> Type) ': r) a -> Eff r (Maybe a) Source #
catchError :: forall e (r :: [Type -> Type]) a. Member (Exc e :: Type -> Type) r => Eff r a -> (e -> Eff r a) -> Eff r a Source #
Run a computation that might produce exceptions, and give it a way to deal with the exceptions that come up. The handler is allowed to rethrow the exception
Arguments
:: forall (r :: [Type -> Type]) a. Eff ((Fail :: Type -> Type) ': r) a | The fallible computation. |
-> Eff r a | The computation to run on failure. |
-> Eff r a |
Add a default value (i.e. failure handler) to a fallible computation. This hides the fact that a failure happened.
rethrowError :: forall e' (r :: [Type -> Type]) e a. Member (Exc e' :: Type -> Type) r => (e -> e') -> Eff ((Exc e :: Type -> Type) ': r) a -> Eff r a Source #
Run a computation until it produces an exception, and convert and throw that exception in a new context.
liftEither :: forall e (r :: [Type -> Type]) a. Member (Exc e :: Type -> Type) r => Either e a -> Eff r a Source #
Treat Lefts as exceptions and Rights as return values.
liftEitherM :: forall e (r :: [Type -> Type]) m a. (Member (Exc e :: Type -> Type) r, Lifted m r) => m (Either e a) -> Eff r a Source #
liftEither
in a lifted Monad
liftMaybe :: forall (r :: [Type -> Type]) a. Member (Fail :: Type -> Type) r => Maybe a -> Eff r a Source #