= Solution
A <string data type> suffices for a name, an <algebraic data type> for the recorded sex, and a triple of <integers> for a date. Use a constructor for `Person` so that selectors are unambiguous in <Haskell>:
``
type Name = String
data Sex = Female | Male deriving (Eq, Show)
data Date = Date { day :: Int, month :: Int, year :: Int }
deriving (Eq, Show)
data Person = Person { name :: Name, sex :: Sex, born :: Date }
deriving (Eq, Show)
type BirthCertificate = (Person, Person, Person)
type Database = [BirthCertificate]
``
Dates have the <precondition> that their fields form a valid calendar date. This simple <database> representation assumes the triple of identifying fields distinguishes the recorded individuals; a production <database> would normally add a stable identifier to distinguish namesakes. The two constructors for `Sex` model the two recorded values used by this exercise. In mathematical notation,
$$
\boxed{\mathrm{Person}=\mathrm{Name}\times\mathrm{Sex}\times\mathrm{Date}.}
$$
Back to article page