Accessing members of a custom data type in Haskell

haskell

Solution

Function application is prefix, so `age person` would correspond to the `person.age()` common in OOP languages. The `print_age` function could be defined pointfree by function composition

print_age = print . age

or point-full

print_age person = print (age person)

Problem

Say I have the following custom data type and function in Haskell: ``` data Person = Person { first_name :: String, last_name :: String, age :: Int } deriving (Eq, Ord, Show) ``` If I want to create a function `print_age` to print a Person's age, like so: `print_age (Person "John" "Smith" 21)` , how would I write `print_age` to access the age parameter? I'm an Object Oriented guy, so I'm out of my element here. I'm basically looking for the equivalent of Person.age.

Original source