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
- liftEither' :: forall tag e m a. Error' tag e m => Either e 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 :: 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. (Error' G e `Via` Tagger G new) m a -> m a
- retagError' :: forall tag new e m a. (Error' tag e `Via` Tagger tag new) m a -> m a
- untagError' :: forall tag e m a. (Error' tag e `Via` 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 # | |
Handle '[Monad] (Error' tag e) others t m => Error' (tag :: k) e (EachVia (Error' tag e ': others) t m) Source # | |
Defined in Control.Effect.Error | |
Find '[Monad] (Error' tag e) other effs t m => Error' (tag :: k) e (EachVia (other ': effs) t m) Source # | |
Defined in Control.Effect.Error throwError' :: e -> EachVia (other ': effs) t m a Source # catchError' :: EachVia (other ': effs) t m a -> (e -> EachVia (other ': effs) t m a) -> EachVia (other ': effs) t m a Source # | |
Control '[Monad] (Error' tag e) t m => Error' (tag :: k) e (EachVia ('[] :: [Effect]) t m) Source # | |
Defined in Control.Effect.Error throwError' :: e -> EachVia '[] t m a Source # catchError' :: EachVia '[] t m a -> (e -> EachVia '[] t m a) -> EachVia '[] t m a Source # | |
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 # |
Convenience Functions
liftEither' :: forall tag e m a. Error' tag e m => Either e a -> 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 #
liftEither :: Error e m => Either e a -> m a Source #
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