1
{-# LANGUAGE BangPatterns #-}
3
import System.Environment
5
import qualified Data.Text as T
6
import qualified Data.Text.IO as T
7
import qualified Data.ByteString as S
10
foldLinesT :: (a -> T.Text -> a) -> a -> Handle -> IO a
11
foldLinesT f z0 h = go z0
19
let z' = f z l in go z'
20
{-# INLINE foldLinesT #-}
22
testT :: Handle -> IO Int
23
testT = foldLinesT (\n _ -> n + 1) 0
26
foldLinesB :: (a -> S.ByteString -> a) -> a -> Handle -> IO a
27
foldLinesB f z0 h = go z0
35
let z' = f z l in go z'
36
{-# INLINE foldLinesB #-}
38
testB :: Handle -> IO Int
39
testB = foldLinesB (\n _ -> n + 1) 0
42
(name : file : _) <- getArgs
43
h <- openFile file ReadMode
44
hSetBuffering h (BlockBuffering (Just 16384))