[Haskell-cafe] Ord methods too strict?

Tom Ellis tom-lists-haskell-cafe-2017 at jaguarpaw.co.uk
Wed Jan 2 11:37:23 UTC 2019


On Wed, Jan 02, 2019 at 09:47:15AM +0000, V.Liepelt wrote:
> I am surprised to find that `False <= undefined = undefined`.
>
> What justifies (<=) to be strict in both arguments?

The implementation of the Ord instance for Bool is derived, as you can see
here:

    https://www.stackage.org/haddock/lts-12.1/ghc-prim-0.5.2.0/src/GHC-Classes.html#Ord

As for the justification, perhaps it's too much of a special case for only
one value of an enumeration to compare to undefined without crashing, and
perhaps it inhibits optimisation opportunities.

Tom


More information about the Haskell-Cafe mailing list