diff options
author | michaelt <what_is_it_to_do_anything@yahoo.com> | 2013-11-20 22:21:26 -0500 |
---|---|---|
committer | michaelt <what_is_it_to_do_anything@yahoo.com> | 2013-11-20 22:21:26 -0500 |
commit | d4732515ee7ab5c5d5888fe3704e33c5b6ff16f9 (patch) | |
tree | 5d11dd826faf196e76db62f1294a97163cbab82f /Pipes | |
parent | b4d21c025864357dab2b0df07091d953c6da98f3 (diff) | |
download | text-pipes-d4732515ee7ab5c5d5888fe3704e33c5b6ff16f9.tar.gz text-pipes-d4732515ee7ab5c5d5888fe3704e33c5b6ff16f9.tar.zst text-pipes-d4732515ee7ab5c5d5888fe3704e33c5b6ff16f9.zip |
rules for following pipes-bytestring
Diffstat (limited to 'Pipes')
-rw-r--r-- | Pipes/Text.hs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/Pipes/Text.hs b/Pipes/Text.hs index f2b4aac..06f2a7f 100644 --- a/Pipes/Text.hs +++ b/Pipes/Text.hs | |||
@@ -305,6 +305,11 @@ toHandle :: MonadIO m => IO.Handle -> Consumer' Text m r | |||
305 | toHandle h = for cat (liftIO . T.hPutStr h) | 305 | toHandle h = for cat (liftIO . T.hPutStr h) |
306 | {-# INLINABLE toHandle #-} | 306 | {-# INLINABLE toHandle #-} |
307 | 307 | ||
308 | {-# RULES "p >-> toHandle h" forall p h . | ||
309 | p >-> toHandle h = for p (\bs -> liftIO (T.hPutStr h bs)) | ||
310 | #-} | ||
311 | |||
312 | |||
308 | -- | Stream text into a file. Uses @pipes-safe@. | 313 | -- | Stream text into a file. Uses @pipes-safe@. |
309 | writeFile :: (MonadSafe m, Base m ~ IO) => FilePath -> Consumer' Text m () | 314 | writeFile :: (MonadSafe m, Base m ~ IO) => FilePath -> Consumer' Text m () |
310 | writeFile file = Safe.withFile file IO.WriteMode toHandle | 315 | writeFile file = Safe.withFile file IO.WriteMode toHandle |
@@ -335,9 +340,10 @@ pack = P.map T.pack | |||
335 | 340 | ||
336 | -- | Transforma a Pipes of 'Text' chunks into one of 'String's | 341 | -- | Transforma a Pipes of 'Text' chunks into one of 'String's |
337 | unpack :: Monad m => Pipe Text String m r | 342 | unpack :: Monad m => Pipe Text String m r |
338 | unpack = P.map T.unpack | 343 | unpack = for cat (\t -> yield (T.unpack t)) |
339 | {-# INLINEABLE unpack #-} | 344 | {-# INLINEABLE unpack #-} |
340 | 345 | ||
346 | |||
341 | -- | @toCaseFold@, @toLower@, @toUpper@ and @stripStart@ are standard 'Text' utility, | 347 | -- | @toCaseFold@, @toLower@, @toUpper@ and @stripStart@ are standard 'Text' utility, |
342 | -- here acting on a 'Text' pipe, rather as they would on a lazy text | 348 | -- here acting on a 'Text' pipe, rather as they would on a lazy text |
343 | toCaseFold :: Monad m => Pipe Text Text m () | 349 | toCaseFold :: Monad m => Pipe Text Text m () |