Skip to content

Commit

Permalink
Merge pull request #11 from lrworth/hoistprime
Browse files Browse the repository at this point in the history
`hoistError'` and `hoistErrorM'`
  • Loading branch information
tonymorris authored Dec 16, 2024
2 parents 3162877 + 1315882 commit 10fd85c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
2 changes: 1 addition & 1 deletion hoist-error.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: hoist-error
version: 0.3.0.0
version: 0.3.1.0
synopsis: Some convenience facilities for hoisting errors into a monad
description: Provides a typeclass and useful combinators for hoisting errors into a monad.
license: MIT
Expand Down
16 changes: 16 additions & 0 deletions src/Control/Monad/Error/Hoist.hs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@

module Control.Monad.Error.Hoist
( hoistError
, hoistError'
, hoistErrorM
, hoistErrorM'
-- ** Operators
-- $mnemonics
, (<%?>)
Expand Down Expand Up @@ -70,6 +72,13 @@ hoistError
-> m a
hoistError f = foldError (throwError . f) pure

-- | @hoistError' = hoistError id@
hoistError'
:: (PluckError e t m, MonadError e m)
=> t a
-> m a
hoistError' = hoistError id

-- | A version of 'hoistError' that operates on values already in the monad.
--
-- @
Expand All @@ -84,6 +93,13 @@ hoistErrorM
-> m a
hoistErrorM e m = m >>= hoistError e

-- | @hoistErrorM' = hoistErrorM id@
hoistErrorM'
:: (PluckError e t m, MonadError e m)
=> m (t a)
-> m a
hoistErrorM' = hoistErrorM id

-- $mnemonics
--
-- The operators in this package are named according to a scheme:
Expand Down
10 changes: 2 additions & 8 deletions src/Control/Monad/Fail/Hoist.hs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ hoistFail
-> m a
hoistFail f = foldError (fail . f) pure

-- | Hoist computations whose error type is already 'String'.
-- | @hoistFail' = hoistFail id@
hoistFail' :: (PluckError String t m, MonadFail m) => t a -> m a
hoistFail' = hoistFail id

Expand All @@ -59,13 +59,7 @@ hoistFailM
-> m a
hoistFailM f m = m >>= hoistFail f

-- | A version of 'hoistFail'' that operates on values already in the monad.
--
-- @
-- 'hoistFailM'' :: 'MonadFail' m => m ('Maybe' a) -> m a
-- 'hoistFailM'' :: 'MonadFail' m => m ('Either' a b) -> m b
-- 'hoistFailM'' :: 'MonadFail' m => 'ExceptT' a m b -> 'ExceptT' a m b
-- @
-- | @hoistFailM' = hoistFailM id@
hoistFailM'
:: (PluckError String t m, MonadFail m)
=> m (t a)
Expand Down

0 comments on commit 10fd85c

Please sign in to comment.