@@ -40,7 +40,7 @@ main = hspec $ do
40 it "simple streamly" $
40 it "simple streamly" $
41 (runStream . streamly) (return (0 :: Int)) `shouldReturn` ()
41 (runStream . streamly) (return (0 :: Int)) `shouldReturn` ()
42 it "simple streamly with IO" $
42 it "simple streamly with IO" $
43− (runStream . streamly) (liftIO $ putStrLn "hello") `shouldReturn` ()
43+ (runStream . streamly) (A.once $ putStrLn "hello") `shouldReturn` ()
45 describe "Empty" $ do
45 describe "Empty" $ do
46 it "Monoid - mempty" $
46 it "Monoid - mempty" $
@@ -450,8 +450,8 @@ nestTwoParallelApp =
450 in (toListParallel ((+) <$> s1 <*> s2) >>= return . sort)
450 in (toListParallel ((+) <$> s1 <*> s2) >>= return . sort)
451 `shouldReturn` sort ([6,7,7,8,8,8,9,9,9,9,10,10,10,11,11,12] :: [Int])
451 `shouldReturn` sort ([6,7,7,8,8,8,9,9,9,9,10,10,10,11,11,12] :: [Int])
453−timed :: MonadIO (t IO) => Int -> t IO Int
453+timed :: (IsStream t, Monad (t IO)) => Int -> t IO Int
454−timed x = liftIO (threadDelay (x * 100000)) >> return x
454+timed x = A.once (threadDelay (x * 100000)) >> return x
456interleaveCheck :: IsStream t
456interleaveCheck :: IsStream t
457 => (t IO Int -> StreamT IO Int)
457 => (t IO Int -> StreamT IO Int)
@@ -462,7 +462,7 @@ interleaveCheck t f =
462 (A.toList . t) ((singleton 0 `f` singleton 1) `f` (singleton 100 `f` singleton 101))
462 (A.toList . t) ((singleton 0 `f` singleton 1) `f` (singleton 100 `f` singleton 101))
463 `shouldReturn` ([0, 100, 1, 101])
463 `shouldReturn` ([0, 100, 1, 101])
465−parallelCheck :: MonadIO (t IO)
465+parallelCheck :: (IsStream t, Monad (t IO))
466 => (t IO Int -> StreamT IO Int)
466 => (t IO Int -> StreamT IO Int)
467 -> (t IO Int -> t IO Int -> t IO Int)
467 -> (t IO Int -> t IO Int -> t IO Int)
@@ -475,7 +475,7 @@ parallelCheck t f = do
475 (A.toList . t) (event 4 `f` (event 3 `f` (event 2 `f` event 1)))
475 (A.toList . t) (event 4 `f` (event 3 `f` (event 2 `f` event 1)))
476 `shouldReturn` ([1..4])
476 `shouldReturn` ([1..4])
478− where event n = (liftIO $ threadDelay (n * 100000)) >> (return n)
478+ where event n = (A.once $ threadDelay (n * 100000)) >> (return n)
480compose :: (IsStream t, Semigroup (t IO Int))
480compose :: (IsStream t, Semigroup (t IO Int))
481 => (t IO Int -> StreamT IO Int) -> t IO Int -> ([Int] -> [Int]) -> Spec
481 => (t IO Int -> StreamT IO Int) -> t IO Int -> ([Int] -> [Int]) -> Spec
@@ -540,7 +540,7 @@ composeAndComposeSimple t1 t2 answer = do
540 `shouldReturn` (answer !! 3)
540 `shouldReturn` (answer !! 3)
543− :: (IsStream t, Semigroup (t IO Int), MonadIO (t IO))
543+ :: (IsStream t, Semigroup (t IO Int), Monad (t IO))
544 => (t IO Int -> t IO Int)
544 => (t IO Int -> t IO Int)
545 -> ([Int] -> [Int])
545 -> ([Int] -> [Int])
546 -> ([Int] -> [Int])
546 -> ([Int] -> [Int])
@@ -555,12 +555,12 @@ loops t tsrt hsrt = do
556 loopHead x = do
556 loopHead x = do
557 -- this print line is important for the test (causes a bind)
557 -- this print line is important for the test (causes a bind)
558− liftIO $ putStrLn "LoopHead..."
558+ A.once $ putStrLn "LoopHead..."
559 t $ (if x < 3 then loopHead (x + 1) else nil) <> return x
559 t $ (if x < 3 then loopHead (x + 1) else nil) <> return x
561 loopTail x = do
561 loopTail x = do
562 -- this print line is important for the test (causes a bind)
562 -- this print line is important for the test (causes a bind)
563− liftIO $ putStrLn "LoopTail..."
563+ A.once $ putStrLn "LoopTail..."
564 t $ return x <> (if x < 3 then loopTail (x + 1) else nil)
564 t $ return x <> (if x < 3 then loopTail (x + 1) else nil)
566bindAndComposeSimple
566bindAndComposeSimple
@@ -628,21 +628,21 @@ mixedOps = do
629 composeMixed :: StreamT IO Int
629 composeMixed :: StreamT IO Int
630 composeMixed = do
630 composeMixed = do
631− liftIO $ return ()
631+ A.once $ return ()
632− liftIO $ putStr ""
632+ A.once $ putStr ""
633 x <- return 1
633 x <- return 1
634 y <- return 2
634 y <- return 2
636 x1 <- parallely $ return 1 <> return 2
636 x1 <- parallely $ return 1 <> return 2
637− liftIO $ return ()
637+ A.once $ return ()
638− liftIO $ putStr ""
638+ A.once $ putStr ""
639 y1 <- coparallely $ return 1 <> return 2
639 y1 <- coparallely $ return 1 <> return 2
641 x11 <- return 1 <> return 2
641 x11 <- return 1 <> return 2
642 y11 <- coparallely $ return 1 <> return 2
642 y11 <- coparallely $ return 1 <> return 2
643 z11 <- costreamly $ return 1 <> return 2
643 z11 <- costreamly $ return 1 <> return 2
644− liftIO $ return ()
644+ A.once $ return ()
645− liftIO $ putStr ""
645+ A.once $ putStr ""
646 return (x11 + y11 + z11)
646 return (x11 + y11 + z11)
647 return (x1 + y1 + z1)
647 return (x1 + y1 + z1)
648 return (x + y + z)
648 return (x + y + z)