Skip to content

Instantly share code, notes, and snippets.

@brinchj
Created December 13, 2011 14:58
Show Gist options
  • Save brinchj/1472418 to your computer and use it in GitHub Desktop.
Save brinchj/1472418 to your computer and use it in GitHub Desktop.
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