> How do you get a subtype in Haskell (or any other functional language
> come to that)? I'm thinking along the lines of (pseudo-notation):
>
> type weekday = {Mon, Tue, Wed, Thur, Fri}
> type weekend = {Sat, Sun}
> type day = weekend + weekday
> Maybe subtypes don't fit elegantly into the functional model. Maybe
> they aren't necessary anyway.
Ummm. Is this what you mean (in SML):
datatype weekday = mon | tue | wed | thu | fri;
datatype weekend = sat | sun;
datatype day = wd of weekday | we of weekend;
Essentially, if you think of your subtypes as "disjoint unions", then
we've defined day as the union of weekday and weekend, and have named
the inclusion functions as wd and we.
Regards,
Stephen Ma