Created
September 24, 2009 15:11
-
-
Save flazz/192789 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 Main where | |
import System (getArgs) | |
import Text.RegexPR | |
-- matches lines against a pattern | |
grep :: String -> [String] -> [String] | |
grep p = filter $ match | |
where match s = case matchRegexPR p s of | |
Just _ -> True | |
Nothing -> False | |
-- take standard in filter through grep, out to standard out | |
main :: IO () | |
main = do | |
args <- getArgs | |
let [pattern] = args | |
interact $ unlines . (grep pattern) . lines |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment