on master help sign in
remove redundant re-exports
b214a85Harendra Kumar
examples/AcidRain.hs+1
@@ -6,6 +6,7 @@
6import Streamly
6import Streamly
7import Control.Concurrent (threadDelay)
7import Control.Concurrent (threadDelay)
8import Control.Monad (when)
8import Control.Monad (when)
9+import Control.Monad.IO.Class (MonadIO(liftIO))
9import Control.Monad.State (MonadState, get, modify, runStateT)
10import Control.Monad.State (MonadState, get, modify, runStateT)
10import Data.Semigroup (cycle1)
11import Data.Semigroup (cycle1)
11
12
examples/ListDir.hs+3−3
@@ -1,7 +1,7 @@
1+import Control.Monad.IO.Class (liftIO)
1import Path.IO (listDir, getCurrentDir)
2import Path.IO (listDir, getCurrentDir)
2import System.IO (stdout, hSetBuffering, BufferMode(LineBuffering))
3import System.IO (stdout, hSetBuffering, BufferMode(LineBuffering))
3import Streamly (runStream, coparallely)
4import Streamly (runStream, coparallely)
4−import Streamly.Prelude (once)
5
5
6-- | List the current directory recursively using concurrent processing
6-- | List the current directory recursively using concurrent processing
7--
7--
@@ -13,6 +13,6 @@ main = do
13 hSetBuffering stdout LineBuffering
13 hSetBuffering stdout LineBuffering
14 runStream . coparallely $ getCurrentDir >>= readdir
14 runStream . coparallely $ getCurrentDir >>= readdir
15 where readdir d = do
15 where readdir d = do
16− (ds, fs) <- once $ listDir d
16+ (ds, fs) <- liftIO $ listDir d
17− once $ mapM_ putStrLn $ map show fs ++ map show ds
17+ liftIO $ mapM_ putStrLn $ map show fs ++ map show ds
18 foldMap readdir ds
18 foldMap readdir ds
src/Streamly.hs−10
@@ -73,13 +73,7 @@ module Streamly
73 , forEachWith
73 , forEachWith
74
74
75 -- * Re-exports
75 -- * Re-exports
76− , Monoid (..)
77 , Semigroup (..)
76 , Semigroup (..)
78− , Alternative (..)
79− , MonadPlus (..)
80− , MonadIO (..)
81− , MonadTrans (..)
82−
83 -- * Deprecated
77 -- * Deprecated
84 , MonadAsync
78 , MonadAsync
85 , Streaming
79 , Streaming
@@ -104,10 +98,6 @@ where
104
98
105import Streamly.Streams
99import Streamly.Streams
106import Data.Semigroup (Semigroup(..))
100import Data.Semigroup (Semigroup(..))
107−import Control.Applicative (Alternative(..))
108−import Control.Monad (MonadPlus(..))
109−import Control.Monad.IO.Class (MonadIO (..))
110−import Control.Monad.Trans.Class (MonadTrans (..))
111
101
112-- $background
102-- $background
113--
103--
test/Main.hs+14−14
@@ -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` ()
44
44
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])
452
452
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
455
455
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])
464
464
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)
468 -> Spec
468 -> Spec
@@ -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])
477
477
478− where event n = (liftIO $ threadDelay (n * 100000)) >> (return n)
478+ where event n = (A.once $ threadDelay (n * 100000)) >> (return n)
479
479
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)
541
541
542loops
542loops
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
555 where
555 where
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
560
560
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)
565
565
566bindAndComposeSimple
566bindAndComposeSimple
@@ -628,21 +628,21 @@ mixedOps = do
628
628
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
635 z <- do
635 z <- do
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
640 z1 <- do
640 z1 <- do
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)