Implement `-Wnoncanonical-monadfail-instances` warning
authorHerbert Valerio Riedel <hvr@gnu.org>
Sun, 24 Jan 2016 13:46:44 +0000 (14:46 +0100)
committerHerbert Valerio Riedel <hvr@gnu.org>
Sun, 24 Jan 2016 20:46:13 +0000 (21:46 +0100)
commitfd6dd41c67f3bd23bbf074357219cfd251eb53d6
treeb74609f5d6752ff10c5aae242949248687b45508
parent2c6fe5b8a854f06ea9574f7dca545b4c2d35b811
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
compiler/main/DynFlags.hs
compiler/rename/RnSource.hs
docs/users_guide/8.0.1-notes.rst
docs/users_guide/using-warnings.rst
testsuite/tests/warnings/should_compile/T11128b.hs [new file with mode: 0644]
testsuite/tests/warnings/should_compile/T11128b.stderr [new file with mode: 0644]
testsuite/tests/warnings/should_compile/all.T
utils/mkUserGuidePart/Options/Warnings.hs