Why isn't there an instance Eq (a - b) ?
allValues :: (Bounded a,Enum a) = [a]
allValues = enumFrom minBound
instance (Bounded a,Enum a,Eq b) = Eq (a - b) where
p == q = fmap p allValues == fmap q allValues
Of course, it's not perfect, since empty types are finite but not
Bounded.
On 14 April 2010 16:03, Ashley Yakeley ash...@semantic.org wrote:
Why isn't there an instance Eq (a - b) ?
How do you prove that f = (2*) and g x = x + x are equal?
Mathematically, you can; but the only way you can prove it in
Haskell is by comparing the values for the entire domain (which gets
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. Which makes the whole
checking every value bit somewhat, shall we say, difficult. :)
So for instance, we want to show
f : S
On Wed, 2010-04-14 at 16:11 +1000, Ivan Miljenovic wrote:
but the only way you can prove it in
Haskell is by comparing the values for the entire domain (which gets
computationally expensive)...
It's not expensive if the domain is, for instance, Bool.
--
Ashley Yakeley
I guess nontermination is a problem (e.g. if one or both functions
fail to terminate for some values, equality will be undecidable).
/Jonas
On 14 April 2010 08:42, Ashley Yakeley ash...@semantic.org wrote:
On Wed, 2010-04-14 at 16:11 +1000, Ivan Miljenovic wrote:
but the only way you can prove
Joe Fredette jfred...@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
Ashley Yakeley ash...@semantic.org writes:
On Wed, 2010-04-14 at 16:11 +1000, Ivan Miljenovic wrote:
but the only way you can prove it in
Haskell is by comparing the values for the entire domain (which gets
computationally expensive)...
It's not expensive if the domain is, for instance,