Created
December 13, 2011 14:58
-
-
Save brinchj/1472418 to your computer and use it in GitHub Desktop.
This file contains 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.Environment | |
import Data.ByteString.Char8 as B | |
import Data.Map as M | |
import Data.List as L | |
import Data.Maybe | |
main = do | |
let known = M.fromList [ (B.pack "foo", 0) | |
, (B.pack "bar", 1) | |
] | |
fname <- L.head `fmap` getArgs | |
ls <- B.lines `fmap` B.readFile fname | |
-- find all lines that exist as a key in known | |
print $ L.reverse $ L.filter (isJust . (flip M.lookup) known) ls |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment