diff options
author | Tommy Bidne <tbidne@protonmail.com> | 2022-08-12 11:14:37 +1200 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2022-09-01 12:01:20 -0400 |
commit | 31a8989a1d4aa5fe1e3ed0b2e789145bb64a8ba8 (patch) | |
tree | c776384a8b95b0fe9b0207df71c091ea3ad06a2b | |
parent | 7d3a055d4df6842f8fbcfbc1ca96e2a45a47d351 (diff) | |
download | haskell-31a8989a1d4aa5fe1e3ed0b2e789145bb64a8ba8.tar.gz |
Change Ord defaults per CLC proposal
Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/24#issuecomment-1233331267
-rw-r--r-- | docs/users_guide/9.6.1-notes.rst | 4 | ||||
-rw-r--r-- | libraries/base/changelog.md | 3 | ||||
-rw-r--r-- | libraries/ghc-prim/GHC/Classes.hs | 7 |
3 files changed, 11 insertions, 3 deletions
diff --git a/docs/users_guide/9.6.1-notes.rst b/docs/users_guide/9.6.1-notes.rst index 6730ad2b0c..e58b56a6d8 100644 --- a/docs/users_guide/9.6.1-notes.rst +++ b/docs/users_guide/9.6.1-notes.rst @@ -94,6 +94,10 @@ This can be convenient when pasting large multi-line blocks of code into GHCi. label (:base-ref:`GHC.Conc.threadLabel`) and status (:base-ref:`GHC.Conc.threadStatus`). +- Change default ``Ord`` implementation of ``(>=)``, ``(>)``, and ``(<)`` to use + ``(<=)`` instead of ``compare`` per CLC proposal: + https://github.com/haskell/core-libraries-committee/issues/24 + ``ghc-prim`` library ~~~~~~~~~~~~~~~~~~~~ diff --git a/libraries/base/changelog.md b/libraries/base/changelog.md index feba1bfbc8..083054d084 100644 --- a/libraries/base/changelog.md +++ b/libraries/base/changelog.md @@ -22,6 +22,9 @@ * `GHC.Conc.Sync.threadLabel` was added, allowing the user to query the label of a given `ThreadId`. * Add `inits1` and `tails1` to `Data.List.NonEmpty`. + * Change default `Ord` implementation of `(>=)`, `(>)`, and `(<)` to use + `(<=)` instead of `compare` per + [Core Libraries proposal](https://github.com/haskell/core-libraries-committee/issues/24). ## 4.17.0.0 *August 2022* diff --git a/libraries/ghc-prim/GHC/Classes.hs b/libraries/ghc-prim/GHC/Classes.hs index aa1c1b2d8b..3ca06ac144 100644 --- a/libraries/ghc-prim/GHC/Classes.hs +++ b/libraries/ghc-prim/GHC/Classes.hs @@ -333,10 +333,11 @@ class (Eq a) => Ord a where else if x <= y then LT else GT - x < y = case compare x y of { LT -> True; _ -> False } x <= y = case compare x y of { GT -> False; _ -> True } - x > y = case compare x y of { GT -> True; _ -> False } - x >= y = case compare x y of { LT -> False; _ -> True } + x >= y = y <= x + x > y = not (x <= y) + x < y = not (y <= x) + -- These two default methods use '<=' rather than 'compare' -- because the latter is often more expensive |