diff options
author | michaelt <what_is_it_to_do_anything@yahoo.com> | 2013-10-04 22:40:44 -0400 |
---|---|---|
committer | michaelt <what_is_it_to_do_anything@yahoo.com> | 2013-10-04 22:40:44 -0400 |
commit | 6f6f9974afc107886c61acc7f9cf4b0a3f5dc6d7 (patch) | |
tree | 7a69504e71884c4801c01547726b069727f273f3 /Data/Text | |
parent | 5a1ecce3ce3cfc085982e3f445ea282713731886 (diff) | |
download | text-pipes-6f6f9974afc107886c61acc7f9cf4b0a3f5dc6d7.tar.gz text-pipes-6f6f9974afc107886c61acc7f9cf4b0a3f5dc6d7.tar.zst text-pipes-6f6f9974afc107886c61acc7f9cf4b0a3f5dc6d7.zip |
a little more documentation
Diffstat (limited to 'Data/Text')
-rw-r--r-- | Data/Text/Pipes.hs | 13 |
1 files changed, 12 insertions, 1 deletions
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 () | |||
205 | stdin = fromHandle IO.stdin | 205 | stdin = fromHandle IO.stdin |
206 | {-# INLINABLE stdin #-} | 206 | {-# INLINABLE stdin #-} |
207 | 207 | ||
208 | -- | Convert a 'IO.Handle' into a byte stream using a default chunk size | 208 | -- | Convert a 'IO.Handle' into a text stream using a chunk size |
209 | -- determined by the good sense of the text library. | ||
209 | fromHandle :: MonadIO m => IO.Handle -> Producer' Text m () | 210 | fromHandle :: MonadIO m => IO.Handle -> Producer' Text m () |
210 | fromHandle h = go where | 211 | fromHandle h = go where |
211 | go = do txt <- liftIO (T.hGetChunk h) | 212 | go = do txt <- liftIO (T.hGetChunk h) |
@@ -213,6 +214,16 @@ fromHandle h = go where | |||
213 | go | 214 | go |
214 | {-# INLINABLE fromHandle#-} | 215 | {-# INLINABLE fromHandle#-} |
215 | 216 | ||
217 | {-| Stream text from a file using Pipes.Safe | ||
218 | |||
219 | >>> runSafeT $ runEffect $ readFile "README.md" >-> map toUpper >-> hoist lift stdout | ||
220 | TEXT-PIPES | ||
221 | ========== | ||
222 | TEXT PIPES, SOMEHOW TO BE FUSED WITH `PIPES-TEXT`. | ||
223 | ... | ||
224 | >>> | ||
225 | -} | ||
226 | |||
216 | readFile :: (MonadSafe m, Base m ~ IO) => FilePath -> Producer' Text m () | 227 | readFile :: (MonadSafe m, Base m ~ IO) => FilePath -> Producer' Text m () |
217 | readFile file = Safe.withFile file IO.ReadMode fromHandle | 228 | readFile file = Safe.withFile file IO.ReadMode fromHandle |
218 | {-# INLINABLE readFile #-} | 229 | {-# INLINABLE readFile #-} |