packages feed

unliftio 0.2.14 → 0.2.15

raw patch · 4 files changed

+31/−2 lines, 4 files

Files

ChangeLog.md view
@@ -1,5 +1,11 @@ # Changelog for unliftio +## 0.2.15++* Updated documentation mentioning that `MonadUnliftIO` may be derived using+  the `newtype` strategy [#72](https://github.com/fpco/unliftio/pull/72)+* Add `mapExceptionM` [#75](https://github.com/fpco/unliftio/pull/75)+ ## 0.2.14  * Add `UnliftIO.QSem`
src/UnliftIO/Exception.hs view
@@ -21,6 +21,8 @@   , fromEither   , fromEitherIO   , fromEitherM+  , mapExceptionM+     -- * Catching (with recovery)   , catch   , catchIO@@ -635,3 +637,10 @@ -- @since 0.1.0.0 fromEitherM :: (Exception e, MonadIO m) => m (Either e a) -> m a fromEitherM = (>>= fromEither)++-- | Same as 'Control.Exception.mapException', except works in+-- a monadic context.+--+-- @since 0.2.15+mapExceptionM :: (Exception e1, Exception e2, MonadUnliftIO m) => (e1 -> e2) -> m a -> m a+mapExceptionM f = handle (throwIO . f)
test/UnliftIO/ExceptionSpec.hs view
@@ -15,3 +15,17 @@     it "Right for defined values" $ shouldRight $ pureTryDeep ()     it "Left for bottom" $ shouldLeft $ pureTryDeep (undefined :: ())     it "Left for wrapped bottom" $ shouldLeft $ pureTryDeep $ Just (undefined :: ())++  describe "mapExceptionM" $ do+    it "should convert an exception" $ do+      result <- try $ mapExceptionM (\Exception1 -> Exception2) (throwIO Exception1)+      result `shouldBe` (Left Exception2 :: Either Exception2 ())+    it "should not convert unrelated exceptions" $ do+      result <- try $ mapExceptionM (\Exception1 -> Exception2) (throwIO Exception2)+      result `shouldBe` (Left Exception2 :: Either Exception2 ())++data Exception1 = Exception1 deriving (Show, Eq)+instance Exception Exception1++data Exception2 = Exception2 deriving (Show, Eq)+instance Exception Exception2
unliftio.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: e737146da57bc35659bcdf122bb96b8fd76e43a33e39f3ebf00fac260c68bb2b+-- hash: 6f6fd7f95df930571d7c917424b5f1163381bfa922c0385872be54ccb48991cc  name:           unliftio-version:        0.2.14+version:        0.2.15 synopsis:       The MonadUnliftIO typeclass for unlifting monads to IO (batteries included) description:    Please see the documentation and README at <https://www.stackage.org/package/unliftio> category:       Control