Copyright | (c) 2023 Sayo Koyoneda |
---|---|
License | MPL-2.0 (see the file LICENSE) |
Maintainer | [email protected] |
Safe Haskell | None |
Language | GHC2021 |
Data.Effect.Except
Description
An effect to escape from the normal control structure with an exception value in the middle of a context.
Synopsis
- data Throw e a where
- data Catch e (f :: Type -> Type) a where
- type LThrow e = LiftFOE (Throw e)
- pattern LThrow :: forall a e f a1. () => forall. (a ~ a1, ()) => e -> LiftFOE (Throw e) f a
- throw :: forall e a f. SendFOE (Throw e) f => e -> f a
- throw' :: forall {k} (tag :: k) e a f. SendFOE (Tag (Throw e) tag) f => e -> f a
- throw'' :: forall {k} (key :: k) e a f. SendFOEBy key (Throw e) f => e -> f a
- catch :: forall a e f. SendHOE (Catch e) f => f a -> (e -> f a) -> f a
- catch' :: forall {k} (tag :: k) a e f. SendHOE (TagH (Catch e) tag) f => f a -> (e -> f a) -> f a
- catch'' :: forall {k} (key :: k) a e f. SendHOEBy key (Catch e) f => f a -> (e -> f a) -> f a
- liftEither :: (Throw e <: f, Applicative f) => Either e a -> f a
- joinEither :: (Throw e <: m, Monad m) => m (Either e a) -> m a
- joinExcept :: Monad m => Either (m a) a -> m a
- exc :: Monad m => m (Either (m a) a) -> m a
- withExcept :: (Catch e <<: f, Throw e <: f, Applicative f) => f a -> (e -> f ()) -> f a
- onExcept :: (Catch e <<: f, Throw e <: f, Applicative f) => f a -> f () -> f a
Documentation
An effect to escape from the normal control structure with an exception value of type e
in the middle of a context.
data Catch e (f :: Type -> Type) a where Source #
An effect to catch exceptions.
Constructors
Catch | Catches exceptions within a scope and processes them according to the given exception handler. |
pattern LThrow :: forall a e f a1. () => forall. (a ~ a1, ()) => e -> LiftFOE (Throw e) f a Source #
throw :: forall e a f. SendFOE (Throw e) f => e -> f a Source #
Throws an exception; that is, escapes from the normal control structure with an exception value in the middle of a context.
throw' :: forall {k} (tag :: k) e a f. SendFOE (Tag (Throw e) tag) f => e -> f a Source #
Throws an exception; that is, escapes from the normal control structure with an exception value in the middle of a context.
throw'' :: forall {k} (key :: k) e a f. SendFOEBy key (Throw e) f => e -> f a Source #
Throws an exception; that is, escapes from the normal control structure with an exception value in the middle of a context.
Arguments
:: forall a e f. SendHOE (Catch e) f | |
=> f a | |
-> (e -> f a) | Exception handler. Defines the processing to perform when an exception is thrown within the scope. |
-> f a |
Catches exceptions within a scope and processes them according to the given exception handler.
Arguments
:: forall {k} (tag :: k) a e f. SendHOE (TagH (Catch e) tag) f | |
=> f a | |
-> (e -> f a) | Exception handler. Defines the processing to perform when an exception is thrown within the scope. |
-> f a |
Catches exceptions within a scope and processes them according to the given exception handler.
Arguments
:: forall {k} (key :: k) a e f. SendHOEBy key (Catch e) f | |
=> f a | |
-> (e -> f a) | Exception handler. Defines the processing to perform when an exception is thrown within the scope. |
-> f a |
Catches exceptions within a scope and processes them according to the given exception handler.
liftEither :: (Throw e <: f, Applicative f) => Either e a -> f a Source #
joinEither :: (Throw e <: m, Monad m) => m (Either e a) -> m a Source #
Throws the result of the given action as an exception if it is Left
.
joinExcept :: Monad m => Either (m a) a -> m a Source #
exc :: Monad m => m (Either (m a) a) -> m a Source #
If the result of the given action is Left
, execute it as an action.
Arguments
:: (Catch e <<: f, Throw e <: f, Applicative f) | |
=> f a | Scope to which the exception handler applies |
-> (e -> f ()) | Exception handler |
-> f a |
If an exception occurs, executes the given exception handler, but the exception is not stopped there and is rethrown.