Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
-- さっきより、良い書き方
data Person = Person { firstName :: String
, lastName :: String
, age :: Int
, height :: Float
, phoneNumber :: String
, flavor :: 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.