X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=Data%2FText%2FPipes.hs;h=e918585ee49d3cebbeaa9c0bff18f2eb9be394c0;hb=13a43263ca34ae5124f630b5b5cefdde831596b3;hp=f972d2d505ed57c3ceca6521a0ff08b1a7d93644;hpb=6f6f9974afc107886c61acc7f9cf4b0a3f5dc6d7;p=github%2Ffretlink%2Ftext-pipes.git 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 @@ {-# LANGUAGE RankNTypes, TypeFamilies #-} -{-| This module provides @pipes@ utilities for \"byte streams\", which are - streams of strict 'Text's chunks. Use byte streams to interact +{-| This module provides @pipes@ utilities for \"text streams\", which are + streams of strict 'Text' chunks. Use text streams to interact with both 'IO.Handle's and lazy 'Text's. To stream to or from 'IO.Handle's, use 'fromHandle' or 'toHandle'. For example, the following program copies data from one file to another: > import Pipes -> import qualified Pipes.Text as P +> import qualified Data.Text.Pipes as P > import System.IO > > main = @@ -16,6 +16,15 @@ > withFile "outFile.txt" WriteMode $ \hOut -> > runEffect $ P.fromHandle hIn >-> P.toHandle hOut + The following is the more Prelude-like and uses Pipes.Safe: + +> import Pipes +> import qualified Data.Text.Pipes as P +> import Pipes.Safe +> +> main = runSafeT $ runEffect $ P.readFile "inFile.txt" >-> P.writeFile "outFile.txt" + + You can stream to and from 'stdin' and 'stdout' using the predefined 'stdin' and 'stdout' proxies, like in the following \"echo\" program: