These are not the monad laws that are violated, but the laws for Eq regarding Ord .
The laws in Eq require that (==) determine the equivalence relation,
forall x. x == x forall x y. x == y <=> y == x forall xy z. x == y && y == z => x == z
and the Ord contract is that < defines a complete ordering,
forall x. not (x < x) forall x y. (x < y) || (x == y) || (y < x) forall x y. not (x < y && y < x)
Floating-point types violate these laws because NaNs (NaN = Not a Number) are compared unevenly with themselves,
0/0 /= 0/0
and any comparison < , <= , ... using NaN returns False .
Therefore, when there are NaNs in the tree to be ordered, a comparison with NaN when searching for an item can send a recursive search down the wrong subtree.
source share