@@ -102,10 +102,13 @@ main = hspec $ do
102 describe "Parallel interleaved (<>) ordering check" $ interleaveCheck asCoparAhead (<>)
102 describe "Parallel interleaved (<>) ordering check" $ interleaveCheck asCoparAhead (<>)
103 describe "Parallel interleaved mappend ordering check" $ interleaveCheck asCoparAhead mappend
103 describe "Parallel interleaved mappend ordering check" $ interleaveCheck asCoparAhead mappend
105+ -- describe "Parallel (<>) ordering check" $ interleaveCheck asParallel (<>)
106+ -- describe "Parallel mappend ordering check" $ interleaveCheck asParallel mappend
105− describe "Coparallel (<>) time order check" $ parallelCheck asParAhead (<>)
108+ describe "ParAhead (<>) time order check" $ parallelCheck asParAhead (<>)
106− describe "Coparallel mappend time order check" $ parallelCheck asParAhead mappend
109+ describe "ParAhead mappend time order check" $ parallelCheck asParAhead mappend
107− describe "Parallel (<>) time order check" $ parallelCheck asCoparAhead (<>)
110+ describe "CoparAhead (<>) time order check" $ parallelCheck asCoparAhead (<>)
108− describe "Parallel mappend time order check" $ parallelCheck asCoparAhead mappend
111+ describe "CoparAhead mappend time order check" $ parallelCheck asCoparAhead mappend
110 ---------------------------------------------------------------------------
113 ---------------------------------------------------------------------------
111 -- Monoidal Compositions, multiset equality checks
114 -- Monoidal Compositions, multiset equality checks
@@ -113,8 +116,9 @@ main = hspec $ do
114 describe "Serial Composition" $ compose asStream mempty id
117 describe "Serial Composition" $ compose asStream mempty id
115 describe "Interleaved Composition" $ compose asCostream mempty sort
118 describe "Interleaved Composition" $ compose asCostream mempty sort
116− describe "Left biased parallel Composition" $ compose asParAhead mempty sort
119+ describe "ParAhead Composition" $ compose asParAhead mempty sort
117− describe "Fair parallel Composition" $ compose asCoparAhead mempty sort
120+ describe "CoparAhead Composition" $ compose asCoparAhead mempty sort
121+ describe "Parallel Composition" $ compose asParallel mempty sort
118 describe "Semigroup Composition for ZipSerial" $ compose asZipStream mempty id
122 describe "Semigroup Composition for ZipSerial" $ compose asZipStream mempty id
119 describe "Semigroup Composition for ZipAsync" $ compose asZipParallel mempty id
123 describe "Semigroup Composition for ZipAsync" $ compose asZipParallel mempty id
120 -- XXX need to check alternative compositions as well
124 -- XXX need to check alternative compositions as well
@@ -198,33 +202,44 @@ main = hspec $ do
198 -- Monoidal composition recursion loops
202 -- Monoidal composition recursion loops
199 ---------------------------------------------------------------------------
203 ---------------------------------------------------------------------------
201− describe "Serial loops (<>)" $ loops asStream id reverse
205+ describe "Serial loops" $ loops asStream id reverse
202− describe "Left biased parallel loops (<|)" $ loops asParAhead sort sort
206+ describe "ParAhead parallel loops" $ loops asParAhead sort sort
203− describe "Fair parallel loops (<|>)" $ loops asCoparAhead sort sort
207+ describe "coparAhead loops" $ loops asCoparAhead sort sort
208+ describe "parallel loops" $ loops asParallel sort sort
205 ---------------------------------------------------------------------------
210 ---------------------------------------------------------------------------
206 -- Bind and monoidal composition combinations
211 -- Bind and monoidal composition combinations
207 ---------------------------------------------------------------------------
212 ---------------------------------------------------------------------------
209− describe "Bind and compose1" $ bindAndComposeSimple asStream asStream
214+ describe "Bind and compose Stream 1" $ bindAndComposeSimple asStream asStream
210− describe "Bind and compose2" $ bindAndComposeSimple asStream asCostream
215+ describe "Bind and compose Stream 2" $ bindAndComposeSimple asStream asCostream
211− describe "Bind and compose3" $ bindAndComposeSimple asStream asParAhead
216+ describe "Bind and compose Stream 3" $ bindAndComposeSimple asStream asParAhead
212− describe "Bind and compose4" $ bindAndComposeSimple asStream asCoparAhead
217+ describe "Bind and compose Stream 4" $ bindAndComposeSimple asStream asCoparAhead
213−
218+ describe "Bind and compose Stream 5" $ bindAndComposeSimple asStream asParallel
214− describe "Bind and compose1" $ bindAndComposeSimple asCostream asStream
220+ describe "Bind and compose Costream 1" $ bindAndComposeSimple asCostream asStream
215− describe "Bind and compose2" $ bindAndComposeSimple asCostream asCostream
221+ describe "Bind and compose Costream 2" $ bindAndComposeSimple asCostream asCostream
216− describe "Bind and compose3" $ bindAndComposeSimple asCostream asParAhead
222+ describe "Bind and compose Costream 3" $ bindAndComposeSimple asCostream asParAhead
217− describe "Bind and compose4" $ bindAndComposeSimple asCostream asCoparAhead
223+ describe "Bind and compose Costream 4" $ bindAndComposeSimple asCostream asCoparAhead
218−
224+ describe "Bind and compose Costream 5" $ bindAndComposeSimple asCostream asParallel
219− describe "Bind and compose1" $ bindAndComposeSimple asParAhead asStream
226+ describe "Bind and compose ParAhead 1" $ bindAndComposeSimple asParAhead asStream
220− describe "Bind and compose2" $ bindAndComposeSimple asParAhead asCostream
227+ describe "Bind and compose ParAhead 2" $ bindAndComposeSimple asParAhead asCostream
221− describe "Bind and compose3" $ bindAndComposeSimple asParAhead asParAhead
228+ describe "Bind and compose ParAhead 3" $ bindAndComposeSimple asParAhead asParAhead
222− describe "Bind and compose4" $ bindAndComposeSimple asParAhead asCoparAhead
229+ describe "Bind and compose ParAhead 4" $ bindAndComposeSimple asParAhead asCoparAhead
223−
230+ describe "Bind and compose ParAhead 5" $ bindAndComposeSimple asParAhead asParallel
224− describe "Bind and compose1" $ bindAndComposeSimple asCoparAhead asStream
232+ describe "Bind and compose CoparAhead 1" $ bindAndComposeSimple asCoparAhead asStream
225− describe "Bind and compose2" $ bindAndComposeSimple asCoparAhead asCostream
233+ describe "Bind and compose CoparAhead 2" $ bindAndComposeSimple asCoparAhead asCostream
226− describe "Bind and compose3" $ bindAndComposeSimple asCoparAhead asParAhead
234+ describe "Bind and compose CoparAhead 3" $ bindAndComposeSimple asCoparAhead asParAhead
235+ describe "Bind and compose CoparAhead 4" $ bindAndComposeSimple asCoparAhead asCoparAhead
227− describe "Bind and compose4" $ bindAndComposeSimple asCoparAhead asCoparAhead
236+ describe "Bind and compose CoparAhead 5" $ bindAndComposeSimple asCoparAhead asParallel
238+ describe "Bind and compose Parallel 1" $ bindAndComposeSimple asParallel asStream
239+ describe "Bind and compose Parallel 2" $ bindAndComposeSimple asParallel asCostream
240+ describe "Bind and compose Parallel 3" $ bindAndComposeSimple asParallel asParAhead
241+ describe "Bind and compose Parallel 4" $ bindAndComposeSimple asParallel asCoparAhead
242+ describe "Bind and compose Parallel 5" $ bindAndComposeSimple asParallel asParallel
229 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
230 fldr = foldr (<>) nil
245 fldr = foldr (<>) nil
@@ -238,6 +253,8 @@ main = hspec $ do
238 describe "Bind and compose" $ bindAndComposeHierarchy asStream asParAhead k
253 describe "Bind and compose" $ bindAndComposeHierarchy asStream asParAhead k
239 forM_ [fldr, fldl] $ \k ->
254 forM_ [fldr, fldl] $ \k ->
240 describe "Bind and compose" $ bindAndComposeHierarchy asStream asCoparAhead k
255 describe "Bind and compose" $ bindAndComposeHierarchy asStream asCoparAhead k
256+ forM_ [fldr, fldl] $ \k ->
257+ describe "Bind and compose" $ bindAndComposeHierarchy asStream asParallel k
242 forM_ [fldr, fldl] $ \k ->
259 forM_ [fldr, fldl] $ \k ->
243 describe "Bind and compose" $ bindAndComposeHierarchy asCostream asStream k
260 describe "Bind and compose" $ bindAndComposeHierarchy asCostream asStream k
@@ -247,6 +264,8 @@ main = hspec $ do
247 describe "Bind and compose" $ bindAndComposeHierarchy asCostream asParAhead k
264 describe "Bind and compose" $ bindAndComposeHierarchy asCostream asParAhead k
248 forM_ [fldr, fldl] $ \k ->
265 forM_ [fldr, fldl] $ \k ->
249 describe "Bind and compose" $ bindAndComposeHierarchy asCostream asCoparAhead k
266 describe "Bind and compose" $ bindAndComposeHierarchy asCostream asCoparAhead k
267+ forM_ [fldr, fldl] $ \k ->
268+ describe "Bind and compose" $ bindAndComposeHierarchy asCostream asParallel k
251 forM_ [fldr, fldl] $ \k ->
270 forM_ [fldr, fldl] $ \k ->
252 describe "Bind and compose" $ bindAndComposeHierarchy asParAhead asStream k
271 describe "Bind and compose" $ bindAndComposeHierarchy asParAhead asStream k
@@ -256,6 +275,8 @@ main = hspec $ do
256 describe "Bind and compose" $ bindAndComposeHierarchy asParAhead asParAhead k
275 describe "Bind and compose" $ bindAndComposeHierarchy asParAhead asParAhead k
257 forM_ [fldr, fldl] $ \k ->
276 forM_ [fldr, fldl] $ \k ->
258 describe "Bind and compose" $ bindAndComposeHierarchy asParAhead asCoparAhead k
277 describe "Bind and compose" $ bindAndComposeHierarchy asParAhead asCoparAhead k
278+ forM_ [fldr, fldl] $ \k ->
279+ describe "Bind and compose" $ bindAndComposeHierarchy asParAhead asParallel k
260 forM_ [fldr, fldl] $ \k ->
281 forM_ [fldr, fldl] $ \k ->
261 describe "Bind and compose" $ bindAndComposeHierarchy asCoparAhead asStream k
282 describe "Bind and compose" $ bindAndComposeHierarchy asCoparAhead asStream k
@@ -265,16 +286,31 @@ main = hspec $ do
265 describe "Bind and compose" $ bindAndComposeHierarchy asCoparAhead asParAhead k
286 describe "Bind and compose" $ bindAndComposeHierarchy asCoparAhead asParAhead k
266 forM_ [fldr, fldl] $ \k ->
287 forM_ [fldr, fldl] $ \k ->
267 describe "Bind and compose" $ bindAndComposeHierarchy asCoparAhead asCoparAhead k
288 describe "Bind and compose" $ bindAndComposeHierarchy asCoparAhead asCoparAhead k
289+ forM_ [fldr, fldl] $ \k ->
290+ describe "Bind and compose" $ bindAndComposeHierarchy asCoparAhead asParallel k
292+ forM_ [fldr, fldl] $ \k ->
293+ describe "Bind and compose" $ bindAndComposeHierarchy asParallel asStream k
294+ forM_ [fldr, fldl] $ \k ->
295+ describe "Bind and compose" $ bindAndComposeHierarchy asParallel asCostream k
296+ forM_ [fldr, fldl] $ \k ->
297+ describe "Bind and compose" $ bindAndComposeHierarchy asParallel asParAhead k
298+ forM_ [fldr, fldl] $ \k ->
299+ describe "Bind and compose" $ bindAndComposeHierarchy asParallel asCoparAhead k
300+ forM_ [fldr, fldl] $ \k ->
301+ describe "Bind and compose" $ bindAndComposeHierarchy asParallel asParallel k
269 -- Nest two lists using different styles of product compositions
303 -- Nest two lists using different styles of product compositions
270 it "Nests two streams using monadic serial composition" nestTwoSerial
304 it "Nests two streams using monadic serial composition" nestTwoSerial
271 it "Nests two streams using monadic interleaved composition" nestTwoInterleaved
305 it "Nests two streams using monadic interleaved composition" nestTwoInterleaved
272− it "Nests two streams using monadic async composition" nestTwoAsync
306+ it "Nests two streams using monadic parAhead composition" nestTwoAsync
307+ it "Nests two streams using monadic CoparAhead composition" nestTwoCoparAhead
273 it "Nests two streams using monadic parallel composition" nestTwoParallel
308 it "Nests two streams using monadic parallel composition" nestTwoParallel
275 it "Nests two streams using applicative serial composition" nestTwoSerialApp
310 it "Nests two streams using applicative serial composition" nestTwoSerialApp
276 it "Nests two streams using applicative interleaved composition" nestTwoInterleavedApp
311 it "Nests two streams using applicative interleaved composition" nestTwoInterleavedApp
277− it "Nests two streams using applicative async composition" nestTwoAsyncApp
312+ it "Nests two streams using applicative parAhead composition" nestTwoAsyncApp
313+ it "Nests two streams using applicative CoparAhead composition" nestTwoCoparAheadApp
278 it "Nests two streams using applicative parallel composition" nestTwoParallelApp
314 it "Nests two streams using applicative parallel composition" nestTwoParallelApp
280 ---------------------------------------------------------------------------
316 ---------------------------------------------------------------------------
@@ -296,6 +332,7 @@ main = hspec $ do
296 describe "Composed MonadThrow asCostream" $ composeWithMonadThrow asCostream
332 describe "Composed MonadThrow asCostream" $ composeWithMonadThrow asCostream
297 describe "Composed MonadThrow asParAhead" $ composeWithMonadThrow asParAhead
333 describe "Composed MonadThrow asParAhead" $ composeWithMonadThrow asParAhead
298 describe "Composed MonadThrow asCoparAhead" $ composeWithMonadThrow asCoparAhead
334 describe "Composed MonadThrow asCoparAhead" $ composeWithMonadThrow asCoparAhead
335+ describe "Composed MonadThrow asParallel" $ composeWithMonadThrow asParallel
300-- XXX need to test that we have promptly cleaned up everything after the error
337-- XXX need to test that we have promptly cleaned up everything after the error
301-- XXX We can also check the output that we are expected to get before the
338-- XXX We can also check the output that we are expected to get before the
@@ -432,22 +469,40 @@ nestTwoAsyncApp =
432 in (toListAsync ((+) <$> s1 <*> s2) >>= return . sort)
469 in (toListAsync ((+) <$> s1 <*> s2) >>= return . sort)
433 `shouldReturn` sort ([6,7,8,9,7,8,9,10,8,9,10,11,9,10,11,12] :: [Int])
470 `shouldReturn` sort ([6,7,8,9,7,8,9,10,8,9,10,11,9,10,11,12] :: [Int])
472+nestTwoCoparAhead :: Expectation
474+ let s1 = foldMapWith (<>) return [1..4]
475+ s2 = foldMapWith (<>) return [5..8]
476+ in ((A.toList . asCoparAhead) (do
480+ ) >>= return . sort)
481+ `shouldReturn` sort ([6,7,7,8,8,8,9,9,9,9,10,10,10,11,11,12] :: [Int])
435nestTwoParallel :: Expectation
483nestTwoParallel :: Expectation
436nestTwoParallel =
484nestTwoParallel =
437 let s1 = foldMapWith (<>) return [1..4]
485 let s1 = foldMapWith (<>) return [1..4]
438 s2 = foldMapWith (<>) return [5..8]
486 s2 = foldMapWith (<>) return [5..8]
439− in (toListParallel (do
487+ in ((A.toList . asParallel) (do
442 return (x + y)
490 return (x + y)
443 ) >>= return . sort)
491 ) >>= return . sort)
444 `shouldReturn` sort ([6,7,7,8,8,8,9,9,9,9,10,10,10,11,11,12] :: [Int])
492 `shouldReturn` sort ([6,7,7,8,8,8,9,9,9,9,10,10,10,11,11,12] :: [Int])
494+nestTwoCoparAheadApp :: Expectation
495+nestTwoCoparAheadApp =
496+ let s1 = foldMapWith (<>) return [1..4]
497+ s2 = foldMapWith (<>) return [5..8]
498+ in ((A.toList . asCoparAhead) ((+) <$> s1 <*> s2) >>= return . sort)
499+ `shouldReturn` sort ([6,7,7,8,8,8,9,9,9,9,10,10,10,11,11,12] :: [Int])
446nestTwoParallelApp :: Expectation
501nestTwoParallelApp :: Expectation
447nestTwoParallelApp =
502nestTwoParallelApp =
448 let s1 = foldMapWith (<>) return [1..4]
503 let s1 = foldMapWith (<>) return [1..4]
449 s2 = foldMapWith (<>) return [5..8]
504 s2 = foldMapWith (<>) return [5..8]
450− in (toListParallel ((+) <$> s1 <*> s2) >>= return . sort)
505+ in ((A.toList . asParallel) ((+) <$> s1 <*> s2) >>= return . sort)
451 `shouldReturn` sort ([6,7,7,8,8,8,9,9,9,9,10,10,10,11,11,12] :: [Int])
506 `shouldReturn` sort ([6,7,7,8,8,8,9,9,9,9,10,10,10,11,11,12] :: [Int])
453timed :: (IsStream t, Monad (t IO)) => Int -> t IO Int
508timed :: (IsStream t, Monad (t IO)) => Int -> t IO Int