More concretely, it's likely that Ord Bool is defined via `compare`, which is necessarily strict in both arguments.

Yes, this did come to mind. In general a non-strict `compare` would only make sense for `()`.

One of the relationships implied by the Ord typeclass is:

a <= b = True  iff  compare a b = EQ \/ compare a b = LT

So wouldn’t it make sense to define `compare` in terms of the “weaker” relations? It seems very unhaskelly to do the unnecessary work of evaluating the second argument to a relation when we already know what the result should be.

Vilem

On 2 Jan 2019, at 10:29, Isaac Elliott <isaace71295@gmail.com> wrote:

One of the relationships implied by the Ord typeclass is:

a <= b = True  iff  compare a b = EQ \/ compare a b = LT

If we write an alternative definition of (<=) that is only strict in its first argument:

False <= _ = True
True <= x = x

Then it's impossible to write `compare` in a way that's consistent with that relation.

More concretely, it's likely that Ord Bool is defined via `compare`, which is necessarily strict in both arguments.

On Wed, 2 Jan. 2019, 7:47 pm V.Liepelt, <V.Liepelt@kent.ac.uk> wrote:
I am surprised to find that `False <= undefined = undefined`.

What justifies (<=) to be strict in both arguments?

Vilem
_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.