@@ -102,10 +102,13 @@ main = hspec $ do
102102 describe "Parallel interleaved (<>) ordering check" $ interleaveCheck asCoparAhead (<>)
103103 describe "Parallel interleaved mappend ordering check" $ interleaveCheck asCoparAhead mappend
104104
105− describe "Coparallel (<>) time order check" $ parallelCheck asParAhead (<>)
106− describe "Coparallel mappend time order check" $ parallelCheck asParAhead mappend
107− describe "Parallel (<>) time order check" $ parallelCheck asCoparAhead (<>)
108− describe "Parallel mappend time order check" $ parallelCheck asCoparAhead mappend
105+ -- describe "Parallel (<>) ordering check" $ interleaveCheck asParallel (<>)
106+ -- describe "Parallel mappend ordering check" $ interleaveCheck asParallel mappend
107+
108+ describe "ParAhead (<>) time order check" $ parallelCheck asParAhead (<>)
109+ describe "ParAhead mappend time order check" $ parallelCheck asParAhead mappend
110+ describe "CoparAhead (<>) time order check" $ parallelCheck asCoparAhead (<>)
111+ describe "CoparAhead mappend time order check" $ parallelCheck asCoparAhead mappend
109112
110113 ---------------------------------------------------------------------------
111114 -- Monoidal Compositions, multiset equality checks
@@ -113,8 +116,9 @@ main = hspec $ do
113116
114117 describe "Serial Composition" $ compose asStream mempty id
115118 describe "Interleaved Composition" $ compose asCostream mempty sort
116− describe "Left biased parallel Composition" $ compose asParAhead mempty sort
117− describe "Fair parallel Composition" $ compose asCoparAhead mempty sort
119+ describe "ParAhead Composition" $ compose asParAhead mempty sort
120+ describe "CoparAhead Composition" $ compose asCoparAhead mempty sort
121+ describe "Parallel Composition" $ compose asParallel mempty sort
118122 describe "Semigroup Composition for ZipSerial" $ compose asZipStream mempty id
119123 describe "Semigroup Composition for ZipAsync" $ compose asZipParallel mempty id
120124 -- XXX need to check alternative compositions as well
@@ -198,33 +202,44 @@ main = hspec $ do
198202 -- Monoidal composition recursion loops
199203 ---------------------------------------------------------------------------
200204
201− describe "Serial loops (<>)" $ loops asStream id reverse
202− describe "Left biased parallel loops (<|)" $ loops asParAhead sort sort
203− describe "Fair parallel loops (<|>)" $ loops asCoparAhead sort sort
205+ describe "Serial loops" $ loops asStream id reverse
206+ describe "ParAhead parallel loops" $ loops asParAhead sort sort
207+ describe "coparAhead loops" $ loops asCoparAhead sort sort
208+ describe "parallel loops" $ loops asParallel sort sort
204209
205210 ---------------------------------------------------------------------------
206211 -- Bind and monoidal composition combinations
207212 ---------------------------------------------------------------------------
208213
209− describe "Bind and compose1" $ bindAndComposeSimple asStream asStream
210− describe "Bind and compose2" $ bindAndComposeSimple asStream asCostream
211− describe "Bind and compose3" $ bindAndComposeSimple asStream asParAhead
212− describe "Bind and compose4" $ bindAndComposeSimple asStream asCoparAhead
213−
214− describe "Bind and compose1" $ bindAndComposeSimple asCostream asStream
215− describe "Bind and compose2" $ bindAndComposeSimple asCostream asCostream
216− describe "Bind and compose3" $ bindAndComposeSimple asCostream asParAhead
217− describe "Bind and compose4" $ bindAndComposeSimple asCostream asCoparAhead
218−
219− describe "Bind and compose1" $ bindAndComposeSimple asParAhead asStream
220− describe "Bind and compose2" $ bindAndComposeSimple asParAhead asCostream
221− describe "Bind and compose3" $ bindAndComposeSimple asParAhead asParAhead
222− describe "Bind and compose4" $ bindAndComposeSimple asParAhead asCoparAhead
223−
224− describe "Bind and compose1" $ bindAndComposeSimple asCoparAhead asStream
225− describe "Bind and compose2" $ bindAndComposeSimple asCoparAhead asCostream
226− describe "Bind and compose3" $ bindAndComposeSimple asCoparAhead asParAhead
227− describe "Bind and compose4" $ bindAndComposeSimple asCoparAhead asCoparAhead
214+ describe "Bind and compose Stream 1" $ bindAndComposeSimple asStream asStream
215+ describe "Bind and compose Stream 2" $ bindAndComposeSimple asStream asCostream
216+ describe "Bind and compose Stream 3" $ bindAndComposeSimple asStream asParAhead
217+ describe "Bind and compose Stream 4" $ bindAndComposeSimple asStream asCoparAhead
218+ describe "Bind and compose Stream 5" $ bindAndComposeSimple asStream asParallel
219+
220+ describe "Bind and compose Costream 1" $ bindAndComposeSimple asCostream asStream
221+ describe "Bind and compose Costream 2" $ bindAndComposeSimple asCostream asCostream
222+ describe "Bind and compose Costream 3" $ bindAndComposeSimple asCostream asParAhead
223+ describe "Bind and compose Costream 4" $ bindAndComposeSimple asCostream asCoparAhead
224+ describe "Bind and compose Costream 5" $ bindAndComposeSimple asCostream asParallel
225+
226+ describe "Bind and compose ParAhead 1" $ bindAndComposeSimple asParAhead asStream
227+ describe "Bind and compose ParAhead 2" $ bindAndComposeSimple asParAhead asCostream
228+ describe "Bind and compose ParAhead 3" $ bindAndComposeSimple asParAhead asParAhead
229+ describe "Bind and compose ParAhead 4" $ bindAndComposeSimple asParAhead asCoparAhead
230+ describe "Bind and compose ParAhead 5" $ bindAndComposeSimple asParAhead asParallel
231+
232+ describe "Bind and compose CoparAhead 1" $ bindAndComposeSimple asCoparAhead asStream
233+ describe "Bind and compose CoparAhead 2" $ bindAndComposeSimple asCoparAhead asCostream
234+ describe "Bind and compose CoparAhead 3" $ bindAndComposeSimple asCoparAhead asParAhead
235+ describe "Bind and compose CoparAhead 4" $ bindAndComposeSimple asCoparAhead asCoparAhead
236+ describe "Bind and compose CoparAhead 5" $ bindAndComposeSimple asCoparAhead asParallel
237+
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
228243
229244 let fldr, fldl :: (IsStream t, Semigroup (t IO Int)) => [t IO Int] -> t IO Int
230245 fldr = foldr (<>) nil
@@ -238,6 +253,8 @@ main = hspec $ do
238253 describe "Bind and compose" $ bindAndComposeHierarchy asStream asParAhead k
239254 forM_ [fldr, fldl] $ \k ->
240255 describe "Bind and compose" $ bindAndComposeHierarchy asStream asCoparAhead k
256+ forM_ [fldr, fldl] $ \k ->
257+ describe "Bind and compose" $ bindAndComposeHierarchy asStream asParallel k
241258
242259 forM_ [fldr, fldl] $ \k ->
243260 describe "Bind and compose" $ bindAndComposeHierarchy asCostream asStream k
@@ -247,6 +264,8 @@ main = hspec $ do
247264 describe "Bind and compose" $ bindAndComposeHierarchy asCostream asParAhead k
248265 forM_ [fldr, fldl] $ \k ->
249266 describe "Bind and compose" $ bindAndComposeHierarchy asCostream asCoparAhead k
267+ forM_ [fldr, fldl] $ \k ->
268+ describe "Bind and compose" $ bindAndComposeHierarchy asCostream asParallel k
250269
251270 forM_ [fldr, fldl] $ \k ->
252271 describe "Bind and compose" $ bindAndComposeHierarchy asParAhead asStream k
@@ -256,6 +275,8 @@ main = hspec $ do
256275 describe "Bind and compose" $ bindAndComposeHierarchy asParAhead asParAhead k
257276 forM_ [fldr, fldl] $ \k ->
258277 describe "Bind and compose" $ bindAndComposeHierarchy asParAhead asCoparAhead k
278+ forM_ [fldr, fldl] $ \k ->
279+ describe "Bind and compose" $ bindAndComposeHierarchy asParAhead asParallel k
259280
260281 forM_ [fldr, fldl] $ \k ->
261282 describe "Bind and compose" $ bindAndComposeHierarchy asCoparAhead asStream k
@@ -265,16 +286,31 @@ main = hspec $ do
265286 describe "Bind and compose" $ bindAndComposeHierarchy asCoparAhead asParAhead k
266287 forM_ [fldr, fldl] $ \k ->
267288 describe "Bind and compose" $ bindAndComposeHierarchy asCoparAhead asCoparAhead k
289+ forM_ [fldr, fldl] $ \k ->
290+ describe "Bind and compose" $ bindAndComposeHierarchy asCoparAhead asParallel k
291+
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
268302
269303 -- Nest two lists using different styles of product compositions
270304 it "Nests two streams using monadic serial composition" nestTwoSerial
271305 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
273308 it "Nests two streams using monadic parallel composition" nestTwoParallel
274309
275310 it "Nests two streams using applicative serial composition" nestTwoSerialApp
276311 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
278314 it "Nests two streams using applicative parallel composition" nestTwoParallelApp
279315
280316 ---------------------------------------------------------------------------
@@ -296,6 +332,7 @@ main = hspec $ do
296332 describe "Composed MonadThrow asCostream" $ composeWithMonadThrow asCostream
297333 describe "Composed MonadThrow asParAhead" $ composeWithMonadThrow asParAhead
298334 describe "Composed MonadThrow asCoparAhead" $ composeWithMonadThrow asCoparAhead
335+ describe "Composed MonadThrow asParallel" $ composeWithMonadThrow asParallel
299336
300337-- XXX need to test that we have promptly cleaned up everything after the error
301338-- XXX We can also check the output that we are expected to get before the
@@ -432,22 +469,40 @@ nestTwoAsyncApp =
432469 in (toListAsync ((+) <$> s1 <*> s2) >>= return . sort)
433470 `shouldReturn` sort ([6,7,8,9,7,8,9,10,8,9,10,11,9,10,11,12] :: [Int])
434471
472+nestTwoCoparAhead :: Expectation
473+nestTwoCoparAhead =
474+ let s1 = foldMapWith (<>) return [1..4]
475+ s2 = foldMapWith (<>) return [5..8]
476+ in ((A.toList . asCoparAhead) (do
477+ x <- s1
478+ y <- s2
479+ return (x + y)
480+ ) >>= return . sort)
481+ `shouldReturn` sort ([6,7,7,8,8,8,9,9,9,9,10,10,10,11,11,12] :: [Int])
482+
435483nestTwoParallel :: Expectation
436484nestTwoParallel =
437485 let s1 = foldMapWith (<>) return [1..4]
438486 s2 = foldMapWith (<>) return [5..8]
439− in (toListParallel (do
487+ in ((A.toList . asParallel) (do
440488 x <- s1
441489 y <- s2
442490 return (x + y)
443491 ) >>= return . sort)
444492 `shouldReturn` sort ([6,7,7,8,8,8,9,9,9,9,10,10,10,11,11,12] :: [Int])
445493
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])
500+
446501nestTwoParallelApp :: Expectation
447502nestTwoParallelApp =
448503 let s1 = foldMapWith (<>) return [1..4]
449504 s2 = foldMapWith (<>) return [5..8]
450− in (toListParallel ((+) <$> s1 <*> s2) >>= return . sort)
505+ in ((A.toList . asParallel) ((+) <$> s1 <*> s2) >>= return . sort)
451506 `shouldReturn` sort ([6,7,7,8,8,8,9,9,9,9,10,10,10,11,11,12] :: [Int])
452507
453508timed :: (IsStream t, Monad (t IO)) => Int -> t IO Int