on master help sign in
Fix nomenclature in tests
b03a7b6Harendra Kumar
test/Main.hs+134−134
@@ -20,27 +20,27 @@ import qualified Streamly.Prelude as A
20singleton :: IsStream t => a -> t m a
20singleton :: IsStream t => a -> t m a
21singleton a = a .: nil
21singleton a = a .: nil
22
22
23−toListSerial :: StreamT IO a -> IO [a]
23+toListSerial :: SerialT IO a -> IO [a]
24−toListSerial = A.toList . asStream
24+toListSerial = A.toList . serially
25
25
26−toListInterleaved :: CostreamT IO a -> IO [a]
26+toListInterleaved :: WSerialT IO a -> IO [a]
27−toListInterleaved = A.toList . asCostream
27+toListInterleaved = A.toList . wSerially
28
28
29−toListAsync :: ParAheadT IO a -> IO [a]
29+toListAsync :: AsyncT IO a -> IO [a]
30−toListAsync = A.toList . asParAhead
30+toListAsync = A.toList . asyncly
31
31
32−toListParallel :: CoparAheadT IO a -> IO [a]
32+toListParallel :: WAsyncT IO a -> IO [a]
33−toListParallel = A.toList . asCoparAhead
33+toListParallel = A.toList . wAsyncly
34
34
35main :: IO ()
35main :: IO ()
36main = hspec $ do
36main = hspec $ do
37 describe "Runners" $ do
37 describe "Runners" $ do
38 -- XXX move these to property tests
38 -- XXX move these to property tests
39 -- XXX use an IORef to store and check the side effects
39 -- XXX use an IORef to store and check the side effects
40− it "simple asStream" $
40+ it "simple serially" $
41− (runStream . asStream) (return (0 :: Int)) `shouldReturn` ()
41+ (runStream . serially) (return (0 :: Int)) `shouldReturn` ()
42− it "simple asStream with IO" $
42+ it "simple serially with IO" $
43− (runStream . asStream) (A.once $ putStrLn "hello") `shouldReturn` ()
43+ (runStream . serially) (A.once $ putStrLn "hello") `shouldReturn` ()
44
44
45 describe "Empty" $ do
45 describe "Empty" $ do
46 it "Monoid - mempty" $
46 it "Monoid - mempty" $
@@ -96,31 +96,31 @@ main = hspec $ do
96 -- for Monoid that is using the right version of semigroup. Instance
96 -- for Monoid that is using the right version of semigroup. Instance
97 -- deriving can cause us to pick wrong instances sometimes.
97 -- deriving can cause us to pick wrong instances sometimes.
98
98
99− describe "Serial interleaved (<>) ordering check" $ interleaveCheck asCostream (<>)
99+ describe "Serial interleaved (<>) ordering check" $ interleaveCheck wSerially (<>)
100− describe "Serial interleaved mappend ordering check" $ interleaveCheck asCostream mappend
100+ describe "Serial interleaved mappend ordering check" $ interleaveCheck wSerially mappend
101
101
102− describe "Parallel interleaved (<>) ordering check" $ interleaveCheck asCoparAhead (<>)
102+ describe "Parallel interleaved (<>) ordering check" $ interleaveCheck wAsyncly (<>)
103− describe "Parallel interleaved mappend ordering check" $ interleaveCheck asCoparAhead mappend
103+ describe "Parallel interleaved mappend ordering check" $ interleaveCheck wAsyncly mappend
104
104
105− -- describe "Parallel (<>) ordering check" $ interleaveCheck asParallel (<>)
105+ -- describe "Parallel (<>) ordering check" $ interleaveCheck parallely (<>)
106− -- describe "Parallel mappend ordering check" $ interleaveCheck asParallel mappend
106+ -- describe "Parallel mappend ordering check" $ interleaveCheck parallely mappend
107
107
108− describe "ParAhead (<>) time order check" $ parallelCheck asParAhead (<>)
108+ describe "ParAhead (<>) time order check" $ parallelCheck asyncly (<>)
109− describe "ParAhead mappend time order check" $ parallelCheck asParAhead mappend
109+ describe "ParAhead mappend time order check" $ parallelCheck asyncly mappend
110− describe "CoparAhead (<>) time order check" $ parallelCheck asCoparAhead (<>)
110+ describe "CoparAhead (<>) time order check" $ parallelCheck wAsyncly (<>)
111− describe "CoparAhead mappend time order check" $ parallelCheck asCoparAhead mappend
111+ describe "CoparAhead mappend time order check" $ parallelCheck wAsyncly mappend
112
112
113 ---------------------------------------------------------------------------
113 ---------------------------------------------------------------------------
114 -- Monoidal Compositions, multiset equality checks
114 -- Monoidal Compositions, multiset equality checks
115 ---------------------------------------------------------------------------
115 ---------------------------------------------------------------------------
116
116
117− describe "Serial Composition" $ compose asStream mempty id
117+ describe "Serial Composition" $ compose serially mempty id
118− describe "Interleaved Composition" $ compose asCostream mempty sort
118+ describe "Interleaved Composition" $ compose wSerially mempty sort
119− describe "ParAhead Composition" $ compose asParAhead mempty sort
119+ describe "ParAhead Composition" $ compose asyncly mempty sort
120− describe "CoparAhead Composition" $ compose asCoparAhead mempty sort
120+ describe "CoparAhead Composition" $ compose wAsyncly mempty sort
121− describe "Parallel Composition" $ compose asParallel mempty sort
121+ describe "Parallel Composition" $ compose parallely mempty sort
122− describe "Semigroup Composition for ZipSerial" $ compose asZipStream mempty id
122+ describe "Semigroup Composition for ZipSerial" $ compose zipSerially mempty id
123− describe "Semigroup Composition for ZipAsync" $ compose asZipParallel mempty id
123+ describe "Semigroup Composition for ZipAsync" $ compose zipAsyncly mempty id
124 -- XXX need to check alternative compositions as well
124 -- XXX need to check alternative compositions as well
125
125
126 ---------------------------------------------------------------------------
126 ---------------------------------------------------------------------------
@@ -128,11 +128,11 @@ main = hspec $ do
128 ---------------------------------------------------------------------------
128 ---------------------------------------------------------------------------
129
129
130 -- TBD need more such combinations to be tested.
130 -- TBD need more such combinations to be tested.
131− describe "<> and <>" $ composeAndComposeSimple asStream asStream (cycle [[1 .. 9]])
131+ describe "<> and <>" $ composeAndComposeSimple serially serially (cycle [[1 .. 9]])
132
132
133 describe "<> and <=>" $ composeAndComposeSimple
133 describe "<> and <=>" $ composeAndComposeSimple
134− asStream
134+ serially
135− asCostream
135+ wSerially
136 ([ [1 .. 9]
136 ([ [1 .. 9]
137 , [1 .. 9]
137 , [1 .. 9]
138 , [1, 3, 2, 4, 6, 5, 7, 9, 8]
138 , [1, 3, 2, 4, 6, 5, 7, 9, 8]
@@ -140,8 +140,8 @@ main = hspec $ do
140 ])
140 ])
141
141
142 describe "<=> and <=>" $ composeAndComposeSimple
142 describe "<=> and <=>" $ composeAndComposeSimple
143− asCostream
143+ wSerially
144− asCostream
144+ wSerially
145 ([ [1, 4, 2, 7, 3, 5, 8, 6, 9]
145 ([ [1, 4, 2, 7, 3, 5, 8, 6, 9]
146 , [1, 7, 4, 8, 2, 9, 5, 3, 6]
146 , [1, 7, 4, 8, 2, 9, 5, 3, 6]
147 , [1, 4, 3, 7, 2, 6, 9, 5, 8]
147 , [1, 4, 3, 7, 2, 6, 9, 5, 8]
@@ -149,8 +149,8 @@ main = hspec $ do
149 ])
149 ])
150
150
151 describe "<=> and <>" $ composeAndComposeSimple
151 describe "<=> and <>" $ composeAndComposeSimple
152− asCostream
152+ wSerially
153− asStream
153+ serially
154 ([ [1, 4, 2, 7, 3, 5, 8, 6, 9]
154 ([ [1, 4, 2, 7, 3, 5, 8, 6, 9]
155 , [1, 7, 4, 8, 2, 9, 5, 3, 6]
155 , [1, 7, 4, 8, 2, 9, 5, 3, 6]
156 , [1, 4, 2, 7, 3, 5, 8, 6, 9]
156 , [1, 4, 2, 7, 3, 5, 8, 6, 9]
@@ -159,8 +159,8 @@ main = hspec $ do
159
159
160 describe "Nested parallel and serial compositions" $ do
160 describe "Nested parallel and serial compositions" $ do
161 let t = timed
161 let t = timed
162− p = asCoparAhead
162+ p = wAsyncly
163− s = asStream
163+ s = serially
164 {-
164 {-
165 -- This is not correct, the result can also be [4,4,8,0,8,0,2,2]
165 -- This is not correct, the result can also be [4,4,8,0,8,0,2,2]
166 -- because of parallelism of [8,0] and [8,0].
166 -- because of parallelism of [8,0] and [8,0].
@@ -172,7 +172,7 @@ main = hspec $ do
172 `shouldReturn` ([4,4,8,8,0,0,2,2])
172 `shouldReturn` ([4,4,8,8,0,0,2,2])
173 -}
173 -}
174 it "Nest <|>, <>, <|> (2)" $
174 it "Nest <|>, <>, <|> (2)" $
175− (A.toList . asCoparAhead) (
175+ (A.toList . wAsyncly) (
176 s (p (t 4 <> t 8) <> p (t 1 <> t 2))
176 s (p (t 4 <> t 8) <> p (t 1 <> t 2))
177 <> s (p (t 4 <> t 8) <> p (t 1 <> t 2)))
177 <> s (p (t 4 <> t 8) <> p (t 1 <> t 2)))
178 `shouldReturn` ([4,4,8,8,1,1,2,2])
178 `shouldReturn` ([4,4,8,8,1,1,2,2])
@@ -193,7 +193,7 @@ main = hspec $ do
193 `shouldReturn` ([4,4,1,1,8,2,9,2])
193 `shouldReturn` ([4,4,1,1,8,2,9,2])
194 -}
194 -}
195 it "Nest <|>, <|>, <|>" $
195 it "Nest <|>, <|>, <|>" $
196− (A.toList . asCoparAhead) (
196+ (A.toList . wAsyncly) (
197 ((t 4 <> t 8) <> (t 0 <> t 2))
197 ((t 4 <> t 8) <> (t 0 <> t 2))
198 <> ((t 4 <> t 8) <> (t 0 <> t 2)))
198 <> ((t 4 <> t 8) <> (t 0 <> t 2)))
199 `shouldReturn` ([0,0,2,2,4,4,8,8])
199 `shouldReturn` ([0,0,2,2,4,4,8,8])
@@ -202,103 +202,103 @@ main = hspec $ do
202 -- Monoidal composition recursion loops
202 -- Monoidal composition recursion loops
203 ---------------------------------------------------------------------------
203 ---------------------------------------------------------------------------
204
204
205− describe "Serial loops" $ loops asStream id reverse
205+ describe "Serial loops" $ loops serially id reverse
206− describe "ParAhead parallel loops" $ loops asParAhead sort sort
206+ describe "ParAhead parallel loops" $ loops asyncly sort sort
207− describe "coparAhead loops" $ loops asCoparAhead sort sort
207+ describe "coparAhead loops" $ loops wAsyncly sort sort
208− describe "parallel loops" $ loops asParallel sort sort
208+ describe "parallel loops" $ loops parallely sort sort
209
209
210 ---------------------------------------------------------------------------
210 ---------------------------------------------------------------------------
211 -- Bind and monoidal composition combinations
211 -- Bind and monoidal composition combinations
212 ---------------------------------------------------------------------------
212 ---------------------------------------------------------------------------
213
213
214− describe "Bind and compose Stream 1" $ bindAndComposeSimple asStream asStream
214+ describe "Bind and compose Stream 1" $ bindAndComposeSimple serially serially
215− describe "Bind and compose Stream 2" $ bindAndComposeSimple asStream asCostream
215+ describe "Bind and compose Stream 2" $ bindAndComposeSimple serially wSerially
216− describe "Bind and compose Stream 3" $ bindAndComposeSimple asStream asParAhead
216+ describe "Bind and compose Stream 3" $ bindAndComposeSimple serially asyncly
217− describe "Bind and compose Stream 4" $ bindAndComposeSimple asStream asCoparAhead
217+ describe "Bind and compose Stream 4" $ bindAndComposeSimple serially wAsyncly
218− describe "Bind and compose Stream 5" $ bindAndComposeSimple asStream asParallel
218+ describe "Bind and compose Stream 5" $ bindAndComposeSimple serially parallely
219−
219+
220− describe "Bind and compose Costream 1" $ bindAndComposeSimple asCostream asStream
220+ describe "Bind and compose Costream 1" $ bindAndComposeSimple wSerially serially
221− describe "Bind and compose Costream 2" $ bindAndComposeSimple asCostream asCostream
221+ describe "Bind and compose Costream 2" $ bindAndComposeSimple wSerially wSerially
222− describe "Bind and compose Costream 3" $ bindAndComposeSimple asCostream asParAhead
222+ describe "Bind and compose Costream 3" $ bindAndComposeSimple wSerially asyncly
223− describe "Bind and compose Costream 4" $ bindAndComposeSimple asCostream asCoparAhead
223+ describe "Bind and compose Costream 4" $ bindAndComposeSimple wSerially wAsyncly
224− describe "Bind and compose Costream 5" $ bindAndComposeSimple asCostream asParallel
224+ describe "Bind and compose Costream 5" $ bindAndComposeSimple wSerially parallely
225−
225+
226− describe "Bind and compose ParAhead 1" $ bindAndComposeSimple asParAhead asStream
226+ describe "Bind and compose ParAhead 1" $ bindAndComposeSimple asyncly serially
227− describe "Bind and compose ParAhead 2" $ bindAndComposeSimple asParAhead asCostream
227+ describe "Bind and compose ParAhead 2" $ bindAndComposeSimple asyncly wSerially
228− describe "Bind and compose ParAhead 3" $ bindAndComposeSimple asParAhead asParAhead
228+ describe "Bind and compose ParAhead 3" $ bindAndComposeSimple asyncly asyncly
229− describe "Bind and compose ParAhead 4" $ bindAndComposeSimple asParAhead asCoparAhead
229+ describe "Bind and compose ParAhead 4" $ bindAndComposeSimple asyncly wAsyncly
230− describe "Bind and compose ParAhead 5" $ bindAndComposeSimple asParAhead asParallel
230+ describe "Bind and compose ParAhead 5" $ bindAndComposeSimple asyncly parallely
231−
231+
232− describe "Bind and compose CoparAhead 1" $ bindAndComposeSimple asCoparAhead asStream
232+ describe "Bind and compose CoparAhead 1" $ bindAndComposeSimple wAsyncly serially
233− describe "Bind and compose CoparAhead 2" $ bindAndComposeSimple asCoparAhead asCostream
233+ describe "Bind and compose CoparAhead 2" $ bindAndComposeSimple wAsyncly wSerially
234− describe "Bind and compose CoparAhead 3" $ bindAndComposeSimple asCoparAhead asParAhead
234+ describe "Bind and compose CoparAhead 3" $ bindAndComposeSimple wAsyncly asyncly
235− describe "Bind and compose CoparAhead 4" $ bindAndComposeSimple asCoparAhead asCoparAhead
235+ describe "Bind and compose CoparAhead 4" $ bindAndComposeSimple wAsyncly wAsyncly
236− describe "Bind and compose CoparAhead 5" $ bindAndComposeSimple asCoparAhead asParallel
236+ describe "Bind and compose CoparAhead 5" $ bindAndComposeSimple wAsyncly parallely
237−
237+
238− describe "Bind and compose Parallel 1" $ bindAndComposeSimple asParallel asStream
238+ describe "Bind and compose Parallel 1" $ bindAndComposeSimple parallely serially
239− describe "Bind and compose Parallel 2" $ bindAndComposeSimple asParallel asCostream
239+ describe "Bind and compose Parallel 2" $ bindAndComposeSimple parallely wSerially
240− describe "Bind and compose Parallel 3" $ bindAndComposeSimple asParallel asParAhead
240+ describe "Bind and compose Parallel 3" $ bindAndComposeSimple parallely asyncly
241− describe "Bind and compose Parallel 4" $ bindAndComposeSimple asParallel asCoparAhead
241+ describe "Bind and compose Parallel 4" $ bindAndComposeSimple parallely wAsyncly
242− describe "Bind and compose Parallel 5" $ bindAndComposeSimple asParallel asParallel
242+ describe "Bind and compose Parallel 5" $ bindAndComposeSimple parallely parallely
243
243
244 let fldr, fldl :: (IsStream t, Semigroup (t IO Int)) => [t IO Int] -> t IO Int
244 let fldr, fldl :: (IsStream t, Semigroup (t IO Int)) => [t IO Int] -> t IO Int
245 fldr = foldr (<>) nil
245 fldr = foldr (<>) nil
246 fldl = foldl (<>) nil
246 fldl = foldl (<>) nil
247
247
248 forM_ [fldr, fldl] $ \k ->
248 forM_ [fldr, fldl] $ \k ->
249− describe "Bind and compose" $ bindAndComposeHierarchy asStream asStream k
249+ describe "Bind and compose" $ bindAndComposeHierarchy serially serially k
250 forM_ [fldr, fldl] $ \k ->
250 forM_ [fldr, fldl] $ \k ->
251− describe "Bind and compose" $ bindAndComposeHierarchy asStream asCostream k
251+ describe "Bind and compose" $ bindAndComposeHierarchy serially wSerially k
252 forM_ [fldr, fldl] $ \k ->
252 forM_ [fldr, fldl] $ \k ->
253− describe "Bind and compose" $ bindAndComposeHierarchy asStream asParAhead k
253+ describe "Bind and compose" $ bindAndComposeHierarchy serially asyncly k
254 forM_ [fldr, fldl] $ \k ->
254 forM_ [fldr, fldl] $ \k ->
255− describe "Bind and compose" $ bindAndComposeHierarchy asStream asCoparAhead k
255+ describe "Bind and compose" $ bindAndComposeHierarchy serially wAsyncly k
256 forM_ [fldr, fldl] $ \k ->
256 forM_ [fldr, fldl] $ \k ->
257− describe "Bind and compose" $ bindAndComposeHierarchy asStream asParallel k
257+ describe "Bind and compose" $ bindAndComposeHierarchy serially parallely k
258
258
259 forM_ [fldr, fldl] $ \k ->
259 forM_ [fldr, fldl] $ \k ->
260− describe "Bind and compose" $ bindAndComposeHierarchy asCostream asStream k
260+ describe "Bind and compose" $ bindAndComposeHierarchy wSerially serially k
261 forM_ [fldr, fldl] $ \k ->
261 forM_ [fldr, fldl] $ \k ->
262− describe "Bind and compose" $ bindAndComposeHierarchy asCostream asCostream k
262+ describe "Bind and compose" $ bindAndComposeHierarchy wSerially wSerially k
263 forM_ [fldr, fldl] $ \k ->
263 forM_ [fldr, fldl] $ \k ->
264− describe "Bind and compose" $ bindAndComposeHierarchy asCostream asParAhead k
264+ describe "Bind and compose" $ bindAndComposeHierarchy wSerially asyncly k
265 forM_ [fldr, fldl] $ \k ->
265 forM_ [fldr, fldl] $ \k ->
266− describe "Bind and compose" $ bindAndComposeHierarchy asCostream asCoparAhead k
266+ describe "Bind and compose" $ bindAndComposeHierarchy wSerially wAsyncly k
267 forM_ [fldr, fldl] $ \k ->
267 forM_ [fldr, fldl] $ \k ->
268− describe "Bind and compose" $ bindAndComposeHierarchy asCostream asParallel k
268+ describe "Bind and compose" $ bindAndComposeHierarchy wSerially parallely k
269
269
270 forM_ [fldr, fldl] $ \k ->
270 forM_ [fldr, fldl] $ \k ->
271− describe "Bind and compose" $ bindAndComposeHierarchy asParAhead asStream k
271+ describe "Bind and compose" $ bindAndComposeHierarchy asyncly serially k
272 forM_ [fldr, fldl] $ \k ->
272 forM_ [fldr, fldl] $ \k ->
273− describe "Bind and compose" $ bindAndComposeHierarchy asParAhead asCostream k
273+ describe "Bind and compose" $ bindAndComposeHierarchy asyncly wSerially k
274 forM_ [fldr, fldl] $ \k ->
274 forM_ [fldr, fldl] $ \k ->
275− describe "Bind and compose" $ bindAndComposeHierarchy asParAhead asParAhead k
275+ describe "Bind and compose" $ bindAndComposeHierarchy asyncly asyncly k
276 forM_ [fldr, fldl] $ \k ->
276 forM_ [fldr, fldl] $ \k ->
277− describe "Bind and compose" $ bindAndComposeHierarchy asParAhead asCoparAhead k
277+ describe "Bind and compose" $ bindAndComposeHierarchy asyncly wAsyncly k
278 forM_ [fldr, fldl] $ \k ->
278 forM_ [fldr, fldl] $ \k ->
279− describe "Bind and compose" $ bindAndComposeHierarchy asParAhead asParallel k
279+ describe "Bind and compose" $ bindAndComposeHierarchy asyncly parallely k
280
280
281 forM_ [fldr, fldl] $ \k ->
281 forM_ [fldr, fldl] $ \k ->
282− describe "Bind and compose" $ bindAndComposeHierarchy asCoparAhead asStream k
282+ describe "Bind and compose" $ bindAndComposeHierarchy wAsyncly serially k
283 forM_ [fldr, fldl] $ \k ->
283 forM_ [fldr, fldl] $ \k ->
284− describe "Bind and compose" $ bindAndComposeHierarchy asCoparAhead asCostream k
284+ describe "Bind and compose" $ bindAndComposeHierarchy wAsyncly wSerially k
285 forM_ [fldr, fldl] $ \k ->
285 forM_ [fldr, fldl] $ \k ->
286− describe "Bind and compose" $ bindAndComposeHierarchy asCoparAhead asParAhead k
286+ describe "Bind and compose" $ bindAndComposeHierarchy wAsyncly asyncly k
287 forM_ [fldr, fldl] $ \k ->
287 forM_ [fldr, fldl] $ \k ->
288− describe "Bind and compose" $ bindAndComposeHierarchy asCoparAhead asCoparAhead k
288+ describe "Bind and compose" $ bindAndComposeHierarchy wAsyncly wAsyncly k
289 forM_ [fldr, fldl] $ \k ->
289 forM_ [fldr, fldl] $ \k ->
290− describe "Bind and compose" $ bindAndComposeHierarchy asCoparAhead asParallel k
290+ describe "Bind and compose" $ bindAndComposeHierarchy wAsyncly parallely k
291
291
292 forM_ [fldr, fldl] $ \k ->
292 forM_ [fldr, fldl] $ \k ->
293− describe "Bind and compose" $ bindAndComposeHierarchy asParallel asStream k
293+ describe "Bind and compose" $ bindAndComposeHierarchy parallely serially k
294 forM_ [fldr, fldl] $ \k ->
294 forM_ [fldr, fldl] $ \k ->
295− describe "Bind and compose" $ bindAndComposeHierarchy asParallel asCostream k
295+ describe "Bind and compose" $ bindAndComposeHierarchy parallely wSerially k
296 forM_ [fldr, fldl] $ \k ->
296 forM_ [fldr, fldl] $ \k ->
297− describe "Bind and compose" $ bindAndComposeHierarchy asParallel asParAhead k
297+ describe "Bind and compose" $ bindAndComposeHierarchy parallely asyncly k
298 forM_ [fldr, fldl] $ \k ->
298 forM_ [fldr, fldl] $ \k ->
299− describe "Bind and compose" $ bindAndComposeHierarchy asParallel asCoparAhead k
299+ describe "Bind and compose" $ bindAndComposeHierarchy parallely wAsyncly k
300 forM_ [fldr, fldl] $ \k ->
300 forM_ [fldr, fldl] $ \k ->
301− describe "Bind and compose" $ bindAndComposeHierarchy asParallel asParallel k
301+ describe "Bind and compose" $ bindAndComposeHierarchy parallely parallely k
302
302
303 -- Nest two lists using different styles of product compositions
303 -- Nest two lists using different styles of product compositions
304 it "Nests two streams using monadic serial composition" nestTwoSerial
304 it "Nests two streams using monadic serial composition" nestTwoSerial
@@ -322,20 +322,20 @@ main = hspec $ do
322 describe "Simple MonadError and MonadThrow" simpleMonadError
322 describe "Simple MonadError and MonadThrow" simpleMonadError
323
323
324 {-
324 {-
325− describe "Composed MonadError asStream" $ composeWithMonadError asStream
325+ describe "Composed MonadError serially" $ composeWithMonadError serially
326− describe "Composed MonadError asCostream" $ composeWithMonadError asCostream
326+ describe "Composed MonadError wSerially" $ composeWithMonadError wSerially
327− describe "Composed MonadError asParAhead" $ composeWithMonadError asParAhead
327+ describe "Composed MonadError asyncly" $ composeWithMonadError asyncly
328− describe "Composed MonadError asCoparAhead" $ composeWithMonadError asCoparAhead
328+ describe "Composed MonadError wAsyncly" $ composeWithMonadError wAsyncly
329 -}
329 -}
330
330
331− describe "Composed MonadThrow asStream" $ composeWithMonadThrow asStream
331+ describe "Composed MonadThrow serially" $ composeWithMonadThrow serially
332− describe "Composed MonadThrow asCostream" $ composeWithMonadThrow asCostream
332+ describe "Composed MonadThrow wSerially" $ composeWithMonadThrow wSerially
333− describe "Composed MonadThrow asParAhead" $ composeWithMonadThrow asParAhead
333+ describe "Composed MonadThrow asyncly" $ composeWithMonadThrow asyncly
334− describe "Composed MonadThrow asCoparAhead" $ composeWithMonadThrow asCoparAhead
334+ describe "Composed MonadThrow wAsyncly" $ composeWithMonadThrow wAsyncly
335− describe "Composed MonadThrow asParallel" $ composeWithMonadThrow asParallel
335+ describe "Composed MonadThrow parallely" $ composeWithMonadThrow parallely
336
336
337 it "Crosses thread limit (2000 threads)" $
337 it "Crosses thread limit (2000 threads)" $
338− runStream (asParAhead $ fold $
338+ runStream (asyncly $ fold $
339 replicate 2000 $ A.once $ threadDelay 1000000)
339 replicate 2000 $ A.once $ threadDelay 1000000)
340 `shouldReturn` ()
340 `shouldReturn` ()
341
341
@@ -368,7 +368,7 @@ composeWithMonadThrow
368 , Semigroup (t IO Int)
368 , Semigroup (t IO Int)
369 , MonadThrow (t IO)
369 , MonadThrow (t IO)
370 )
370 )
371− => (t IO Int -> StreamT IO Int) -> Spec
371+ => (t IO Int -> SerialT IO Int) -> Spec
372composeWithMonadThrow t = do
372composeWithMonadThrow t = do
373 it "Compose throwM, nil" $
373 it "Compose throwM, nil" $
374 (try $ tl (throwM (ExampleException "E") <> A.nil))
374 (try $ tl (throwM (ExampleException "E") <> A.nil))
@@ -376,16 +376,16 @@ composeWithMonadThrow t = do
376 it "Compose nil, throwM" $
376 it "Compose nil, throwM" $
377 (try $ tl (A.nil <> throwM (ExampleException "E")))
377 (try $ tl (A.nil <> throwM (ExampleException "E")))
378 `shouldReturn` (Left (ExampleException "E") :: Either ExampleException [Int])
378 `shouldReturn` (Left (ExampleException "E") :: Either ExampleException [Int])
379− oneLevelNestedSum "asStream" asStream
379+ oneLevelNestedSum "serially" serially
380− oneLevelNestedSum "asCostream" asCostream
380+ oneLevelNestedSum "wSerially" wSerially
381− oneLevelNestedSum "asParAhead" asParAhead
381+ oneLevelNestedSum "asyncly" asyncly
382− oneLevelNestedSum "asCoparAhead" asCoparAhead
382+ oneLevelNestedSum "wAsyncly" wAsyncly
383 -- XXX add two level nesting
383 -- XXX add two level nesting
384
384
385− oneLevelNestedProduct "asStream" asStream
385+ oneLevelNestedProduct "serially" serially
386− oneLevelNestedProduct "asCostream" asCostream
386+ oneLevelNestedProduct "wSerially" wSerially
387− oneLevelNestedProduct "asParAhead" asParAhead
387+ oneLevelNestedProduct "asyncly" asyncly
388− oneLevelNestedProduct "asCoparAhead" asCoparAhead
388+ oneLevelNestedProduct "wAsyncly" wAsyncly
389
389
390 where
390 where
391 tl = A.toList . t
391 tl = A.toList . t
@@ -414,7 +414,7 @@ _composeWithMonadError
414 , Semigroup (t (ExceptT String IO) Int)
414 , Semigroup (t (ExceptT String IO) Int)
415 , MonadError String (t (ExceptT String IO))
415 , MonadError String (t (ExceptT String IO))
416 )
416 )
417− => (t (ExceptT String IO) Int -> StreamT (ExceptT String IO) Int) -> Spec
417+ => (t (ExceptT String IO) Int -> SerialT (ExceptT String IO) Int) -> Spec
418_composeWithMonadError t = do
418_composeWithMonadError t = do
419 let tl = A.toList . t
419 let tl = A.toList . t
420 it "Compose throwError, nil" $
420 it "Compose throwError, nil" $
@@ -478,7 +478,7 @@ nestTwoCoparAhead :: Expectation
478nestTwoCoparAhead =
478nestTwoCoparAhead =
479 let s1 = foldMapWith (<>) return [1..4]
479 let s1 = foldMapWith (<>) return [1..4]
480 s2 = foldMapWith (<>) return [5..8]
480 s2 = foldMapWith (<>) return [5..8]
481− in ((A.toList . asCoparAhead) (do
481+ in ((A.toList . wAsyncly) (do
482 x <- s1
482 x <- s1
483 y <- s2
483 y <- s2
484 return (x + y)
484 return (x + y)
@@ -489,7 +489,7 @@ nestTwoParallel :: Expectation
489nestTwoParallel =
489nestTwoParallel =
490 let s1 = foldMapWith (<>) return [1..4]
490 let s1 = foldMapWith (<>) return [1..4]
491 s2 = foldMapWith (<>) return [5..8]
491 s2 = foldMapWith (<>) return [5..8]
492− in ((A.toList . asParallel) (do
492+ in ((A.toList . parallely) (do
493 x <- s1
493 x <- s1
494 y <- s2
494 y <- s2
495 return (x + y)
495 return (x + y)
@@ -500,21 +500,21 @@ nestTwoCoparAheadApp :: Expectation
500nestTwoCoparAheadApp =
500nestTwoCoparAheadApp =
501 let s1 = foldMapWith (<>) return [1..4]
501 let s1 = foldMapWith (<>) return [1..4]
502 s2 = foldMapWith (<>) return [5..8]
502 s2 = foldMapWith (<>) return [5..8]
503− in ((A.toList . asCoparAhead) ((+) <$> s1 <*> s2) >>= return . sort)
503+ in ((A.toList . wAsyncly) ((+) <$> s1 <*> s2) >>= return . sort)
504 `shouldReturn` sort ([6,7,7,8,8,8,9,9,9,9,10,10,10,11,11,12] :: [Int])
504 `shouldReturn` sort ([6,7,7,8,8,8,9,9,9,9,10,10,10,11,11,12] :: [Int])
505
505
506nestTwoParallelApp :: Expectation
506nestTwoParallelApp :: Expectation
507nestTwoParallelApp =
507nestTwoParallelApp =
508 let s1 = foldMapWith (<>) return [1..4]
508 let s1 = foldMapWith (<>) return [1..4]
509 s2 = foldMapWith (<>) return [5..8]
509 s2 = foldMapWith (<>) return [5..8]
510− in ((A.toList . asParallel) ((+) <$> s1 <*> s2) >>= return . sort)
510+ in ((A.toList . parallely) ((+) <$> s1 <*> s2) >>= return . sort)
511 `shouldReturn` sort ([6,7,7,8,8,8,9,9,9,9,10,10,10,11,11,12] :: [Int])
511 `shouldReturn` sort ([6,7,7,8,8,8,9,9,9,9,10,10,10,11,11,12] :: [Int])
512
512
513timed :: (IsStream t, Monad (t IO)) => Int -> t IO Int
513timed :: (IsStream t, Monad (t IO)) => Int -> t IO Int
514timed x = A.once (threadDelay (x * 100000)) >> return x
514timed x = A.once (threadDelay (x * 100000)) >> return x
515
515
516interleaveCheck :: IsStream t
516interleaveCheck :: IsStream t
517− => (t IO Int -> StreamT IO Int)
517+ => (t IO Int -> SerialT IO Int)
518 -> (t IO Int -> t IO Int -> t IO Int)
518 -> (t IO Int -> t IO Int -> t IO Int)
519 -> Spec
519 -> Spec
520interleaveCheck t f =
520interleaveCheck t f =
@@ -523,7 +523,7 @@ interleaveCheck t f =
523 `shouldReturn` ([0, 100, 1, 101])
523 `shouldReturn` ([0, 100, 1, 101])
524
524
525parallelCheck :: (IsStream t, Monad (t IO))
525parallelCheck :: (IsStream t, Monad (t IO))
526− => (t IO Int -> StreamT IO Int)
526+ => (t IO Int -> SerialT IO Int)
527 -> (t IO Int -> t IO Int -> t IO Int)
527 -> (t IO Int -> t IO Int -> t IO Int)
528 -> Spec
528 -> Spec
529parallelCheck t f = do
529parallelCheck t f = do
@@ -538,7 +538,7 @@ parallelCheck t f = do
538 where event n = (A.once $ threadDelay (n * 100000)) >> (return n)
538 where event n = (A.once $ threadDelay (n * 100000)) >> (return n)
539
539
540compose :: (IsStream t, Semigroup (t IO Int))
540compose :: (IsStream t, Semigroup (t IO Int))
541− => (t IO Int -> StreamT IO Int) -> t IO Int -> ([Int] -> [Int]) -> Spec
541+ => (t IO Int -> SerialT IO Int) -> t IO Int -> ([Int] -> [Int]) -> Spec
542compose t z srt = do
542compose t z srt = do
543 -- XXX these should get covered by the property tests
543 -- XXX these should get covered by the property tests
544 it "Compose mempty, mempty" $
544 it "Compose mempty, mempty" $
@@ -577,7 +577,7 @@ composeAndComposeSimple
577 , Semigroup (t2 IO Int)
577 , Semigroup (t2 IO Int)
578#endif
578#endif
579 )
579 )
580− => (t1 IO Int -> StreamT IO Int)
580+ => (t1 IO Int -> SerialT IO Int)
581 -> (t2 IO Int -> t2 IO Int)
581 -> (t2 IO Int -> t2 IO Int)
582 -> [[Int]] -> Spec
582 -> [[Int]] -> Spec
583composeAndComposeSimple t1 t2 answer = do
583composeAndComposeSimple t1 t2 answer = do
@@ -625,7 +625,7 @@ loops t tsrt hsrt = do
625
625
626bindAndComposeSimple
626bindAndComposeSimple
627 :: ( IsStream t1, IsStream t2, Semigroup (t2 IO Int), Monad (t2 IO))
627 :: ( IsStream t1, IsStream t2, Semigroup (t2 IO Int), Monad (t2 IO))
628− => (t1 IO Int -> StreamT IO Int)
628+ => (t1 IO Int -> SerialT IO Int)
629 -> (t2 IO Int -> t2 IO Int)
629 -> (t2 IO Int -> t2 IO Int)
630 -> Spec
630 -> Spec
631bindAndComposeSimple t1 t2 = do
631bindAndComposeSimple t1 t2 = do
@@ -642,7 +642,7 @@ bindAndComposeSimple t1 t2 = do
642bindAndComposeHierarchy
642bindAndComposeHierarchy
643 :: ( IsStream t1, Monad (t1 IO)
643 :: ( IsStream t1, Monad (t1 IO)
644 , IsStream t2, Monad (t2 IO))
644 , IsStream t2, Monad (t2 IO))
645− => (t1 IO Int -> StreamT IO Int)
645+ => (t1 IO Int -> SerialT IO Int)
646 -> (t2 IO Int -> t2 IO Int)
646 -> (t2 IO Int -> t2 IO Int)
647 -> ([t2 IO Int] -> t2 IO Int)
647 -> ([t2 IO Int] -> t2 IO Int)
648 -> Spec
648 -> Spec
@@ -659,7 +659,7 @@ bindAndComposeHierarchy t1 t2 g = do
659
659
660 where
660 where
661
661
662− -- bindComposeNested :: ACoparAheadT IO Int
662+ -- bindComposeNested :: WAsyncT IO Int
663 bindComposeNested =
663 bindComposeNested =
664 let c1 = tripleCompose (return 1) (return 2) (return 3)
664 let c1 = tripleCompose (return 1) (return 2) (return 3)
665 c2 = tripleCompose (return 4) (return 5) (return 6)
665 c2 = tripleCompose (return 4) (return 5) (return 6)
@@ -686,21 +686,21 @@ mixedOps = do
686 ] :: [Int])
686 ] :: [Int])
687 where
687 where
688
688
689− composeMixed :: StreamT IO Int
689+ composeMixed :: SerialT IO Int
690 composeMixed = do
690 composeMixed = do
691 A.once $ return ()
691 A.once $ return ()
692 A.once $ putStr ""
692 A.once $ putStr ""
693 x <- return 1
693 x <- return 1
694 y <- return 2
694 y <- return 2
695 z <- do
695 z <- do
696− x1 <- asCoparAhead $ return 1 <> return 2
696+ x1 <- wAsyncly $ return 1 <> return 2
697 A.once $ return ()
697 A.once $ return ()
698 A.once $ putStr ""
698 A.once $ putStr ""
699− y1 <- asParAhead $ return 1 <> return 2
699+ y1 <- asyncly $ return 1 <> return 2
700 z1 <- do
700 z1 <- do
701 x11 <- return 1 <> return 2
701 x11 <- return 1 <> return 2
702− y11 <- asParAhead $ return 1 <> return 2
702+ y11 <- asyncly $ return 1 <> return 2
703− z11 <- asCostream $ return 1 <> return 2
703+ z11 <- wSerially $ return 1 <> return 2
704 A.once $ return ()
704 A.once $ return ()
705 A.once $ putStr ""
705 A.once $ putStr ""
706 return (x11 + y11 + z11)
706 return (x11 + y11 + z11)
test/Prop.hs+134−134
@@ -36,7 +36,7 @@ equals eq stream list = do
36
36
37constructWithReplicateM
37constructWithReplicateM
38 :: IsStream t
38 :: IsStream t
39− => (t IO Int -> StreamT IO Int)
39+ => (t IO Int -> SerialT IO Int)
40 -> Word8
40 -> Word8
41 -> Property
41 -> Property
42constructWithReplicateM op len =
42constructWithReplicateM op len =
@@ -50,7 +50,7 @@ transformFromList
50 :: ([Int] -> t IO Int)
50 :: ([Int] -> t IO Int)
51 -> ([Int] -> [Int] -> Bool)
51 -> ([Int] -> [Int] -> Bool)
52 -> ([Int] -> [Int])
52 -> ([Int] -> [Int])
53− -> (t IO Int -> StreamT IO Int)
53+ -> (t IO Int -> SerialT IO Int)
54 -> [Int]
54 -> [Int]
55 -> Property
55 -> Property
56transformFromList constr eq listOp op a =
56transformFromList constr eq listOp op a =
@@ -61,7 +61,7 @@ transformFromList constr eq listOp op a =
61
61
62foldFromList
62foldFromList
63 :: ([Int] -> t IO Int)
63 :: ([Int] -> t IO Int)
64− -> (t IO Int -> StreamT IO Int)
64+ -> (t IO Int -> SerialT IO Int)
65 -> ([Int] -> [Int] -> Bool)
65 -> ([Int] -> [Int] -> Bool)
66 -> [Int]
66 -> [Int]
67 -> Property
67 -> Property
@@ -82,8 +82,8 @@ eliminateOp constr listOp op a =
82
82
83elemOp
83elemOp
84 :: ([Word8] -> t IO Word8)
84 :: ([Word8] -> t IO Word8)
85− -> (t IO Word8 -> StreamT IO Word8)
85+ -> (t IO Word8 -> SerialT IO Word8)
86− -> (Word8 -> StreamT IO Word8 -> IO Bool)
86+ -> (Word8 -> SerialT IO Word8 -> IO Bool)
87 -> (Word8 -> [Word8] -> Bool)
87 -> (Word8 -> [Word8] -> Bool)
88 -> (Word8, [Word8])
88 -> (Word8, [Word8])
89 -> Property
89 -> Property
@@ -97,7 +97,7 @@ functorOps
97 :: Functor (t IO)
97 :: Functor (t IO)
98 => ([Int] -> t IO Int)
98 => ([Int] -> t IO Int)
99 -> String
99 -> String
100− -> (t IO Int -> StreamT IO Int)
100+ -> (t IO Int -> SerialT IO Int)
101 -> ([Int] -> [Int] -> Bool)
101 -> ([Int] -> [Int] -> Bool)
102 -> Spec
102 -> Spec
103functorOps constr desc t eq = do
103functorOps constr desc t eq = do
@@ -108,7 +108,7 @@ transformOps
108 :: IsStream t
108 :: IsStream t
109 => ([Int] -> t IO Int)
109 => ([Int] -> t IO Int)
110 -> String
110 -> String
111− -> (t IO Int -> StreamT IO Int)
111+ -> (t IO Int -> SerialT IO Int)
112 -> ([Int] -> [Int] -> Bool)
112 -> ([Int] -> [Int] -> Bool)
113 -> Spec
113 -> Spec
114transformOps constr desc t eq = do
114transformOps constr desc t eq = do
@@ -159,7 +159,7 @@ wrapMaybe f =
159eliminationOps
159eliminationOps
160 :: ([Int] -> t IO Int)
160 :: ([Int] -> t IO Int)
161 -> String
161 -> String
162− -> (t IO Int -> StreamT IO Int)
162+ -> (t IO Int -> SerialT IO Int)
163 -> Spec
163 -> Spec
164eliminationOps constr desc t = do
164eliminationOps constr desc t = do
165 -- Elimination
165 -- Elimination
@@ -180,7 +180,7 @@ eliminationOps constr desc t = do
180serialEliminationOps
180serialEliminationOps
181 :: ([Int] -> t IO Int)
181 :: ([Int] -> t IO Int)
182 -> String
182 -> String
183− -> (t IO Int -> StreamT IO Int)
183+ -> (t IO Int -> SerialT IO Int)
184 -> Spec
184 -> Spec
185serialEliminationOps constr desc t = do
185serialEliminationOps constr desc t = do
186 prop (desc ++ " head") $ eliminateOp constr (wrapMaybe head) $ A.head . t
186 prop (desc ++ " head") $ eliminateOp constr (wrapMaybe head) $ A.head . t
@@ -194,7 +194,7 @@ serialEliminationOps constr desc t = do
194transformOpsWord8
194transformOpsWord8
195 :: ([Word8] -> t IO Word8)
195 :: ([Word8] -> t IO Word8)
196 -> String
196 -> String
197− -> (t IO Word8 -> StreamT IO Word8)
197+ -> (t IO Word8 -> SerialT IO Word8)
198 -> Spec
198 -> Spec
199transformOpsWord8 constr desc t = do
199transformOpsWord8 constr desc t = do
200 prop (desc ++ " elem") $ elemOp constr t A.elem elem
200 prop (desc ++ " elem") $ elemOp constr t A.elem elem
@@ -209,7 +209,7 @@ semigroupOps
209#endif
209#endif
210 , Monoid (t IO Int))
210 , Monoid (t IO Int))
211 => String
211 => String
212− -> (t IO Int -> StreamT IO Int)
212+ -> (t IO Int -> SerialT IO Int)
213 -> ([Int] -> [Int] -> Bool)
213 -> ([Int] -> [Int] -> Bool)
214 -> Spec
214 -> Spec
215semigroupOps desc t eq = do
215semigroupOps desc t eq = do
@@ -219,7 +219,7 @@ semigroupOps desc t eq = do
219applicativeOps
219applicativeOps
220 :: Applicative (t IO)
220 :: Applicative (t IO)
221 => ([Int] -> t IO Int)
221 => ([Int] -> t IO Int)
222− -> (t IO (Int, Int) -> StreamT IO (Int, Int))
222+ -> (t IO (Int, Int) -> SerialT IO (Int, Int))
223 -> ([(Int, Int)] -> [(Int, Int)] -> Bool)
223 -> ([(Int, Int)] -> [(Int, Int)] -> Bool)
224 -> ([Int], [Int])
224 -> ([Int], [Int])
225 -> Property
225 -> Property
@@ -231,7 +231,7 @@ applicativeOps constr t eq (a, b) = monadicIO $ do
231zipApplicative
231zipApplicative
232 :: (IsStream t, Applicative (t IO))
232 :: (IsStream t, Applicative (t IO))
233 => ([Int] -> t IO Int)
233 => ([Int] -> t IO Int)
234− -> (t IO (Int, Int) -> StreamT IO (Int, Int))
234+ -> (t IO (Int, Int) -> SerialT IO (Int, Int))
235 -> ([(Int, Int)] -> [(Int, Int)] -> Bool)
235 -> ([(Int, Int)] -> [(Int, Int)] -> Bool)
236 -> ([Int], [Int])
236 -> ([Int], [Int])
237 -> Property
237 -> Property
@@ -247,7 +247,7 @@ zipApplicative constr t eq (a, b) = monadicIO $ do
247zipMonadic
247zipMonadic
248 :: (IsStream t, Monad (t IO))
248 :: (IsStream t, Monad (t IO))
249 => ([Int] -> t IO Int)
249 => ([Int] -> t IO Int)
250− -> (t IO (Int, Int) -> StreamT IO (Int, Int))
250+ -> (t IO (Int, Int) -> SerialT IO (Int, Int))
251 -> ([(Int, Int)] -> [(Int, Int)] -> Bool)
251 -> ([(Int, Int)] -> [(Int, Int)] -> Bool)
252 -> ([Int], [Int])
252 -> ([Int], [Int])
253 -> Property
253 -> Property
@@ -260,7 +260,7 @@ zipMonadic constr t eq (a, b) =
260 stream2 <-
260 stream2 <-
261 run
261 run
262 ((A.toList . t)
262 ((A.toList . t)
263− (A.zipParallelWithM (\x y -> return (x, y)) (constr a) (constr b)))
263+ (A.zipAsyncWithM (\x y -> return (x, y)) (constr a) (constr b)))
264 let list = getZipList $ (,) <$> ZipList a <*> ZipList b
264 let list = getZipList $ (,) <$> ZipList a <*> ZipList b
265 equals eq stream1 list
265 equals eq stream1 list
266 equals eq stream2 list
266 equals eq stream2 list
@@ -268,7 +268,7 @@ zipMonadic constr t eq (a, b) =
268monadThen
268monadThen
269 :: Monad (t IO)
269 :: Monad (t IO)
270 => ([Int] -> t IO Int)
270 => ([Int] -> t IO Int)
271− -> (t IO Int -> StreamT IO Int)
271+ -> (t IO Int -> SerialT IO Int)
272 -> ([Int] -> [Int] -> Bool)
272 -> ([Int] -> [Int] -> Bool)
273 -> ([Int], [Int])
273 -> ([Int], [Int])
274 -> Property
274 -> Property
@@ -280,7 +280,7 @@ monadThen constr t eq (a, b) = monadicIO $ do
280monadBind
280monadBind
281 :: Monad (t IO)
281 :: Monad (t IO)
282 => ([Int] -> t IO Int)
282 => ([Int] -> t IO Int)
283− -> (t IO Int -> StreamT IO Int)
283+ -> (t IO Int -> SerialT IO Int)
284 -> ([Int] -> [Int] -> Bool)
284 -> ([Int] -> [Int] -> Bool)
285 -> ([Int], [Int])
285 -> ([Int], [Int])
286 -> Property
286 -> Property
@@ -297,151 +297,151 @@ main :: IO ()
297main = hspec $ do
297main = hspec $ do
298 describe "Construction" $ do
298 describe "Construction" $ do
299 -- XXX test for all types of streams
299 -- XXX test for all types of streams
300− prop "asStream replicateM" $ constructWithReplicateM asStream
300+ prop "serially replicateM" $ constructWithReplicateM serially
301 it "iterate" $
301 it "iterate" $
302− (A.toList . asStream . (A.take 100) $ (A.iterate (+ 1) (0 :: Int)))
302+ (A.toList . serially . (A.take 100) $ (A.iterate (+ 1) (0 :: Int)))
303 `shouldReturn` (take 100 $ iterate (+ 1) 0)
303 `shouldReturn` (take 100 $ iterate (+ 1) 0)
304
304
305 it "iterateM" $ do
305 it "iterateM" $ do
306 let addM = (\ y -> return (y + 1))
306 let addM = (\ y -> return (y + 1))
307− A.toList . asStream . (A.take 100) $ A.iterateM addM (0 :: Int)
307+ A.toList . serially . (A.take 100) $ A.iterateM addM (0 :: Int)
308 `shouldReturn` (take 100 $ iterate (+ 1) 0)
308 `shouldReturn` (take 100 $ iterate (+ 1) 0)
309
309
310 let folded :: IsStream t => [a] -> t IO a
310 let folded :: IsStream t => [a] -> t IO a
311− folded = asStream . (\xs ->
311+ folded = serially . (\xs ->
312 case xs of
312 case xs of
313 [x] -> return x -- singleton stream case
313 [x] -> return x -- singleton stream case
314 _ -> foldMapWith (<>) return xs
314 _ -> foldMapWith (<>) return xs
315 )
315 )
316 describe "Functor operations" $ do
316 describe "Functor operations" $ do
317− functorOps A.fromFoldable "asStream" asStream (==)
317+ functorOps A.fromFoldable "serially" serially (==)
318− functorOps folded "asStream folded" asStream (==)
318+ functorOps folded "serially folded" serially (==)
319− functorOps A.fromFoldable "asCostream" asCostream (==)
319+ functorOps A.fromFoldable "wSerially" wSerially (==)
320− functorOps folded "asCostream folded" asCostream (==)
320+ functorOps folded "wSerially folded" wSerially (==)
321− functorOps A.fromFoldable "asParAhead" asParAhead sortEq
321+ functorOps A.fromFoldable "asyncly" asyncly sortEq
322− functorOps folded "asParAhead folded" asParAhead sortEq
322+ functorOps folded "asyncly folded" asyncly sortEq
323− functorOps A.fromFoldable "asCoparAhead" asCoparAhead sortEq
323+ functorOps A.fromFoldable "wAsyncly" wAsyncly sortEq
324− functorOps folded "asCoparAhead folded" asCoparAhead sortEq
324+ functorOps folded "wAsyncly folded" wAsyncly sortEq
325− functorOps A.fromFoldable "asParallel" asParallel sortEq
325+ functorOps A.fromFoldable "parallely" parallely sortEq
326− functorOps folded "asParallel folded" asParallel sortEq
326+ functorOps folded "parallely folded" parallely sortEq
327− functorOps A.fromFoldable "asZipStream" asZipStream (==)
327+ functorOps A.fromFoldable "zipSerially" zipSerially (==)
328− functorOps folded "asZipStream folded" asZipStream (==)
328+ functorOps folded "zipSerially folded" zipSerially (==)
329− functorOps A.fromFoldable "asZipParallel" asZipParallel (==)
329+ functorOps A.fromFoldable "zipAsyncly" zipAsyncly (==)
330− functorOps folded "asZipParallel folded" asZipParallel (==)
330+ functorOps folded "zipAsyncly folded" zipAsyncly (==)
331
331
332 describe "Semigroup operations" $ do
332 describe "Semigroup operations" $ do
333− semigroupOps "asStream" asStream (==)
333+ semigroupOps "serially" serially (==)
334− semigroupOps "asCostream" asCostream (==)
334+ semigroupOps "wSerially" wSerially (==)
335− semigroupOps "asParAhead" asParAhead sortEq
335+ semigroupOps "asyncly" asyncly sortEq
336− semigroupOps "asCoparAhead" asCoparAhead sortEq
336+ semigroupOps "wAsyncly" wAsyncly sortEq
337− semigroupOps "asParallel" asParallel sortEq
337+ semigroupOps "parallely" parallely sortEq
338− semigroupOps "asZipStream" asZipStream (==)
338+ semigroupOps "zipSerially" zipSerially (==)
339− semigroupOps "asZipParallel" asZipParallel (==)
339+ semigroupOps "zipAsyncly" zipAsyncly (==)
340
340
341 describe "Applicative operations" $ do
341 describe "Applicative operations" $ do
342 -- The tests using sorted equality are weaker tests
342 -- The tests using sorted equality are weaker tests
343 -- We need to have stronger unit tests for all those
343 -- We need to have stronger unit tests for all those
344 -- XXX applicative with three arguments
344 -- XXX applicative with three arguments
345− prop "asStream applicative" $ applicativeOps A.fromFoldable asStream (==)
345+ prop "serially applicative" $ applicativeOps A.fromFoldable serially (==)
346− prop "asStream applicative folded" $ applicativeOps folded asStream (==)
346+ prop "serially applicative folded" $ applicativeOps folded serially (==)
347− prop "asCostream applicative" $ applicativeOps A.fromFoldable asCostream sortEq
347+ prop "wSerially applicative" $ applicativeOps A.fromFoldable wSerially sortEq
348− prop "asCostream applicative folded" $ applicativeOps folded asCostream sortEq
348+ prop "wSerially applicative folded" $ applicativeOps folded wSerially sortEq
349− prop "asParAhead applicative" $ applicativeOps A.fromFoldable asParAhead sortEq
349+ prop "asyncly applicative" $ applicativeOps A.fromFoldable asyncly sortEq
350− prop "asParAhead applicative folded" $ applicativeOps folded asParAhead sortEq
350+ prop "asyncly applicative folded" $ applicativeOps folded asyncly sortEq
351− prop "asCoparAhead applicative folded" $ applicativeOps folded asCoparAhead sortEq
351+ prop "wAsyncly applicative folded" $ applicativeOps folded wAsyncly sortEq
352− prop "asParallel applicative folded" $ applicativeOps folded asParallel sortEq
352+ prop "parallely applicative folded" $ applicativeOps folded parallely sortEq
353
353
354 describe "Zip operations" $ do
354 describe "Zip operations" $ do
355− prop "asZipStream applicative" $ zipApplicative A.fromFoldable asZipStream (==)
355+ prop "zipSerially applicative" $ zipApplicative A.fromFoldable zipSerially (==)
356 -- XXX this hangs
356 -- XXX this hangs
357− -- prop "asZipParallel applicative" $ zipApplicative asZipParallel (==)
357+ -- prop "zipAsyncly applicative" $ zipApplicative zipAsyncly (==)
358− prop "zip monadic asStream" $ zipMonadic A.fromFoldable asStream (==)
358+ prop "zip monadic serially" $ zipMonadic A.fromFoldable serially (==)
359− prop "zip monadic asStream folded" $ zipMonadic folded asStream (==)
359+ prop "zip monadic serially folded" $ zipMonadic folded serially (==)
360− prop "zip monadic asCostream" $ zipMonadic A.fromFoldable asCostream (==)
360+ prop "zip monadic wSerially" $ zipMonadic A.fromFoldable wSerially (==)
361− prop "zip monadic asCostream folded" $ zipMonadic folded asCostream (==)
361+ prop "zip monadic wSerially folded" $ zipMonadic folded wSerially (==)
362− prop "zip monadic asParAhead" $ zipMonadic A.fromFoldable asParAhead (==)
362+ prop "zip monadic asyncly" $ zipMonadic A.fromFoldable asyncly (==)
363− prop "zip monadic asParAhead folded" $ zipMonadic folded asParAhead (==)
363+ prop "zip monadic asyncly folded" $ zipMonadic folded asyncly (==)
364− prop "zip monadic asCoparAhead" $ zipMonadic A.fromFoldable asCoparAhead (==)
364+ prop "zip monadic wAsyncly" $ zipMonadic A.fromFoldable wAsyncly (==)
365− prop "zip monadic asCoparAhead folded" $ zipMonadic folded asCoparAhead (==)
365+ prop "zip monadic wAsyncly folded" $ zipMonadic folded wAsyncly (==)
366− prop "zip monadic asParallel" $ zipMonadic A.fromFoldable asParallel (==)
366+ prop "zip monadic parallely" $ zipMonadic A.fromFoldable parallely (==)
367− prop "zip monadic asParallel folded" $ zipMonadic folded asParallel (==)
367+ prop "zip monadic parallely folded" $ zipMonadic folded parallely (==)
368
368
369 describe "Monad operations" $ do
369 describe "Monad operations" $ do
370− prop "asStream monad then" $ monadThen A.fromFoldable asStream (==)
370+ prop "serially monad then" $ monadThen A.fromFoldable serially (==)
371− prop "asCostream monad then" $ monadThen A.fromFoldable asCostream sortEq
371+ prop "wSerially monad then" $ monadThen A.fromFoldable wSerially sortEq
372− prop "asParAhead monad then" $ monadThen A.fromFoldable asParAhead sortEq
372+ prop "asyncly monad then" $ monadThen A.fromFoldable asyncly sortEq
373− prop "asCoparAhead monad then" $ monadThen A.fromFoldable asCoparAhead sortEq
373+ prop "wAsyncly monad then" $ monadThen A.fromFoldable wAsyncly sortEq
374− prop "asParallel monad then" $ monadThen A.fromFoldable asParallel sortEq
374+ prop "parallely monad then" $ monadThen A.fromFoldable parallely sortEq
375−
375+
376− prop "asStream monad then folded" $ monadThen folded asStream (==)
376+ prop "serially monad then folded" $ monadThen folded serially (==)
377− prop "asCostream monad then folded" $ monadThen folded asCostream sortEq
377+ prop "wSerially monad then folded" $ monadThen folded wSerially sortEq
378− prop "asParAhead monad then folded" $ monadThen folded asParAhead sortEq
378+ prop "asyncly monad then folded" $ monadThen folded asyncly sortEq
379− prop "asCoparAhead monad then folded" $ monadThen folded asCoparAhead sortEq
379+ prop "wAsyncly monad then folded" $ monadThen folded wAsyncly sortEq
380− prop "asParallel monad then folded" $ monadThen folded asParallel sortEq
380+ prop "parallely monad then folded" $ monadThen folded parallely sortEq
381−
381+
382− prop "asStream monad bind" $ monadBind A.fromFoldable asStream (==)
382+ prop "serially monad bind" $ monadBind A.fromFoldable serially (==)
383− prop "asCostream monad bind" $ monadBind A.fromFoldable asCostream sortEq
383+ prop "wSerially monad bind" $ monadBind A.fromFoldable wSerially sortEq
384− prop "asParAhead monad bind" $ monadBind A.fromFoldable asParAhead sortEq
384+ prop "asyncly monad bind" $ monadBind A.fromFoldable asyncly sortEq
385− prop "asCoparAhead monad bind" $ monadBind A.fromFoldable asCoparAhead sortEq
385+ prop "wAsyncly monad bind" $ monadBind A.fromFoldable wAsyncly sortEq
386− prop "asParallel monad bind" $ monadBind A.fromFoldable asParallel sortEq
386+ prop "parallely monad bind" $ monadBind A.fromFoldable parallely sortEq
387
387
388 describe "Stream transform operations" $ do
388 describe "Stream transform operations" $ do
389− transformOps A.fromFoldable "asStream" asStream (==)
389+ transformOps A.fromFoldable "serially" serially (==)
390− transformOps A.fromFoldable "asCostream" asCostream (==)
390+ transformOps A.fromFoldable "wSerially" wSerially (==)
391− transformOps A.fromFoldable "asZipStream" asZipStream (==)
391+ transformOps A.fromFoldable "zipSerially" zipSerially (==)
392− transformOps A.fromFoldable "asZipParallel" asZipParallel (==)
392+ transformOps A.fromFoldable "zipAsyncly" zipAsyncly (==)
393− transformOps A.fromFoldable "asParAhead" asParAhead sortEq
393+ transformOps A.fromFoldable "asyncly" asyncly sortEq
394− transformOps A.fromFoldable "asCoparAhead" asCoparAhead sortEq
394+ transformOps A.fromFoldable "wAsyncly" wAsyncly sortEq
395− transformOps A.fromFoldable "asParallel" asParallel sortEq
395+ transformOps A.fromFoldable "parallely" parallely sortEq
396−
396+
397− transformOps folded "asStream folded" asStream (==)
397+ transformOps folded "serially folded" serially (==)
398− transformOps folded "asCostream folded" asCostream (==)
398+ transformOps folded "wSerially folded" wSerially (==)
399− transformOps folded "asZipStream folded" asZipStream (==)
399+ transformOps folded "zipSerially folded" zipSerially (==)
400− transformOps folded "asZipParallel folded" asZipParallel (==)
400+ transformOps folded "zipAsyncly folded" zipAsyncly (==)
401− transformOps folded "asParAhead folded" asParAhead sortEq
401+ transformOps folded "asyncly folded" asyncly sortEq
402− transformOps folded "asCoparAhead folded" asCoparAhead sortEq
402+ transformOps folded "wAsyncly folded" wAsyncly sortEq
403− transformOps folded "asParallel folded" asParallel sortEq
403+ transformOps folded "parallely folded" parallely sortEq
404−
404+
405− transformOpsWord8 A.fromFoldable "asStream" asStream
405+ transformOpsWord8 A.fromFoldable "serially" serially
406− transformOpsWord8 A.fromFoldable "asCostream" asCostream
406+ transformOpsWord8 A.fromFoldable "wSerially" wSerially
407− transformOpsWord8 A.fromFoldable "asZipStream" asZipStream
407+ transformOpsWord8 A.fromFoldable "zipSerially" zipSerially
408− transformOpsWord8 A.fromFoldable "asZipParallel" asZipParallel
408+ transformOpsWord8 A.fromFoldable "zipAsyncly" zipAsyncly
409− transformOpsWord8 A.fromFoldable "asParAhead" asParAhead
409+ transformOpsWord8 A.fromFoldable "asyncly" asyncly
410− transformOpsWord8 A.fromFoldable "asCoparAhead" asCoparAhead
410+ transformOpsWord8 A.fromFoldable "wAsyncly" wAsyncly
411− transformOpsWord8 A.fromFoldable "asParallel" asParallel
411+ transformOpsWord8 A.fromFoldable "parallely" parallely
412−
412+
413− transformOpsWord8 folded "asStream folded" asStream
413+ transformOpsWord8 folded "serially folded" serially
414− transformOpsWord8 folded "asCostream folded" asCostream
414+ transformOpsWord8 folded "wSerially folded" wSerially
415− transformOpsWord8 folded "asZipStream folded" asZipStream
415+ transformOpsWord8 folded "zipSerially folded" zipSerially
416− transformOpsWord8 folded "asZipParallel folded" asZipParallel
416+ transformOpsWord8 folded "zipAsyncly folded" zipAsyncly
417− transformOpsWord8 folded "asParAhead folded" asParAhead
417+ transformOpsWord8 folded "asyncly folded" asyncly
418− transformOpsWord8 folded "asCoparAhead folded" asCoparAhead
418+ transformOpsWord8 folded "wAsyncly folded" wAsyncly
419− transformOpsWord8 folded "asParallel folded" asParallel
419+ transformOpsWord8 folded "parallely folded" parallely
420
420
421 describe "Stream elimination operations" $ do
421 describe "Stream elimination operations" $ do
422− eliminationOps A.fromFoldable "asStream" asStream
422+ eliminationOps A.fromFoldable "serially" serially
423− eliminationOps A.fromFoldable "asCostream" asCostream
423+ eliminationOps A.fromFoldable "wSerially" wSerially
424− eliminationOps A.fromFoldable "asZipStream" asZipStream
424+ eliminationOps A.fromFoldable "zipSerially" zipSerially
425− eliminationOps A.fromFoldable "asZipParallel" asZipParallel
425+ eliminationOps A.fromFoldable "zipAsyncly" zipAsyncly
426− eliminationOps A.fromFoldable "asParAhead" asParAhead
426+ eliminationOps A.fromFoldable "asyncly" asyncly
427− eliminationOps A.fromFoldable "asCoparAhead" asCoparAhead
427+ eliminationOps A.fromFoldable "wAsyncly" wAsyncly
428− eliminationOps A.fromFoldable "asParallel" asParallel
428+ eliminationOps A.fromFoldable "parallely" parallely
429−
429+
430− eliminationOps folded "asStream folded" asStream
430+ eliminationOps folded "serially folded" serially
431− eliminationOps folded "asCostream folded" asCostream
431+ eliminationOps folded "wSerially folded" wSerially
432− eliminationOps folded "asZipStream folded" asZipStream
432+ eliminationOps folded "zipSerially folded" zipSerially
433− eliminationOps folded "asZipParallel folded" asZipParallel
433+ eliminationOps folded "zipAsyncly folded" zipAsyncly
434− eliminationOps folded "asParAhead folded" asParAhead
434+ eliminationOps folded "asyncly folded" asyncly
435− eliminationOps folded "asCoparAhead folded" asCoparAhead
435+ eliminationOps folded "wAsyncly folded" wAsyncly
436− eliminationOps folded "asParallel folded" asParallel
436+ eliminationOps folded "parallely folded" parallely
437
437
438 describe "Stream elimination operations" $ do
438 describe "Stream elimination operations" $ do
439− serialEliminationOps A.fromFoldable "asStream" asStream
439+ serialEliminationOps A.fromFoldable "serially" serially
440− serialEliminationOps A.fromFoldable "asCostream" asCostream
440+ serialEliminationOps A.fromFoldable "wSerially" wSerially
441− serialEliminationOps A.fromFoldable "asZipStream" asZipStream
441+ serialEliminationOps A.fromFoldable "zipSerially" zipSerially
442− serialEliminationOps A.fromFoldable "asZipParallel" asZipParallel
442+ serialEliminationOps A.fromFoldable "zipAsyncly" zipAsyncly
443−
443+
444− serialEliminationOps folded "asStream folded" asStream
444+ serialEliminationOps folded "serially folded" serially
445− serialEliminationOps folded "asCostream folded" asCostream
445+ serialEliminationOps folded "wSerially folded" wSerially
446− serialEliminationOps folded "asZipStream folded" asZipStream
446+ serialEliminationOps folded "zipSerially folded" zipSerially
447− serialEliminationOps folded "asZipParallel folded" asZipParallel
447+ serialEliminationOps folded "zipAsyncly folded" zipAsyncly
test/loops.hs+9−9
@@ -25,14 +25,14 @@ main = do
25 x <- loopHeadA 0
25 x <- loopHeadA 0
26 once $ print (x :: Int)
26 once $ print (x :: Int)
27
27
28− putStrLn $ "\ncosplice:\n"
28+ putStrLn $ "\nwSerial:\n"
29 runStream $ do
29 runStream $ do
30− x <- (return 0 <> return 1) `cosplice` (return 100 <> return 101)
30+ x <- (return 0 <> return 1) `wSerial` (return 100 <> return 101)
31 once $ print (x :: Int)
31 once $ print (x :: Int)
32
32
33 putStrLn $ "\nParallel interleave:\n"
33 putStrLn $ "\nParallel interleave:\n"
34 runStream $ do
34 runStream $ do
35− x <- (return 0 <> return 1) `coparAhead` (return 100 <> return 101)
35+ x <- (return 0 <> return 1) `wAsync` (return 100 <> return 101)
36 once $ print (x :: Int)
36 once $ print (x :: Int)
37
37
38 where
38 where
@@ -43,7 +43,7 @@ main = do
43
43
44 -- Generates a value and then loops. Can be used to generate an infinite
44 -- Generates a value and then loops. Can be used to generate an infinite
45 -- stream. Interleaves the generator and the consumer.
45 -- stream. Interleaves the generator and the consumer.
46− loopTail :: Int -> Stream Int
46+ loopTail :: Int -> Serial Int
47 loopTail x = do
47 loopTail x = do
48 once $ putStrLn "LoopTail..."
48 once $ putStrLn "LoopTail..."
49 return x <> (if x < 3 then loopTail (x + 1) else nil)
49 return x <> (if x < 3 then loopTail (x + 1) else nil)
@@ -51,7 +51,7 @@ main = do
51 -- Loops and then generates a value. The consumer can run only after the
51 -- Loops and then generates a value. The consumer can run only after the
52 -- loop has finished. An infinite generator will not let the consumer run
52 -- loop has finished. An infinite generator will not let the consumer run
53 -- at all.
53 -- at all.
54− loopHead :: Int -> Stream Int
54+ loopHead :: Int -> Serial Int
55 loopHead x = do
55 loopHead x = do
56 once $ putStrLn "LoopHead..."
56 once $ putStrLn "LoopHead..."
57 (if x < 3 then loopHead (x + 1) else nil) <> return x
57 (if x < 3 then loopHead (x + 1) else nil) <> return x
@@ -60,15 +60,15 @@ main = do
60-- Concurrent (multi-threaded) adaptive demand-based stream generator loops
60-- Concurrent (multi-threaded) adaptive demand-based stream generator loops
61-------------------------------------------------------------------------------
61-------------------------------------------------------------------------------
62
62
63− loopTailA :: Int -> Stream Int
63+ loopTailA :: Int -> Serial Int
64 loopTailA x = do
64 loopTailA x = do
65 once $ putStrLn "LoopTailA..."
65 once $ putStrLn "LoopTailA..."
66− return x `parAhead` (if x < 3 then loopTailA (x + 1) else nil)
66+ return x `async` (if x < 3 then loopTailA (x + 1) else nil)
67
67
68− loopHeadA :: Int -> Stream Int
68+ loopHeadA :: Int -> Serial Int
69 loopHeadA x = do
69 loopHeadA x = do
70 once $ putStrLn "LoopHeadA..."
70 once $ putStrLn "LoopHeadA..."
71− (if x < 3 then loopHeadA (x + 1) else nil) `parAhead` return x
71+ (if x < 3 then loopHeadA (x + 1) else nil) `async` return x
72
72
73-------------------------------------------------------------------------------
73-------------------------------------------------------------------------------
74-- Parallel (fairly scheduled, multi-threaded) stream generator loops
74-- Parallel (fairly scheduled, multi-threaded) stream generator loops
test/nested-loops.hs+2−2
@@ -16,9 +16,9 @@ main = runStream $ do
16
16
17 -- we can just use
17 -- we can just use
18 -- parallely $ mconcat $ replicate n $ once (...)
18 -- parallely $ mconcat $ replicate n $ once (...)
19− loop :: String -> Int -> StreamT IO String
19+ loop :: String -> Int -> SerialT IO String
20 loop name n = do
20 loop name n = do
21 rnd <- once (randomIO :: IO Int)
21 rnd <- once (randomIO :: IO Int)
22 let result = (name ++ show rnd)
22 let result = (name ++ show rnd)
23 repeat = if n > 1 then loop name (n - 1) else nil
23 repeat = if n > 1 then loop name (n - 1) else nil
24− in (return result) `coparAhead` repeat
24+ in (return result) `wAsync` repeat
test/parallel-loops.hs+3−3
@@ -7,7 +7,7 @@ import qualified Streamly.Prelude as S
7main = do
7main = do
8 hSetBuffering stdout LineBuffering
8 hSetBuffering stdout LineBuffering
9 runStream $ do
9 runStream $ do
10− x <- S.take 10 $ loop "A" `coparAhead` loop "B"
10+ x <- S.take 10 $ loop "A" `parallel` loop "B"
11 S.once $ myThreadId >>= putStr . show
11 S.once $ myThreadId >>= putStr . show
12 >> putStr " got "
12 >> putStr " got "
13 >> print x
13 >> print x
@@ -16,11 +16,11 @@ main = do
16
16
17 -- we can just use
17 -- we can just use
18 -- parallely $ cycle1 $ once (...)
18 -- parallely $ cycle1 $ once (...)
19− loop :: String -> Stream (String, Int)
19+ loop :: String -> Serial (String, Int)
20 loop name = do
20 loop name = do
21 S.once $ threadDelay 1000000
21 S.once $ threadDelay 1000000
22 rnd <- S.once (randomIO :: IO Int)
22 rnd <- S.once (randomIO :: IO Int)
23 S.once $ myThreadId >>= putStr . show
23 S.once $ myThreadId >>= putStr . show
24 >> putStr " yielding "
24 >> putStr " yielding "
25 >> print rnd
25 >> print rnd
26− return (name, rnd) `coparAhead` loop name
26+ return (name, rnd) `parallel` loop name