|
1 | 1 | {-| "Pipes.Group.Tutorial" is the correct introduction to the use of this module, |
2 | 2 | which is mostly just an optimized @Pipes.Group@, replacing @FreeT@ with @Stream@. |
| 3 | + The module also includes optimized functions for interoperation: |
| 4 | +
|
| 5 | +> fromStream :: Monad m => Stream (Of a) m r -> Producer' a m r |
| 6 | +> toStream :: Monad m => Producer a m r -> Stream (Of a) m r |
3 | 7 | . |
4 | | - The only systematic difference is that this simple module omits lenses, which |
| 8 | + It is not a drop in replacement for @Pipes.Group@. The only systematic difference |
| 9 | + is that this simple module omits lenses. It is hoped that this will |
5 | 10 | may make elementary usage easier to grasp. The lenses exported the pipes packages |
6 | | - come into their own with the simple @StateT@ parsing procedure pipes promotes. |
7 | | - I hope to make a corresponding @Streaming.Pipes.Lens@ soon. |
| 11 | + only come into their own with the simple @StateT@ parsing procedure pipes promotes. |
| 12 | + We are not attempting here to replicate this advanced procedure, but only to make |
| 13 | + elementary forms of breaking and splitting possible in the simplest possible way. |
8 | 14 | . |
9 | 15 | The @pipes-group@ tutorial |
10 | 16 | is framed as a hunt for a genuinely streaming |
11 | | - @threeGroups@. The formulation it opts for in the end would |
| 17 | + @threeGroups@, which would collect the first three groups of matching items while |
| 18 | + never holding more than the present item in memory. |
| 19 | + The formulation it opts for in the end would |
12 | 20 | be expressed here thus: |
13 | 21 |
|
14 | 22 | > import Pipes |
|
28 | 36 | 'b' |
29 | 37 | 'c' |
30 | 38 | 'c' |
31 | | -
|
| 39 | + |
| 40 | + The new user might look at the examples of splitting, breaking and joining |
| 41 | + in @Streaming.Prelude@ keeping in mind that @Producer a m r@ is equivalent |
| 42 | + to @Stream (Of a) m r@. |
| 43 | + . |
32 | 44 | For the rest, only part of the tutorial that would need revision is |
33 | 45 | the bit at the end about writing explicit @FreeT@ programs. Here one does |
34 | 46 | not proceed by pattern matching, but uses `inspect` in place of `runFreeT` |
|
48 | 60 |
|
49 | 61 | {-#LANGUAGE RankNTypes, BangPatterns #-} |
50 | 62 |
|
51 | | - |
52 | | - |
53 | 63 | module Streaming.Pipes ( |
54 | 64 | -- * @Streaming@ \/ @Pipes@ interoperation |
55 | 65 | fromStream, |
@@ -185,6 +195,7 @@ span predicate = loop where |
185 | 195 | -} |
186 | 196 | break :: Monad m => (a -> Bool) -> Producer a m r -> Producer a m (Producer a m r) |
187 | 197 | break predicate = span (not . predicate) |
| 198 | +{-#INLINE break #-} |
188 | 199 |
|
189 | 200 | split :: (Eq a, Monad m) => |
190 | 201 | a -> Producer a m r -> Stream (Producer a m) m r |
|
0 commit comments