packages feed

iteratee-0.8.1.0: tests/foo.hs

import Data.ByteString (ByteString)
import Data.Iteratee as I
import Data.Iteratee.Char
import System

main = do
        args <- getArgs
        let fname     = args !! 0
        let blockSize = read $ args !! 1

        fileDriver (leak blockSize) fname >>= print

leak :: Int -> Iteratee ByteString IO ()
leak blockSize = chunkedRead
    where
        consChunk :: Iteratee ByteString IO String
        consChunk = (joinI $ I.take blockSize I.length) >>= return . show

        chunkedRead :: Iteratee ByteString IO ()
        chunkedRead = joinI $ convStream consChunk printLinesUnterminated