aboutsummaryrefslogtreecommitdiffhomepage
path: root/Data/Text
diff options
context:
space:
mode:
authormichaelt <what_is_it_to_do_anything@yahoo.com>2013-10-04 22:40:44 -0400
committermichaelt <what_is_it_to_do_anything@yahoo.com>2013-10-04 22:40:44 -0400
commit6f6f9974afc107886c61acc7f9cf4b0a3f5dc6d7 (patch)
tree7a69504e71884c4801c01547726b069727f273f3 /Data/Text
parent5a1ecce3ce3cfc085982e3f445ea282713731886 (diff)
downloadtext-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.hs13
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 ()
205stdin = fromHandle IO.stdin 205stdin = 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.
209fromHandle :: MonadIO m => IO.Handle -> Producer' Text m () 210fromHandle :: MonadIO m => IO.Handle -> Producer' Text m ()
210fromHandle h = go where 211fromHandle 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
220TEXT-PIPES
221==========
222TEXT PIPES, SOMEHOW TO BE FUSED WITH `PIPES-TEXT`.
223...
224>>>
225-}
226
216readFile :: (MonadSafe m, Base m ~ IO) => FilePath -> Producer' Text m () 227readFile :: (MonadSafe m, Base m ~ IO) => FilePath -> Producer' Text m ()
217readFile file = Safe.withFile file IO.ReadMode fromHandle 228readFile file = Safe.withFile file IO.ReadMode fromHandle
218{-# INLINABLE readFile #-} 229{-# INLINABLE readFile #-}