[Git][ghc/ghc][master] Deprecate -Wsemigroup

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Wed Jan 10 22:36:26 UTC 2024



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


Commits:
e3ca78f3 by Krzysztof Gogolewski at 2024-01-10T17:35:59-05:00
Deprecate -Wsemigroup

This warning was used to prepare for Semigroup becoming a superclass
of Monoid, and for (<>) being exported from Prelude. This happened in
GHC 8.4 in 8ae263ceb3566 and feac0a3bc69fd3.

The leftover logic for (<>) has been removed in GHC 9.8, 4d29ecdfcc79.
Now the warning does nothing at all and can be deprecated.

- - - - -


7 changed files:

- compiler/GHC/Driver/Flags.hs
- compiler/GHC/Driver/Session.hs
- docs/users_guide/using-warnings.rst
- testsuite/tests/ghci/scripts/ghci024.stdout
- testsuite/tests/ghci/scripts/ghci024.stdout-mingw32
- testsuite/tests/wcompat-warnings/Template.hs
- testsuite/tests/wcompat-warnings/WCompatWarningsOn.stderr


Changes:

=====================================
compiler/GHC/Driver/Flags.hs
=====================================
@@ -623,7 +623,7 @@ data WarningFlag =
    | Opt_WarnRedundantRecordWildcards
    | Opt_WarnDeprecatedFlags
    | Opt_WarnMissingMonadFailInstances               -- since 8.0, has no effect since 8.8
-   | Opt_WarnSemigroup                               -- since 8.0
+   | Opt_WarnSemigroup                               -- since 8.0, has no effect since 9.8
    | Opt_WarnDodgyExports
    | Opt_WarnDodgyImports
    | Opt_WarnOrphans
@@ -1002,8 +1002,7 @@ minusWeverythingOpts = [ toEnum 0 .. ]
 -- code future compatible to fix issues before they even generate warnings.
 minusWcompatOpts :: [WarningFlag]
 minusWcompatOpts
-    = [ Opt_WarnSemigroup
-      , Opt_WarnNonCanonicalMonoidInstances
+    = [ Opt_WarnNonCanonicalMonoidInstances
       , Opt_WarnNonCanonicalMonadInstances
       , Opt_WarnCompatUnqualifiedImports
       , Opt_WarnTypeEqualityOutOfScope


=====================================
compiler/GHC/Driver/Session.hs
=====================================
@@ -2215,7 +2215,7 @@ wWarningFlagsDeps = [minBound..maxBound] >>= \x -> case x of
   Opt_WarnMissingMethods -> warnSpec x
   Opt_WarnMissingMonadFailInstances
     -> depWarnSpec x "fail is no longer a method of Monad"
-  Opt_WarnSemigroup -> warnSpec x
+  Opt_WarnSemigroup -> depWarnSpec x "Semigroup is now a superclass of Monoid"
   Opt_WarnMissingSignatures -> warnSpec x
   Opt_WarnMissingKindSignatures -> warnSpec x
   Opt_WarnMissingPolyKindSignatures -> warnSpec x


=====================================
docs/users_guide/using-warnings.rst
=====================================
@@ -165,7 +165,6 @@ as ``-Wno-...`` for every individual warning in the group.
     .. hlist::
         :columns: 3
 
-        * :ghc-flag:`-Wsemigroup`
         * :ghc-flag:`-Wnoncanonical-monoid-instances`
         * :ghc-flag:`-Wnoncanonical-monad-instances`
         * :ghc-flag:`-Wcompat-unqualified-imports`
@@ -654,8 +653,9 @@ of ``-W(no-)*``.
     a ``MonadFail`` instance.
 
 .. ghc-flag:: -Wsemigroup
-    :shortdesc: warn when a ``Monoid`` is not ``Semigroup``, and on non-
-        ``Semigroup`` definitions of ``(<>)``?
+    :shortdesc: *(deprecated)*
+        Warn when a ``Monoid`` is not ``Semigroup``, and on non-``Semigroup``
+        definitions of ``(<>)``
     :type: dynamic
     :reverse: -Wno-semigroup
     :category:
@@ -665,15 +665,11 @@ of ``-W(no-)*``.
     .. index::
        single: semigroup; warning
 
-    Warn when definitions are in conflict with the future inclusion of
-    ``Semigroup`` into the standard typeclasses.
-
-     1. Instances of ``Monoid`` should also be instances of ``Semigroup``
-     2. The ``Semigroup`` operator ``(<>)`` will be in ``Prelude``, which
-        clashes with custom local definitions of such an operator
-
-    Being part of the :ghc-flag:`-Wcompat` option group, this warning is off by
-    default, but will be switched on in a future GHC release.
+    This warning is deprecated. It no longer has any effect since GHC 9.8.
+    It was used during the transition period of the semigroup proposal,
+    to warn when an instance of ``Monoid`` was not an instance of ``Semigroup``,
+    or when a custom local operator ``(<>)`` could clash with `(<>)`,
+    now exported from ``Prelude``.
 
 .. ghc-flag:: -Wdeprecated-flags
     :shortdesc: warn about uses of commandline flags that are deprecated


=====================================
testsuite/tests/ghci/scripts/ghci024.stdout
=====================================
@@ -16,7 +16,6 @@ other dynamic, non-language, flag settings:
   -fprefer-byte-code
   -fbreak-points
 warning settings:
-  -Wsemigroup
   -Wcompat-unqualified-imports
   -Wtype-equality-out-of-scope
   -Wimplicit-rhs-quantification


=====================================
testsuite/tests/ghci/scripts/ghci024.stdout-mingw32
=====================================
@@ -15,7 +15,6 @@ other dynamic, non-language, flag settings:
   -fprefer-byte-code
   -fbreak-points
 warning settings:
-  -Wsemigroup
   -Wcompat-unqualified-imports
   -Wtype-equality-out-of-scope
   -Wimplicit-rhs-quantification


=====================================
testsuite/tests/wcompat-warnings/Template.hs
=====================================
@@ -2,8 +2,6 @@ module WCompatWarningsOnOff where
 
 import qualified Data.Semigroup as Semi
 
-(<>) = undefined -- Semigroup warnings
-
 -- -fwarn-noncanonical-monoid-instances
 newtype S = S Int
 


=====================================
testsuite/tests/wcompat-warnings/WCompatWarningsOn.stderr
=====================================
@@ -1,12 +1,12 @@
 
-Template.hs:11:3: warning: [GHC-50928] [-Wnoncanonical-monoid-instances (in -Wdefault, -Wcompat)]
+Template.hs:9:3: warning: [GHC-50928] [-Wnoncanonical-monoid-instances (in -Wdefault, -Wcompat)]
     Noncanonical ‘(<>) = mappend’ definition detected
     in the instance declaration for ‘Semigroup S’.
     Suggested fix:
       Move definition from ‘mappend’ to ‘(<>)’
       See also: https://gitlab.haskell.org/ghc/ghc/-/wikis/proposal/semigroup-monoid
 
-Template.hs:14:3: warning: [GHC-50928] [-Wnoncanonical-monoid-instances (in -Wdefault, -Wcompat)]
+Template.hs:12:3: warning: [GHC-50928] [-Wnoncanonical-monoid-instances (in -Wdefault, -Wcompat)]
     Noncanonical ‘mappend’ definition detected
     in the instance declaration for ‘Monoid S’.
     ‘mappend’ will eventually be removed in favour of ‘(<>)’
@@ -14,21 +14,21 @@ Template.hs:14:3: warning: [GHC-50928] [-Wnoncanonical-monoid-instances (in -Wde
       Either remove definition for ‘mappend’ (recommended) or define as ‘mappend = (<>)’
       See also: https://gitlab.haskell.org/ghc/ghc/-/wikis/proposal/semigroup-monoid
 
-Template.hs:24:3: warning: [GHC-22705] [-Wnoncanonical-monad-instances (in -Wdefault, -Wcompat)]
+Template.hs:22:3: warning: [GHC-22705] [-Wnoncanonical-monad-instances (in -Wdefault, -Wcompat)]
     Noncanonical ‘pure = return’ definition detected
     in the instance declaration for ‘Applicative M’.
     Suggested fix:
       Move definition from ‘return’ to ‘pure’
       See also: https://gitlab.haskell.org/ghc/ghc/-/wikis/proposal/monad-of-no-return
 
-Template.hs:25:3: warning: [GHC-22705] [-Wnoncanonical-monad-instances (in -Wdefault, -Wcompat)]
+Template.hs:23:3: warning: [GHC-22705] [-Wnoncanonical-monad-instances (in -Wdefault, -Wcompat)]
     Noncanonical ‘(*>) = (>>)’ definition detected
     in the instance declaration for ‘Applicative M’.
     Suggested fix:
       Move definition from ‘(>>)’ to ‘(*>)’
       See also: https://gitlab.haskell.org/ghc/ghc/-/wikis/proposal/monad-of-no-return
 
-Template.hs:28:3: warning: [GHC-22705] [-Wnoncanonical-monad-instances (in -Wdefault, -Wcompat)]
+Template.hs:26:3: warning: [GHC-22705] [-Wnoncanonical-monad-instances (in -Wdefault, -Wcompat)]
     Noncanonical ‘return’ definition detected
     in the instance declaration for ‘Monad M’.
     ‘return’ will eventually be removed in favour of ‘pure’
@@ -36,7 +36,7 @@ Template.hs:28:3: warning: [GHC-22705] [-Wnoncanonical-monad-instances (in -Wdef
       Either remove definition for ‘return’ (recommended) or define as ‘return = pure’
       See also: https://gitlab.haskell.org/ghc/ghc/-/wikis/proposal/monad-of-no-return
 
-Template.hs:30:3: warning: [GHC-22705] [-Wnoncanonical-monad-instances (in -Wdefault, -Wcompat)]
+Template.hs:28:3: warning: [GHC-22705] [-Wnoncanonical-monad-instances (in -Wdefault, -Wcompat)]
     Noncanonical ‘(>>)’ definition detected
     in the instance declaration for ‘Monad M’.
     ‘(>>)’ will eventually be removed in favour of ‘(*>)’



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

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e3ca78f3767176dd9870509aa334505d0146d94c
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/20240110/390f18d0/attachment-0001.html>


More information about the ghc-commits mailing list