on master help sign in
Move some functions from Streamly to Streamly.Prelude

* `runStream`, `foldWith`, `foldMapWith`, `forEachWith` have been moved from "Streamly" module to "Streamly.Prelude" module.

commitf1670f31ce0480101835e5ac1bc73285bb1ba45d authorHarendra Kumar <harendra.kumar@gmail.com> dateSat 4 May 2019, 02:42 (7 years ago) parentb98a3c1
10 files changed+131−101
Changelog.md+3 benchmark/Linear.hs+1−1 benchmark/LinearOps.hs+1−1 benchmark/NestedOps.hs+1−1 src/Streamly.hs+37−18 src/Streamly/Prelude.hs+38−30 test/Main.hs+44−44 test/Prop.hs+3−3 test/loops.hs+2−2 test/parallel-loops.hs+1−1
Changelog.md+3
@@ -18,6 +18,9 @@
1818 reason we no longer support this version of right fold. Please use `foldrM`
1919 instead.
2020
21+* `runStream`, `foldWith`, `foldMapWith`, `forEachWith` have been moved from
22+ "Streamly" module to "Streamly.Prelude" module.
23+
2124## 0.6.1
2225
2326### Bug Fixes
benchmark/Linear.hs+1−1
@@ -66,7 +66,7 @@ benchPureSinkIO name f =
6666
6767{-# INLINE benchPureSrc #-}
6868benchPureSrc :: String -> (Int -> SerialT Identity a) -> Benchmark
69−benchPureSrc name src = benchPure name src (runIdentity . runStream)
69+benchPureSrc name src = benchPure name src (runIdentity . S.runStream)
7070
7171main :: IO ()
7272main =
benchmark/LinearOps.hs+1−1
@@ -27,7 +27,7 @@ import qualified GHC.Exts as GHC
2727import Control.DeepSeq (NFData)
2828import GHC.Generics (Generic)
2929
30−import qualified Streamly as S
30+import qualified Streamly as S hiding (foldMapWith, runStream)
3131import qualified Streamly.Prelude as S
3232
3333value, maxValue :: Int
benchmark/NestedOps.hs+1−1
@@ -13,7 +13,7 @@ module NestedOps where
1313import Control.Exception (try)
1414import GHC.Exception (ErrorCall)
1515
16−import qualified Streamly as S
16+import qualified Streamly as S hiding (runStream)
1717import qualified Streamly.Prelude as S
1818
1919sumCount :: Int
src/Streamly.hs+37−18
@@ -88,8 +88,6 @@ module Streamly
8888 , ZipSerialM
8989 , ZipAsyncM
9090
91− -- * Running Streams
92− , P.runStream
9391 -- * Parallel Function Application
9492 -- $application
9593 , (|$)
@@ -120,12 +118,6 @@ module Streamly
120118 , maxRate
121119 , constRate
122120
123− -- * Folding Containers of Streams
124− -- $foldutils
125− , foldWith
126− , foldMapWith
127− , forEachWith
128−
129121 -- * Stream Type Adapters
130122 -- $adapters
131123 , IsStream ()
@@ -170,6 +162,13 @@ module Streamly
170162 , zippingAsync
171163 , (<=>)
172164 , (<|)
165+
166+ -- * Moved
167+ -- | These APIs have been moved to other modules
168+ , runStream
169+ , foldWith
170+ , foldMapWith
171+ , forEachWith
173172 )
174173where
175174
@@ -179,7 +178,6 @@ import Streamly.Streams.Ahead
179178import Streamly.Streams.Async
180179import Streamly.Streams.Combinators
181180import Streamly.Streams.Parallel
182−import Streamly.Streams.Prelude
183181import Streamly.Streams.Serial
184182import Streamly.Streams.StreamK hiding (runStream, serial)
185183import Streamly.Streams.Zip
@@ -187,8 +185,6 @@ import Streamly.Streams.Zip
187185import qualified Streamly.Prelude as P
188186import qualified Streamly.Streams.StreamK as K
189187
190−-- XXX This should perhaps be moved to Prelude.
191−
192188------------------------------------------------------------------------------
193189-- Eliminating a stream
194190------------------------------------------------------------------------------
@@ -207,6 +203,12 @@ runStreaming = P.runStream . K.adapt
207203runStreamT :: Monad m => SerialT m a -> m ()
208204runStreamT = P.runStream
209205
206+-- | Same as "Streamly.Prelude.runStream".
207+--
208+{-# DEPRECATED runStream "Please use Streamly.Prelude.runStream instead." #-}
209+runStream :: Monad m => SerialT m a -> m ()
210+runStream = P.runStream
211+
210212-- | Same as @runStream . wSerially@.
211213--
212214-- @since 0.1.0
@@ -242,6 +244,30 @@ runZipStream = P.runStream . K.adapt
242244runZipAsync :: Monad m => ZipAsyncM m a -> m ()
243245runZipAsync = P.runStream . K.adapt
244246
247+-- | Same as "Streamly.Prelude.foldWith".
248+--
249+{-# DEPRECATED foldWith "Please use Streamly.Prelude.foldWith instead." #-}
250+{-# INLINABLE foldWith #-}
251+foldWith :: (IsStream t, Foldable f)
252+ => (t m a -> t m a -> t m a) -> f (t m a) -> t m a
253+foldWith = P.foldWith
254+
255+-- | Same as "Streamly.Prelude.foldMapWith".
256+--
257+{-# DEPRECATED foldMapWith "Please use Streamly.Prelude.foldMapWith instead." #-}
258+{-# INLINABLE foldMapWith #-}
259+foldMapWith :: (IsStream t, Foldable f)
260+ => (t m b -> t m b -> t m b) -> (a -> t m b) -> f a -> t m b
261+foldMapWith = P.foldMapWith
262+
263+-- | Same as "Streamly.Prelude.forEachWith".
264+--
265+{-# DEPRECATED forEachWith "Please use Streamly.Prelude.forEachWith instead." #-}
266+{-# INLINABLE forEachWith #-}
267+forEachWith :: (IsStream t, Foldable f)
268+ => (t m b -> t m b -> t m b) -> f a -> (a -> t m b) -> t m b
269+forEachWith = P.forEachWith
270+
245271------------------------------------------------------------------------------
246272-- Documentation
247273------------------------------------------------------------------------------
@@ -325,10 +351,3 @@ runZipAsync = P.runStream . K.adapt
325351-- which specific type you are converting from or to. If you see a an
326352-- @ambiguous type variable@ error then most likely you are using 'adapt'
327353-- unnecessarily on polymorphic code.
328−--
329−
330−-- $foldutils
331−--
332−-- These are variants of standard 'Foldable' fold functions that use a
333−-- polymorphic stream sum operation (e.g. 'async' or 'wSerial') to fold a
334−-- container of streams.
src/Streamly/Prelude.hs+38−30
@@ -373,34 +373,6 @@ module Streamly.Prelude
373373 -- ** Reordering
374374 , reverse
375375
376− -- ** Nested Producer Loops
377− -- | Map each element to a stream and then flatten the results into a
378− -- single stream. In imperative terms, a 'concatMap' corresponds to nested
379− -- loops. We loop over the outer stream and then for each element of the
380− -- outer stream an inner stream is generated and then we loop over the
381− -- inner stream as well to generate a single output stream.
382− --
383− -- @
384− --
385− -- ----Stream m a----|-Stream m b-|-Stream m b-|-...-|----Stream m b
386− --
387− -- @
388− --
389− -- 'concatMap' can perform filtering by mapping an element to a 'nil'
390− -- stream. Its a map, therefore it can degenerate to a simple map
391− -- operation as well:
392− --
393− -- > filter p m = S.concatMap (\x -> if p x then S.yield x else S.nil) m
394− -- > map f m = S.concatMap (\x -> S.yield (f x)) m
395− --
396− -- Though 'concatMap' is not inherently stateful, it can be combined with a
397− -- scan to perform stateful operations.
398−
399− , concatMapM
400− , concatMap
401− -- , interposeBy
402− -- , intercalate
403−
404376 -- * Multi-Stream Operations
405377 -- | New streams can be constructed by appending, merging or zipping
406378 -- existing streams.
@@ -454,7 +426,25 @@ module Streamly.Prelude
454426 , Z.zipAsyncWith
455427 , Z.zipAsyncWithM
456428
457− -- ** Stream Level Folds
429+ -- ** Nested Streams
430+ -- | Stream operations represent loops in imperative programming, streams
431+ -- of streams represent nested loops.
432+
433+ , concatMapM
434+ , concatMap
435+ -- , interposeBy
436+ -- , intercalate
437+
438+ -- ** Containers of Streams
439+ -- | These are variants of standard 'Foldable' fold functions that use a
440+ -- polymorphic stream sum operation (e.g. 'async' or 'wSerial') to fold a
441+ -- finite container of streams.
442+ --
443+ , foldWith
444+ , foldMapWith
445+ , forEachWith
446+
447+ -- ** Folding
458448 , eqBy
459449 , cmpBy
460450 , isPrefixOf
@@ -493,7 +483,8 @@ import Streamly.Enumeration (Enumerable(..), enumerate, enumerateTo)
493483import Streamly.SVar (MonadAsync, defState)
494484import Streamly.Streams.Async (mkAsync')
495485import Streamly.Streams.Combinators (maxYields)
496−import Streamly.Streams.Prelude (fromStreamS, toStreamS)
486+import Streamly.Streams.Prelude
487+ (fromStreamS, toStreamS, foldWith, foldMapWith, forEachWith)
497488import Streamly.Streams.StreamD (fromStreamD, toStreamD)
498489import Streamly.Streams.StreamK (IsStream(..))
499490import Streamly.Streams.Serial (SerialT)
@@ -2102,6 +2093,23 @@ mergeAsyncByM f m1 m2 = K.mkStream $ \st stp sng yld -> do
21022093--
21032094-- > concatMap f = concatMapM (return . f)
21042095--
2096+-- In imperative terms, a 'concatMap' corresponds to nested loops. We loop over
2097+-- the input stream and then for each element of the input stream another
2098+-- stream is generated and then we loop over that inner stream as well to yield
2099+-- each element of that stream to generate a single output stream.
2100+--
2101+-- 'concatMap' can perform filtering by mapping an element to a 'nil'
2102+-- stream:
2103+--
2104+-- > filter p m = S.concatMap (\x -> if p x then S.yield x else S.nil) m
2105+--
2106+-- Its a map, therefore it can degenerate to a simple map operation as well:
2107+--
2108+-- > map f m = S.concatMap (\x -> S.yield (f x)) m
2109+--
2110+-- 'concatMap' is not inherently stateful, however, it can be combined with a
2111+-- scan to perform stateful operations.
2112+--
21052113-- @since 0.6.0
21062114{-# INLINE concatMap #-}
21072115concatMap ::(IsStream t, Monad m) => (a -> t m b) -> t m a -> t m b
test/Main.hs+44−44
@@ -153,7 +153,7 @@ checkCleanup :: IsStream t
153153 -> IO ()
154154checkCleanup d t op = do
155155 r <- newIORef (-1 :: Int)
156− runStream . serially $ do
156+ S.runStream . serially $ do
157157 _ <- t $ op $ delay r 0 S.|: delay r 1 S.|: delay r 2 S.|: S.nil
158158 return ()
159159 performMajorGC
@@ -193,9 +193,9 @@ parallelTests = H.parallel $ do
193193 -- XXX move these to property tests
194194 -- XXX use an IORef to store and check the side effects
195195 it "simple serially" $
196− (runStream . serially) (return (0 :: Int)) `shouldReturn` ()
196+ (S.runStream . serially) (return (0 :: Int)) `shouldReturn` ()
197197 it "simple serially with IO" $
198− (runStream . serially) (S.yieldM $ putStrLn "hello") `shouldReturn` ()
198+ (S.runStream . serially) (S.yieldM $ putStrLn "hello") `shouldReturn` ()
199199
200200 describe "Empty" $ -- do
201201 it "Monoid - mempty" $
@@ -541,12 +541,12 @@ parallelTests = H.parallel $ do
541541 ---------------------------------------------------------------------------
542542
543543 it "asyncly crosses thread limit (2000 threads)" $
544− runStream (asyncly $ fold $
544+ S.runStream (asyncly $ fold $
545545 replicate 2000 $ S.yieldM $ threadDelay 1000000)
546546 `shouldReturn` ()
547547
548548 it "aheadly crosses thread limit (4000 threads)" $
549− runStream (aheadly $ fold $
549+ S.runStream (aheadly $ fold $
550550 replicate 4000 $ S.yieldM $ threadDelay 1000000)
551551 `shouldReturn` ()
552552
@@ -596,7 +596,7 @@ monadicStateSnapshot
596596 , MonadState Int (t (StateT Int IO))
597597 )
598598 => (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
600600
601601stateCompOp
602602 :: ( AsyncT (StateT Int IO) ()
@@ -619,7 +619,7 @@ monadicStateSnapshotOp
619619 -> AsyncT (StateT Int IO) ()
620620 )
621621 -> IO ()
622−monadicStateSnapshotOp op = void $ runStateT (runStream $ stateCompOp op) 0
622+monadicStateSnapshotOp op = void $ runStateT (S.runStream $ stateCompOp op) 0
623623
624624takeCombined :: (Monad m, Semigroup (t m Int), Show a, Eq a, IsStream t)
625625 => Int -> (t m Int -> SerialT IO a) -> IO ()
@@ -669,7 +669,7 @@ checkScanxStrictness :: IO ()
669669checkScanxStrictness = do
670670 let s = return (1 :: Int) `S.consM` error "failure"
671671 catch
672− (runStream (
672+ (S.runStream (
673673 S.scanx (\_ a ->
674674 if a == 1
675675 then error "success"
@@ -687,7 +687,7 @@ checkScanl'Strictness :: IO ()
687687checkScanl'Strictness = do
688688 let s = return (1 :: Int) `S.consM` error "failure"
689689 catch
690− (runStream
690+ (S.runStream
691691 (S.scanl'
692692 (\_ a ->
693693 if a == 1
@@ -722,13 +722,13 @@ checkScanlMStrictness :: (IORef Int -> SerialT IO Int -> SerialT IO ()) -> IO ()
722722checkScanlMStrictness f = do
723723 ref <- newIORef 0
724724 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 ())
726726 readIORef ref `shouldReturn` 1
727727
728728takeInfinite :: IsStream t => (t IO Int -> SerialT IO Int) -> Spec
729729takeInfinite t =
730730 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)))
732732 `shouldReturn` ()
733733
734734-- XXX need to test that we have promptly cleaned up everything after the error
@@ -743,16 +743,16 @@ simpleMonadError :: Spec
743743simpleMonadError = do
744744{-
745745 it "simple runExceptT" $ do
746− (runExceptT $ runStream $ return ())
746+ (runExceptT $ S.runStream $ return ())
747747 `shouldReturn` (Right () :: Either String ())
748748 it "simple runExceptT with error" $ do
749− (runExceptT $ runStream $ throwError "E") `shouldReturn` Left "E"
749+ (runExceptT $ S.runStream $ throwError "E") `shouldReturn` Left "E"
750750 -}
751751 it "simple try" $
752− try (runStream $ return ())
752+ try (S.runStream $ return ())
753753 `shouldReturn` (Right () :: Either ExampleException ())
754754 it "simple try with throw error" $
755− try (runStream $ throwM $ ExampleException "E")
755+ try (S.runStream $ throwM $ ExampleException "E")
756756 `shouldReturn` (Left (ExampleException "E") :: Either ExampleException ())
757757
758758composeWithMonadThrow
@@ -790,8 +790,8 @@ composeWithMonadThrow t = do
790790
791791 oneLevelNestedProduct desc t1 =
792792 it ("One level nested product" <> desc) $ do
793− let s1 = t $ foldMapWith (<>) return [1..4]
794− s2 = t1 $ foldMapWith (<>) return [5..8]
793+ let s1 = t $ S.foldMapWith (<>) return [1..4]
794+ s2 = t1 $ S.foldMapWith (<>) return [5..8]
795795 try $ tl (do
796796 x <- adapt s1
797797 y <- s2
@@ -816,8 +816,8 @@ _composeWithMonadError t = do
816816
817817nestTwoSerial :: Expectation
818818nestTwoSerial =
819− let s1 = foldMapWith (<>) return [1..4]
820− s2 = foldMapWith (<>) return [5..8]
819+ let s1 = S.foldMapWith (<>) return [1..4]
820+ s2 = S.foldMapWith (<>) return [5..8]
821821 in toListSerial (do
822822 x <- s1
823823 y <- s2
@@ -826,8 +826,8 @@ nestTwoSerial =
826826
827827nestTwoAhead :: Expectation
828828nestTwoAhead =
829− let s1 = foldMapWith (<>) return [1..4]
830− s2 = foldMapWith (<>) return [5..8]
829+ let s1 = S.foldMapWith (<>) return [1..4]
830+ s2 = S.foldMapWith (<>) return [5..8]
831831 in (S.toList . aheadly) (do
832832 x <- s1
833833 y <- s2
@@ -836,22 +836,22 @@ nestTwoAhead =
836836
837837nestTwoSerialApp :: Expectation
838838nestTwoSerialApp =
839− let s1 = foldMapWith (<>) return [1..4]
840− s2 = foldMapWith (<>) return [5..8]
839+ let s1 = S.foldMapWith (<>) return [1..4]
840+ s2 = S.foldMapWith (<>) return [5..8]
841841 in toListSerial ((+) <$> s1 <*> s2)
842842 `shouldReturn` ([6,7,8,9,7,8,9,10,8,9,10,11,9,10,11,12] :: [Int])
843843
844844nestTwoAheadApp :: Expectation
845845nestTwoAheadApp =
846− let s1 = foldMapWith (<>) return [1..4]
847− s2 = foldMapWith (<>) return [5..8]
846+ let s1 = S.foldMapWith (<>) return [1..4]
847+ s2 = S.foldMapWith (<>) return [5..8]
848848 in (S.toList . aheadly) ((+) <$> s1 <*> s2)
849849 `shouldReturn` ([6,7,8,9,7,8,9,10,8,9,10,11,9,10,11,12] :: [Int])
850850
851851nestTwoInterleaved :: Expectation
852852nestTwoInterleaved =
853− let s1 = foldMapWith (<>) return [1..4]
854− s2 = foldMapWith (<>) return [5..8]
853+ let s1 = S.foldMapWith (<>) return [1..4]
854+ s2 = S.foldMapWith (<>) return [5..8]
855855 in toListInterleaved (do
856856 x <- s1
857857 y <- s2
@@ -860,15 +860,15 @@ nestTwoInterleaved =
860860
861861nestTwoInterleavedApp :: Expectation
862862nestTwoInterleavedApp =
863− let s1 = foldMapWith (<>) return [1..4]
864− s2 = foldMapWith (<>) return [5..8]
863+ let s1 = S.foldMapWith (<>) return [1..4]
864+ s2 = S.foldMapWith (<>) return [5..8]
865865 in toListInterleaved ((+) <$> s1 <*> s2)
866866 `shouldReturn` ([6,7,7,8,8,8,9,9,9,9,10,10,10,11,11,12] :: [Int])
867867
868868nestTwoAsync :: Expectation
869869nestTwoAsync =
870− let s1 = foldMapWith (<>) return [1..4]
871− s2 = foldMapWith (<>) return [5..8]
870+ let s1 = S.foldMapWith (<>) return [1..4]
871+ s2 = S.foldMapWith (<>) return [5..8]
872872 in sort <$> toListAsync (do
873873 x <- s1
874874 y <- s2
@@ -877,15 +877,15 @@ nestTwoAsync =
877877
878878nestTwoAsyncApp :: Expectation
879879nestTwoAsyncApp =
880− let s1 = foldMapWith (<>) return [1..4]
881− s2 = foldMapWith (<>) return [5..8]
880+ let s1 = S.foldMapWith (<>) return [1..4]
881+ s2 = S.foldMapWith (<>) return [5..8]
882882 in sort <$> toListAsync ((+) <$> s1 <*> s2)
883883 `shouldReturn` sort ([6,7,8,9,7,8,9,10,8,9,10,11,9,10,11,12] :: [Int])
884884
885885nestTwoWAsync :: Expectation
886886nestTwoWAsync =
887− let s1 = foldMapWith (<>) return [1..4]
888− s2 = foldMapWith (<>) return [5..8]
887+ let s1 = S.foldMapWith (<>) return [1..4]
888+ s2 = S.foldMapWith (<>) return [5..8]
889889 in sort <$> (S.toList . wAsyncly) (do
890890 x <- s1
891891 y <- s2
@@ -894,8 +894,8 @@ nestTwoWAsync =
894894
895895nestTwoParallel :: Expectation
896896nestTwoParallel =
897− let s1 = foldMapWith (<>) return [1..4]
898− s2 = foldMapWith (<>) return [5..8]
897+ let s1 = S.foldMapWith (<>) return [1..4]
898+ s2 = S.foldMapWith (<>) return [5..8]
899899 in sort <$> (S.toList . parallely) (do
900900 x <- s1
901901 y <- s2
@@ -904,15 +904,15 @@ nestTwoParallel =
904904
905905nestTwoWAsyncApp :: Expectation
906906nestTwoWAsyncApp =
907− let s1 = foldMapWith (<>) return [1..4]
908− s2 = foldMapWith (<>) return [5..8]
907+ let s1 = S.foldMapWith (<>) return [1..4]
908+ s2 = S.foldMapWith (<>) return [5..8]
909909 in sort <$> (S.toList . wAsyncly) ((+) <$> s1 <*> s2)
910910 `shouldReturn` sort ([6,7,7,8,8,8,9,9,9,9,10,10,10,11,11,12] :: [Int])
911911
912912nestTwoParallelApp :: Expectation
913913nestTwoParallelApp =
914− let s1 = foldMapWith (<>) return [1..4]
915− s2 = foldMapWith (<>) return [5..8]
914+ let s1 = S.foldMapWith (<>) return [1..4]
915+ s2 = S.foldMapWith (<>) return [5..8]
916916 in sort <$> (S.toList . parallely) ((+) <$> s1 <*> s2)
917917 `shouldReturn` sort ([6,7,7,8,8,8,9,9,9,9,10,10,10,11,11,12] :: [Int])
918918
@@ -954,7 +954,7 @@ compose t z srt = do
954954 srt <$> tl (singleton 0 <> singleton 1)
955955 `shouldReturn` [0, 1]
956956 it "Compose many" $
957− srt <$> tl (forEachWith (<>) [1..100] singleton)
957+ srt <$> tl (S.forEachWith (<>) [1..100] singleton)
958958 `shouldReturn` [1..100]
959959
960960 -- These are not covered by the property tests
@@ -984,7 +984,7 @@ composeAndComposeSimple
984984 -> (t2 IO Int -> t2 IO Int)
985985 -> [[Int]] -> Spec
986986composeAndComposeSimple t1 t2 answer = do
987− let rfold = adapt . t2 . foldMapWith (<>) return
987+ let rfold = adapt . t2 . S.foldMapWith (<>) return
988988 it "Compose right associated outer expr, right folded inner" $
989989 (S.toList . t1) (rfold [1,2,3] <> (rfold [4,5,6] <> rfold [7,8,9]))
990990 `shouldReturn` head answer
@@ -1035,7 +1035,7 @@ bindAndComposeSimple t1 t2 = do
10351035 -- XXX need a bind in the body of forEachWith instead of a simple return
10361036 it "Compose many (right fold) with bind" $
10371037 (sort <$> (S.toList . t1)
1038− (adapt . t2 $ forEachWith (<>) [1..10 :: Int] return))
1038+ (adapt . t2 $ S.forEachWith (<>) [1..10 :: Int] return))
10391039 `shouldReturn` [1..10]
10401040
10411041 it "Compose many (left fold) with bind" $
test/Prop.hs+3−3
@@ -693,8 +693,8 @@ semigroupOps
693693 -> (t IO Int -> SerialT IO Int)
694694 -> Spec
695695semigroupOps desc eq t = do
696− prop (desc <> " <>") $ foldFromList (foldMapWith (<>) singleton) t eq
697− prop (desc <> " mappend") $ foldFromList (foldMapWith mappend singleton) t eq
696+ prop (desc <> " <>") $ foldFromList (S.foldMapWith (<>) singleton) t eq
697+ prop (desc <> " mappend") $ foldFromList (S.foldMapWith mappend singleton) t eq
698698
699699-------------------------------------------------------------------------------
700700-- Functor operations
@@ -829,7 +829,7 @@ main = hspec
829829 folded = serially . (\xs ->
830830 case xs of
831831 [x] -> return x -- singleton stream case
832− _ -> foldMapWith (<>) return xs
832+ _ -> S.foldMapWith (<>) return xs
833833 )
834834
835835 let makeOps t =
test/loops.hs+2−2
@@ -1,6 +1,6 @@
1−import Streamly
1+import Streamly hiding (runStream)
22import System.IO (stdout, hSetBuffering, BufferMode(LineBuffering))
3−import Streamly.Prelude (nil, yieldM)
3+import Streamly.Prelude (nil, yieldM, runStream)
44
55main :: IO ()
66main = do
test/parallel-loops.hs+1−1
@@ -7,7 +7,7 @@ import qualified Streamly.Prelude as S
77main :: IO ()
88main = do
99 hSetBuffering stdout LineBuffering
10− runStream $ do
10+ S.runStream $ do
1111 x <- S.take 10 $ loop "A" `parallel` loop "B"
1212 S.yieldM $ myThreadId >>= putStr . show
1313 >> putStr " got "