[Git][ghc/ghc][wip/marge_bot_batch_merge_job] 2 commits: Change Ord defaults per CLC proposal

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Thu Sep 1 12:51:20 UTC 2022



Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC


Commits:
08b76fbf by Tommy Bidne at 2022-09-01T08:51:10-04:00
Change Ord defaults per CLC proposal

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

- - - - -
44a6a9ca by Matthew Pickering at 2022-09-01T08:51:11-04:00
Fix bootstrap with ghc-9.0

It turns out Solo is a very recent addition to base, so for older GHC
versions we just defined it inline here the one place we use it in the
compiler.

- - - - -


4 changed files:

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


Changes:

=====================================
compiler/GHC/Core/Opt/SpecConstr.hs
=====================================
@@ -1,3 +1,4 @@
+{-# LANGUAGE CPP #-}
 {-
 ToDo [Oct 2013]
 ~~~~~~~~~~~~~~~
@@ -974,6 +975,14 @@ lookupHowBound env id = lookupVarEnv (sc_how_bound env) id
 scSubstId :: ScEnv -> InId -> OutExpr
 scSubstId env v = lookupIdSubst (sc_subst env) v
 
+
+-- Solo is only defined in base starting from ghc-9.2
+#if !(MIN_VERSION_base(4, 16, 0))
+
+data Solo a = Solo a
+
+#endif
+
 -- The !subst ensures that we force the selection `(sc_subst env)`, which avoids
 -- retaining all of `env` when we only need `subst`.  The `Solo` means that the
 -- substitution itself is lazy, because that type is often discarded.


=====================================
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/-/compare/fce81df1c5d187c23acc16cb3f8e6978bf003d2a...44a6a9caf7c3c6daa5cd61654046bdc868278953

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fce81df1c5d187c23acc16cb3f8e6978bf003d2a...44a6a9caf7c3c6daa5cd61654046bdc868278953
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/02101654/attachment-0001.html>


More information about the ghc-commits mailing list