Enum class

Lennart Augustsson lennart@augustsson.net
Tue, 23 Oct 2001 19:28:48 +0200

Tim Barbour wrote:

> Lennart Augustsson writes:
>  > "Ch. A. Herrmann" wrote:
>  >
>  > > (1) What is the justification for the types "Float" and "Double"
>  > >     to be members of the type class "Enum"? This might induce students
>  > >     to use floating point values as counters in arithmetic
>  > >     sequences.
>  >
>  > And what's wrong with that? If the students are using are using values
>  > like 0.1 and expecting it to be represented exactly then they should have
>  > some lectures about floating point arithmetic.
> Real numbers (which floating point numbers are trying to be) are not enumerable
> (that is, they cannot be placed in a one-one correspondence with the integers).

But belonging to the Enum class does not mean that all the elements of the type
can be enumerated (so maybe the name of the class is wrong).  The Enum class
has a number of operations that are very useful even for real numbers (not that
Haskell has real numbers).

    -- Lennart