Skip to content

Instantly share code, notes, and snippets.

@shigemk2 shigemk2/person.hs
Created Mar 4, 2015

Embed
What would you like to do?
-- マシな方法が思いつかない
data Person = Person String String Int Float String String
deriving (Show)
firstName :: Person -> String
firstName (Person firstname _ _ _ _ _) = firstname
lastName :: Person -> String
lastName (Person _ lastname _ _ _ _) = lastname
age :: Person -> Int
age (Person _ _ age _ _ _) = age
height :: Person -> Float
height (Person _ _ _ height _ _) = height
phoneNumber :: Person -> String
phoneNumber (Person _ _ _ _ number _) = number
flavor :: Person -> String
flavor (Person _ _ _ _ _ flavor) = flavor
main = do
print guy
print $ firstName guy
print $ height guy
print $ flavor guy
where
guy = Person "Buddy" "Finklestein" 43 184.2 "526-2928" "Chocolate"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.