[ketil@ii.uib.no: Re: Enum class]
Ketil Malde
ketil@ii.uib.no
25 Oct 2001 11:11:42 +0200
Dylan Thurston <dpt@math.harvard.edu> writes:
> On Thu, Oct 25, 2001 at 10:01:57AM +0200, Ketil Malde wrote:
> I think it's clear from the thread that the language designers did
> _not_ intend this, and that one should not use the default instances
> for the standard numeric classes. See Simon Peyton-Jones' recent
> post.
Yeah, I just read it. Unfortunately, I got this thread first :-)
> I agree that Enum instances for Float/Double are not likely to be
> useful.
>From a gut feeling, I could see a use for expressions like
[1.5, 1.6..] and [1.5, 1.6..2.0]
(i.e. enumFromThen and enumFromThenTo) but enumFrom and enumFromTo
making list of rounded integers seems strange to me.
It seems to me that enumFromThen and -To could be implemented
something like:
enumFromThen beg next = beg : enumFromThen next (next+delta)
where delta = next-beg
similarly for enumFromThenTo, of course.
i.e. depending only on functionality found in Num. Why not put these
functions there, and remove Float and Double as Enum instances?
What am I missing?
-kzm
--
If I haven't seen further, it is by standing in the footprints of giants