Note: The solution of this exercise is given near the end of the chapter, so we recommend that you attempt it before getting there.
Reread the function definitions above. Then look closer at the showDate helper function. We said it was provided "for the sake of code clarity", but there is a certain clumsiness in the way it is used. You have to pass three separate Int arguments to it, but these arguments are always linked to each other as part of a single date. It would make no sense to do things like passing the year, month and day values of the Anniversary in a different order, or to pass the month value twice and omit the day.
Could we use what we've seen in this chapter so far to reduce this clumsiness?
Declare a Date type which is composed of three Int, corresponding to year, month and day. Then, rewrite showDate so that it uses the new Date data type. What changes will then be needed in showAnniversary and the Anniversary for them to make use of Date?.
dataAnniversary=BirthdayStringDate|WeddingStringStringDatedataDate=DateIntIntInt-- Year, Month, DayshowDate::Date->StringshowDate(Dateymd)=showy++"-"++showm++"-"++showdshowAnniversary::Anniversary->StringshowAnniversary(Birthdaynamedate)=name++" born "++showDatedateshowAnniversary(Weddingname1name2date)=name1++" married "++name2++" on "++showDatedate