import Data.List (isPrefixOf) import System.Environment (getArgs) main = do args <- getArgs mapM_ identify args identify f = do g <- catch (isInteresting f) handler case g of Just h -> putStrLn (f ++ ": " ++ if h then "interesting" else "boring") Nothing -> return () where handler e = do print e return Nothing isInteresting f = do x <- readFile f return (Just (x `contains` "Haskell")) [] `contains` _ = False (x:xs) `contains` y = y `isPrefixOf` (x:xs) || xs `contains` y