{- To be compiled with $ ghc --make -main-is Grep Grep.hs -} module Grep where import Data.List (isInfixOf) import System.Environment grepLines :: String -> String -> String grepLines w = unlines . map showLine . grep . zip [1..] . lines where grep = filter (isInfixOf w . snd) showLine (n,l) = show n ++ ": " ++ l main = do [word] <- getArgs interact (grepLines word)