import Prelude hiding (all, concatMap, unlines) copyFile :: FilePath -> FilePath -> IO () copyFile from to = readFile from >>= writeFile to fileLength :: FilePath -> IO Int fileLength fn = readFile fn >>= return . length -- Returns the number of lines in a file. numOfLines :: FilePath -> IO Int numOfLines fn = readFile fn >>= return . length . lines -- Returns the number of empty/blank lines in a file. numberOfBlankLInes :: FilePath -> IO Int numberOfBlankLInes fn = readFile fn >>= return . length . filter (all (==' ')) . lines allBlanks :: String -> Bool allBlanks s = foldr (&&) True (map (==' ') s) -- Returns True if all elements of a list satisfy the given predicate. all :: (a -> Bool) -> [a] -> Bool --all p xs = foldr (&&) True (map p xs) all p = foldr (&&) True . map p enumerateLines :: String -> String enumerateLines = unlines . map (uncurry (++)) . zip (map (\n -> show n ++ ": ") [1..]) . lines concatMap :: (a -> [b]) -> [a] -> [b] concatMap f = concat . map f unlines :: [String] -> String unlines = concatMap (++"\n") showEnumeratedFileLines :: String -> IO () showEnumeratedFileLines fn = readFile fn >>= putStr . enumerateLines