[Haskell-cafe] instance Eq (a -> b)

Ketil Malde ketil at malde.org
Wed Apr 14 04:02:57 EDT 2010


Joe Fredette <jfredett at gmail.com> writes:

> Consider the set of all rationals with 1 as a numerator, and positive
> denominator, eg:
>
> 	S = {1/n, n : Nat}

> this is bounded, enumerable, but infinite.

Isn't making this an instance of Enum something of an abuse?

How would you use enumFromThenTo (or equivalently, [x0,x1..xn]) for
these fractions?  I think the intuition is that you can use 'enumFromTo
minBound maxBound' to exhaustively list the values in a type.
E.g. Ashley's own:

>>   allValues :: (Bounded a,Enum a) => [a]
>>   allValues = enumFrom minBound

But this doesn't work for Double (or rational), either, so it's abuse
with some precedent.

Another practical consideration is that checking a function taking a
simple Int parameter for equality would mean 2^65 function evaluations.
I think function equality would be too much of a black hole to be
worth it.

-k
-- 
If I haven't seen further, it is by standing in the footprints of giants


More information about the Haskell-Cafe mailing list