+{- $textio
+ Where pipes IO replaces lazy IO, @Producer Text m r@ replaces lazy 'Text'.
+ This module exports some convenient functions for producing and consuming
+ pipes 'Text' in IO, with caveats described below. The main points are as in
+ <https://hackage.haskell.org/package/pipes-bytestring-1.0.0/docs/Pipes-ByteString.html @Pipes.ByteString@>
+
+ An 'IO.Handle' can be associated with a 'Producer' or 'Consumer' according as it is read or written to.
+
+ To stream to or from 'IO.Handle's, one can use 'fromHandle' or 'toHandle'. For
+ example, the following program copies a document from one file to another:
+
+> import Pipes
+> import qualified Pipes.Text as Text
+> import qualified Pipes.Text.IO as Text
+> import System.IO
+>
+> main =
+> withFile "inFile.txt" ReadMode $ \hIn ->
+> withFile "outFile.txt" WriteMode $ \hOut ->
+> runEffect $ Text.fromHandle hIn >-> Text.toHandle hOut
+
+To stream from files, the following is perhaps more Prelude-like (note that it uses Pipes.Safe):
+
+> import Pipes
+> import qualified Pipes.Text as Text
+> import qualified Pipes.Text.IO as Text
+> import Pipes.Safe
+>
+> main = runSafeT $ runEffect $ Text.readFile "inFile.txt" >-> Text.writeFile "outFile.txt"
+
+ You can stream to and from 'stdin' and 'stdout' using the predefined 'stdin'
+ and 'stdout' pipes, as with the following \"echo\" program:
+
+> main = runEffect $ Text.stdin >-> Text.stdout
+
+-}
+
+
+{- $caveats
+
+ The operations exported here are a convenience, like the similar operations in
+ @Data.Text.IO@ (or rather, @Data.Text.Lazy.IO@, since, again, @Producer Text m r@ is
+ 'effectful text' and something like the pipes equivalent of lazy Text.)
+
+ * Like the functions in @Data.Text.IO@, they attempt to work with the system encoding.
+
+ * Like the functions in @Data.Text.IO@, they are slower than ByteString operations. Where
+ you know what encoding you are working with, use @Pipes.ByteString@ and @Pipes.Text.Encoding@ instead,
+ e.g. @view utf8 Bytes.stdin@ instead of @Text.stdin@
+
+ * Like the functions in @Data.Text.IO@ , they use Text exceptions.
+
+ Something like
+
+> view utf8 . Bytes.fromHandle :: Handle -> Producer Text IO (Producer ByteString m ())
+
+ yields a stream of Text, and follows
+ standard pipes protocols by reverting to (i.e. returning) the underlying byte stream
+ upon reaching any decoding error. (See especially the pipes-binary package.)
+
+ By contrast, something like
+
+> Text.fromHandle :: Handle -> Producer Text IO ()
+
+ supplies a stream of text returning '()', which is convenient for many tasks,
+ but violates the pipes @pipes-binary@ approach to decoding errors and
+ throws an exception of the kind characteristic of the @text@ library instead.
+
+
+-}