Commit 75b0360 DDC
committed
1 parent bc8228d commit 75b0360 Copy full SHA for 75b0360
File tree 7 files changed +23
-2
lines changed
streamy-pipes/lib/Streamy
streamy-streaming/lib/Streamy
streamy-testsuite/lib/Test
7 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -18,3 +18,4 @@ cabal.sandbox.config
18
18
.stack-work /
19
19
cabal.project.local
20
20
.HTF /
21
+ Session.vim
Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ module Streamy.Pipes (
36
36
, Streamy.Pipes. group
37
37
, Streamy.Pipes. maps
38
38
, Streamy.Pipes. concats
39
+ , Streamy.Pipes. yields
39
40
) where
40
41
41
42
import qualified Data.List
@@ -46,6 +47,7 @@ import qualified Pipes.Group as PG
46
47
47
48
import Control.Monad
48
49
import Control.Monad.Trans.Class
50
+ import Control.Monad.Trans.Free (liftF )
49
51
import Control.Monad.IO.Class
50
52
51
53
import Lens.Micro.Extras (view )
@@ -158,3 +160,5 @@ maps f (Groups gs) = Groups $ PG.maps f gs
158
160
concats :: Monad m => Groups a m r -> Stream a m r
159
161
concats (Groups gs) = PG. concats gs
160
162
163
+ yields :: Monad m => Stream a m r -> Groups a m r
164
+ yields producer = Groups $ liftF producer
Original file line number Diff line number Diff line change @@ -29,7 +29,8 @@ package.
29
29
30
30
## Feature matrix
31
31
32
- There are gaps in coverage in implementation of functions. Below is a feature matrix saying which functions are supported by which libraries.
32
+ There are gaps in coverage in implementation of functions. Below is a feature
33
+ matrix saying which functions are supported by which libraries.
33
34
34
35
Key | Module name
35
36
----|--------------------------
@@ -85,5 +86,5 @@ There are gaps in coverage in implementation of functions. Below is a feature m
85
86
| group | X | X | |
86
87
| maps | X | X | |
87
88
| concats | X | X | |
88
-
89
+ | yields | X | X | |
89
90
Original file line number Diff line number Diff line change @@ -85,4 +85,6 @@ maps :: Monad m => (forall x. Stream a m x -> Stream b m x) -> Groups a m r -> G
85
85
86
86
concats :: Monad m => Groups a m r -> Stream a m r
87
87
88
+ yields :: Monad m => Stream a m r -> Groups a m r
89
+
88
90
Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ module Streamy.Streaming (
37
37
, Streamy.Streaming. group
38
38
, Streamy.Streaming. maps
39
39
, Streamy.Streaming. concats
40
+ , Streamy.Streaming. yields
40
41
) where
41
42
42
43
import Control.Monad
@@ -161,6 +162,9 @@ maps f (Groups gs) = Groups $ Q.maps (getStream . f . Stream) gs
161
162
concats :: Monad m => Groups a m r -> Stream a m r
162
163
concats (Groups gs) = Stream $ Q. concats gs
163
164
165
+ yields :: Monad m => Stream a m r -> Groups a m r
166
+ yields (Stream s) = Groups $ Q. yields s
167
+
164
168
--
165
169
toTup :: Of a r -> (a ,r )
166
170
toTup = \ (a :> r) -> (a,r)
Original file line number Diff line number Diff line change @@ -20,9 +20,17 @@ import Data.IORef
20
20
grouping :: [TestTree ]
21
21
grouping =
22
22
[ testCase " group-map-concats" basic
23
+ , testCase " yields" testYields
23
24
]
24
25
25
26
basic :: Assertion
26
27
basic = do
27
28
r <- Y. toList_ . Y. concats . Y. maps (\ s -> Y. yield ' <' *> s <* Y. yield ' >' ) . Y. group $ Y. each " aabbcc"
28
29
assertEqual " " " <aa><bb><cc>" r
30
+
31
+ testYields :: Assertion
32
+ testYields = do
33
+ r <- Y. toList_ . Y. concats . Y. yields $ Y. each " aaa" *> Y. each " bbb"
34
+ assertEqual " " " aaabbb" r
35
+
36
+
Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ signature Test.Grouping.Streamy (
32
32
, group
33
33
, maps
34
34
, concats
35
+ , yields
35
36
) where
36
37
37
38
import Prelude () -- weird confusions otherwise
You can’t perform that action at this time.
0 commit comments