[Git][ghc/ghc][wip/marge_bot_batch_merge_job] 7 commits: Document :unadd GHCi command in user guide

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Tue Sep 20 08:22:03 UTC 2022



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


Commits:
19f45a25 by Jan Hrček at 2022-09-20T03:49:29-04:00
Document :unadd GHCi command in user guide

- - - - -
545ff490 by sheaf at 2022-09-20T03:50:06-04:00
Hadrian: merge archives even in stage 0

We now always merge .a archives when ar supports -L.
This change is necessary in order to bootstrap GHC using GHC 9.4
on Windows, as nested archives aren't supported.
Not doing so triggered bug #21990 when trying to use the Win32
package, with errors such as:

  Not a x86_64 PE+ file.
  Unknown COFF 4 type in getHeaderInfo.

  ld.lld: error: undefined symbol: Win32zm2zi12zi0zi0_SystemziWin32ziConsoleziCtrlHandler_withConsoleCtrlHandler1_info

We have to be careful about which ar is meant: in stage 0, the check
should be done on the system ar (system-ar in system.config).

- - - - -
59fe128c by Vladislav Zavialov at 2022-09-20T03:50:42-04:00
Fix -Woperator-whitespace for consym (part of #19372)

Due to an oversight, the initial specification and implementation of
-Woperator-whitespace focused on varsym exclusively and completely
ignored consym.

This meant that expressions such as "x+ y" would produce a warning,
while "x:+ y" would not.

The specification was corrected in ghc-proposals pull request #404,
and this patch updates the implementation accordingly.

Regression test included.

- - - - -
7ef7c636 by John Ericson at 2022-09-20T04:21:31-04:00
Add `Eq` and `Ord` instances for `Generically1`

These are needed so the subsequent commit overhauling the `*1` classes
type-checks.

- - - - -
1b9f2a41 by John Ericson at 2022-09-20T04:21:31-04:00
Relax instances for Functor combinators; put superclass on Class1 and Class2 to make non-breaking

This change is approved by the Core Libraries commitee in
https://github.com/haskell/core-libraries-committee/issues/10

The first change makes the `Eq`, `Ord`, `Show`, and `Read` instances for
`Sum`, `Product`, and `Compose` match those for `:+:`, `:*:`, and `:.:`.
These have the proper flexible contexts that are exactly what the
instance needs:

For example, instead of
```haskell
instance (Eq1 f, Eq1 g, Eq a) => Eq (Compose f g a) where
  (==) = eq1
```
we do
```haskell
deriving instance Eq (f (g a)) => Eq (Compose f g a)
```

But, that change alone is rather breaking, because until now `Eq (f a)`
and `Eq1 f` (and respectively the other classes and their `*1`
equivalents too) are *incomparable* constraints. This has always been an
annoyance of working with the `*1` classes, and now it would rear it's
head one last time as an pesky migration.

Instead, we give the `*1` classes superclasses, like so:
```haskell
(forall a. Eq a => Eq (f a)) => Eq1 f
```
along with some laws that canonicity is preserved, like:
```haskell
liftEq (==) = (==)
```

and likewise for `*2` classes:
```haskell
(forall a. Eq a => Eq1 (f a)) => Eq2 f
```
and laws:
```haskell
liftEq2 (==) = liftEq1
```

The `*1` classes also have default methods using the `*2` classes where
possible.

What this means, as explained in the docs, is that `*1` classes really
are generations of the regular classes, indicating that the methods can
be split into a canonical lifting combined with a canonical inner, with
the super class "witnessing" the laws[1] in a fashion.

Circling back to the pragmatics of migrating, note that the superclass
means evidence for the old `Sum`, `Product`, and `Compose` instances is
(more than) sufficient, so breakage is less likely --- as long no
instances are "missing", existing polymorphic code will continue to
work.

Breakage can occur when a datatype implements the `*1` class but not the
corresponding regular class, but this is almost certainly an oversight.
For example, containers made that mistake for `Tree` and `Ord`, which I
fixed in https://github.com/haskell/containers/pull/761, but fixing the
issue by adding `Ord1` was extremely *un*controversial.

`Generically1` was also missing `Eq`, `Ord`, `Read,` and `Show`
instances. It is unlikely this would have been caught without
implementing this change.

-----

[1]: In fact, someday, when the laws are part of the language and not
only documentation, we might be able to drop the superclass field of the
dictionary by using the laws to recover the superclass in an
instance-agnostic manner, e.g. with a *non*-overloaded function with
type:

```haskell
DictEq1 f -> DictEq a -> DictEq (f a)
```

But I don't wish to get into optomizations now, just demonstrate the
close relationship between the law and the superclass.

Bump haddock submodule because of test output changing.

- - - - -
a849c930 by Tom Ellis at 2022-09-20T04:21:37-04:00
Add notes to ghc-prim Haddocks that users should not import it

- - - - -
45886dc1 by matoro at 2022-09-20T04:21:40-04:00
docs: clarify that LLVM codegen is not available in unregisterised mode

The current docs are misleading and suggest that it is possible to use
LLVM codegen from an unregisterised build.  This is not the case;
attempting to pass `-fllvm` to an unregisterised build warns:

```
when making flags consistent: warning:
    Target platform uses unregisterised ABI, so compiling via C
```

and uses the C codegen anyway.

- - - - -


27 changed files:

- compiler/GHC/Parser/Lexer.x
- configure.ac
- docs/users_guide/9.6.1-notes.rst
- docs/users_guide/codegens.rst
- docs/users_guide/ghci.rst
- ghc/GHCi/UI.hs
- hadrian/cfg/system.config.in
- hadrian/src/Oracles/Flag.hs
- hadrian/src/Settings/Builders/Ar.hs
- libraries/base/Data/Functor/Classes.hs
- libraries/base/Data/Functor/Compose.hs
- libraries/base/Data/Functor/Product.hs
- libraries/base/Data/Functor/Sum.hs
- libraries/base/GHC/Generics.hs
- libraries/base/changelog.md
- libraries/ghc-prim/GHC/Classes.hs
- libraries/ghc-prim/GHC/Debug.hs
- libraries/ghc-prim/GHC/Prim/Exception.hs
- libraries/ghc-prim/GHC/Prim/Ext.hs
- libraries/ghc-prim/GHC/Prim/Panic.hs
- libraries/ghc-prim/GHC/Tuple.hs
- libraries/ghc-prim/ghc-prim.cabal
- + testsuite/tests/parser/should_compile/T19372consym.hs
- + testsuite/tests/parser/should_compile/T19372consym.stderr
- testsuite/tests/parser/should_compile/all.T
- utils/genprimopcode/Main.hs
- utils/haddock


Changes:

=====================================
compiler/GHC/Parser/Lexer.x
=====================================
@@ -496,7 +496,7 @@ $tab          { warnTab }
   @qvarsym                                         { idtoken qvarsym }
   @qconsym                                         { idtoken qconsym }
   @varsym                                          { with_op_ws varsym }
-  @consym                                          { consym }
+  @consym                                          { with_op_ws consym }
 }
 
 -- For the normal boxed literals we need to be careful
@@ -1681,7 +1681,7 @@ qconsym buf len = ITqconsym $! splitQualName buf len False
 
 -- See Note [Whitespace-sensitive operator parsing]
 varsym :: OpWs -> Action
-varsym OpWsPrefix = sym $ \span exts s ->
+varsym opws at OpWsPrefix = sym $ \span exts s ->
   let warnExtConflict errtok =
         do { addPsMessage (mkSrcSpanPs span) (PsWarnOperatorWhitespaceExtConflict errtok)
            ; return (ITvarsym s) }
@@ -1709,35 +1709,48 @@ varsym OpWsPrefix = sym $ \span exts s ->
      | s == fsLit "!" -> return ITbang
      | s == fsLit "~" -> return ITtilde
      | otherwise ->
-         do { addPsMessage
-                (mkSrcSpanPs span)
-                (PsWarnOperatorWhitespace s OperatorWhitespaceOccurrence_Prefix)
+         do { warnOperatorWhitespace opws span s
             ; return (ITvarsym s) }
-varsym OpWsSuffix = sym $ \span _ s ->
+varsym opws at OpWsSuffix = sym $ \span _ s ->
   if | s == fsLit "@" -> failMsgP (\srcLoc -> mkPlainErrorMsgEnvelope srcLoc $ PsErrSuffixAT)
      | s == fsLit "." -> return ITdot
      | otherwise ->
-         do { addPsMessage
-                (mkSrcSpanPs span)
-                (PsWarnOperatorWhitespace s OperatorWhitespaceOccurrence_Suffix)
+         do { warnOperatorWhitespace opws span s
             ; return (ITvarsym s) }
-varsym OpWsTightInfix = sym $ \span exts s ->
+varsym opws at OpWsTightInfix = sym $ \span exts s ->
   if | s == fsLit "@" -> return ITat
      | s == fsLit ".", OverloadedRecordDotBit `xtest` exts  -> return (ITproj False)
      | s == fsLit "." -> return ITdot
      | otherwise ->
-         do { addPsMessage
-                (mkSrcSpanPs span)
-                (PsWarnOperatorWhitespace s (OperatorWhitespaceOccurrence_TightInfix))
-            ;  return (ITvarsym s) }
+         do { warnOperatorWhitespace opws span s
+            ; return (ITvarsym s) }
 varsym OpWsLooseInfix = sym $ \_ _ s ->
   if | s == fsLit "."
      -> return ITdot
      | otherwise
      -> return $ ITvarsym s
 
-consym :: Action
-consym = sym (\_span _exts s -> return $ ITconsym s)
+consym :: OpWs -> Action
+consym opws = sym $ \span _exts s ->
+  do { warnOperatorWhitespace opws span s
+     ; return (ITconsym s) }
+
+warnOperatorWhitespace :: OpWs -> PsSpan -> FastString -> P ()
+warnOperatorWhitespace opws span s =
+  whenIsJust (check_unusual_opws opws) $ \opws' ->
+    addPsMessage
+      (mkSrcSpanPs span)
+      (PsWarnOperatorWhitespace s opws')
+
+-- Check an operator occurrence for unusual whitespace (prefix, suffix, tight infix).
+-- This determines if -Woperator-whitespace is triggered.
+check_unusual_opws :: OpWs -> Maybe OperatorWhitespaceOccurrence
+check_unusual_opws opws =
+  case opws of
+    OpWsPrefix     -> Just OperatorWhitespaceOccurrence_Prefix
+    OpWsSuffix     -> Just OperatorWhitespaceOccurrence_Suffix
+    OpWsTightInfix -> Just OperatorWhitespaceOccurrence_TightInfix
+    OpWsLooseInfix -> Nothing
 
 sym :: (PsSpan -> ExtsBitmap -> FastString -> P Token) -> Action
 sym con span buf len _buf2 =


=====================================
configure.ac
=====================================
@@ -201,6 +201,7 @@ if test "$WithGhc" != ""; then
   fi
   BOOTSTRAPPING_GHC_INFO_FIELD([AR_OPTS_STAGE0],[ar flags])
   BOOTSTRAPPING_GHC_INFO_FIELD([ArSupportsAtFile_STAGE0],[ar supports at file])
+  BOOTSTRAPPING_GHC_INFO_FIELD([ArSupportsDashL_STAGE0],[ar supports -L])
   BOOTSTRAPPING_GHC_INFO_FIELD([SUPPORT_SMP_STAGE0],[Support SMP])
   BOOTSTRAPPING_GHC_INFO_FIELD([RTS_WAYS_STAGE0],[RTS ways])
 


=====================================
docs/users_guide/9.6.1-notes.rst
=====================================
@@ -68,6 +68,9 @@ Compiler
 - The :extension:`TypeInType` is now marked as deprecated. Its meaning has been included
   in :extension:`PolyKinds` and :extension:`DataKinds`.
 
+- The :ghc-flag:`-Woperator-whitespace` warning no longer ignores constructor symbols
+  (operators starting with ``:``).
+
 GHCi
 ~~~~
 


=====================================
docs/users_guide/codegens.rst
=====================================
@@ -108,10 +108,9 @@ disabling some of the platform-specific tricks that GHC normally uses to
 make programs go faster. When compiling unregisterised, GHC simply
 generates a C file which is compiled via gcc.
 
-When GHC is build in unregisterised mode only the LLVM and C code
-generators will be available. The native code generator won't be. LLVM
-usually offers a substantial performance benefit over the C backend in
-unregisterised mode.
+When GHC is built in unregisterised mode only the C code generator is
+available.  Neither the LLVM nor native code generator can be used by an
+unregisterised build.
 
 Unregisterised compilation can be useful when porting GHC to a new
 machine, since it reduces the prerequisite tools to ``gcc``, ``as``, and


=====================================
docs/users_guide/ghci.rst
=====================================
@@ -541,8 +541,9 @@ including entities that are in scope in the current module context.
 
 .. warning::
     Temporary bindings introduced at the prompt only last until the
-    next :ghci-cmd:`:load` or :ghci-cmd:`:reload` command, at which time they
-    will be simply lost. However, they do survive a change of context with
+    next :ghci-cmd:`:load`, :ghci-cmd:`:reload`, :ghci-cmd:`:add` or 
+    :ghci-cmd:`:unadd` command, at which time they will be simply lost.
+    However, they do survive a change of context with
     :ghci-cmd:`:module`: the temporary bindings just move to the new location.
 
 .. hint::
@@ -731,7 +732,7 @@ When you type an expression at the prompt, what identifiers and types
 are in scope? GHCi provides a flexible way to control exactly how the
 context for an expression is constructed:
 
--  The :ghci-cmd:`:load`, :ghci-cmd:`:add`, and :ghci-cmd:`:reload` commands
+-  The :ghci-cmd:`:load`, :ghci-cmd:`:reload`, :ghci-cmd:`:add` and :ghci-cmd:`:unadd` commands
    (:ref:`ghci-load-scope`).
 
 -  The ``import`` declaration (:ref:`ghci-import-decl`).
@@ -751,7 +752,7 @@ contribute to the top-level scope.
 The effect of ``:load`` on what is in scope
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
-The :ghci-cmd:`:load`, :ghci-cmd:`:add`, and :ghci-cmd:`:reload` commands
+The :ghci-cmd:`:load`, :ghci-cmd:`:reload`, :ghci-cmd:`:add` and :ghci-cmd:`:unadd` commands
 (:ref:`loading-source-files` and :ref:`ghci-compiled`) affect the
 top-level scope. Let's start with the simple cases; when you start GHCi
 the prompt looks like this:
@@ -796,7 +797,7 @@ automatically-added imports can be seen with :ghci-cmd:`:show imports`:
     *ghci>
 
 and the automatically-added import is replaced the next time you use
-:ghci-cmd:`:load`, :ghci-cmd:`:add`, or :ghci-cmd:`:reload`. It can also be
+:ghci-cmd:`:load`, :ghci-cmd:`:reload`, :ghci-cmd:`:add` or :ghci-cmd:`:unadd`. It can also be
 removed by :ghci-cmd:`:module` as with normal imports.
 
 .. _ghci-import-decl:
@@ -895,13 +896,13 @@ can use both to bring a module into scope. However, there is a very important
 difference. GHCi is concerned with two sets of modules:
 
 -  The set of modules that are currently *loaded*. This set is modified
-   by :ghci-cmd:`:load`, :ghci-cmd:`:add` and :ghci-cmd:`:reload`, and can be shown with
+   by :ghci-cmd:`:load`, :ghci-cmd:`:reload`, :ghci-cmd:`:add` and :ghci-cmd:`:unadd`, and can be shown with
    :ghci-cmd:`:show modules`.
 
 -  The set of modules that are currently *in scope* at the prompt. This set is
    modified by ``import`` and :ghci-cmd:`:module`, and it is also modified
-   automatically after :ghci-cmd:`:load`, :ghci-cmd:`:add`, and
-   :ghci-cmd:`:reload`, as described above. The set of modules in scope can be
+   automatically after :ghci-cmd:`:load`, :ghci-cmd:`:reload`, :ghci-cmd:`:add`
+   and :ghci-cmd:`:unadd`, as described above. The set of modules in scope can be
    shown with :ghci-cmd:`:show imports`.
 
 You can add a module to the scope (via :ghci-cmd:`:module` or ``import``) only
@@ -1173,7 +1174,7 @@ The :ghc-flag:`-interactive-print ⟨name⟩` flag allows to specify any functio
 of type ``C a => a -> IO ()``, for some constraint ``C``, as the function for
 printing evaluated expressions. The function can reside in any loaded module or
 any registered package, but only when it resides in a registered package will
-it survive a :ghci-cmd:`:cd`, :ghci-cmd:`:add`, :ghci-cmd:`:load`,
+it survive a :ghci-cmd:`:cd`, :ghci-cmd:`:add`, :ghci-cmd:`:unadd`, :ghci-cmd:`:load`,
 :ghci-cmd:`:reload` or, :ghci-cmd:`:set`.
 
 .. ghc-flag:: -interactive-print ⟨name⟩
@@ -2191,7 +2192,7 @@ commonly used commands.
     Using the ``*`` prefix forces the module to be loaded as byte-code.
 
     ⟨module⟩ may be a file path. A "``~``" symbol at the beginning of
-    ⟨module⟩  will be replaced by the contents of the environment variable
+    ⟨module⟩ will be replaced by the contents of the environment variable
     :envvar:`HOME`.
 
 .. ghci-cmd:: :all-types
@@ -2948,6 +2949,12 @@ commonly used commands.
     Show the currently active language flags for expressions typed at
     the prompt (see also :ghci-cmd:`:seti`).
 
+.. ghci-cmd:: :show targets
+
+    Show list of currently loaded modules.
+    This set of loaded modules can be modified by :ghci-cmd:`:load`,
+    :ghci-cmd:`:reload`, :ghci-cmd:`:add` and :ghci-cmd:`:unadd`.
+
 .. ghci-cmd:: :show; [args|prog|prompt|editor|stop]
 
     Displays the specified setting (see :ghci-cmd:`:set`).
@@ -3044,6 +3051,11 @@ commonly used commands.
 
     The :ghci-cmd:`:type-at` command requires :ghci-cmd:`:set +c` to be set.
 
+.. ghci-cmd:: :unadd; ⟨module⟩
+
+    Removes ⟨module⟩(s) from the current target set, and perform a reload
+    (see :ghci-cmd:`:add` above).
+
 .. ghci-cmd:: :undef; ⟨name⟩
 
     Undefines the user-defined command ⟨name⟩ (see :ghci-cmd:`:def` above).


=====================================
ghc/GHCi/UI.hs
=====================================
@@ -1994,7 +1994,7 @@ instancesCmd s = do
     printForUser $ vcat $ map ppr res
 
 -----------------------------------------------------------------------------
--- :load, :add, :reload
+-- :load, :add, :unadd, :reload
 
 -- | Sets '-fdefer-type-errors' if 'defer' is true, executes 'load' and unsets
 -- '-fdefer-type-errors' again if it has not been set before.


=====================================
hadrian/cfg/system.config.in
=====================================
@@ -39,10 +39,11 @@ python         = @PythonCmd@
 # Information about builders:
 #============================
 
-ar-supports-at-file = @ArSupportsAtFile@
-ar-supports-dash-l  = @ArSupportsDashL@
-cc-llvm-backend     = @CcLlvmBackend@
-hs-cpp-args         = @HaskellCPPArgs@
+ar-supports-at-file       = @ArSupportsAtFile@
+ar-supports-dash-l        = @ArSupportsDashL@
+system-ar-supports-dash-l = @ArSupportsDashL_STAGE0@
+cc-llvm-backend           = @CcLlvmBackend@
+hs-cpp-args               = @HaskellCPPArgs@
 
 # Build options:
 #===============


=====================================
hadrian/src/Oracles/Flag.hs
=====================================
@@ -5,7 +5,8 @@ module Oracles.Flag (
     platformSupportsSharedLibs,
     platformSupportsGhciObjects,
     targetSupportsSMP,
-    useLibffiForAdjustors
+    useLibffiForAdjustors,
+    arSupportsDashL
     ) where
 
 import Hadrian.Oracles.TextFile
@@ -16,6 +17,7 @@ import Oracles.Setting
 
 data Flag = ArSupportsAtFile
           | ArSupportsDashL
+          | SystemArSupportsDashL
           | CrossCompiling
           | CcLlvmBackend
           | GhcUnregisterised
@@ -39,6 +41,7 @@ flag f = do
     let key = case f of
             ArSupportsAtFile     -> "ar-supports-at-file"
             ArSupportsDashL      -> "ar-supports-dash-l"
+            SystemArSupportsDashL-> "system-ar-supports-dash-l"
             CrossCompiling       -> "cross-compiling"
             CcLlvmBackend        -> "cc-llvm-backend"
             GhcUnregisterised    -> "ghc-unregisterised"
@@ -69,6 +72,10 @@ platformSupportsGhciObjects :: Action Bool
 platformSupportsGhciObjects =
     not . null <$> settingsFileSetting SettingsFileSetting_MergeObjectsCommand
 
+arSupportsDashL :: Stage -> Action Bool
+arSupportsDashL (Stage0 {}) = flag SystemArSupportsDashL
+arSupportsDashL _           = flag ArSupportsDashL
+
 platformSupportsSharedLibs :: Action Bool
 platformSupportsSharedLibs = do
     windows       <- isWinTarget


=====================================
hadrian/src/Settings/Builders/Ar.hs
=====================================
@@ -6,7 +6,9 @@ import Settings.Builders.Common
 -- want to place these in a response file. This is handled in
 -- 'Hadrian.Builder.Ar.runAr'.
 arBuilderArgs :: Args
-arBuilderArgs = mconcat
+arBuilderArgs = do
+  stage <- getStage
+  mconcat
     [ builder (Ar Pack) ? mconcat
       [ -- When building on platforms which don't support object merging
         -- we must use the -L flag supported by llvm-ar, which ensures that
@@ -14,7 +16,7 @@ arBuilderArgs = mconcat
         -- not added as a single file. This requires that we are using llvm-ar
         --
         -- See Note [Object merging] in GHC.Driver.Pipeline.Execute for details.
-        ifM ((&&) <$> notStage0 <*> expr (flag ArSupportsDashL)) (arg "qL") (arg "q")
+        ifM (expr $ arSupportsDashL stage) (arg "qL") (arg "q")
       , arg =<< getOutput
       ]
     , builder (Ar Unpack) ? mconcat


=====================================
libraries/base/Data/Functor/Classes.hs
=====================================
@@ -1,7 +1,10 @@
 {-# LANGUAGE FlexibleContexts     #-}
+{-# LANGUAGE DefaultSignatures    #-}
 {-# LANGUAGE InstanceSigs         #-}
 {-# LANGUAGE Safe                 #-}
+{-# LANGUAGE TypeOperators        #-}
 {-# LANGUAGE UndecidableInstances #-}
+{-# LANGUAGE QuantifiedConstraints #-}
 -----------------------------------------------------------------------------
 -- |
 -- Module      :  Data.Functor.Classes
@@ -91,8 +94,18 @@ import Text.Show (showListWith)
 
 -- | Lifting of the 'Eq' class to unary type constructors.
 --
+-- Any instance should be subject to the following law that canonicity
+-- is preserved:
+--
+-- @liftEq (==)@ = @(==)@
+--
+-- This class therefore represents the generalization of 'Eq' by
+-- decomposing its main method into a canonical lifting on a canonical
+-- inner method, so that the lifting can be reused for other arguments
+-- than the canonical one.
+--
 -- @since 4.9.0.0
-class Eq1 f where
+class (forall a. Eq a => Eq (f a)) => Eq1 f where
     -- | Lift an equality test through the type constructor.
     --
     -- The function will usually be applied to an equality function,
@@ -102,6 +115,10 @@ class Eq1 f where
     --
     -- @since 4.9.0.0
     liftEq :: (a -> b -> Bool) -> f a -> f b -> Bool
+    default liftEq
+        :: (f ~ f' c, Eq2 f', Eq c)
+        => (a -> b -> Bool) -> f a -> f b -> Bool
+    liftEq = liftEq2 (==)
 
 -- | Lift the standard @('==')@ function through the type constructor.
 --
@@ -111,8 +128,18 @@ eq1 = liftEq (==)
 
 -- | Lifting of the 'Ord' class to unary type constructors.
 --
+-- Any instance should be subject to the following law that canonicity
+-- is preserved:
+--
+-- @liftCompare compare@ = 'compare'
+--
+-- This class therefore represents the generalization of 'Ord' by
+-- decomposing its main method into a canonical lifting on a canonical
+-- inner method, so that the lifting can be reused for other arguments
+-- than the canonical one.
+--
 -- @since 4.9.0.0
-class (Eq1 f) => Ord1 f where
+class (Eq1 f, forall a. Ord a => Ord (f a)) => Ord1 f where
     -- | Lift a 'compare' function through the type constructor.
     --
     -- The function will usually be applied to a comparison function,
@@ -122,6 +149,10 @@ class (Eq1 f) => Ord1 f where
     --
     -- @since 4.9.0.0
     liftCompare :: (a -> b -> Ordering) -> f a -> f b -> Ordering
+    default liftCompare
+        :: (f ~ f' c, Ord2 f', Ord c)
+        => (a -> b -> Ordering) -> f a -> f b -> Ordering
+    liftCompare = liftCompare2 compare
 
 -- | Lift the standard 'compare' function through the type constructor.
 --
@@ -131,6 +162,22 @@ compare1 = liftCompare compare
 
 -- | Lifting of the 'Read' class to unary type constructors.
 --
+-- Any instance should be subject to the following laws that canonicity
+-- is preserved:
+--
+-- @liftReadsPrec readsPrec readList@ = 'readsPrec'
+--
+-- @liftReadList readsPrec readList@ = 'readList'
+--
+-- @liftReadPrec readPrec readListPrec@ = 'readPrec'
+--
+-- @liftReadListPrec readPrec readListPrec@ = 'readListPrec'
+--
+-- This class therefore represents the generalization of 'Read' by
+-- decomposing it's methods into a canonical lifting on a canonical
+-- inner method, so that the lifting can be reused for other arguments
+-- than the canonical one.
+--
 -- Both 'liftReadsPrec' and 'liftReadPrec' exist to match the interface
 -- provided in the 'Read' type class, but it is recommended to implement
 -- 'Read1' instances using 'liftReadPrec' as opposed to 'liftReadsPrec', since
@@ -145,7 +192,7 @@ compare1 = liftCompare compare
 -- For more information, refer to the documentation for the 'Read' class.
 --
 -- @since 4.9.0.0
-class Read1 f where
+class (forall a. Read a => Read (f a)) => Read1 f where
     {-# MINIMAL liftReadsPrec | liftReadPrec #-}
 
     -- | 'readsPrec' function for an application of the type constructor
@@ -219,14 +266,30 @@ liftReadListPrecDefault rp rl = list (liftReadPrec rp rl)
 
 -- | Lifting of the 'Show' class to unary type constructors.
 --
+-- Any instance should be subject to the following laws that canonicity
+-- is preserved:
+--
+-- @liftShowsPrec showsPrec showList@ = 'showsPrec'
+--
+-- @liftShowList showsPrec showList@ = 'showList'
+--
+-- This class therefore represents the generalization of 'Show' by
+-- decomposing it's methods into a canonical lifting on a canonical
+-- inner method, so that the lifting can be reused for other arguments
+-- than the canonical one.
+--
 -- @since 4.9.0.0
-class Show1 f where
+class (forall a. Show a => Show (f a)) => Show1 f where
     -- | 'showsPrec' function for an application of the type constructor
     -- based on 'showsPrec' and 'showList' functions for the argument type.
     --
     -- @since 4.9.0.0
     liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) ->
         Int -> f a -> ShowS
+    default liftShowsPrec
+        :: (f ~ f' b, Show2 f', Show b)
+        => (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> f a -> ShowS
+    liftShowsPrec = liftShowsPrec2 showsPrec showList
 
     -- | 'showList' function for an application of the type constructor
     -- based on 'showsPrec' and 'showList' functions for the argument type.
@@ -248,7 +311,7 @@ showsPrec1 = liftShowsPrec showsPrec showList
 -- | Lifting of the 'Eq' class to binary type constructors.
 --
 -- @since 4.9.0.0
-class Eq2 f where
+class (forall a. Eq a => Eq1 (f a)) => Eq2 f where
     -- | Lift equality tests through the type constructor.
     --
     -- The function will usually be applied to equality functions,
@@ -268,7 +331,7 @@ eq2 = liftEq2 (==) (==)
 -- | Lifting of the 'Ord' class to binary type constructors.
 --
 -- @since 4.9.0.0
-class (Eq2 f) => Ord2 f where
+class (Eq2 f, forall a. Ord a => Ord1 (f a)) => Ord2 f where
     -- | Lift 'compare' functions through the type constructor.
     --
     -- The function will usually be applied to comparison functions,
@@ -302,7 +365,7 @@ compare2 = liftCompare2 compare compare
 -- For more information, refer to the documentation for the 'Read' class.
 --
 -- @since 4.9.0.0
-class Read2 f where
+class (forall a. Read a => Read1 (f a)) => Read2 f where
     {-# MINIMAL liftReadsPrec2 | liftReadPrec2 #-}
 
     -- | 'readsPrec' function for an application of the type constructor
@@ -385,7 +448,7 @@ liftReadListPrec2Default rp1 rl1 rp2 rl2 = list (liftReadPrec2 rp1 rl1 rp2 rl2)
 -- | Lifting of the 'Show' class to binary type constructors.
 --
 -- @since 4.9.0.0
-class Show2 f where
+class (forall a. Show a => Show1 (f a)) => Show2 f where
     -- | 'showsPrec' function for an application of the type constructor
     -- based on 'showsPrec' and 'showList' functions for the argument types.
     --


=====================================
libraries/base/Data/Functor/Compose.hs
=====================================
@@ -5,6 +5,7 @@
 {-# LANGUAGE PolyKinds #-}
 {-# LANGUAGE ScopedTypeVariables #-}
 {-# LANGUAGE Trustworthy #-}
+{-# LANGUAGE StandaloneDeriving #-}
 
 -----------------------------------------------------------------------------
 -- |
@@ -32,7 +33,7 @@ import Data.Coerce (coerce)
 import Data.Data (Data)
 import Data.Type.Equality (TestEquality(..), (:~:)(..))
 import GHC.Generics (Generic, Generic1)
-import Text.Read (Read(..), readListDefault, readListPrecDefault)
+import Text.Read ()
 
 infixr 9 `Compose`
 
@@ -47,6 +48,17 @@ newtype Compose f g a = Compose { getCompose :: f (g a) }
            , Monoid    -- ^ @since 4.16.0.0
            )
 
+-- Instances of Prelude classes
+
+-- | @since 4.18.0.0
+deriving instance Eq (f (g a)) => Eq (Compose f g a)
+-- | @since 4.18.0.0
+deriving instance Ord (f (g a)) => Ord (Compose f g a)
+-- | @since 4.18.0.0
+deriving instance Read (f (g a)) => Read (Compose f g a)
+-- | @since 4.18.0.0
+deriving instance Show (f (g a)) => Show (Compose f g a)
+
 -- Instances of lifted Prelude classes
 
 -- | @since 4.9.0.0
@@ -77,27 +89,6 @@ instance (Show1 f, Show1 g) => Show1 (Compose f g) where
         sp' = liftShowsPrec sp sl
         sl' = liftShowList sp sl
 
--- Instances of Prelude classes
-
--- | @since 4.9.0.0
-instance (Eq1 f, Eq1 g, Eq a) => Eq (Compose f g a) where
-    (==) = eq1
-
--- | @since 4.9.0.0
-instance (Ord1 f, Ord1 g, Ord a) => Ord (Compose f g a) where
-    compare = compare1
-
--- | @since 4.9.0.0
-instance (Read1 f, Read1 g, Read a) => Read (Compose f g a) where
-    readPrec = readPrec1
-
-    readListPrec = readListPrecDefault
-    readList     = readListDefault
-
--- | @since 4.9.0.0
-instance (Show1 f, Show1 g, Show a) => Show (Compose f g a) where
-    showsPrec = showsPrec1
-
 -- Functor instances
 
 -- | @since 4.9.0.0


=====================================
libraries/base/Data/Functor/Product.hs
=====================================
@@ -2,6 +2,7 @@
 {-# LANGUAGE DeriveGeneric #-}
 {-# LANGUAGE PolyKinds #-}
 {-# LANGUAGE Safe #-}
+{-# LANGUAGE StandaloneDeriving #-}
 -----------------------------------------------------------------------------
 -- |
 -- Module      :  Data.Functor.Product
@@ -28,7 +29,7 @@ import Control.Monad.Zip (MonadZip(mzipWith))
 import Data.Data (Data)
 import Data.Functor.Classes
 import GHC.Generics (Generic, Generic1)
-import Text.Read (Read(..), readListDefault, readListPrecDefault)
+import Text.Read ()
 
 -- | Lifted product of functors.
 data Product f g a = Pair (f a) (g a)
@@ -37,6 +38,15 @@ data Product f g a = Pair (f a) (g a)
            , Generic1 -- ^ @since 4.9.0.0
            )
 
+-- | @since 4.18.0.0
+deriving instance (Eq (f a), Eq (g a)) => Eq (Product f g a)
+-- | @since 4.18.0.0
+deriving instance (Ord (f a), Ord (g a)) => Ord (Product f g a)
+-- | @since 4.18.0.0
+deriving instance (Read (f a), Read (g a)) => Read (Product f g a)
+-- | @since 4.18.0.0
+deriving instance (Show (f a), Show (g a)) => Show (Product f g a)
+
 -- | @since 4.9.0.0
 instance (Eq1 f, Eq1 g) => Eq1 (Product f g) where
     liftEq eq (Pair x1 y1) (Pair x2 y2) = liftEq eq x1 x2 && liftEq eq y1 y2
@@ -59,25 +69,6 @@ instance (Show1 f, Show1 g) => Show1 (Product f g) where
     liftShowsPrec sp sl d (Pair x y) =
         showsBinaryWith (liftShowsPrec sp sl) (liftShowsPrec sp sl) "Pair" d x y
 
--- | @since 4.9.0.0
-instance (Eq1 f, Eq1 g, Eq a) => Eq (Product f g a)
-    where (==) = eq1
-
--- | @since 4.9.0.0
-instance (Ord1 f, Ord1 g, Ord a) => Ord (Product f g a) where
-    compare = compare1
-
--- | @since 4.9.0.0
-instance (Read1 f, Read1 g, Read a) => Read (Product f g a) where
-    readPrec = readPrec1
-
-    readListPrec = readListPrecDefault
-    readList     = readListDefault
-
--- | @since 4.9.0.0
-instance (Show1 f, Show1 g, Show a) => Show (Product f g a) where
-    showsPrec = showsPrec1
-
 -- | @since 4.9.0.0
 instance (Functor f, Functor g) => Functor (Product f g) where
     fmap f (Pair x y) = Pair (fmap f x) (fmap f y)


=====================================
libraries/base/Data/Functor/Sum.hs
=====================================
@@ -2,6 +2,7 @@
 {-# LANGUAGE DeriveGeneric #-}
 {-# LANGUAGE PolyKinds #-}
 {-# LANGUAGE Safe #-}
+{-# LANGUAGE StandaloneDeriving #-}
 -----------------------------------------------------------------------------
 -- |
 -- Module      :  Data.Functor.Sum
@@ -25,7 +26,7 @@ import Control.Applicative ((<|>))
 import Data.Data (Data)
 import Data.Functor.Classes
 import GHC.Generics (Generic, Generic1)
-import Text.Read (Read(..), readListDefault, readListPrecDefault)
+import Text.Read ()
 
 -- | Lifted sum of functors.
 data Sum f g a = InL (f a) | InR (g a)
@@ -34,6 +35,15 @@ data Sum f g a = InL (f a) | InR (g a)
            , Generic1 -- ^ @since 4.9.0.0
            )
 
+-- | @since 4.18.0.0
+deriving instance (Eq (f a), Eq (g a)) => Eq (Sum f g a)
+-- | @since 4.18.0.0
+deriving instance (Ord (f a), Ord (g a)) => Ord (Sum f g a)
+-- | @since 4.18.0.0
+deriving instance (Read (f a), Read (g a)) => Read (Sum f g a)
+-- | @since 4.18.0.0
+deriving instance (Show (f a), Show (g a)) => Show (Sum f g a)
+
 -- | @since 4.9.0.0
 instance (Eq1 f, Eq1 g) => Eq1 (Sum f g) where
     liftEq eq (InL x1) (InL x2) = liftEq eq x1 x2
@@ -64,22 +74,6 @@ instance (Show1 f, Show1 g) => Show1 (Sum f g) where
     liftShowsPrec sp sl d (InR y) =
         showsUnaryWith (liftShowsPrec sp sl) "InR" d y
 
--- | @since 4.9.0.0
-instance (Eq1 f, Eq1 g, Eq a) => Eq (Sum f g a) where
-    (==) = eq1
--- | @since 4.9.0.0
-instance (Ord1 f, Ord1 g, Ord a) => Ord (Sum f g a) where
-    compare = compare1
--- | @since 4.9.0.0
-instance (Read1 f, Read1 g, Read a) => Read (Sum f g a) where
-    readPrec = readPrec1
-
-    readListPrec = readListPrecDefault
-    readList     = readListDefault
--- | @since 4.9.0.0
-instance (Show1 f, Show1 g, Show a) => Show (Sum f g a) where
-    showsPrec = showsPrec1
-
 -- | @since 4.9.0.0
 instance (Functor f, Functor g) => Functor (Sum f g) where
     fmap f (InL x) = InL (fmap f x)


=====================================
libraries/base/GHC/Generics.hs
=====================================
@@ -1480,6 +1480,15 @@ type    Generically1 :: forall k. (k -> Type) -> (k -> Type)
 newtype Generically1 f a where
   Generically1 :: forall {k} f a. f a -> Generically1 @k f a
 
+-- | @since 4.18.0.0
+instance (Generic1 f, Eq (Rep1 f a)) => Eq (Generically1 f a) where
+   Generically1 x == Generically1 y = from1 x == from1 y
+   Generically1 x /= Generically1 y = from1 x /= from1 y
+
+-- | @since 4.18.0.0
+instance (Generic1 f, Ord (Rep1 f a)) => Ord (Generically1 f a) where
+   Generically1 x `compare` Generically1 y = from1 x `compare` from1 y
+
 -- | @since 4.17.0.0
 instance (Generic1 f, Functor (Rep1 f)) => Functor (Generically1 f) where
   fmap :: (a -> a') -> (Generically1 f a -> Generically1 f a')


=====================================
libraries/base/changelog.md
=====================================
@@ -30,6 +30,12 @@
     for the related discussion,
     as well as [the migration guide](https://github.com/haskell/core-libraries-committee/blob/main/guides/export-lifta2-prelude.md)
   * Update to Unicode 15.0.0.
+  * Add `Eq` and `Ord` instances for `Generically1`.
+  * Relax instances for Functor combinators; put superclass on Class1 and Class2
+    to make non-breaking. See [CLC
+    #10](https://github.com/haskell/core-libraries-committee/issues/10) for the
+    related discussion, as well as [the migration
+    guide](https://github.com/haskell/core-libraries-committee/blob/main/guides/functor-combinator-instances-and-class1s.md).
 
 ## 4.17.0.0 *August 2022*
 


=====================================
libraries/ghc-prim/GHC/Classes.hs
=====================================
@@ -27,6 +27,9 @@
 -- Portability :  non-portable (GHC extensions)
 --
 -- Basic classes.
+-- Do not import this module directly.  It is an GHC internal only
+-- module.  Some of its contents are instead available from @Prelude@
+-- and @GHC.Int at .
 --
 -----------------------------------------------------------------------------
 
@@ -35,6 +38,8 @@ module GHC.Classes(
     IP(..),
 
     -- * Equality and ordering
+    -- | Do not import these classes from this module. Import them
+    -- from @Prelude@ instead.
     Eq(..),
     Ord(..),
     -- ** Monomorphic equality operators
@@ -48,6 +53,8 @@ module GHC.Classes(
     gtWord, geWord, leWord, ltWord, compareWord, compareWord#,
 
     -- * Functions over Bool
+    -- | Do not import these functions from this module. Import them
+    -- from @Prelude@ instead.
     (&&), (||), not,
 
     -- * Integer arithmetic


=====================================
libraries/ghc-prim/GHC/Debug.hs
=====================================
@@ -1,6 +1,8 @@
 {-# LANGUAGE Trustworthy #-}
 {-# LANGUAGE MagicHash, NoImplicitPrelude, UnboxedTuples, UnliftedFFITypes #-}
 
+-- | Users should not import this module.  It is GHC internal only.
+
 module GHC.Debug ( debugLn, debugErrLn ) where
 
 import GHC.Prim


=====================================
libraries/ghc-prim/GHC/Prim/Exception.hs
=====================================
@@ -6,6 +6,8 @@
 {-# LANGUAGE EmptyCase #-}
 
 -- | Primitive exceptions.
+--
+-- Users should not import this module.  It is GHC internal only.
 module GHC.Prim.Exception
    ( raiseOverflow
    , raiseUnderflow


=====================================
libraries/ghc-prim/GHC/Prim/Ext.hs
=====================================
@@ -18,6 +18,9 @@
 
 -- | Extra C-- routines exposed from the RTS
 --
+-- Users should not import this module.  It is GHC internal only.  Use
+-- "GHC.Conc" instead.
+--
 -- Actual primops are emitted by the compiler itself. They are special bits of
 -- code with backend support. The foreign functions in this module aren't actual
 -- primops because the compiler doesn't care about them at all: they just are


=====================================
libraries/ghc-prim/GHC/Prim/Panic.hs
=====================================
@@ -6,6 +6,8 @@
 {-# LANGUAGE EmptyCase #-}
 
 -- | Primitive panics.
+--
+-- Users should not import this module.  It is GHC internal only.
 module GHC.Prim.Panic
    ( absentSumFieldError
    , panicError


=====================================
libraries/ghc-prim/GHC/Tuple.hs
=====================================
@@ -12,6 +12,8 @@
 --
 -- The tuple data types
 --
+-- Users should not import this module.  It is GHC internal only.
+--
 -----------------------------------------------------------------------------
 
 module GHC.Tuple where


=====================================
libraries/ghc-prim/ghc-prim.cabal
=====================================
@@ -12,6 +12,11 @@ build-type:     Custom
 description:
     This package contains the primitive types and operations supplied by GHC.
 
+    It is an internal package, only for the use of GHC developers.
+    GHC users should not use it!  If you do use it then expect
+    breaking changes at any time without warning.  You should prefer
+    to import @GHC.Exts@ from the @base@ package instead.
+
 extra-source-files: changelog.md
 
 source-repository head


=====================================
testsuite/tests/parser/should_compile/T19372consym.hs
=====================================
@@ -0,0 +1,15 @@
+{-# OPTIONS -Woperator-whitespace #-}
+
+module T19372consym where
+
+import Data.List.NonEmpty
+
+a_suffix      = \x y -> x: y
+a_prefix      = \x y -> x :y
+a_tight_infix = \x y -> x:y
+a_loose_infix = \x y -> x : y   -- Only this one should be without a warning.
+
+b_suffix      = \x y -> x:| y
+b_prefix      = \x y -> x :|y
+b_tight_infix = \x y -> x:|y
+b_loose_infix = \x y -> x :| y  -- Only this one should be without a warning.


=====================================
testsuite/tests/parser/should_compile/T19372consym.stderr
=====================================
@@ -0,0 +1,15 @@
+
+T19372consym.hs:12:26: warning: [GHC-40798] [-Woperator-whitespace]
+    The suffix use of a ‘:|’ might be repurposed as special syntax
+      by a future language extension.
+    Suggested fix: Add whitespace around ‘:|’.
+
+T19372consym.hs:13:27: warning: [GHC-40798] [-Woperator-whitespace]
+    The prefix use of a ‘:|’ might be repurposed as special syntax
+      by a future language extension.
+    Suggested fix: Add whitespace around ‘:|’.
+
+T19372consym.hs:14:26: warning: [GHC-40798] [-Woperator-whitespace]
+    The tight infix use of a ‘:|’ might be repurposed as special syntax
+      by a future language extension.
+    Suggested fix: Add whitespace around ‘:|’.


=====================================
testsuite/tests/parser/should_compile/all.T
=====================================
@@ -193,3 +193,4 @@ test('T20718',  normal, compile, ['-dsuppress-uniques -ddump-parsed-ast -dkeep-c
 test('T20718b',  normal, compile, ['-dsuppress-uniques -ddump-parsed-ast -dkeep-comments'])
 
 test('T21589', normal, compile, [''])
+test('T19372consym', normal, compile, [''])


=====================================
utils/genprimopcode/Main.hs
=====================================
@@ -446,7 +446,9 @@ In PrimopWrappers we set some crucial GHC options
 
 gen_wrappers :: Info -> String
 gen_wrappers (Info _ entries)
-   =    "{-# LANGUAGE MagicHash, NoImplicitPrelude, UnboxedTuples #-}\n"
+   =    "-- | Users should not import this module.  It is GHC internal only.\n"
+     ++ "-- Use \"GHC.Exts\" instead.\n"
+     ++ "{-# LANGUAGE MagicHash, NoImplicitPrelude, UnboxedTuples #-}\n"
         -- Dependencies on Prelude must be explicit in libraries/base, but we
         -- don't need the Prelude here so we add NoImplicitPrelude.
      ++ "{-# OPTIONS_GHC -Wno-deprecations -O0 -fno-do-eta-reduction #-}\n"


=====================================
utils/haddock
=====================================
@@ -1 +1 @@
-Subproject commit b5e40b15228fdca5ce7d4e2f2241156d0b085261
+Subproject commit 7e4326f999056fb7b0b955ccadf5eab86b755a0d



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8f2037ca2808d034cd455d879c186529cb46f5ad...45886dc1297631659ff2b6e1bf935da964f25b5e

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8f2037ca2808d034cd455d879c186529cb46f5ad...45886dc1297631659ff2b6e1bf935da964f25b5e
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/20220920/06642e0d/attachment-0001.html>


More information about the ghc-commits mailing list