@@ -73,6 +73,15 @@ import Prelude hiding (map, repeat, zipWith, errorWithoutStackTrace)
74#include "Instances.hs"
74#include "Instances.hs"
77+-- >>> import Control.Concurrent (threadDelay)
80+-- threadDelay (n * 1000000) -- sleep for n seconds
81+-- putStrLn (show n ++ " sec") -- print "n sec"
76-- | Like 'zipWith' but using a monadic zipping function.
85-- | Like 'zipWith' but using a monadic zipping function.
78-- @since 0.4.0
87-- @since 0.4.0
@@ -120,9 +129,14 @@ zipAsyncWith f = zipAsyncWithM (\a b -> return (f a b))
120-- Serially Zipping Streams
129-- Serially Zipping Streams
121------------------------------------------------------------------------------
130------------------------------------------------------------------------------
123−-- | The applicative instance of 'ZipSerialM' zips a number of streams serially
132+-- | For 'ZipSerialM' streams:
124−-- i.e. it produces one element from each stream serially and then zips all
133+--
125−-- those elements.
134+-- @
135+-- (<>) = 'Streamly.Prelude.serial'
136+-- (<*>) = 'Streamly.Prelude.serial.zipWith' id
139+-- Applicative evaluates the streams being zipped serially:
127-- >>> s1 = Stream.fromFoldable [1, 2]
141-- >>> s1 = Stream.fromFoldable [1, 2]
128-- >>> s2 = Stream.fromFoldable [3, 4]
142-- >>> s2 = Stream.fromFoldable [3, 4]
@@ -130,9 +144,6 @@ zipAsyncWith f = zipAsyncWithM (\a b -> return (f a b))
130-- >>> Stream.toList $ Stream.zipSerially $ (,,) <$> s1 <*> s2 <*> s3
144-- >>> Stream.toList $ Stream.zipSerially $ (,,) <$> s1 <*> s2 <*> s3
131-- [(1,3,5),(2,4,6)]
145-- [(1,3,5),(2,4,6)]
133−-- The 'Semigroup' instance of this type works the same way as that of
136-- /Since: 0.2.0 ("Streamly")/
147-- /Since: 0.2.0 ("Streamly")/
138-- @since 0.8.0
149-- @since 0.8.0
@@ -202,21 +213,20 @@ TRAVERSABLE_INSTANCE(ZipSerialM)
202-- Parallely Zipping Streams
213-- Parallely Zipping Streams
203------------------------------------------------------------------------------
214------------------------------------------------------------------------------
205−-- | Like 'ZipSerialM' but zips in parallel, it generates all the elements to
216+-- | For 'ZipAsyncM' streams:
206−-- be zipped concurrently.
209−-- main = (toList . 'zipAsyncly' $ (,,) \<$\> s1 \<*\> s2 \<*\> s3) >>= print
219+-- (<>) = 'Streamly.Prelude.serial'
210−-- where s1 = fromFoldable [1, 2]
220+-- (<*>) = 'Streamly.Prelude.serial.zipAsyncWith' id
211−-- s2 = fromFoldable [3, 4]
212−-- s3 = fromFoldable [5, 6]
218−-- The 'Semigroup' instance of this type works the same way as that of
223+-- Applicative evaluates the streams being zipped concurrently, the following
219−-- 'SerialT'.
224+-- would take half the time that it would take in serial zipping:
226+-- >>> s = Stream.fromFoldableM $ Prelude.map delay [1, 1, 1]
227+-- >>> Stream.toList $ Stream.zipAsyncly $ (,) <$> s <*> s
229+-- [(1,1),(1,1),(1,1)]
221-- /Since: 0.2.0 ("Streamly")/
231-- /Since: 0.2.0 ("Streamly")/