aboutsummaryrefslogtreecommitdiffhomepage
path: root/Data/Text
diff options
context:
space:
mode:
Diffstat (limited to 'Data/Text')
-rw-r--r--Data/Text/Pipes.hs15
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