• Herbert Valerio Riedel's avatar
    Implement new `-fwarn-noncanonical-monad-instances` · f09f2470
    Herbert Valerio Riedel authored
    Warn about incoherent/non-canonical 'Applicative'/'Monad' instance
    declarations. Specifically the following invariants are checked:
    
    In 'Monad' instances declarations warn if the any of the following
    conditions does not hold:
    
     * If `return` is overridden it must be canonical (i.e. `return = pure`).
     * If `(>>)` is overridden it must be canonical (i.e. `(>>) = (*>)`).
    
    In 'Applicative' instance declarations:
    
     * Warn if 'pure' is defined backwards (i.e. `pure = return`).
     * Warn if '(*>)' is defined backwards (i.e. `(*>) = (>>)`).
    
    NB, this warning flag is not enabled via `-Wall` nor `-Wcompat`.
    
    This addresses #11128
    
    Reviewers: quchen, austin, bgamari
    
    Reviewed By: bgamari
    
    Differential Revision: https://phabricator.haskell.org/D1516
    f09f2470
7.12.1-notes.rst 12.3 KB