Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
import Data.List
data Person = Person { name, address :: String} deriving Show
ps = [ Person "Tarou" "Tokyo"
, Person "Jirou" "Osaka"
, Person "Saburou" "Nagoya"
getAddress n ps = case find ((== n) . name) ps of
Just x -> address x
Nothing -> n ++ " ha imasen"
main = mapM_ (putStrLn . flip getAddress ps) ["Tarou","Hanako"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment