Created
May 21, 2019 15:36
-
-
Save cblp/19f89e8238903d29b4a0d3d377649924 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 CountLines where | |
import Prelude hiding (length, lines, | |
readFile) | |
import Control.Monad.Trans.Resource (runResourceT) | |
import Data.ByteString.Streaming.Char8 (lines, readFile, toLazy) | |
import Streaming (mapped) | |
import Streaming.Prelude (fst', length) | |
countLines :: FilePath -> IO Int | |
countLines = | |
runResourceT . fmap fst' . length . mapped toLazy . lines . readFile | |
countLinesInFiles :: [FilePath] -> IO Int | |
countLinesInFiles = fmap sum . traverse countLines |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment