I'm looking on the Haskell 98 Report, and the definition of (==) for values of type Array a b looks wrong to me. Here is the definition given:
a == a' = (assocs a == assocs a')
But this fails to account for the array length in each dimension; hence, if
- x is a 0 x 2 array,
- y is a 2 x 0, and
- z is a 0 x 0 array,
then
are all True, even though
- bounds x != bounds y,
- bounds x != bounds z, and
- bounds y != bounds z.
This violates the most fundamental property of equality: that if a == b, then you can substitute a for b in an expression without changing the value of the expression.
I can't possibly be the first person to have noticed this. So why is equality for Arrays defined this way?