@@ -153,7 +153,7 @@ checkCleanup :: IsStream t
154checkCleanup d t op = do
154checkCleanup d t op = do
155 r <- newIORef (-1 :: Int)
155 r <- newIORef (-1 :: Int)
156− runStream . serially $ do
156+ S.runStream . serially $ do
157 _ <- t $ op $ delay r 0 S.|: delay r 1 S.|: delay r 2 S.|: S.nil
157 _ <- t $ op $ delay r 0 S.|: delay r 1 S.|: delay r 2 S.|: S.nil
158 return ()
158 return ()
159 performMajorGC
159 performMajorGC
@@ -193,9 +193,9 @@ parallelTests = H.parallel $ do
193 -- XXX move these to property tests
193 -- XXX move these to property tests
194 -- XXX use an IORef to store and check the side effects
194 -- XXX use an IORef to store and check the side effects
195 it "simple serially" $
195 it "simple serially" $
196− (runStream . serially) (return (0 :: Int)) `shouldReturn` ()
196+ (S.runStream . serially) (return (0 :: Int)) `shouldReturn` ()
197 it "simple serially with IO" $
197 it "simple serially with IO" $
198− (runStream . serially) (S.yieldM $ putStrLn "hello") `shouldReturn` ()
198+ (S.runStream . serially) (S.yieldM $ putStrLn "hello") `shouldReturn` ()
200 describe "Empty" $ -- do
200 describe "Empty" $ -- do
201 it "Monoid - mempty" $
201 it "Monoid - mempty" $
@@ -541,12 +541,12 @@ parallelTests = H.parallel $ do
541 ---------------------------------------------------------------------------
541 ---------------------------------------------------------------------------
543 it "asyncly crosses thread limit (2000 threads)" $
543 it "asyncly crosses thread limit (2000 threads)" $
544− runStream (asyncly $ fold $
544+ S.runStream (asyncly $ fold $
545 replicate 2000 $ S.yieldM $ threadDelay 1000000)
545 replicate 2000 $ S.yieldM $ threadDelay 1000000)
546 `shouldReturn` ()
546 `shouldReturn` ()
548 it "aheadly crosses thread limit (4000 threads)" $
548 it "aheadly crosses thread limit (4000 threads)" $
549− runStream (aheadly $ fold $
549+ S.runStream (aheadly $ fold $
550 replicate 4000 $ S.yieldM $ threadDelay 1000000)
550 replicate 4000 $ S.yieldM $ threadDelay 1000000)
551 `shouldReturn` ()
551 `shouldReturn` ()
@@ -596,7 +596,7 @@ monadicStateSnapshot
596 , MonadState Int (t (StateT Int IO))
596 , MonadState Int (t (StateT Int IO))
598 => (t (StateT Int IO) () -> SerialT (StateT Int IO) ()) -> IO ()
598 => (t (StateT Int IO) () -> SerialT (StateT Int IO) ()) -> IO ()
599−monadicStateSnapshot t = void $ runStateT (runStream $ t stateComp) 0
599+monadicStateSnapshot t = void $ runStateT (S.runStream $ t stateComp) 0
601stateCompOp
601stateCompOp
602 :: ( AsyncT (StateT Int IO) ()
602 :: ( AsyncT (StateT Int IO) ()
@@ -619,7 +619,7 @@ monadicStateSnapshotOp
619 -> AsyncT (StateT Int IO) ()
619 -> AsyncT (StateT Int IO) ()
622−monadicStateSnapshotOp op = void $ runStateT (runStream $ stateCompOp op) 0
622+monadicStateSnapshotOp op = void $ runStateT (S.runStream $ stateCompOp op) 0
624takeCombined :: (Monad m, Semigroup (t m Int), Show a, Eq a, IsStream t)
624takeCombined :: (Monad m, Semigroup (t m Int), Show a, Eq a, IsStream t)
625 => Int -> (t m Int -> SerialT IO a) -> IO ()
625 => Int -> (t m Int -> SerialT IO a) -> IO ()
@@ -669,7 +669,7 @@ checkScanxStrictness :: IO ()
669checkScanxStrictness = do
669checkScanxStrictness = do
670 let s = return (1 :: Int) `S.consM` error "failure"
670 let s = return (1 :: Int) `S.consM` error "failure"
672− (runStream (
672+ (S.runStream (
673 S.scanx (\_ a ->
673 S.scanx (\_ a ->
674 if a == 1
674 if a == 1
675 then error "success"
675 then error "success"
@@ -687,7 +687,7 @@ checkScanl'Strictness :: IO ()
687checkScanl'Strictness = do
687checkScanl'Strictness = do
688 let s = return (1 :: Int) `S.consM` error "failure"
688 let s = return (1 :: Int) `S.consM` error "failure"
690− (runStream
690+ (S.runStream
691 (S.scanl'
691 (S.scanl'
693 if a == 1
693 if a == 1
@@ -722,13 +722,13 @@ checkScanlMStrictness :: (IORef Int -> SerialT IO Int -> SerialT IO ()) -> IO ()
722checkScanlMStrictness f = do
722checkScanlMStrictness f = do
723 ref <- newIORef 0
723 ref <- newIORef 0
724 let s = return 1 `S.consM` error "x"
724 let s = return 1 `S.consM` error "x"
725− catch (runStream $ f ref s) (\(_ :: ErrorCall) -> return ())
725+ catch (S.runStream $ f ref s) (\(_ :: ErrorCall) -> return ())
726 readIORef ref `shouldReturn` 1
726 readIORef ref `shouldReturn` 1
728takeInfinite :: IsStream t => (t IO Int -> SerialT IO Int) -> Spec
728takeInfinite :: IsStream t => (t IO Int -> SerialT IO Int) -> Spec
729takeInfinite t =
729takeInfinite t =
730 it "take 1" $
730 it "take 1" $
731− runStream (t $ S.take 1 $ S.repeatM (print "hello" >> return (1::Int)))
731+ S.runStream (t $ S.take 1 $ S.repeatM (print "hello" >> return (1::Int)))
732 `shouldReturn` ()
732 `shouldReturn` ()
734-- XXX need to test that we have promptly cleaned up everything after the error
734-- XXX need to test that we have promptly cleaned up everything after the error
@@ -743,16 +743,16 @@ simpleMonadError :: Spec
743simpleMonadError = do
743simpleMonadError = do
745 it "simple runExceptT" $ do
745 it "simple runExceptT" $ do
746− (runExceptT $ runStream $ return ())
746+ (runExceptT $ S.runStream $ return ())
747 `shouldReturn` (Right () :: Either String ())
747 `shouldReturn` (Right () :: Either String ())
748 it "simple runExceptT with error" $ do
748 it "simple runExceptT with error" $ do
749− (runExceptT $ runStream $ throwError "E") `shouldReturn` Left "E"
749+ (runExceptT $ S.runStream $ throwError "E") `shouldReturn` Left "E"
751 it "simple try" $
751 it "simple try" $
752− try (runStream $ return ())
752+ try (S.runStream $ return ())
753 `shouldReturn` (Right () :: Either ExampleException ())
753 `shouldReturn` (Right () :: Either ExampleException ())
754 it "simple try with throw error" $
754 it "simple try with throw error" $
755− try (runStream $ throwM $ ExampleException "E")
755+ try (S.runStream $ throwM $ ExampleException "E")
756 `shouldReturn` (Left (ExampleException "E") :: Either ExampleException ())
756 `shouldReturn` (Left (ExampleException "E") :: Either ExampleException ())
758composeWithMonadThrow
758composeWithMonadThrow
@@ -790,8 +790,8 @@ composeWithMonadThrow t = do
791 oneLevelNestedProduct desc t1 =
791 oneLevelNestedProduct desc t1 =
792 it ("One level nested product" <> desc) $ do
792 it ("One level nested product" <> desc) $ do
793− let s1 = t $ foldMapWith (<>) return [1..4]
793+ let s1 = t $ S.foldMapWith (<>) return [1..4]
794− s2 = t1 $ foldMapWith (<>) return [5..8]
794+ s2 = t1 $ S.foldMapWith (<>) return [5..8]
795 try $ tl (do
795 try $ tl (do
796 x <- adapt s1
796 x <- adapt s1
@@ -816,8 +816,8 @@ _composeWithMonadError t = do
817nestTwoSerial :: Expectation
817nestTwoSerial :: Expectation
818nestTwoSerial =
818nestTwoSerial =
819− let s1 = foldMapWith (<>) return [1..4]
819+ let s1 = S.foldMapWith (<>) return [1..4]
820− s2 = foldMapWith (<>) return [5..8]
820+ s2 = S.foldMapWith (<>) return [5..8]
821 in toListSerial (do
821 in toListSerial (do
@@ -826,8 +826,8 @@ nestTwoSerial =
827nestTwoAhead :: Expectation
827nestTwoAhead :: Expectation
828nestTwoAhead =
828nestTwoAhead =
829− let s1 = foldMapWith (<>) return [1..4]
829+ let s1 = S.foldMapWith (<>) return [1..4]
830− s2 = foldMapWith (<>) return [5..8]
830+ s2 = S.foldMapWith (<>) return [5..8]
831 in (S.toList . aheadly) (do
831 in (S.toList . aheadly) (do
@@ -836,22 +836,22 @@ nestTwoAhead =
837nestTwoSerialApp :: Expectation
837nestTwoSerialApp :: Expectation
838nestTwoSerialApp =
838nestTwoSerialApp =
839− let s1 = foldMapWith (<>) return [1..4]
839+ let s1 = S.foldMapWith (<>) return [1..4]
840− s2 = foldMapWith (<>) return [5..8]
840+ s2 = S.foldMapWith (<>) return [5..8]
841 in toListSerial ((+) <$> s1 <*> s2)
841 in toListSerial ((+) <$> s1 <*> s2)
842 `shouldReturn` ([6,7,8,9,7,8,9,10,8,9,10,11,9,10,11,12] :: [Int])
842 `shouldReturn` ([6,7,8,9,7,8,9,10,8,9,10,11,9,10,11,12] :: [Int])
844nestTwoAheadApp :: Expectation
844nestTwoAheadApp :: Expectation
845nestTwoAheadApp =
845nestTwoAheadApp =
846− let s1 = foldMapWith (<>) return [1..4]
846+ let s1 = S.foldMapWith (<>) return [1..4]
847− s2 = foldMapWith (<>) return [5..8]
847+ s2 = S.foldMapWith (<>) return [5..8]
848 in (S.toList . aheadly) ((+) <$> s1 <*> s2)
848 in (S.toList . aheadly) ((+) <$> s1 <*> s2)
849 `shouldReturn` ([6,7,8,9,7,8,9,10,8,9,10,11,9,10,11,12] :: [Int])
849 `shouldReturn` ([6,7,8,9,7,8,9,10,8,9,10,11,9,10,11,12] :: [Int])
851nestTwoInterleaved :: Expectation
851nestTwoInterleaved :: Expectation
852nestTwoInterleaved =
852nestTwoInterleaved =
853− let s1 = foldMapWith (<>) return [1..4]
853+ let s1 = S.foldMapWith (<>) return [1..4]
854− s2 = foldMapWith (<>) return [5..8]
854+ s2 = S.foldMapWith (<>) return [5..8]
855 in toListInterleaved (do
855 in toListInterleaved (do
@@ -860,15 +860,15 @@ nestTwoInterleaved =
861nestTwoInterleavedApp :: Expectation
861nestTwoInterleavedApp :: Expectation
862nestTwoInterleavedApp =
862nestTwoInterleavedApp =
863− let s1 = foldMapWith (<>) return [1..4]
863+ let s1 = S.foldMapWith (<>) return [1..4]
864− s2 = foldMapWith (<>) return [5..8]
864+ s2 = S.foldMapWith (<>) return [5..8]
865 in toListInterleaved ((+) <$> s1 <*> s2)
865 in toListInterleaved ((+) <$> s1 <*> s2)
866 `shouldReturn` ([6,7,7,8,8,8,9,9,9,9,10,10,10,11,11,12] :: [Int])
866 `shouldReturn` ([6,7,7,8,8,8,9,9,9,9,10,10,10,11,11,12] :: [Int])
868nestTwoAsync :: Expectation
868nestTwoAsync :: Expectation
869nestTwoAsync =
869nestTwoAsync =
870− let s1 = foldMapWith (<>) return [1..4]
870+ let s1 = S.foldMapWith (<>) return [1..4]
871− s2 = foldMapWith (<>) return [5..8]
871+ s2 = S.foldMapWith (<>) return [5..8]
872 in sort <$> toListAsync (do
872 in sort <$> toListAsync (do
@@ -877,15 +877,15 @@ nestTwoAsync =
878nestTwoAsyncApp :: Expectation
878nestTwoAsyncApp :: Expectation
879nestTwoAsyncApp =
879nestTwoAsyncApp =
880− let s1 = foldMapWith (<>) return [1..4]
880+ let s1 = S.foldMapWith (<>) return [1..4]
881− s2 = foldMapWith (<>) return [5..8]
881+ s2 = S.foldMapWith (<>) return [5..8]
882 in sort <$> toListAsync ((+) <$> s1 <*> s2)
882 in sort <$> toListAsync ((+) <$> s1 <*> s2)
883 `shouldReturn` sort ([6,7,8,9,7,8,9,10,8,9,10,11,9,10,11,12] :: [Int])
883 `shouldReturn` sort ([6,7,8,9,7,8,9,10,8,9,10,11,9,10,11,12] :: [Int])
885nestTwoWAsync :: Expectation
885nestTwoWAsync :: Expectation
886nestTwoWAsync =
886nestTwoWAsync =
887− let s1 = foldMapWith (<>) return [1..4]
887+ let s1 = S.foldMapWith (<>) return [1..4]
888− s2 = foldMapWith (<>) return [5..8]
888+ s2 = S.foldMapWith (<>) return [5..8]
889 in sort <$> (S.toList . wAsyncly) (do
889 in sort <$> (S.toList . wAsyncly) (do
@@ -894,8 +894,8 @@ nestTwoWAsync =
895nestTwoParallel :: Expectation
895nestTwoParallel :: Expectation
896nestTwoParallel =
896nestTwoParallel =
897− let s1 = foldMapWith (<>) return [1..4]
897+ let s1 = S.foldMapWith (<>) return [1..4]
898− s2 = foldMapWith (<>) return [5..8]
898+ s2 = S.foldMapWith (<>) return [5..8]
899 in sort <$> (S.toList . parallely) (do
899 in sort <$> (S.toList . parallely) (do
@@ -904,15 +904,15 @@ nestTwoParallel =
905nestTwoWAsyncApp :: Expectation
905nestTwoWAsyncApp :: Expectation
906nestTwoWAsyncApp =
906nestTwoWAsyncApp =
907− let s1 = foldMapWith (<>) return [1..4]
907+ let s1 = S.foldMapWith (<>) return [1..4]
908− s2 = foldMapWith (<>) return [5..8]
908+ s2 = S.foldMapWith (<>) return [5..8]
909 in sort <$> (S.toList . wAsyncly) ((+) <$> s1 <*> s2)
909 in sort <$> (S.toList . wAsyncly) ((+) <$> s1 <*> s2)
910 `shouldReturn` sort ([6,7,7,8,8,8,9,9,9,9,10,10,10,11,11,12] :: [Int])
910 `shouldReturn` sort ([6,7,7,8,8,8,9,9,9,9,10,10,10,11,11,12] :: [Int])
912nestTwoParallelApp :: Expectation
912nestTwoParallelApp :: Expectation
913nestTwoParallelApp =
913nestTwoParallelApp =
914− let s1 = foldMapWith (<>) return [1..4]
914+ let s1 = S.foldMapWith (<>) return [1..4]
915− s2 = foldMapWith (<>) return [5..8]
915+ s2 = S.foldMapWith (<>) return [5..8]
916 in sort <$> (S.toList . parallely) ((+) <$> s1 <*> s2)
916 in sort <$> (S.toList . parallely) ((+) <$> s1 <*> s2)
917 `shouldReturn` sort ([6,7,7,8,8,8,9,9,9,9,10,10,10,11,11,12] :: [Int])
917 `shouldReturn` sort ([6,7,7,8,8,8,9,9,9,9,10,10,10,11,11,12] :: [Int])
@@ -954,7 +954,7 @@ compose t z srt = do
954 srt <$> tl (singleton 0 <> singleton 1)
954 srt <$> tl (singleton 0 <> singleton 1)
955 `shouldReturn` [0, 1]
955 `shouldReturn` [0, 1]
956 it "Compose many" $
956 it "Compose many" $
957− srt <$> tl (forEachWith (<>) [1..100] singleton)
957+ srt <$> tl (S.forEachWith (<>) [1..100] singleton)
958 `shouldReturn` [1..100]
958 `shouldReturn` [1..100]
960 -- These are not covered by the property tests
960 -- These are not covered by the property tests
@@ -984,7 +984,7 @@ composeAndComposeSimple
984 -> (t2 IO Int -> t2 IO Int)
984 -> (t2 IO Int -> t2 IO Int)
985 -> [[Int]] -> Spec
985 -> [[Int]] -> Spec
986composeAndComposeSimple t1 t2 answer = do
986composeAndComposeSimple t1 t2 answer = do
987− let rfold = adapt . t2 . foldMapWith (<>) return
987+ let rfold = adapt . t2 . S.foldMapWith (<>) return
988 it "Compose right associated outer expr, right folded inner" $
988 it "Compose right associated outer expr, right folded inner" $
989 (S.toList . t1) (rfold [1,2,3] <> (rfold [4,5,6] <> rfold [7,8,9]))
989 (S.toList . t1) (rfold [1,2,3] <> (rfold [4,5,6] <> rfold [7,8,9]))
990 `shouldReturn` head answer
990 `shouldReturn` head answer
@@ -1035,7 +1035,7 @@ bindAndComposeSimple t1 t2 = do
1035 -- XXX need a bind in the body of forEachWith instead of a simple return
1035 -- XXX need a bind in the body of forEachWith instead of a simple return
1036 it "Compose many (right fold) with bind" $
1036 it "Compose many (right fold) with bind" $
1037 (sort <$> (S.toList . t1)
1037 (sort <$> (S.toList . t1)
1038− (adapt . t2 $ forEachWith (<>) [1..10 :: Int] return))
1038+ (adapt . t2 $ S.forEachWith (<>) [1..10 :: Int] return))
1039 `shouldReturn` [1..10]
1039 `shouldReturn` [1..10]
1041 it "Compose many (left fold) with bind" $
1041 it "Compose many (left fold) with bind" $