dph-prim-seq: Add lockedZipWiths up to 8
[packages/dph.git] / dph-prim-seq / Data / Array / Parallel / Unlifted / Stream / Locked.hs
1 {-# LANGUAGE CPP, NoMonomorphismRestriction #-}
2 #include "fusion-phases.h"
3 -- | Locked streamers and zippers.
4 --
5 -- The streams are 'locked together', meaning they have the same length and
6 -- cannot yield 'Skip' states.
7 --
8 -- These functions are used for processing data read directly from vectors
9 -- where we know the vectors all have the same length.
10 --
11 module Data.Array.Parallel.Unlifted.Stream.Locked
12 ( stream2, lockedZip2S
13 , stream3, lockedZip3S
14 , stream4, lockedZip4S
15 , stream5, lockedZip5S
16 , stream6, lockedZip6S
17 , stream7, lockedZip7S
18 , stream8, lockedZip8S)
19 where
20 import Data.Array.Parallel.Unlifted.Stream.Swallow
21 import Data.Vector.Generic as G
22 import Data.Vector.Fusion.Stream.Monadic as S
23 import Data.Vector.Fusion.Stream.Size as S
24
25
26 -------------------------------------------
27 -- | Stream two vectors of the same length.
28 -- The fact that they are the same length means the generated code only
29 -- needs to maintain one loop counter for all streams.
30 --
31 -- Trying to stream vectors of differing lengths is undefined.
32 --
33 stream2 :: (Monad m, Vector v a, Vector v b)
34 => v a -> v b
35 -> Stream m (a, b)
36
37 stream2 aa bb
38 = lockedZip2S (G.length aa) (swallow aa) (swallow bb)
39 {-# INLINE_STREAM stream2 #-}
40
41
42 ---------------------------------------------
43 -- | Stream three vectors of the same length.
44 stream3 :: (Monad m, Vector v a, Vector v b, Vector v c)
45 => v a -> v b -> v c
46 -> Stream m (a, b, c)
47
48 stream3 aa bb cc
49 = lockedZip3S (G.length aa) (swallow aa) (swallow bb) (swallow cc)
50 {-# INLINE_STREAM stream3 #-}
51
52
53 -- When we see that one of the vectors is being created G.new then push down a
54 -- 'swallow' wrapper to signal that the consumer (lockedZip2S) knows how many
55 -- elements to demand. This lets us generate better code on the producer side
56 -- as it doesn't need to track how many elements still need to be generated.
57
58 {-# RULES "stream3/new_1"
59 forall as bs cs
60 . stream3 (G.new as) bs cs
61 = S.map (\((b, c), a) -> (a, b, c))
62 $ lockedZip2S (G.length bs) (swallow2 bs cs) (swallow (G.new as))
63 #-}
64
65 {-# RULES "stream3/new_2"
66 forall as bs cs
67 . stream3 as (G.new bs) cs
68 = S.map (\((a, c), b) -> (a, b, c))
69 $ lockedZip2S (G.length as) (swallow2 as cs) (swallow (G.new bs))
70 #-}
71
72 {-# RULES "stream3/new_3"
73 forall as bs cs
74 . stream3 as bs (G.new cs)
75 = S.map (\((a, b), c) -> (a, b, c))
76 $ lockedZip2S (G.length as) (swallow2 as bs) (swallow (G.new cs))
77 #-}
78
79
80 ---------------------------------------------
81 -- | Stream four vectors of the same length.
82 stream4 :: (Monad m, Vector v a, Vector v b, Vector v c, Vector v d)
83 => v a -> v b -> v c -> v d
84 -> Stream m (a, b, c, d)
85
86 stream4 aa bb cc dd
87 = lockedZip4S (G.length aa)
88 (swallow aa) (swallow bb) (swallow cc) (swallow dd)
89 {-# INLINE_STREAM stream4 #-}
90
91 {-# RULES "stream4/new_1"
92 forall as bs cs ds
93 . stream4 (G.new as) bs cs ds
94 = S.map (\((b, c, d), a) -> (a, b, c, d))
95 $ lockedZip2S (G.length bs) (swallow3 bs cs ds) (swallow (G.new as))
96 #-}
97
98 {-# RULES "stream4/new_2"
99 forall as bs cs ds
100 . stream4 as (G.new bs) cs ds
101 = S.map (\((a, c, d), b) -> (a, b, c, d))
102 $ lockedZip2S (G.length as) (swallow3 as cs ds) (swallow (G.new bs))
103 #-}
104
105 {-# RULES "stream4/new_3"
106 forall as bs cs ds
107 . stream4 as bs (G.new cs) ds
108 = S.map (\((a, b, d), c) -> (a, b, c, d))
109 $ lockedZip2S (G.length as) (swallow3 as bs ds) (swallow (G.new cs))
110 #-}
111
112 {-# RULES "stream4/new_4"
113 forall as bs cs ds
114 . stream4 as bs cs (G.new ds)
115 = S.map (\((a, b, c), d) -> (a, b, c, d))
116 $ lockedZip2S (G.length as) (swallow3 as bs cs) (swallow (G.new ds))
117 #-}
118
119
120 ---------------------------------------------
121 -- | Stream five vectors of the same length.
122 stream5 :: (Monad m, Vector v a, Vector v b, Vector v c, Vector v d, Vector v e)
123 => v a -> v b -> v c -> v d -> v e
124 -> Stream m (a, b, c, d, e)
125
126 stream5 aa bb cc dd ee
127 = lockedZip5S (G.length aa)
128 (swallow aa) (swallow bb) (swallow cc) (swallow dd)
129 (swallow ee)
130 {-# INLINE_STREAM stream5 #-}
131
132 {-# RULES "stream5/new_1"
133 forall as bs cs ds es
134 . stream5 (G.new as) bs cs ds es
135 = S.map (\((b, c, d, e), a) -> (a, b, c, d, e))
136 $ lockedZip2S (G.length bs) (swallow4 bs cs ds es) (swallow (G.new as))
137 #-}
138
139 {-# RULES "stream5/new_2"
140 forall as bs cs ds es
141 . stream5 as (G.new bs) cs ds es
142 = S.map (\((a, c, d, e), b) -> (a, b, c, d, e))
143 $ lockedZip2S (G.length as) (swallow4 as cs ds es) (swallow (G.new bs))
144 #-}
145
146 {-# RULES "stream5/new_3"
147 forall as bs cs ds es
148 . stream5 as bs (G.new cs) ds es
149 = S.map (\((a, b, d, e), c) -> (a, b, c, d, e))
150 $ lockedZip2S (G.length as) (swallow4 as bs ds es) (swallow (G.new cs))
151 #-}
152
153 {-# RULES "stream5/new_4"
154 forall as bs cs ds es
155 . stream5 as bs cs (G.new ds) es
156 = S.map (\((a, b, c, e), d) -> (a, b, c, d, e))
157 $ lockedZip2S (G.length as) (swallow4 as bs cs es) (swallow (G.new ds))
158 #-}
159
160 {-# RULES "stream5/new_5"
161 forall as bs cs ds es
162 . stream5 as bs cs ds (G.new es)
163 = S.map (\((a, b, c, d), e) -> (a, b, c, d, e))
164 $ lockedZip2S (G.length as) (swallow4 as bs cs ds) (swallow (G.new es))
165 #-}
166
167
168 ---------------------------------------------
169 -- | Stream six vectors of the same length.
170 stream6 :: (Monad m, Vector v a, Vector v b, Vector v c, Vector v d, Vector v e, Vector v f)
171 => v a -> v b -> v c -> v d -> v e -> v f
172 -> Stream m (a, b, c, d, e, f)
173
174 stream6 aa bb cc dd ee ff
175 = lockedZip6S (G.length aa)
176 (swallow aa) (swallow bb) (swallow cc) (swallow dd)
177 (swallow ee) (swallow ff)
178 {-# INLINE_STREAM stream6 #-}
179
180 {-# RULES "stream6/new_1"
181 forall as bs cs ds es fs
182 . stream6 (G.new as) bs cs ds es fs
183 = S.map (\((b, c, d, e, f), a) -> (a, b, c, d, e, f))
184 $ lockedZip2S (G.length bs) (swallow5 bs cs ds es fs) (swallow (G.new as))
185 #-}
186
187 {-# RULES "stream6/new_2"
188 forall as bs cs ds es fs
189 . stream6 as (G.new bs) cs ds es fs
190 = S.map (\((a, c, d, e, f), b) -> (a, b, c, d, e, f))
191 $ lockedZip2S (G.length as) (swallow5 as cs ds es fs) (swallow (G.new bs))
192 #-}
193
194 {-# RULES "stream6/new_3"
195 forall as bs cs ds es fs
196 . stream6 as bs (G.new cs) ds es fs
197 = S.map (\((a, b, d, e, f), c) -> (a, b, c, d, e, f))
198 $ lockedZip2S (G.length as) (swallow5 as bs ds es fs) (swallow (G.new cs))
199 #-}
200
201 {-# RULES "stream6/new_4"
202 forall as bs cs ds es fs
203 . stream6 as bs cs (G.new ds) es fs
204 = S.map (\((a, b, c, e, f), d) -> (a, b, c, d, e, f))
205 $ lockedZip2S (G.length as) (swallow5 as bs cs es fs) (swallow (G.new ds))
206 #-}
207
208 {-# RULES "stream6/new_5"
209 forall as bs cs ds es fs
210 . stream6 as bs cs ds (G.new es) fs
211 = S.map (\((a, b, c, d, f), e) -> (a, b, c, d, e, f))
212 $ lockedZip2S (G.length as) (swallow5 as bs cs ds fs) (swallow (G.new es))
213 #-}
214
215 {-# RULES "stream6/new_6"
216 forall as bs cs ds es fs
217 . stream6 as bs cs ds es (G.new fs)
218 = S.map (\((a, b, c, d, e), f) -> (a, b, c, d, e, f))
219 $ lockedZip2S (G.length as) (swallow5 as bs cs ds es) (swallow (G.new fs))
220 #-}
221
222
223 ---------------------------------------------
224 -- | Stream seven vectors of the same length.
225 stream7 :: (Monad m, Vector v a, Vector v b, Vector v c, Vector v d, Vector v e, Vector v f, Vector v g)
226 => v a -> v b -> v c -> v d -> v e -> v f -> v g
227 -> Stream m (a, b, c, d, e, f, g)
228
229 stream7 aa bb cc dd ee ff gg
230 = lockedZip7S (G.length aa)
231 (swallow aa) (swallow bb) (swallow cc) (swallow dd)
232 (swallow ee) (swallow ff) (swallow gg)
233 {-# INLINE_STREAM stream7 #-}
234
235 {-# RULES "stream7/new_1"
236 forall as bs cs ds es fs gs
237 . stream7 (G.new as) bs cs ds es fs gs
238 = S.map (\((b, c, d, e, f, g), a) -> (a, b, c, d, e, f, g))
239 $ lockedZip2S (G.length bs) (swallow6 bs cs ds es fs gs) (swallow (G.new as))
240 #-}
241
242 {-# RULES "stream7/new_2"
243 forall as bs cs ds es fs gs
244 . stream7 as (G.new bs) cs ds es fs gs
245 = S.map (\((a, c, d, e, f, g), b) -> (a, b, c, d, e, f, g))
246 $ lockedZip2S (G.length as) (swallow6 as cs ds es fs gs) (swallow (G.new bs))
247 #-}
248
249 {-# RULES "stream7/new_3"
250 forall as bs cs ds es fs gs
251 . stream7 as bs (G.new cs) ds es fs gs
252 = S.map (\((a, b, d, e, f, g), c) -> (a, b, c, d, e, f, g))
253 $ lockedZip2S (G.length as) (swallow6 as bs ds es fs gs) (swallow (G.new cs))
254 #-}
255
256 {-# RULES "stream7/new_4"
257 forall as bs cs ds es fs gs
258 . stream7 as bs cs (G.new ds) es fs gs
259 = S.map (\((a, b, c, e, f, g), d) -> (a, b, c, d, e, f, g))
260 $ lockedZip2S (G.length as) (swallow6 as bs cs es fs gs) (swallow (G.new ds))
261 #-}
262
263 {-# RULES "stream7/new_5"
264 forall as bs cs ds es fs gs
265 . stream7 as bs cs ds (G.new es) fs gs
266 = S.map (\((a, b, c, d, f, g), e) -> (a, b, c, d, e, f, g))
267 $ lockedZip2S (G.length as) (swallow6 as bs cs ds fs gs) (swallow (G.new es))
268 #-}
269
270 {-# RULES "stream7/new_6"
271 forall as bs cs ds es fs gs
272 . stream7 as bs cs ds es (G.new fs) gs
273 = S.map (\((a, b, c, d, e, g), f) -> (a, b, c, d, e, f, g))
274 $ lockedZip2S (G.length as) (swallow6 as bs cs ds es gs) (swallow (G.new fs))
275 #-}
276
277 {-# RULES "stream7/new_7"
278 forall as bs cs ds es fs gs
279 . stream7 as bs cs ds es fs (G.new gs)
280 = S.map (\((a, b, c, d, e, f), g) -> (a, b, c, d, e, f, g))
281 $ lockedZip2S (G.length as) (swallow6 as bs cs ds es fs) (swallow (G.new gs))
282 #-}
283
284
285 ---------------------------------------------
286 -- | Stream seven vectors of the same length.
287 stream8 :: (Monad m, Vector v a, Vector v b, Vector v c, Vector v d, Vector v e, Vector v f, Vector v g, Vector v h)
288 => v a -> v b -> v c -> v d -> v e -> v f -> v g -> v h
289 -> Stream m (a, b, c, d, e, f, g, h)
290
291 stream8 aa bb cc dd ee ff gg hh
292 = lockedZip8S (G.length aa)
293 (swallow aa) (swallow bb) (swallow cc) (swallow dd)
294 (swallow ee) (swallow ff) (swallow gg) (swallow hh)
295 {-# INLINE_STREAM stream8 #-}
296
297 {-# RULES "stream8/new_1"
298 forall as bs cs ds es fs gs hs
299 . stream8 (G.new as) bs cs ds es fs gs hs
300 = S.map (\((b, c, d, e, f, g, h), a) -> (a, b, c, d, e, f, g, h))
301 $ lockedZip2S (G.length bs) (swallow7 bs cs ds es fs gs hs) (swallow (G.new as))
302 #-}
303
304 {-# RULES "stream8/new_2"
305 forall as bs cs ds es fs gs hs
306 . stream8 as (G.new bs) cs ds es fs gs hs
307 = S.map (\((a, c, d, e, f, g, h), b) -> (a, b, c, d, e, f, g, h))
308 $ lockedZip2S (G.length as) (swallow7 as cs ds es fs gs hs) (swallow (G.new bs))
309 #-}
310
311 {-# RULES "stream8/new_3"
312 forall as bs cs ds es fs gs hs
313 . stream8 as bs (G.new cs) ds es fs gs hs
314 = S.map (\((a, b, d, e, f, g, h), c) -> (a, b, c, d, e, f, g, h))
315 $ lockedZip2S (G.length as) (swallow7 as bs ds es fs gs hs) (swallow (G.new cs))
316 #-}
317
318 {-# RULES "stream8/new_4"
319 forall as bs cs ds es fs gs hs
320 . stream8 as bs cs (G.new ds) es fs gs hs
321 = S.map (\((a, b, c, e, f, g, h), d) -> (a, b, c, d, e, f, g, h))
322 $ lockedZip2S (G.length as) (swallow7 as bs cs es fs gs hs) (swallow (G.new ds))
323 #-}
324
325 {-# RULES "stream8/new_5"
326 forall as bs cs ds es fs gs hs
327 . stream8 as bs cs ds (G.new es) fs gs hs
328 = S.map (\((a, b, c, d, f, g, h), e) -> (a, b, c, d, e, f, g, h))
329 $ lockedZip2S (G.length as) (swallow7 as bs cs ds fs gs hs) (swallow (G.new es))
330 #-}
331
332 {-# RULES "stream8/new_6"
333 forall as bs cs ds es fs gs hs
334 . stream8 as bs cs ds es (G.new fs) gs hs
335 = S.map (\((a, b, c, d, e, g, h), f) -> (a, b, c, d, e, f, g, h))
336 $ lockedZip2S (G.length as) (swallow7 as bs cs ds es gs hs) (swallow (G.new fs))
337 #-}
338
339 {-# RULES "stream8/new_7"
340 forall as bs cs ds es fs gs hs
341 . stream8 as bs cs ds es fs (G.new gs) hs
342 = S.map (\((a, b, c, d, e, f, h), g) -> (a, b, c, d, e, f, g, h))
343 $ lockedZip2S (G.length as) (swallow7 as bs cs ds es fs hs) (swallow (G.new gs))
344 #-}
345
346 {-# RULES "stream8/new_8"
347 forall as bs cs ds es fs gs hs
348 . stream8 as bs cs ds es fs gs (G.new hs)
349 = S.map (\((a, b, c, d, e, f, h), g) -> (a, b, c, d, e, f, g, h))
350 $ lockedZip2S (G.length as) (swallow7 as bs cs ds es fs gs) (swallow (G.new hs))
351 #-}
352
353
354
355
356 -- Locked zips ----------------------------------------------------------------
357 -- | Zip the first 'n' elements of two streams.
358 lockedZip2S
359 :: Monad m
360 => Int
361 -> Stream m a -> Stream m b
362 -> Stream m (a, b)
363
364 lockedZip2S len
365 (Stream mkStep1 sa1 _)
366 (Stream mkStep2 sa2 _)
367 = Stream step (sa1, sa2, 0) (S.Exact len)
368 where
369 {-# INLINE_INNER step #-}
370 step (s1, s2, i)
371 = i `seq`
372 do step1 <- mkStep1 s1
373 step2 <- mkStep2 s2
374 return $ case (step1, step2) of
375 (Yield x1 s1', Yield x2 s2')
376 | i < len -> Yield (x1, x2) (s1', s2', i + 1)
377 _ -> Done
378 {-# INLINE_STREAM lockedZip2S #-}
379
380
381 -------------------------------------------------
382 -- | Zip the first 'n' elements of three streams.
383 lockedZip3S
384 :: Monad m
385 => Int
386 -> Stream m a -> Stream m b -> Stream m c
387 -> Stream m (a, b, c)
388
389 lockedZip3S len
390 (Stream mkStep1 sa1 _)
391 (Stream mkStep2 sa2 _)
392 (Stream mkStep3 sa3 _)
393 = Stream step (sa1, sa2, sa3, 0) (S.Exact len)
394 where
395 {-# INLINE_INNER step #-}
396 step (s1, s2, s3, i)
397 = i `seq`
398 do step1 <- mkStep1 s1
399 step2 <- mkStep2 s2
400 step3 <- mkStep3 s3
401 return $ case (step1, step2, step3) of
402 (Yield x1 s1', Yield x2 s2', Yield x3 s3')
403 | i < len -> Yield (x1, x2, x3) (s1', s2', s3', i + 1)
404
405 _ -> Done
406 {-# INLINE_STREAM lockedZip3S #-}
407
408
409 -------------------------------------------------
410 -- | Zip the first 'n' elements of four streams.
411 lockedZip4S
412 :: Monad m
413 => Int
414 -> Stream m a -> Stream m b -> Stream m c -> Stream m d
415 -> Stream m (a, b, c, d)
416
417 lockedZip4S len
418 (Stream mkStep1 sa1 _)
419 (Stream mkStep2 sa2 _)
420 (Stream mkStep3 sa3 _)
421 (Stream mkStep4 sa4 _)
422 = Stream step (sa1, sa2, sa3, sa4, 0) (S.Exact len)
423 where
424 {-# INLINE_INNER step #-}
425 step (s1, s2, s3, s4, i)
426 = i `seq`
427 do step1 <- mkStep1 s1
428 step2 <- mkStep2 s2
429 step3 <- mkStep3 s3
430 step4 <- mkStep4 s4
431 return $ case (step1, step2, step3, step4) of
432 (Yield x1 s1', Yield x2 s2', Yield x3 s3', Yield x4 s4')
433 | i < len -> Yield (x1, x2, x3, x4) (s1', s2', s3', s4', i + 1)
434
435 _ -> Done
436 {-# INLINE_STREAM lockedZip4S #-}
437
438
439 -------------------------------------------------
440 -- | Zip the first 'n' elements of five streams.
441 lockedZip5S
442 :: Monad m
443 => Int
444 -> Stream m a -> Stream m b -> Stream m c -> Stream m d -> Stream m e
445 -> Stream m (a, b, c, d, e)
446
447 lockedZip5S len
448 (Stream mkStep1 sa1 _)
449 (Stream mkStep2 sa2 _)
450 (Stream mkStep3 sa3 _)
451 (Stream mkStep4 sa4 _)
452 (Stream mkStep5 sa5 _)
453 = Stream step (sa1, sa2, sa3, sa4, sa5, 0) (S.Exact len)
454 where
455 {-# INLINE_INNER step #-}
456 step (s1, s2, s3, s4, s5, i)
457 = i `seq`
458 do step1 <- mkStep1 s1
459 step2 <- mkStep2 s2
460 step3 <- mkStep3 s3
461 step4 <- mkStep4 s4
462 step5 <- mkStep5 s5
463 return $ case (step1, step2, step3, step4, step5) of
464 (Yield x1 s1', Yield x2 s2', Yield x3 s3', Yield x4 s4', Yield x5 s5')
465 | i < len -> Yield (x1, x2, x3, x4, x5) (s1', s2', s3', s4', s5', i + 1)
466
467 _ -> Done
468 {-# INLINE_STREAM lockedZip5S #-}
469
470
471 -------------------------------------------------
472 -- | Zip the first 'n' elements of six streams.
473 lockedZip6S
474 :: Monad m
475 => Int
476 -> Stream m a -> Stream m b -> Stream m c -> Stream m d -> Stream m e -> Stream m f
477 -> Stream m (a, b, c, d, e, f)
478
479 lockedZip6S len
480 (Stream mkStep1 sa1 _)
481 (Stream mkStep2 sa2 _)
482 (Stream mkStep3 sa3 _)
483 (Stream mkStep4 sa4 _)
484 (Stream mkStep5 sa5 _)
485 (Stream mkStep6 sa6 _)
486 = Stream step (sa1, sa2, sa3, sa4, sa5, sa6, 0) (S.Exact len)
487 where
488 {-# INLINE_INNER step #-}
489 step (s1, s2, s3, s4, s5, s6, i)
490 = i `seq`
491 do step1 <- mkStep1 s1
492 step2 <- mkStep2 s2
493 step3 <- mkStep3 s3
494 step4 <- mkStep4 s4
495 step5 <- mkStep5 s5
496 step6 <- mkStep6 s6
497 return $ case (step1, step2, step3, step4, step5, step6) of
498 (Yield x1 s1', Yield x2 s2', Yield x3 s3', Yield x4 s4', Yield x5 s5', Yield x6 s6')
499 | i < len -> Yield (x1, x2, x3, x4, x5, x6) (s1', s2', s3', s4', s5', s6', i + 1)
500
501 _ -> Done
502 {-# INLINE_STREAM lockedZip6S #-}
503
504
505 -------------------------------------------------
506 -- | Zip the first 'n' elements of seven streams.
507 lockedZip7S
508 :: Monad m
509 => Int
510 -> Stream m a -> Stream m b -> Stream m c -> Stream m d -> Stream m e -> Stream m f -> Stream m g
511 -> Stream m (a, b, c, d, e, f, g)
512
513 lockedZip7S len
514 (Stream mkStep1 sa1 _)
515 (Stream mkStep2 sa2 _)
516 (Stream mkStep3 sa3 _)
517 (Stream mkStep4 sa4 _)
518 (Stream mkStep5 sa5 _)
519 (Stream mkStep6 sa6 _)
520 (Stream mkStep7 sa7 _)
521 = Stream step (sa1, sa2, sa3, sa4, sa5, sa6, sa7, 0) (S.Exact len)
522 where
523 {-# INLINE_INNER step #-}
524 step (s1, s2, s3, s4, s5, s6, s7, i)
525 = i `seq`
526 do step1 <- mkStep1 s1
527 step2 <- mkStep2 s2
528 step3 <- mkStep3 s3
529 step4 <- mkStep4 s4
530 step5 <- mkStep5 s5
531 step6 <- mkStep6 s6
532 step7 <- mkStep7 s7
533 return $ case (step1, step2, step3, step4, step5, step6, step7) of
534 (Yield x1 s1', Yield x2 s2', Yield x3 s3', Yield x4 s4', Yield x5 s5', Yield x6 s6', Yield x7 s7')
535 | i < len -> Yield (x1, x2, x3, x4, x5, x6, x7) (s1', s2', s3', s4', s5', s6', s7', i + 1)
536
537 _ -> Done
538 {-# INLINE_STREAM lockedZip7S #-}
539
540
541 -------------------------------------------------
542 -- | Zip the first 'n' elements of eight streams.
543 lockedZip8S
544 :: Monad m
545 => Int
546 -> Stream m a -> Stream m b -> Stream m c -> Stream m d -> Stream m e -> Stream m f -> Stream m g -> Stream m h
547 -> Stream m (a, b, c, d, e, f, g, h)
548
549 lockedZip8S len
550 (Stream mkStep1 sa1 _)
551 (Stream mkStep2 sa2 _)
552 (Stream mkStep3 sa3 _)
553 (Stream mkStep4 sa4 _)
554 (Stream mkStep5 sa5 _)
555 (Stream mkStep6 sa6 _)
556 (Stream mkStep7 sa7 _)
557 (Stream mkStep8 sa8 _)
558 = Stream step (sa1, sa2, sa3, sa4, sa5, sa6, sa7, sa8, 0) (S.Exact len)
559 where
560 {-# INLINE_INNER step #-}
561 step (s1, s2, s3, s4, s5, s6, s7, s8, i)
562 = i `seq`
563 do step1 <- mkStep1 s1
564 step2 <- mkStep2 s2
565 step3 <- mkStep3 s3
566 step4 <- mkStep4 s4
567 step5 <- mkStep5 s5
568 step6 <- mkStep6 s6
569 step7 <- mkStep7 s7
570 step8 <- mkStep8 s8
571 return $ case (step1, step2, step3, step4, step5, step6, step7, step8) of
572 (Yield x1 s1', Yield x2 s2', Yield x3 s3', Yield x4 s4', Yield x5 s5', Yield x6 s6', Yield x7 s7', Yield x8 s8')
573 | i < len -> Yield (x1, x2, x3, x4, x5, x6, x7, x8) (s1', s2', s3', s4', s5', s6', s7', s8', i + 1)
574
575 _ -> Done
576 {-# INLINE_STREAM lockedZip8S #-}