From e3ca78f3767176dd9870509aa334505d0146d94c Mon Sep 17 00:00:00 2001 From: Krzysztof Gogolewski <krzysztof.gogolewski@tweag.io> Date: Thu, 9 Nov 2023 15:37:08 +0100 Subject: [PATCH] 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. --- compiler/GHC/Driver/Flags.hs | 5 ++--- compiler/GHC/Driver/Session.hs | 2 +- docs/users_guide/using-warnings.rst | 20 ++++++++----------- testsuite/tests/ghci/scripts/ghci024.stdout | 1 - .../tests/ghci/scripts/ghci024.stdout-mingw32 | 1 - testsuite/tests/wcompat-warnings/Template.hs | 2 -- .../wcompat-warnings/WCompatWarningsOn.stderr | 12 +++++------ 7 files changed, 17 insertions(+), 26 deletions(-) diff --git a/compiler/GHC/Driver/Flags.hs b/compiler/GHC/Driver/Flags.hs index 0aadea7c3d38..a819caf7a0d3 100644 --- a/compiler/GHC/Driver/Flags.hs +++ b/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 diff --git a/compiler/GHC/Driver/Session.hs b/compiler/GHC/Driver/Session.hs index 6f330707bb9d..f700610037ed 100644 --- a/compiler/GHC/Driver/Session.hs +++ b/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 diff --git a/docs/users_guide/using-warnings.rst b/docs/users_guide/using-warnings.rst index 720d3114e341..c759bed50fea 100644 --- a/docs/users_guide/using-warnings.rst +++ b/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 diff --git a/testsuite/tests/ghci/scripts/ghci024.stdout b/testsuite/tests/ghci/scripts/ghci024.stdout index e82226aff141..8af7066534f9 100644 --- a/testsuite/tests/ghci/scripts/ghci024.stdout +++ b/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 diff --git a/testsuite/tests/ghci/scripts/ghci024.stdout-mingw32 b/testsuite/tests/ghci/scripts/ghci024.stdout-mingw32 index c7658f986c2f..8914a08aeefc 100644 --- a/testsuite/tests/ghci/scripts/ghci024.stdout-mingw32 +++ b/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 diff --git a/testsuite/tests/wcompat-warnings/Template.hs b/testsuite/tests/wcompat-warnings/Template.hs index 86c1449c6405..1a6c328f6c04 100644 --- a/testsuite/tests/wcompat-warnings/Template.hs +++ b/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 diff --git a/testsuite/tests/wcompat-warnings/WCompatWarningsOn.stderr b/testsuite/tests/wcompat-warnings/WCompatWarningsOn.stderr index 4ef1b425b119..db1e5c990979 100644 --- a/testsuite/tests/wcompat-warnings/WCompatWarningsOn.stderr +++ b/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 ‘(*>)’ -- GitLab