on master help sign in
remove redundant re-exports
commitb214a854073d592d98778beca3594c125744e925 authorHarendra Kumar <harendra.kumar@gmail.com> dateFri 4 May 2018, 02:04 (8 years ago) parentd59ff9d
4 files changed+18−27
examples/AcidRain.hs+1 examples/ListDir.hs+3−3 src/Streamly.hs−10 test/Main.hs+14−14
examples/AcidRain.hs+1
@@ -6,6 +6,7 @@
66import Streamly
77import Control.Concurrent (threadDelay)
88import Control.Monad (when)
9+import Control.Monad.IO.Class (MonadIO(liftIO))
910import Control.Monad.State (MonadState, get, modify, runStateT)
1011import Data.Semigroup (cycle1)
1112
examples/ListDir.hs+3−3
@@ -1,7 +1,7 @@
1+import Control.Monad.IO.Class (liftIO)
12import Path.IO (listDir, getCurrentDir)
23import System.IO (stdout, hSetBuffering, BufferMode(LineBuffering))
34import Streamly (runStream, coparallely)
4−import Streamly.Prelude (once)
55
66-- | List the current directory recursively using concurrent processing
77--
@@ -13,6 +13,6 @@ main = do
1313 hSetBuffering stdout LineBuffering
1414 runStream . coparallely $ getCurrentDir >>= readdir
1515 where readdir d = do
16− (ds, fs) <- once $ listDir d
17− once $ mapM_ putStrLn $ map show fs ++ map show ds
16+ (ds, fs) <- liftIO $ listDir d
17+ liftIO $ mapM_ putStrLn $ map show fs ++ map show ds
1818 foldMap readdir ds
src/Streamly.hs−10
@@ -73,13 +73,7 @@ module Streamly
7373 , forEachWith
7474
7575 -- * Re-exports
76− , Monoid (..)
7776 , Semigroup (..)
78− , Alternative (..)
79− , MonadPlus (..)
80− , MonadIO (..)
81− , MonadTrans (..)
82−
8377 -- * Deprecated
8478 , MonadAsync
8579 , Streaming
@@ -104,10 +98,6 @@ where
10498
10599import Streamly.Streams
106100import 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 (..))
111101
112102-- $background
113103--
test/Main.hs+14−14
@@ -40,7 +40,7 @@ main = hspec $ do
4040 it "simple streamly" $
4141 (runStream . streamly) (return (0 :: Int)) `shouldReturn` ()
4242 it "simple streamly with IO" $
43− (runStream . streamly) (liftIO $ putStrLn "hello") `shouldReturn` ()
43+ (runStream . streamly) (A.once $ putStrLn "hello") `shouldReturn` ()
4444
4545 describe "Empty" $ do
4646 it "Monoid - mempty" $
@@ -450,8 +450,8 @@ nestTwoParallelApp =
450450 in (toListParallel ((+) <$> s1 <*> s2) >>= return . sort)
451451 `shouldReturn` sort ([6,7,7,8,8,8,9,9,9,9,10,10,10,11,11,12] :: [Int])
452452
453−timed :: MonadIO (t IO) => Int -> t IO Int
454−timed x = liftIO (threadDelay (x * 100000)) >> return x
453+timed :: (IsStream t, Monad (t IO)) => Int -> t IO Int
454+timed x = A.once (threadDelay (x * 100000)) >> return x
455455
456456interleaveCheck :: IsStream t
457457 => (t IO Int -> StreamT IO Int)
@@ -462,7 +462,7 @@ interleaveCheck t f =
462462 (A.toList . t) ((singleton 0 `f` singleton 1) `f` (singleton 100 `f` singleton 101))
463463 `shouldReturn` ([0, 100, 1, 101])
464464
465−parallelCheck :: MonadIO (t IO)
465+parallelCheck :: (IsStream t, Monad (t IO))
466466 => (t IO Int -> StreamT IO Int)
467467 -> (t IO Int -> t IO Int -> t IO Int)
468468 -> Spec
@@ -475,7 +475,7 @@ parallelCheck t f = do
475475 (A.toList . t) (event 4 `f` (event 3 `f` (event 2 `f` event 1)))
476476 `shouldReturn` ([1..4])
477477
478− where event n = (liftIO $ threadDelay (n * 100000)) >> (return n)
478+ where event n = (A.once $ threadDelay (n * 100000)) >> (return n)
479479
480480compose :: (IsStream t, Semigroup (t IO Int))
481481 => (t IO Int -> StreamT IO Int) -> t IO Int -> ([Int] -> [Int]) -> Spec
@@ -540,7 +540,7 @@ composeAndComposeSimple t1 t2 answer = do
540540 `shouldReturn` (answer !! 3)
541541
542542loops
543− :: (IsStream t, Semigroup (t IO Int), MonadIO (t IO))
543+ :: (IsStream t, Semigroup (t IO Int), Monad (t IO))
544544 => (t IO Int -> t IO Int)
545545 -> ([Int] -> [Int])
546546 -> ([Int] -> [Int])
@@ -555,12 +555,12 @@ loops t tsrt hsrt = do
555555 where
556556 loopHead x = do
557557 -- this print line is important for the test (causes a bind)
558− liftIO $ putStrLn "LoopHead..."
558+ A.once $ putStrLn "LoopHead..."
559559 t $ (if x < 3 then loopHead (x + 1) else nil) <> return x
560560
561561 loopTail x = do
562562 -- this print line is important for the test (causes a bind)
563− liftIO $ putStrLn "LoopTail..."
563+ A.once $ putStrLn "LoopTail..."
564564 t $ return x <> (if x < 3 then loopTail (x + 1) else nil)
565565
566566bindAndComposeSimple
@@ -628,21 +628,21 @@ mixedOps = do
628628
629629 composeMixed :: StreamT IO Int
630630 composeMixed = do
631− liftIO $ return ()
632− liftIO $ putStr ""
631+ A.once $ return ()
632+ A.once $ putStr ""
633633 x <- return 1
634634 y <- return 2
635635 z <- do
636636 x1 <- parallely $ return 1 <> return 2
637− liftIO $ return ()
638− liftIO $ putStr ""
637+ A.once $ return ()
638+ A.once $ putStr ""
639639 y1 <- coparallely $ return 1 <> return 2
640640 z1 <- do
641641 x11 <- return 1 <> return 2
642642 y11 <- coparallely $ return 1 <> return 2
643643 z11 <- costreamly $ return 1 <> return 2
644− liftIO $ return ()
645− liftIO $ putStr ""
644+ A.once $ return ()
645+ A.once $ putStr ""
646646 return (x11 + y11 + z11)
647647 return (x1 + y1 + z1)
648648 return (x + y + z)