@@ -136,6 +136,8 @@ import qualified Streamly.Data.Fold as FL
136import qualified Streamly.Internal.Data.Stream.IsStream as S
136import qualified Streamly.Internal.Data.Stream.IsStream as S
137import qualified Streamly.Internal.Data.Unfold as UF
137import qualified Streamly.Internal.Data.Unfold as UF
139+import qualified Data.Map.Strict as Map
139import Streamly.Test.Common
141import Streamly.Test.Common
141maxStreamLen :: Int
143maxStreamLen :: Int
@@ -1498,6 +1500,37 @@ finallyProp t vec =
1498 refValue <- run $ readIORef ioRef
1500 refValue <- run $ readIORef ioRef
1499 assert $ refValue == 1
1501 assert $ refValue == 1
1505+ ref <- runIO $ newIORef (0 :: Int)
1506+ res <- runIO $ S.toList (S.retry emap handler (stream1 ref))
1507+ refVal <- runIO $ readIORef ref
1512+ emap = Map.singleton (ExampleException "E") 10
1518+ , atomicModifyIORef' ref (\a -> (a + 1, ()))
1519+ >> throwM (ExampleException "E")
1524+ stream2 = S.fromList [5, 6, 7 :: Int]
1525+ handler = const stream2
1526+ expectedRes = [1, 2, 5, 6, 7]
1527+ expectedRefVal = 11
1529+ spec res refVal = do
1530+ it "Runs the exception handler properly" $ res `shouldBe` expectedRes
1531+ it "Runs retires the exception correctly"
1532+ $ refVal `shouldBe` expectedRefVal
1501#ifdef DEVBUILD
1534#ifdef DEVBUILD
1502finallyPartialStreamProp ::
1535finallyPartialStreamProp ::
1503 (IsStream t) => (t IO Int -> SerialT IO Int) -> [Int] -> Property
1536 (IsStream t) => (t IO Int -> SerialT IO Int) -> [Int] -> Property
@@ -1606,12 +1639,13 @@ exceptionOps desc t = do
1607 prop (desc <> " finally exception in stream") $ finallyExceptionProp t
1640 prop (desc <> " finally exception in stream") $ finallyExceptionProp t
1608 prop (desc <> " handle") $ handleProp t
1641 prop (desc <> " handle") $ handleProp t
1610-------------------------------------------------------------------------------
1644-------------------------------------------------------------------------------
1611-- Compose with MonadThrow
1645-- Compose with MonadThrow
1612-------------------------------------------------------------------------------
1646-------------------------------------------------------------------------------
1614−newtype ExampleException = ExampleException String deriving (Eq, Show)
1648+newtype ExampleException = ExampleException String deriving (Eq, Show, Ord)
1616instance Exception ExampleException
1650instance Exception ExampleException