[Git][ghc/ghc][master] Change Ord defaults per CLC proposal

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Thu Sep 1 16:01:37 UTC 2022



Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC


Commits:
31a8989a by Tommy Bidne at 2022-09-01T12:01:20-04:00
Change Ord defaults per CLC proposal

Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/24#issuecomment-1233331267

- - - - -


3 changed files:

- docs/users_guide/9.6.1-notes.rst
- libraries/base/changelog.md
- libraries/ghc-prim/GHC/Classes.hs


Changes:

=====================================
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
 ~~~~~~~~~~~~~~~~~~~~
 


=====================================
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*
 


=====================================
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



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/31a8989a1d4aa5fe1e3ed0b2e789145bb64a8ba8

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/31a8989a1d4aa5fe1e3ed0b2e789145bb64a8ba8
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20220901/62cb3fc3/attachment-0001.html>


More information about the ghc-commits mailing list