Created
May 7, 2011 15:34
-
-
Save 23Skidoo/960585 to your computer and use it in GitHub Desktop.
zcat with iterIO
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main | |
where | |
import Control.Monad.IO.Class (MonadIO) | |
import Data.ByteString.Lazy (ByteString) | |
import Data.IterIO | |
import Data.IterIO.Zlib (inumGunzip) | |
import System.Environment | |
import System.IO | |
printUsage :: IO () | |
printUsage = putStrLn "Usage: myZcat FILENAME" | |
main :: IO () | |
main = do fs <- getArgs | |
case fs of | |
[] -> processInum $ enumHandle' stdin | |
_ | ("--help" `elem` fs) || ("-h" `elem` fs) -> printUsage | |
| otherwise -> processInum $ (foldr1 cat [enumFile' f | f <- fs]) | |
-- TODO: read up on what that (IterR ByteString m ()) thingy does. | |
processInum :: MonadIO m => Onum ByteString m (IterR ByteString m ()) -> m () | |
processInum i = i |. (inumRepeat inumGunzip) |$ stdoutI |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment