Permalink
Browse files

Change formatting of Control.Pipe.Tee.

  • Loading branch information...
1 parent dc6ea60 commit c814dbfb3f98cfc60243db9da8169e693a0ddc4d @pcapriotti committed Mar 8, 2012
Showing with 33 additions and 29 deletions.
  1. +33 −29 pipes-extra/Control/Pipe/Tee.hs
@@ -1,45 +1,49 @@
-{- |
-Module : Control.Pipe.Tee
-Description : Combinators similar to the unix 'tee' command.
-Copyright : (c) 2012 Jeremy Shaw
-License : BSD3
-
-Maintainer : jeremy@n-heptane.com
-Stability : experimental
-Portability : portable
-
-The 'tee' combinators act like 'idP', but also send a copy of the input to the
-supplied 'Consumer', a file, etc. This is typically done for the purpose of
-logging a pipeline, showing progress, etc.
--}
-module Control.Pipe.Tee where
+-- |
+-- Module : Control.Pipe.Tee
+-- Copyright : (c) 2012 Jeremy Shaw
+-- (c) 2012 Paolo Capriotti
+-- License : BSD3
+--
+-- Maintainer : jeremy@n-heptane.com
+-- Stability : experimental
+-- Portability : portable
+--
+-- The 'tee' combinators act like 'idP', but also send a copy of the input to the
+-- supplied 'Consumer' (e.g. a file). This is typically done for the purpose of
+-- logging a pipeline, showing progress, etc.
+module Control.Pipe.Tee (
+ tee,
+ teeFile,
+ teeFileBS
+ ) where
import Control.Monad.Trans (MonadIO(..))
-import Control.Pipe (Pipe, (>+>), firstP, discardL, idP, pipe)
+import Control.Pipe
import Control.Pipe.Binary (fileWriter)
-import Control.Pipe.Monoidal ((***), splitP)
import Data.ByteString (ByteString)
import Data.Void (Void)
--- | acts like 'idP', but also passes a copy to the supplied consumer
-tee :: (Monad m) =>
- Pipe a Void m r -- ^ 'Consumer' that will receive a copy of all the input
+-- | Acts like 'idP', but also passes a copy to the supplied consumer.
+tee :: (Monad m)
+ => Pipe a Void m r -- ^ 'Consumer' that will receive a copy of all the input
-> Pipe a a m r
tee consumer =
splitP >+> firstP consumer >+> discardL
--- | acts like 'idP', but also writes a copy to a file
-teeFile :: (MonadIO m) =>
- (a -> ByteString) -- ^ function to convert the value to a 'ByteString' which can be written to the log
- -> FilePath -- ^ file to log to
+-- | Acts like 'idP', but also writes a copy to a file.
+teeFile :: (MonadIO m)
+ => (a -> ByteString) -- ^ function to convert the value to a
+ -- 'ByteString' which can be written to
+ -- the log
+ -> FilePath -- ^ file to log to
-> Pipe a a m ()
teeFile showBS logFile =
tee (pipe showBS >+> fileWriter logFile)
--- | acts like, 'idP', but also writes a copy to the specified log file
+-- | Acts like, 'idP', but also writes a copy to the specified log file.
--
--- just an alias for @teeFile id@
-teeFileBS :: (MonadIO m) =>
- FilePath -- ^ file to log to
- -> Pipe ByteString ByteString m ()
+-- This function is equivalent to @teeFile id@.
+teeFileBS :: (MonadIO m)
+ => FilePath -- ^ file to log to
+ -> Pipe ByteString ByteString m ()
teeFileBS = teeFile id

0 comments on commit c814dbf

Please sign in to comment.