Enum class

Ch. A. Herrmann herrmann@infosun.fmi.uni-passau.de
Tue, 23 Oct 2001 12:27:37 +0200

>>>>> "Lennart" == Lennart Augustsson <lennart@augustsson.net> writes:

    Lennart> "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.

    Lennart> And what's wrong with that? If the students are using are
    Lennart> using values like 0.1 and expecting it to be represented
    Lennart> exactly then they should have some lectures about floating
    Lennart> point arithmetic.

The point is that students might use the fact that Float and Double are
in type class Enum as a justification to use it in practice, e.g.,
to avoid an Int->Float conversion. Maybe one can even prove that
approximation errors will not harm in a particular situation.
The question is whether a language should impose a style that protects
programmers from taking such risks, and Haskell is a language that
uses to follow this direction. 

    Lennart> I've heard your complaint before, but I
    Lennart> can't really understand why removing Float and Double 

Removing them would possibly cause problems with existing programs 
and this is definitely not my aim. However, it'll make sense to 
think about long-term improvements. I wouldn't call Float and Double 
enumeration types. Maybe, a just misunderstood what Enum means.