Skip to content

Instantly share code, notes, and snippets.

@ymirpl
Created January 14, 2012 11:26
Show Gist options
  • Save ymirpl/1611056 to your computer and use it in GitHub Desktop.
Save ymirpl/1611056 to your computer and use it in GitHub Desktop.
cute data types
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