diff options
author | Herbert Valerio Riedel <hvr@gnu.org> | 2016-01-24 14:46:44 +0100 |
---|---|---|
committer | Herbert Valerio Riedel <hvr@gnu.org> | 2016-01-24 21:46:13 +0100 |
commit | fd6dd41c67f3bd23bbf074357219cfd251eb53d6 (patch) | |
tree | b74609f5d6752ff10c5aae242949248687b45508 /compiler/main | |
parent | 2c6fe5b8a854f06ea9574f7dca545b4c2d35b811 (diff) | |
download | haskell-fd6dd41c67f3bd23bbf074357219cfd251eb53d6.tar.gz |
Implement `-Wnoncanonical-monadfail-instances` warning
The MonadFail proposal implemented so far via #10751 only warns about
missing `MonadFail` instances based on existence of failible pattern
matches in `do`-blocks.
However, based on the noncanonical Monad warnings implemented via #11150
we can provide a different mechanism for detecting missing `MonadFail`
instances quite cheaply. That is, by checking for canonical `fail` definitions.
In the case of `Monad`/`MonadFail`, we define the canonical implementation of
`fail` to be such that the soft-deprecated method shall (iff overridden) be
defined in terms of the non-deprecated method. Consequently, in case of
`MonadFail`, the `Monad(fail)` method shall be defined as alias of
the `MonadFail(fail)` method.
This allows us at some distant point in the future to remove `fail` from
the `Monad` class, while having GHC ignore/tolerate such literal canonical
method definitions.
Reviewed By: bgamari, RyanGlScott
Differential Revision: https://phabricator.haskell.org/D1838
Diffstat (limited to 'compiler/main')
-rw-r--r-- | compiler/main/DynFlags.hs | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs index c9b7a993e3..5189e235fa 100644 --- a/compiler/main/DynFlags.hs +++ b/compiler/main/DynFlags.hs @@ -594,6 +594,7 @@ data WarningFlag = | Opt_WarnDerivingTypeable | Opt_WarnDeferredTypeErrors | Opt_WarnNonCanonicalMonadInstances -- since 8.0 + | Opt_WarnNonCanonicalMonadFailInstances -- since 8.0 | Opt_WarnNonCanonicalMonoidInstances -- since 8.0 | Opt_WarnMissingPatSynSigs -- since 8.0 deriving (Eq, Show, Enum) @@ -2933,6 +2934,8 @@ wWarningFlags = [ flagSpec "name-shadowing" Opt_WarnNameShadowing, flagSpec "noncanonical-monad-instances" Opt_WarnNonCanonicalMonadInstances, + flagSpec "noncanonical-monadfail-instances" + Opt_WarnNonCanonicalMonadFailInstances, flagSpec "noncanonical-monoid-instances" Opt_WarnNonCanonicalMonoidInstances, flagSpec "orphans" Opt_WarnOrphans, |