diff options
Diffstat (limited to 'Pipes/Text.hs')
-rw-r--r-- | Pipes/Text.hs | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/Pipes/Text.hs b/Pipes/Text.hs index 9f84429..e027d00 100644 --- a/Pipes/Text.hs +++ b/Pipes/Text.hs | |||
@@ -137,10 +137,10 @@ import Prelude hiding ( | |||
137 | 137 | ||
138 | * /I. Effectful Text/ | 138 | * /I. Effectful Text/ |
139 | 139 | ||
140 | This package provides @pipes@ utilities for /text streams/, understood as | 140 | This package provides @pipes@ utilities for /text streams/ or /character streams/, |
141 | streams of 'Text' chunks. The individual chunks are uniformly /strict/, and thus you | 141 | realized as streams of 'Text' chunks. The individual chunks are uniformly /strict/, |
142 | will generally want @Data.Text@ in scope. But the type @Producer Text m r@ as we | 142 | and thus you will generally want @Data.Text@ in scope. But the type |
143 | are using it is a sort of pipes equivalent of the lazy @Text@ type. | 143 | @Producer Text m r@ ,as we are using it, is a sort of /pipes/ equivalent of the lazy @Text@ type. |
144 | 144 | ||
145 | This particular module provides many functions equivalent in one way or another to | 145 | This particular module provides many functions equivalent in one way or another to |
146 | the pure functions in | 146 | the pure functions in |
@@ -210,7 +210,7 @@ import Prelude hiding ( | |||
210 | would drop the leading white space from each line. | 210 | would drop the leading white space from each line. |
211 | 211 | ||
212 | The lenses in this library are marked as /improper/; this just means that | 212 | The lenses in this library are marked as /improper/; this just means that |
213 | they don't admit all the operations of an ideal lens, but only "getting" and "focussing". | 213 | they don't admit all the operations of an ideal lens, but only /getting/ and /focusing/. |
214 | Just for this reason, though, the magnificent complexities of the lens libraries | 214 | Just for this reason, though, the magnificent complexities of the lens libraries |
215 | are a distraction. The lens combinators to keep in mind, the ones that make sense for | 215 | are a distraction. The lens combinators to keep in mind, the ones that make sense for |
216 | our lenses, are @view@ \/ @(^.)@), @over@ \/ @(%~)@ , and @zoom@. | 216 | our lenses, are @view@ \/ @(^.)@), @over@ \/ @(%~)@ , and @zoom@. |
@@ -252,7 +252,7 @@ import Prelude hiding ( | |||
252 | contain at the start. Then we might write something like this: | 252 | contain at the start. Then we might write something like this: |
253 | 253 | ||
254 | > obey :: Monad m => Producer Text m b -> Producer Text m b | 254 | > obey :: Monad m => Producer Text m b -> Producer Text m b |
255 | > obey p = do (ts, p') <- lift $ runStateT (zoom (Text.splitAt 8) drawAll) p | 255 | > obey p = do (ts, p') <- lift $ runStateT (zoom (Text.splitAt 7) drawAll) p |
256 | > let seven = T.concat ts | 256 | > let seven = T.concat ts |
257 | > case T.toUpper seven of | 257 | > case T.toUpper seven of |
258 | > "TOUPPER" -> p' >-> Text.toUpper | 258 | > "TOUPPER" -> p' >-> Text.toUpper |
@@ -260,6 +260,11 @@ import Prelude hiding ( | |||
260 | > _ -> do yield seven | 260 | > _ -> do yield seven |
261 | > p' | 261 | > p' |
262 | 262 | ||
263 | |||
264 | > >>> let doc = each ["toU","pperTh","is document.\n"] | ||
265 | > >>> runEffect $ obey doc >-> Text.stdout | ||
266 | > THIS DOCUMENT. | ||
267 | |||
263 | The purpose of exporting lenses is the mental economy achieved with this three-way | 268 | The purpose of exporting lenses is the mental economy achieved with this three-way |
264 | applicability. That one expression, e.g. @lines@ or @splitAt 17@ can have these | 269 | applicability. That one expression, e.g. @lines@ or @splitAt 17@ can have these |
265 | three uses is no more surprising than that a pipe can act as a function modifying | 270 | three uses is no more surprising than that a pipe can act as a function modifying |
@@ -314,7 +319,7 @@ import Prelude hiding ( | |||
314 | 319 | ||
315 | > join :: Monad m => Producer Text m (Producer m r) -> Producer m r | 320 | > join :: Monad m => Producer Text m (Producer m r) -> Producer m r |
316 | 321 | ||
317 | The return type of 'lines', 'words', 'chunksOf' and the other "splitter" functions, | 322 | The return type of 'lines', 'words', 'chunksOf' and the other /splitter/ functions, |
318 | @FreeT (Producer m Text) m r@ -- our @Texts m r@ -- is the type of (effectful) | 323 | @FreeT (Producer m Text) m r@ -- our @Texts m r@ -- is the type of (effectful) |
319 | lists of (effectful) texts. The type @([Text],r)@ might be seen to gather | 324 | lists of (effectful) texts. The type @([Text],r)@ might be seen to gather |
320 | together things of the forms: | 325 | together things of the forms: |
@@ -368,7 +373,7 @@ import Prelude hiding ( | |||
368 | of @FreeT (Producer Text m) m r@ is simply the 'effectful' version of this. | 373 | of @FreeT (Producer Text m) m r@ is simply the 'effectful' version of this. |
369 | 374 | ||
370 | The @Pipes.Group@ module, which can generally be imported without qualification, | 375 | The @Pipes.Group@ module, which can generally be imported without qualification, |
371 | provides many functions for working with things of type @FreeT (Producer a m) m r@ | 376 | provides many functions for working with things of type @FreeT (Producer a m) m r@. |
372 | In particular it conveniently exports the constructors for @FreeT@ and the associated | 377 | In particular it conveniently exports the constructors for @FreeT@ and the associated |
373 | @FreeF@ type -- a fancy form of @Either@, namely | 378 | @FreeF@ type -- a fancy form of @Either@, namely |
374 | 379 | ||