Skip to content
  • Herbert Valerio Riedel's avatar
    Implement `-Wnoncanonical-monadfail-instances` warning · fd6dd41c
    Herbert Valerio Riedel authored
    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
    fd6dd41c