Copyright | (c) Michael Szvetits 2020 |
---|---|
License | BSD3 (see the file LICENSE) |
Maintainer | typedbyte@qualified.name |
Stability | stable |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
The error effect, similar to the MonadError
type class from the
mtl
library.
Synopsis
- class Monad m => Error' tag e m | tag m -> e where
- throwError' :: e -> m a
- catchError' :: m a -> (e -> m a) -> m a
- type Error e = Error' G e
- throwError :: Error e m => e -> m a
- catchError :: Error e m => m a -> (e -> m a) -> m a
- liftEither' :: forall tag e m a. Error' tag e m => Either e a -> m a
- liftEither :: Error e m => Either e a -> m a
- runError' :: (Error' tag e `Via` ExceptT e) m a -> m (Either e a)
- runError :: (Error e `Via` ExceptT e) m a -> m (Either e a)
- tagError' :: forall new e m a. Via (Error' G e) (Tagger G new) m a -> m a
- retagError' :: forall tag new e m a. Via (Error' tag e) (Tagger tag new) m a -> m a
- untagError' :: forall tag e m a. Via (Error' tag e) (Tagger tag G) m a -> m a
Tagged Error Effect
class Monad m => Error' tag e m | tag m -> e where Source #
An effect that equips a computation with the ability to throw and catch exceptions.
throwError' :: e -> m a Source #
Throws an exception during the computation and begins exception processing.
catchError' :: m a -> (e -> m a) -> m a Source #
Catches an exception in order to handle it and return to normal execution.
Instances
Monad m => Error' (tag :: k) e (ExceptT e m) Source # | |
Defined in Control.Effect.Error throwError' :: e -> ExceptT e m a Source # catchError' :: ExceptT e m a -> (e -> ExceptT e m a) -> ExceptT e m a Source # | |
Control (Error' tag e) t m => Error' (tag :: k) e (Via eff t m) Source # | |
Defined in Control.Effect.Error throwError' :: e -> Via eff t m a Source # catchError' :: Via eff t m a -> (e -> Via eff t m a) -> Via eff t m a Source # | |
Handle (Error' tag e) t m => Error' (tag :: k) e (Via (Error' tag e) t m) Source # | |
Defined in Control.Effect.Error | |
Error' new e m => Error' (tag :: k2) e (Tagger tag new m) Source # | |
Defined in Control.Effect.Error throwError' :: e -> Tagger tag new m a Source # catchError' :: Tagger tag new m a -> (e -> Tagger tag new m a) -> Tagger tag new m a Source # |
Untagged Error Effect
If you don't require disambiguation of multiple error effects (i.e., you only have one error effect in your monadic context), it is recommended to always use the untagged error effect.
throwError :: Error e m => e -> m a Source #
catchError :: Error e m => m a -> (e -> m a) -> m a Source #
Convenience Functions
If you don't require disambiguation of multiple error effects (i.e., you only have one error effect in your monadic context), it is recommended to always use the untagged functions.
liftEither' :: forall tag e m a. Error' tag e m => Either e a -> m a Source #
liftEither :: Error e m => Either e a -> m a Source #
The untagged version of liftEither'
.
Interpretations
runError' :: (Error' tag e `Via` ExceptT e) m a -> m (Either e a) Source #
Runs the error effect by wrapping exceptions in the Either
type.
runError :: (Error e `Via` ExceptT e) m a -> m (Either e a) Source #
The untagged version of runError'
.
Tagging and Untagging
Conversion functions between the tagged and untagged error effect, usually used in combination with type applications, like:
tagError'
@"newTag" programretagError'
@"oldTag" @"newTag" programuntagError'
@"erasedTag" program