Enum class
Tom Pledger
Tom.Pledger@peace.com
Wed, 24 Oct 2001 10:32:07 +1300
Jan-Willem Maessen writes:
| * Split the Enum class into two. Possibly "correspondence with Int"
| belongs in "Bounded"---but it depends what you think "Bounded"
| means.
FWIW I sometimes use a data type for the very purpose of adding bounds
to an open-ended type.
data Close a
= Lo
| Mid a
| Hi
deriving (Eq, Ord, Show)
instance Bounded (Close a) where
minBound = Lo
maxBound = Hi
This leads to an Enum instance where pred Hi = Hi, fromEnum Hi = _|_,
etc., which I don't intend to use but is necessary for making Close
Integer an instance of Integral.
- Tom