aboutsummaryrefslogtreecommitdiffhomepage
path: root/Pipes/Text/IO.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Pipes/Text/IO.hs')
-rw-r--r--Pipes/Text/IO.hs11
1 files changed, 5 insertions, 6 deletions
diff --git a/Pipes/Text/IO.hs b/Pipes/Text/IO.hs
index 23aff69..101052b 100644
--- a/Pipes/Text/IO.hs
+++ b/Pipes/Text/IO.hs
@@ -35,17 +35,15 @@ import Prelude hiding (readFile, writeFile)
35{- $textio 35{- $textio
36 Where pipes IO replaces lazy IO, @Producer Text m r@ replaces lazy 'Text'. 36 Where pipes IO replaces lazy IO, @Producer Text m r@ replaces lazy 'Text'.
37 This module exports some convenient functions for producing and consuming 37 This module exports some convenient functions for producing and consuming
38 pipes 'Text' in IO, with caveats described below. 38 pipes 'Text' in IO, namely, 'readFile', 'writeFile', 'fromHandle', 'toHandle',
39 'stdin' and 'stdout'. Some caveats described below.
39 40
40 The main points are as in 41 The main points are as in
41 <https://hackage.haskell.org/package/pipes-bytestring-1.0.0/docs/Pipes-ByteString.html Pipes.ByteString> 42 <https://hackage.haskell.org/package/pipes-bytestring-1.0.0/docs/Pipes-ByteString.html Pipes.ByteString>
42 43
43 An 'IO.Handle' can be associated with a 'Producer' or 'Consumer' according 44 An 'IO.Handle' can be associated with a 'Producer' or 'Consumer' according
44 as it is read or written to. 45 as it is read or written to.
45 46
46 To stream to or from 'IO.Handle's, one can use 'fromHandle' or 'toHandle'. For
47 example, the following program copies a document from one file to another:
48
49> import Pipes 47> import Pipes
50> import qualified Pipes.Text as Text 48> import qualified Pipes.Text as Text
51> import qualified Pipes.Text.IO as Text 49> import qualified Pipes.Text.IO as Text
@@ -65,11 +63,12 @@ To stream from files, the following is perhaps more Prelude-like (note that it u
65> 63>
66> main = runSafeT $ runEffect $ Text.readFile "inFile.txt" >-> Text.writeFile "outFile.txt" 64> main = runSafeT $ runEffect $ Text.readFile "inFile.txt" >-> Text.writeFile "outFile.txt"
67 65
68 You can stream to and from 'stdin' and 'stdout' using the predefined 'stdin' 66 Finally, you can stream to and from 'stdin' and 'stdout' using the predefined 'stdin'
69 and 'stdout' pipes, as with the following \"echo\" program: 67 and 'stdout' pipes, as with the following \"echo\" program:
70 68
71> main = runEffect $ Text.stdin >-> Text.stdout 69> main = runEffect $ Text.stdin >-> Text.stdout
72 70
71
73-} 72-}
74 73
75 74