From 6f6f9974afc107886c61acc7f9cf4b0a3f5dc6d7 Mon Sep 17 00:00:00 2001 From: michaelt Date: Fri, 4 Oct 2013 22:40:44 -0400 Subject: a little more documentation --- Data/Text/Pipes.hs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'Data/Text') diff --git a/Data/Text/Pipes.hs b/Data/Text/Pipes.hs index e9b5488..f972d2d 100644 --- a/Data/Text/Pipes.hs +++ b/Data/Text/Pipes.hs @@ -205,7 +205,8 @@ stdin :: MonadIO m => Producer' Text m () stdin = fromHandle IO.stdin {-# INLINABLE stdin #-} --- | Convert a 'IO.Handle' into a byte stream using a default chunk size +-- | Convert a 'IO.Handle' into a text stream using a chunk size +-- determined by the good sense of the text library. fromHandle :: MonadIO m => IO.Handle -> Producer' Text m () fromHandle h = go where go = do txt <- liftIO (T.hGetChunk h) @@ -213,6 +214,16 @@ fromHandle h = go where go {-# INLINABLE fromHandle#-} +{-| Stream text from a file using Pipes.Safe + +>>> runSafeT $ runEffect $ readFile "README.md" >-> map toUpper >-> hoist lift stdout +TEXT-PIPES +========== +TEXT PIPES, SOMEHOW TO BE FUSED WITH `PIPES-TEXT`. +... +>>> +-} + readFile :: (MonadSafe m, Base m ~ IO) => FilePath -> Producer' Text m () readFile file = Safe.withFile file IO.ReadMode fromHandle {-# INLINABLE readFile #-} -- cgit v1.2.3