Created
January 14, 2012 11:26
-
-
Save ymirpl/1611056 to your computer and use it in GitHub Desktop.
cute data types
This file contains hidden or 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
data Car a b c = Car { company :: a | |
, model :: b | |
, year :: c | |
} deriving (Show) | |
tellCar :: Car -> String | |
tellCar (Car {company = c, model = m, year = y} = "This " ++ c ++ " " ++ m ++ " was made in " | |
) | |
++ show y | |
ghci> let stang = Car {company="Ford", model="Mustang", year=1967} | |
ghci> tellCar stang | |
"This Ford Mustang was made in 1967" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment