diff options
author | michaelt <what_is_it_to_do_anything@yahoo.com> | 2013-10-04 22:49:53 -0400 |
---|---|---|
committer | michaelt <what_is_it_to_do_anything@yahoo.com> | 2013-10-04 22:49:53 -0400 |
commit | 13a43263ca34ae5124f630b5b5cefdde831596b3 (patch) | |
tree | 7d32d4e67ced9307092e14785aa13a31c23131df /Data/Text | |
parent | aa62e66de787f066f48e579e047ab2ce52071bd4 (diff) | |
download | text-pipes-13a43263ca34ae5124f630b5b5cefdde831596b3.tar.gz text-pipes-13a43263ca34ae5124f630b5b5cefdde831596b3.tar.zst text-pipes-13a43263ca34ae5124f630b5b5cefdde831596b3.zip |
a little more documentation
Diffstat (limited to 'Data/Text')
-rw-r--r-- | Data/Text/Pipes.hs | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/Data/Text/Pipes.hs b/Data/Text/Pipes.hs index f972d2d..e918585 100644 --- a/Data/Text/Pipes.hs +++ b/Data/Text/Pipes.hs | |||
@@ -1,14 +1,14 @@ | |||
1 | {-# LANGUAGE RankNTypes, TypeFamilies #-} | 1 | {-# LANGUAGE RankNTypes, TypeFamilies #-} |
2 | 2 | ||
3 | {-| This module provides @pipes@ utilities for \"byte streams\", which are | 3 | {-| This module provides @pipes@ utilities for \"text streams\", which are |
4 | streams of strict 'Text's chunks. Use byte streams to interact | 4 | streams of strict 'Text' chunks. Use text streams to interact |
5 | with both 'IO.Handle's and lazy 'Text's. | 5 | with both 'IO.Handle's and lazy 'Text's. |
6 | 6 | ||
7 | To stream to or from 'IO.Handle's, use 'fromHandle' or 'toHandle'. For | 7 | To stream to or from 'IO.Handle's, use 'fromHandle' or 'toHandle'. For |
8 | example, the following program copies data from one file to another: | 8 | example, the following program copies data from one file to another: |
9 | 9 | ||
10 | > import Pipes | 10 | > import Pipes |
11 | > import qualified Pipes.Text as P | 11 | > import qualified Data.Text.Pipes as P |
12 | > import System.IO | 12 | > import System.IO |
13 | > | 13 | > |
14 | > main = | 14 | > main = |
@@ -16,6 +16,15 @@ | |||
16 | > withFile "outFile.txt" WriteMode $ \hOut -> | 16 | > withFile "outFile.txt" WriteMode $ \hOut -> |
17 | > runEffect $ P.fromHandle hIn >-> P.toHandle hOut | 17 | > runEffect $ P.fromHandle hIn >-> P.toHandle hOut |
18 | 18 | ||
19 | The following is the more Prelude-like and uses Pipes.Safe: | ||
20 | |||
21 | > import Pipes | ||
22 | > import qualified Data.Text.Pipes as P | ||
23 | > import Pipes.Safe | ||
24 | > | ||
25 | > main = runSafeT $ runEffect $ P.readFile "inFile.txt" >-> P.writeFile "outFile.txt" | ||
26 | |||
27 | |||
19 | You can stream to and from 'stdin' and 'stdout' using the predefined 'stdin' | 28 | You can stream to and from 'stdin' and 'stdout' using the predefined 'stdin' |
20 | and 'stdout' proxies, like in the following \"echo\" program: | 29 | and 'stdout' proxies, like in the following \"echo\" program: |
21 | 30 | ||