Copyright | (c) 2016-2017 Red Hat Inc. |
---|---|
License | LGPL |
Maintainer | https://github.com/weldr |
Stability | alpha |
Portability | portable |
Safe Haskell | Safe |
Language | Haskell2010 |
BDCS.Utils.Error
Description
Functions to help with errors
- errorToEither :: MonadError e m => m a -> m (Either e a)
- errorToMaybe :: MonadError e m => m a -> m (Maybe a)
- mapError :: MonadError e' m => (e -> e') -> ExceptT e m a -> m a
Documentation
errorToEither :: MonadError e m => m a -> m (Either e a) Source #
Convert an error action into an Either
This is essentially runExceptT
generalized to MonadError
errorToMaybe :: MonadError e m => m a -> m (Maybe a) Source #
Convert an error into into nothing
mapError :: MonadError e' m => (e -> e') -> ExceptT e m a -> m a Source #
Run an ExceptT
action. On error, run a supplied function to convert the error into
some type that can be thrown with throwError
in MonadError
. On success, simply
return the value of the action.