either-result 0.1.1.0 → 0.1.2.0
raw patch · 3 files changed
+19/−2 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Data.Either.Result: toMonadFail :: MonadFail m => Result a -> m a
Files
- CHANGELOG.md +6/−0
- either-result.cabal +1/−1
- src/Data/Either/Result.hs +12/−1
CHANGELOG.md view
@@ -1,5 +1,11 @@ # Revision history for either-result +## 0.1.2.0++*2020.07.31*++- Add `toMonadFail`.+ ## 0.1.1.0 *2020.07.28*
either-result.cabal view
@@ -1,7 +1,7 @@ cabal-version: 2.2 name: either-result-version: 0.1.1.0+version: 0.1.2.0 synopsis: ‘Result a’ is a wrapper of ‘Either String a’. description: ‘Result a’ is a wrapper of ‘Either String a’, but ‘Result’ is an instance of ‘MonadFail’. homepage: https://github.com/kakkun61/either-result
src/Data/Either/Result.hs view
@@ -18,9 +18,12 @@ , fromEither , toEither , fromSuccess+ , toMonadFail ) where -import Prelude hiding (either)+#if !MIN_VERSION_base(4,13,0)+import Prelude hiding (fail)+#endif import Control.Applicative (Alternative (empty, (<|>))) import Control.Monad (MonadPlus (mplus, mzero))@@ -110,6 +113,7 @@ result :: (String -> b) -> (a -> b) -> Result a -> b result f _ (Error e) = f e result _ g (Success a) = g a+{-# INLINE result #-} -- | Convert @'Either' 'String' a@ to @'Result' a@. fromEither :: Either String a -> Result a@@ -125,3 +129,10 @@ fromSuccess :: a -> Result a -> a fromSuccess _ (Success a) = a fromSuccess a _ = a+{-# INLINE fromSuccess #-}++-- | Convert @'Result' a@ to @'MonadFail' m => m a@.+toMonadFail :: MonadFail m => Result a -> m a+toMonadFail (Success a) = pure a+toMonadFail (Error e) = fail e+{-# INLINE toMonadFail #-}