@@ -14,20 +14,20 @@ import qualified Asyncly.Prelude as A
1414main :: IO ()
1515main = hspec $ do
1616 describe "Runners" $ do
17− it "simple runAsyncly" $
18− runAsyncly (return (0 :: Int)) `shouldReturn` ()
19− it "simple runAsyncly with IO" $
20− runAsyncly (liftIO $ putStrLn "hello") `shouldReturn` ()
17+ it "simple serially" $
18+ serially (return (0 :: Int)) `shouldReturn` ()
19+ it "simple serially with IO" $
20+ serially (liftIO $ putStrLn "hello") `shouldReturn` ()
2121 it "Captures a return value using toList" $
22− toList (return 0) `shouldReturn` ([0] :: [Int])
22+ toListSerial (return 0) `shouldReturn` ([0] :: [Int])
2323
2424 describe "Empty" $ do
2525 it "Monoid - mempty" $
26− (toList mempty) `shouldReturn` ([] :: [Int])
26+ (toListSerial mempty) `shouldReturn` ([] :: [Int])
2727 it "Alternative - empty" $
28− (toList empty) `shouldReturn` ([] :: [Int])
28+ (toListSerial empty) `shouldReturn` ([] :: [Int])
2929 it "MonadPlus - mzero" $
30− (toList mzero) `shouldReturn` ([] :: [Int])
30+ (toListSerial mzero) `shouldReturn` ([] :: [Int])
3131
3232 ---------------------------------------------------------------------------
3333 -- Functor
@@ -35,12 +35,12 @@ main = hspec $ do
3535
3636 describe "Functor (fmap)" $ do
3737 it "Simple fmap" $
38− (toList $ fmap (+1) (return 1)) `shouldReturn` ([2] :: [Int])
38+ (toListSerial $ fmap (+1) (return 1)) `shouldReturn` ([2] :: [Int])
3939 it "fmap on composed (<>)" $
40− (toList $ fmap (+1) (return 1 <> return 2))
40+ (toListSerial $ fmap (+1) (return 1 <> return 2))
4141 `shouldReturn` ([2,3] :: [Int])
4242 it "fmap on composed (<|>)" $
43− (toList $ fmap (+1) (return 1 <|> return 2))
43+ (toListSerial $ fmap (+1) (return 1 <|> return 2))
4444 `shouldReturn` ([2,3] :: [Int])
4545
4646 ---------------------------------------------------------------------------
@@ -49,23 +49,23 @@ main = hspec $ do
4949
5050 describe "Applicative" $ do
5151 it "Simple apply" $
52− (toList $ (,) <$> (return 1) <*> (return 2))
52+ (toListSerial $ (,) <$> (return 1) <*> (return 2))
5353 `shouldReturn` ([(1,2)] :: [(Int, Int)])
5454
5555 it "Apply - serial composed first argument" $
56− (toList $ (,) <$> (return 1 <> return 2) <*> (return 3))
56+ (toListSerial $ (,) <$> (return 1 <> return 2) <*> (return 3))
5757 `shouldReturn` ([(1,3),(2,3)] :: [(Int, Int)])
5858
5959 it "Apply - serial composed second argument" $
60− (toList $ (,) <$> (return 1) <*> (return 2 <> return 3))
60+ (toListSerial $ (,) <$> (return 1) <*> (return 2 <> return 3))
6161 `shouldReturn` ([(1,2),(1,3)] :: [(Int, Int)])
6262
6363 it "Apply - parallel composed first argument" $
64− (toList $ (,) <$> (return 1 <|> return 2) <*> (return 3))
64+ (toListSerial $ (,) <$> (return 1 <|> return 2) <*> (return 3))
6565 `shouldReturn` ([(1,3),(2,3)] :: [(Int, Int)])
6666
6767 it "Apply - parallel composed second argument" $
68− (toList $ (,) <$> (return 1) <*> (return 2 <|> return 3))
68+ (toListSerial $ (,) <$> (return 1) <*> (return 2 <|> return 3))
6969 `shouldReturn` ([(1,2),(1,3)] :: [(Int, Int)])
7070
7171 ---------------------------------------------------------------------------
@@ -73,15 +73,15 @@ main = hspec $ do
7373 ---------------------------------------------------------------------------
7474
7575 describe "Bind then" thenBind
76− describe "Pure bind serial" $ pureBind (>>=)
77− describe "Pure bind serial interleaved" $ pureBind (>->)
78− describe "Pure bind parallel DFS" $ pureBind (>>|)
79− describe "Pure bind parallel BFS" $ pureBind (>|>)
76+ describe "Pure bind serial" $ pureBind toListSerial
77+ describe "Pure bind serial interleaved" $ pureBind toListInterleaved
78+ describe "Pure bind parallel DFS" $ pureBind toListAsync
79+ describe "Pure bind parallel BFS" $ pureBind toListParallel
8080
81− describe "Bind (>>=) with empty" $ bindEmpty (>>=)
82− describe "Bind (>->) with empty" $ bindEmpty (>->)
83− describe "Bind (>|>) with empty" $ bindEmpty (>|>)
84− describe "Bind (>>|) with empty" $ bindEmpty (>>|)
81+ describe "Bind (>>=) with empty" $ bindEmpty toListSerial
82+ describe "Bind (>->) with empty" $ bindEmpty toListInterleaved
83+ describe "Bind (>|>) with empty" $ bindEmpty toListAsync
84+ describe "Bind (>>|) with empty" $ bindEmpty toListParallel
8585
8686 ---------------------------------------------------------------------------
8787 -- Monoidal Compositions
@@ -98,8 +98,8 @@ main = hspec $ do
9898 -- Monoidal Composition ordering checks
9999 ---------------------------------------------------------------------------
100100
101− describe "Serial interleaved ordering check (<=>)" $ interleaved (<=>)
102− describe "Parallel interleaved ordering check (<|>)" $ interleaved (<|>)
101+ describe "Serial interleaved ordering check (<=>)" $ interleaveCheck (<=>)
102+ describe "Parallel interleaved ordering check (<|>)" $ interleaveCheck (<|>)
103103 describe "Left biased parallel time order check" $ parallelCheck (<|)
104104 describe "Fair parallel time order check" $ parallelCheck (<|>)
105105
@@ -140,13 +140,13 @@ main = hspec $ do
140140 describe "Nested parallel and serial compositions" $ do
141141 it "Nest <|>, <>, <|> (1)" $
142142 let t = timed
143− in toList (
143+ in toListSerial (
144144 ((t 8 <|> t 4) <> (t 2 <|> t 0))
145145 <|> ((t 8 <|> t 4) <> (t 2 <|> t 0)))
146146 `shouldReturn` ([4,4,8,8,0,0,2,2])
147147 it "Nest <|>, <>, <|> (2)" $
148148 let t = timed
149− in toList (
149+ in toListSerial (
150150 ((t 4 <|> t 8) <> (t 1 <|> t 2))
151151 <|> ((t 4 <|> t 8) <> (t 1 <|> t 2)))
152152 `shouldReturn` ([4,4,8,8,1,1,2,2])
@@ -155,20 +155,20 @@ main = hspec $ do
155155 {-
156156 it "Nest <|>, <=>, <|> (1)" $
157157 let t = timed
158− in toList (
158+ in toListSerial (
159159 ((t 8 <|> t 4) <=> (t 2 <|> t 0))
160160 <|> ((t 9 <|> t 4) <=> (t 2 <|> t 0)))
161161 `shouldReturn` ([4,4,0,0,8,2,9,2])
162162 it "Nest <|>, <=>, <|> (2)" $
163163 let t = timed
164− in toList (
164+ in toListSerial (
165165 ((t 4 <|> t 8) <=> (t 1 <|> t 2))
166166 <|> ((t 4 <|> t 9) <=> (t 1 <|> t 2)))
167167 `shouldReturn` ([4,4,1,1,8,2,9,2])
168168 -}
169169 it "Nest <|>, <|>, <|>" $
170170 let t = timed
171− in toList (
171+ in toListSerial (
172172 ((t 4 <|> t 8) <|> (t 0 <|> t 2))
173173 <|> ((t 4 <|> t 8) <|> (t 0 <|> t 2)))
174174 `shouldReturn` ([0,0,2,2,4,4,8,8])
@@ -185,17 +185,37 @@ main = hspec $ do
185185 -- Bind and monoidal composition combinations
186186 ---------------------------------------------------------------------------
187187
188− forM_ [(>>=), (>->), (>>|), (>|>)] $ \f ->
189− forM_ [(<>), (<=>), (<|), (<|>)] $ \g ->
190− describe "Bind and compose" $ bindAndComposeSimple f g
188+ forM_ [(<>), (<=>), (<|), (<|>)] $ \g ->
189+ describe "Bind and compose" $ bindAndComposeSimple toListSerial g
190+
191+ forM_ [(<>), (<=>), (<|), (<|>)] $ \g ->
192+ describe "Bind and compose" $ bindAndComposeSimple toListInterleaved g
193+
194+ forM_ [(<>), (<=>), (<|), (<|>)] $ \g ->
195+ describe "Bind and compose" $ bindAndComposeSimple toListAsync g
196+
197+ forM_ [(<>), (<=>), (<|), (<|>)] $ \g ->
198+ describe "Bind and compose" $ bindAndComposeSimple toListParallel g
191199
192200 let fldr f = foldr f empty
193201 fldl f = foldl f empty
194− in forM_ [(>>=), (>->), (>>|), (>|>)] $ \f ->
195− forM_ [(<>), (<=>), (<|), (<|>)] $ \g ->
196− forM_ [fldr, fldl] $ \k ->
197− describe "Bind and compose" $
198− bindAndComposeHierarchy f (k g)
202+ in do
203+ forM_ [(<>), (<=>), (<|), (<|>)] $ \g ->
204+ forM_ [fldr, fldl] $ \k ->
205+ describe "Bind and compose" $
206+ bindAndComposeHierarchy toListSerial (k g)
207+ forM_ [(<>), (<=>), (<|), (<|>)] $ \g ->
208+ forM_ [fldr, fldl] $ \k ->
209+ describe "Bind and compose" $
210+ bindAndComposeHierarchy toListInterleaved (k g)
211+ forM_ [(<>), (<=>), (<|), (<|>)] $ \g ->
212+ forM_ [fldr, fldl] $ \k ->
213+ describe "Bind and compose" $
214+ bindAndComposeHierarchy toListAsync (k g)
215+ forM_ [(<>), (<=>), (<|), (<|>)] $ \g ->
216+ forM_ [fldr, fldl] $ \k ->
217+ describe "Bind and compose" $
218+ bindAndComposeHierarchy toListParallel (k g)
199219
200220 ---------------------------------------------------------------------------
201221 -- TBD Bind and Bind combinations
@@ -206,149 +226,153 @@ main = hspec $ do
206226
207227 describe "Transformation" $ transformOps (<>)
208228 describe "Serial zipping" $
209− zipOps A.zipWith A.zipWithM A.ZipSerial A.getZipSerial
229+ zipOps A.zipWith A.zipWithM fromStream fromZipStream
210230 describe "Async zipping" $
211− zipOps A.zipAsyncWith A.zipAsyncWithM A.ZipAsync A.getZipAsync
231+ zipOps A.zipAsyncWith A.zipAsyncWithM fromStream fromZipAsync
212232
213233zipOps :: Applicative (f IO)
214234 => (forall a b c. (a -> b -> c)
215− -> AsyncT IO a -> AsyncT IO b -> AsyncT IO c)
216− -> (forall a b c. (a -> b -> AsyncT IO c)
217− -> AsyncT IO a -> AsyncT IO b -> AsyncT IO c)
218− -> (forall a. AsyncT IO a -> f IO a)
219− -> (forall a. f IO a -> AsyncT IO a)
235+ -> StreamT IO a -> StreamT IO b -> StreamT IO c)
236+ -> (forall a b c. (a -> b -> StreamT IO c)
237+ -> StreamT IO a -> StreamT IO b -> StreamT IO c)
238+ -> (forall a. StreamT IO a -> f IO a)
239+ -> (forall a. f IO a -> StreamT IO a)
220240 -> Spec
221241zipOps z zM app getz = do
222242 it "zipWith" $
223243 let s1 = foldMapWith (<|>) return [1..10]
224244 s2 = foldMapWith (<>) return [1..]
225− in toList (z (+) s1 s2)
245+ in toListSerial (z (+) s1 s2)
226246 `shouldReturn` ([2,4..20] :: [Int])
227247
228248 it "zipWithM" $
229249 let s1 = foldMapWith (<|>) return [1..10]
230250 s2 = foldMapWith (<>) return [1..]
231− in toList (zM (\a b -> return (a + b)) s1 s2)
251+ in toListSerial (zM (\a b -> return (a + b)) s1 s2)
232252 `shouldReturn` ([2,4..20] :: [Int])
233253
234254 it "Applicative zip" $
235255 let s1 = foldMapWith (<|>) return [1..10]
236256 s2 = foldMapWith (<>) return [1..]
237− in toList (getz ((+) <$> app s1 <*> app s2))
257+ in toListSerial (getz ((+) <$> app s1 <*> app s2))
238258 `shouldReturn` ([2,4..20] :: [Int])
239259
240−timed :: Int -> AsyncT IO Int
260+timed :: Int -> StreamT IO Int
241261timed x = liftIO (threadDelay (x * 100000)) >> return x
242262
243263thenBind :: Spec
244264thenBind = do
245265 it "Simple runAsyncly and 'then' with IO" $
246− runAsyncly (liftIO (putStrLn "hello") >> liftIO (putStrLn "world"))
266+ serially (liftIO (putStrLn "hello") >> liftIO (putStrLn "world"))
247267 `shouldReturn` ()
248268 it "Then and toList" $
249− toList (return (1 :: Int) >> return 2) `shouldReturn` ([2] :: [Int])
269+ toListSerial (return (1 :: Int) >> return 2) `shouldReturn` ([2] :: [Int])
250270
251−pureBind :: (AsyncT IO Int -> (Int -> AsyncT IO Int) -> AsyncT IO Int) -> Spec
252−pureBind f = do
271+type ToListType s = (forall a. s IO a -> IO [a])
272+pureBind :: Monad (s IO) => ToListType s -> Spec
273+pureBind l = do
253274 it "Bind and toList" $
254− toList (return 1 `f` \x -> return 2 `f` \y -> return (x + y))
275+ l (return 1 `f` \x -> return 2 `f` \y -> return (x + y))
255276 `shouldReturn` ([3] :: [Int])
277+ where f = (>>=)
256278
257−bindEmpty :: (AsyncT IO Int -> (Int -> AsyncT IO Int) -> AsyncT IO Int) -> Spec
258−bindEmpty f = it "Binds with empty" $
259− (toList (return 1 `f` \_ -> empty `f` \_ -> return 2))
279+bindEmpty :: (Monad (s IO), Alternative (s IO)) => ToListType s -> Spec
280+bindEmpty l = it "Binds with empty" $
281+ (l (return (1 :: Int) `f` \_ -> empty `f` \_ -> return 2))
260282 `shouldReturn` ([] :: [Int])
283+ where f = (>>=)
261284
262−interleaved
263− :: (AsyncT IO Int -> AsyncT IO Int -> AsyncT IO Int)
285+interleaveCheck
286+ :: (StreamT IO Int -> StreamT IO Int -> StreamT IO Int)
264287 -> Spec
265−interleaved f =
288+interleaveCheck f =
266289 it "Interleave four" $
267− toList ((return 0 <> return 1) `f` (return 100 <> return 101))
290+ toListSerial ((return 0 <> return 1) `f` (return 100 <> return 101))
268291 `shouldReturn` ([0, 100, 1, 101])
269292
270−parallelCheck :: (AsyncT IO Int -> AsyncT IO Int -> AsyncT IO Int) -> Spec
293+parallelCheck :: (StreamT IO Int -> StreamT IO Int -> StreamT IO Int) -> Spec
271294parallelCheck f = do
272295 it "Parallel ordering left associated" $
273− toList (((event 4 `f` event 3) `f` event 2) `f` event 1)
296+ toListSerial (((event 4 `f` event 3) `f` event 2) `f` event 1)
274297 `shouldReturn` ([1..4])
275298
276299 it "Parallel ordering right associated" $
277− toList (event 4 `f` (event 3 `f` (event 2 `f` event 1)))
300+ toListSerial (event 4 `f` (event 3 `f` (event 2 `f` event 1)))
278301 `shouldReturn` ([1..4])
279302
280303 where event n = (liftIO $ threadDelay (n * 100000)) >> (return n)
281304
282305compose
283− :: (AsyncT IO Int -> AsyncT IO Int -> AsyncT IO Int)
306+ :: (StreamT IO Int -> StreamT IO Int -> StreamT IO Int)
284307 -> ([Int] -> [Int])
285308 -> Spec
286309compose f srt = do
287310 it "Compose mempty, mempty" $
288− (toList (mempty `f` mempty)) `shouldReturn` []
311+ (tl (mempty `f` mempty)) `shouldReturn` []
289312 it "Compose empty, empty" $
290− (toList (empty `f` empty)) `shouldReturn` []
313+ (tl (empty `f` empty)) `shouldReturn` []
291314 it "Compose empty at the beginning" $
292− (toList $ (empty `f` return 1)) `shouldReturn` [1]
315+ (tl $ (empty `f` return 1)) `shouldReturn` [1]
293316 it "Compose empty at the end" $
294− (toList $ (return 1 `f` empty)) `shouldReturn` [1]
317+ (tl $ (return 1 `f` empty)) `shouldReturn` [1]
295318 it "Compose two" $
296− (toList (return 0 `f` return 1) >>= return . srt)
319+ (tl (return 0 `f` return 1) >>= return . srt)
297320 `shouldReturn` [0, 1]
298321 it "Compose three - empty in the middle" $
299− ((toList $ (return 0 `f` empty `f` return 1)) >>= return . srt)
322+ ((tl $ (return 0 `f` empty `f` return 1)) >>= return . srt)
300323 `shouldReturn` [0, 1]
301324 it "Compose left associated" $
302− ((toList $ (((return 0 `f` return 1) `f` return 2) `f` return 3))
325+ ((tl $ (((return 0 `f` return 1) `f` return 2) `f` return 3))
303326 >>= return . srt) `shouldReturn` [0, 1, 2, 3]
304327 it "Compose right associated" $
305− ((toList $ (return 0 `f` (return 1 `f` (return 2 `f` return 3))))
328+ ((tl $ (return 0 `f` (return 1 `f` (return 2 `f` return 3))))
306329 >>= return . srt) `shouldReturn` [0, 1, 2, 3]
307330 it "Compose many" $
308− ((toList $ forEachWith f [1..100] return) >>= return . srt)
331+ ((tl $ forEachWith f [1..100] return) >>= return . srt)
309332 `shouldReturn` [1..100]
310333 it "Compose hierarchical (multiple levels)" $
311− ((toList $ (((return 0 `f` return 1) `f` (return 2 `f` return 3))
334+ ((tl $ (((return 0 `f` return 1) `f` (return 2 `f` return 3))
312335 `f` ((return 4 `f` return 5) `f` (return 6 `f` return 7)))
313336 ) >>= return . srt) `shouldReturn` [0..7]
337+ where tl = toListSerial
314338
315339composeAndComposeSimple
316− :: (AsyncT IO Int -> AsyncT IO Int -> AsyncT IO Int)
317− -> (AsyncT IO Int -> AsyncT IO Int -> AsyncT IO Int)
340+ :: (StreamT IO Int -> StreamT IO Int -> StreamT IO Int)
341+ -> (StreamT IO Int -> StreamT IO Int -> StreamT IO Int)
318342 -> [[Int]]
319343 -> Spec
320344composeAndComposeSimple f g answer = do
321345 it "Compose right associated outer expr, right folded inner" $
322346 let fold = foldMapWith g return
323− in (toList (fold [1,2,3] `f` (fold [4,5,6] `f` fold [7,8,9])))
347+ in (toListSerial (fold [1,2,3] `f` (fold [4,5,6] `f` fold [7,8,9])))
324348 `shouldReturn` (answer !! 0)
325349
326350 it "Compose left associated outer expr, right folded inner" $
327351 let fold = foldMapWith g return
328− in (toList ((fold [1,2,3] `f` fold [4,5,6]) `f` fold [7,8,9]))
352+ in (toListSerial ((fold [1,2,3] `f` fold [4,5,6]) `f` fold [7,8,9]))
329353 `shouldReturn` (answer !! 1)
330354
331355 it "Compose right associated outer expr, left folded inner" $
332356 let fold xs = foldl g empty $ map return xs
333− in (toList (fold [1,2,3] `f` (fold [4,5,6] `f` fold [7,8,9])))
357+ in (toListSerial (fold [1,2,3] `f` (fold [4,5,6] `f` fold [7,8,9])))
334358 `shouldReturn` (answer !! 2)
335359
336360 it "Compose left associated outer expr, left folded inner" $
337361 let fold xs = foldl g empty $ map return xs
338− in (toList ((fold [1,2,3] `f` fold [4,5,6]) `f` fold [7,8,9]))
362+ in (toListSerial ((fold [1,2,3] `f` fold [4,5,6]) `f` fold [7,8,9]))
339363 `shouldReturn` (answer !! 3)
340364
341365
342366loops
343− :: (AsyncT IO Int -> AsyncT IO Int -> AsyncT IO Int)
367+ :: (StreamT IO Int -> StreamT IO Int -> StreamT IO Int)
344368 -> ([Int] -> [Int])
345369 -> ([Int] -> [Int])
346370 -> Spec
347371loops f tsrt hsrt = do
348− it "Tail recursive loop" $ (toList (loopTail 0) >>= return . tsrt)
372+ it "Tail recursive loop" $ (toListSerial (loopTail 0) >>= return . tsrt)
349373 `shouldReturn` [0..3]
350374
351− it "Head recursive loop" $ (toList (loopHead 0) >>= return . hsrt)
375+ it "Head recursive loop" $ (toListSerial (loopHead 0) >>= return . hsrt)
352376 `shouldReturn` [0..3]
353377
354378 where
@@ -363,26 +387,27 @@ loops f tsrt hsrt = do
363387 return x `f` (if x < 3 then loopTail (x + 1) else empty)
364388
365389bindAndComposeSimple
366− :: (AsyncT IO Int -> (Int -> AsyncT IO Int) -> AsyncT IO Int)
367− -> (AsyncT IO Int -> AsyncT IO Int -> AsyncT IO Int)
390+ :: (Alternative (s IO), Monad (s IO), Monoid (s IO Int)) => (forall a. s IO a -> IO [a])
391+ -> (s IO Int -> s IO Int -> s IO Int)
368392 -> Spec
369−bindAndComposeSimple f g = do
393+bindAndComposeSimple tl g = do
370394 it "Compose many (right fold) with bind" $
371− (toList (forEachWith g [1..10 :: Int] $ \x -> return x `f` (return . id))
395+ (tl (forEachWith g [1..10 :: Int] $ \x -> return x `f` (return . id))
372396 >>= return . sort) `shouldReturn` [1..10]
373397
374398 it "Compose many (left fold) with bind" $
375399 let forL xs k = foldl g empty $ map k xs
376− in (toList (forL [1..10 :: Int] $ \x -> return x `f` (return . id))
400+ in (tl (forL [1..10 :: Int] $ \x -> return x `f` (return . id))
377401 >>= return . sort) `shouldReturn` [1..10]
402+ where f = (>>=)
378403
379404bindAndComposeHierarchy
380− :: (AsyncT IO Int -> (Int -> AsyncT IO Int) -> AsyncT IO Int)
381− -> ([AsyncT IO Int] -> AsyncT IO Int)
405+ :: Monad (s IO) => (forall a. s IO a -> IO [a])
406+ -> ([s IO Int] -> s IO Int)
382407 -> Spec
383−bindAndComposeHierarchy f g = do
408+bindAndComposeHierarchy tl g = do
384409 it "Bind and compose nested" $
385− (toList bindComposeNested >>= return . sort)
410+ (tl bindComposeNested >>= return . sort)
386411 `shouldReturn` (sort (
387412 [12, 18]
388413 ++ replicate 3 13
@@ -393,7 +418,7 @@ bindAndComposeHierarchy f g = do
393418
394419 where
395420
396− bindComposeNested :: AsyncT IO Int
421+ -- bindComposeNested :: AsyncT IO Int
397422 bindComposeNested =
398423 let c1 = tripleCompose (return 1) (return 2) (return 3)
399424 c2 = tripleCompose (return 4) (return 5) (return 6)
@@ -410,17 +435,18 @@ bindAndComposeHierarchy f g = do
410435 mx `f` \x -> my
411436 `f` \y -> mz
412437 `f` \z -> return (x + y + z)
438+ f = (>>=)
413439
414440mixedOps :: Spec
415441mixedOps = do
416442 it "Compose many ops" $
417− (toList composeMixed >>= return . sort)
443+ (toListSerial composeMixed >>= return . sort)
418444 `shouldReturn` ([8,9,9,9,9,9,10,10,10,10,10,10,10,10,10,10,11,11
419445 ,11,11,11,11,11,11,11,11,12,12,12,12,12,13
420446 ] :: [Int])
421447 where
422448
423− composeMixed :: AsyncT IO Int
449+ composeMixed :: StreamT IO Int
424450 composeMixed = do
425451 liftIO $ return ()
426452 liftIO $ putStr ""
@@ -441,24 +467,24 @@ mixedOps = do
441467 return (x1 + y1 + z1)
442468 return (x + y + z)
443469
444−transformOps :: (AsyncT IO Int -> AsyncT IO Int -> AsyncT IO Int) -> Spec
470+transformOps :: (StreamT IO Int -> StreamT IO Int -> StreamT IO Int) -> Spec
445471transformOps f = do
446472 it "take all" $
447− (toList $ A.take 10 $ foldMapWith f return [1..10])
473+ (toListSerial $ A.take 10 $ foldMapWith f return [1..10])
448474 `shouldReturn` [1..10]
449475 it "take none" $
450− (toList $ A.take 0 $ foldMapWith f return [1..10])
476+ (toListSerial $ A.take 0 $ foldMapWith f return [1..10])
451477 `shouldReturn` []
452478 it "take 5" $
453− (toList $ A.take 5 $ foldMapWith f return [1..10])
479+ (toListSerial $ A.take 5 $ foldMapWith f return [1..10])
454480 `shouldReturn` [1..5]
455481
456482 it "drop all" $
457− (toList $ A.drop 10 $ foldMapWith f return [1..10])
483+ (toListSerial $ A.drop 10 $ foldMapWith f return [1..10])
458484 `shouldReturn` []
459485 it "drop none" $
460− (toList $ A.drop 0 $ foldMapWith f return [1..10])
486+ (toListSerial $ A.drop 0 $ foldMapWith f return [1..10])
461487 `shouldReturn` [1..10]
462488 it "drop 5" $
463− (toList $ A.drop 5 $ foldMapWith f return [1..10])
489+ (toListSerial $ A.drop 5 $ foldMapWith f return [1..10])
464490 `shouldReturn` [6..10]