in a way that is independent of the boundaries of the underlying @Text@ chunks.
This means that they may freely split text into smaller texts and /discard empty texts/.
The objective, though, is that they should not /concatenate texts/ in order to provide strict upper
- bounds on memory usage.
+ bounds on memory usage even for indefinitely complex compositions.
For example, to stream only the first three lines of 'stdin' to 'stdout' you
might write:
> import qualified Pipes.Text as Text
> import qualified Pipes.Text.IO as Text
> import Pipes.Group (takes')
-> import Lens.Family (view, (%~)) -- or, Control.Lens
+> import Lens.Family (view, over) -- or `Lens.Micro.Mtl` or `Control.Lens` or etc.
>
> main = runEffect $ takeLines 3 Text.stdin >-> Text.stdout
> where
> takeLines n = view Text.unlines . takes' n . view Text.lines
-> -- or equivalently: Text.unlines %~ takes' n
+> -- or equivalently: over Text.unlines (takes' n)
This program will not bring more into memory than what @Text.stdin@ considers
one chunk of text (~ 32 KB), even if individual lines are split
name: pipes-text
-version: 0.0.2.0
-synopsis: Text pipes.
-description: * This organization of the package follows the rule
+version: 0.0.2.1
+synopsis: properly streaming text
+description: /New in version 0.0.2/:
+ .
+ A new module @Pipes.Prelude.Text@ exports line-based @Text@ producers and consumers as a drop-in replacement for the @String@ material in @Pipes.Prelude@ and @Pipes.Safe.Prelude@. They can be used as one uses @Pipes.Prelude@ without reference to the rest of this package. See the caveats in the documentation for that module.
+ .
+ For the rest, the organization of this package follows the rule:
.
* @pipes-text : pipes-bytestring :: text : bytestring@
.
Familiarity with the other three packages should give one an idea what to expect where. The package has three principal modules, @Pipes.Text@ , @Pipes.Text.Encoding@ and @Pipes.Text.IO@; the division has more or less the significance it has in the @text@ library. A fourth module @Pipes.Prelude.Text@ is explained below.
.
- Note that the module @Pipes.Text.IO@ is present as a convenience (as is @Data.Text.IO@). Official pipes IO would use @Pipes.ByteString@ together with the bytestring decoding functions in @Pipes.Text.Encoding@. In particular, the @Pipes.Text.IO@ functions use Text exceptions.
- .
- The fourth module @Pipes.Prelude.Text@ exports line-based Text producers and consumers as a drop-in replacement for the String material in @Pipes.Prelude@ and @Pipes.Safe.Prelude@. They can be used as one uses @Pipes.Prelude@ without reference to the rest of this package. See the caveats in the documentation for that module.
+ The module @Pipes.Text.IO@ is present as a convenience. Official pipes IO would use @Pipes.ByteString@ together with the bytestring decoding functions in @Pipes.Text.Encoding@. In particular, the @Pipes.Text.IO@ functions use Text exceptions.
.
@Pipes.Text.IO@ and @Pipes.Prelude.Text@ use version 0.11.3 or later of the @text@ library. To use a (very) old version of @text@, install with the flag @-fnoio@
other-extensions: RankNTypes
default-language: Haskell2010
- ghc-options: -O2
if !flag(noio)
exposed-modules: Pipes.Text.IO, Pipes.Text.Tutorial, Pipes.Prelude.Text