|
31 | 31 | -- |
32 | 32 | -- == Parallel |
33 | 33 | -- |
34 | | --- An unordered concurrent version of the serial 'Nested' type. Runs multiple |
35 | | --- iterations of the nested loops concurrently, iterations may execute out of |
36 | | --- order. More outer iterations are started only if the existing inner |
37 | | --- iterations are not saturating the resources. |
| 34 | +-- A newtype wrapper over the 'Stream' type; the Applicative and Monad |
| 35 | +-- instances generate a cross product of the two streams in a concurrent |
| 36 | +-- manner. The order in which the stream elements are produced is not |
| 37 | +-- deterministic, this is supposed to be used if order does not matter. |
| 38 | + |
| 39 | +-- Loops over the outer stream, generating multiple elements concurrently; for |
| 40 | +-- each outer stream element, loop over the inner stream concurrently. More |
| 41 | +-- outer iterations are started only if the existing inner iterations are not |
| 42 | +-- saturating the resources. |
| 43 | +-- |
| 44 | +-- Use 'mkParallel' to construct from 'Stream' type and 'unParallel' to |
| 45 | +-- deconstruct back to 'Stream'. |
38 | 46 | -- |
39 | 47 | -- >>> :{ |
| 48 | +-- bind :: MonadAsync m => Stream m a -> (a -> Stream m b) -> Stream m b |
40 | 49 | -- bind = flip (Stream.parConcatMap id) |
41 | 50 | -- $(mkCrossType "Parallel" "bind" True) |
42 | 51 | -- :} |
43 | 52 | -- |
44 | 53 | -- This is a bounded concurrent, unordered list-transformer (ListT) monad. |
45 | 54 | -- |
46 | 55 | -- WARNING! By design, monad bind of this type is not associative, because of |
47 | | --- concurrency order of effects as well as results may be unpredictable. |
| 56 | +-- concurrency, order of effects as well as results is non-deterministic. |
48 | 57 | -- |
49 | | --- Same as the deprecated 'Streamly.Prelude.AsyncT' type. |
| 58 | +-- Serves the same purpose as the 'Streamly.Prelude.AsyncT' type in older |
| 59 | +-- releases. |
50 | 60 | -- |
51 | 61 | -- == FairParallel |
52 | 62 | -- |
53 | 63 | -- Like Parallel but strikes a balance between going deeper into existing |
54 | | --- iterations of the loop and starting new iterations. |
| 64 | +-- iterations of the loop and starting new outer loop iterations. |
| 65 | +-- |
| 66 | +-- Use 'mkFairParallel' to construct from 'Stream' type and 'unFairParallel' to |
| 67 | +-- deconstruct back to 'Stream'. |
55 | 68 | -- |
56 | 69 | -- >>> :{ |
| 70 | +-- bind :: MonadAsync m => Stream m a -> (a -> Stream m b) -> Stream m b |
57 | 71 | -- bind = flip (Stream.parConcatMap (Stream.interleaved True)) |
58 | 72 | -- $(mkCrossType "FairParallel" "bind" True) |
59 | 73 | -- :} |
60 | 74 | -- |
61 | 75 | -- This is a bounded concurrent, fair logic programming (LogicT) monad. |
62 | 76 | -- |
63 | 77 | -- WARNING! By design, monad bind of this type is not associative, because of |
64 | | --- concurrency order of effects as well as results may be unpredictable. |
| 78 | +-- concurrency, order of effects as well as results may be unpredictable. |
65 | 79 | -- |
66 | | --- Same as the deprecated 'Streamly.Prelude.WAsyncT' type. |
| 80 | +-- Serves the same purpose as the 'Streamly.Prelude.WAsyncT' type in older |
| 81 | +-- releases. |
67 | 82 | -- |
68 | 83 | -- == EagerParallel |
69 | 84 | -- |
70 | 85 | -- Like Parallel, but executes as many actions concurrently as possible. This |
71 | 86 | -- is useful if you want all actions to be scheduled at the same time so that |
72 | 87 | -- something does not get starved due to others. |
73 | 88 | -- |
| 89 | +-- Use 'mkEagerParallel' to construct from 'Stream' type and 'unEagerParallel' |
| 90 | +-- to deconstruct back to 'Stream'. |
| 91 | +-- |
74 | 92 | -- >>> :{ |
| 93 | +-- bind :: MonadAsync m => Stream m a -> (a -> Stream m b) -> Stream m b |
75 | 94 | -- parBind = flip (Stream.parConcatMap (Stream.eager True)) |
76 | 95 | -- $(mkCrossType "EagerParallel" "parBind" True) |
77 | 96 | -- :} |
|
81 | 100 | -- WARNING! By design, monad bind of this type is not associative, because of |
82 | 101 | -- concurrency order of effects as well as results may be unpredictable. |
83 | 102 | -- |
84 | | --- Same as the deprecated 'Streamly.Prelude.ParallelT' type. |
| 103 | +-- Serves the same purpose as the 'Streamly.Prelude.ParallelT' type in older |
| 104 | +-- releases. |
85 | 105 | -- |
86 | 106 | -- == OrderedParallel |
87 | 107 | -- |
|
90 | 110 | -- specified in the code. This is closest to the serial Nested type in behavior |
91 | 111 | -- among all the concurrent types. |
92 | 112 | -- |
| 113 | +-- Use 'mkOrderedParallel' to construct from 'Stream' type and |
| 114 | +-- 'unOrderedParallel' to deconstruct back to 'Stream'. |
| 115 | +-- |
93 | 116 | -- >>> :{ |
| 117 | +-- bind :: MonadAsync m => Stream m a -> (a -> Stream m b) -> Stream m b |
94 | 118 | -- bind = flip (Stream.parConcatMap (Stream.ordered True)) |
95 | 119 | -- $(mkCrossType "OrderedParallel" "bind" True) |
96 | 120 | -- :} |
|
100 | 124 | -- WARNING! Monad bind of this type is associative for values, but because of |
101 | 125 | -- concurrency, order of effects may be unpredictable. |
102 | 126 | -- |
103 | | --- Same as the deprecated 'Streamly.Prelude.AheadT' type. |
| 127 | +-- Serves the same purpose as the 'Streamly.Prelude.AheadT' type in older |
| 128 | +-- releases. |
104 | 129 | -- |
105 | 130 | -- == Zip |
106 | 131 | -- |
107 | | --- An applicative type to zip two streams. |
| 132 | +-- A newtype wrapper over the 'Stream' type, the applicative instance zips two |
| 133 | +-- streams. |
| 134 | +-- |
| 135 | +-- Use 'mkZip' to construct from 'Stream' type and 'unZip' to deconstruct back |
| 136 | +-- to 'Stream'. |
108 | 137 | -- |
109 | 138 | -- >>> :{ |
| 139 | +-- zipApply :: Monad m => Stream m (a -> b) -> Stream m a -> Stream m b |
110 | 140 | -- zipApply = Stream.zipWith ($) |
111 | 141 | -- $(mkZipType "Zip" "zipApply" False) |
112 | 142 | -- :} |
113 | 143 | -- |
114 | 144 | -- Same as the deprcated 'Streamly.Prelude.ZipSerialM' type. |
115 | 145 | -- |
116 | | --- == ParZip |
| 146 | +-- == ZipParallel |
| 147 | +-- |
| 148 | +-- Like Zip but evaluates the streams being zipped concurrently. |
117 | 149 | -- |
118 | | --- Like Zip but evaluates the two streams concurrently. |
| 150 | +-- Use 'mkZipParallel' to construct from 'Stream' type and 'unZipParallel' to |
| 151 | +-- deconstruct back to 'Stream'. |
119 | 152 | -- |
120 | 153 | -- >>> :{ |
121 | | --- parCrossApply = Stream.parCrossApply id |
122 | | --- $(mkZipType "ParZip" "parCrossApply" True) |
| 154 | +-- parZipApply :: MonadAsync m => Stream m (a -> b) -> Stream m a -> Stream m b |
| 155 | +-- parZipApply = Stream.parZipWith id id |
| 156 | +-- $(mkZipType "ZipParallel" "parZipApply" True) |
123 | 157 | -- :} |
124 | 158 | -- |
125 | 159 | -- Same as the deprecated 'Streamly.Prelude.ZipAsync' type. |
|
0 commit comments