Implement warnings for Semigroups as parent of Monoid
ClosedPublic

Authored by quchen on Nov 27 2015, 10:06 AM.

Details

Summary

This patch is similar to the AMP patch (Trac #8004), which offered two functions:

  1. Warn when an instance of a class has been given, but the type does not have a certain superclass instance
  2. Warn when top-level definitions conflict with future Prelude names

These warnings are issued as part of the new -Wcompat warning group.

Diff Detail

Repository
rGHC Glasgow Haskell Compiler
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
quchen updated this revision to Diff 5338.Nov 27 2015, 10:06 AM
quchen retitled this revision from to Implement warnings for Semigroups as parent of Monoid.
quchen updated this object.
quchen edited the test plan for this revision. (Show Details)
quchen added a reviewer: hvr.
quchen edited edge metadata.Nov 27 2015, 10:07 AM
quchen updated the Trac tickets for this revision.
quchen updated this object.Nov 27 2015, 10:09 AM
quchen updated this revision to Diff 5339.Nov 27 2015, 11:24 AM
  • Fix semigroup warnings
  • Rename warning flag to -fwarn-semigroup
  • Add docs
ekmett accepted this revision.Nov 27 2015, 1:56 PM
ekmett added a reviewer: ekmett.
ekmett added a subscriber: ekmett.

LGTM

This revision is now accepted and ready to land.Nov 27 2015, 1:56 PM
hvr accepted this revision.Nov 27 2015, 3:34 PM
hvr edited edge metadata.

LGTM (except for minor markup issue)

compiler/hsSyn/HsTypes.hs
182–185

Btw, this definition will need to be inverted once mappend is defined in terms of (<>)

Maybe it makes sense to implement a -fwarn-noncanonical-monoid-instances warning to catch such cases early on to pave the way for the final stage of the Semigroup/Monoid Proposal. When people start providing Semigroup instances better have them use canonical instance definitions rightaway rather than define them inconsistently and have more work lateron.

utils/mkUserGuidePart/Options/Warnings.hs
165

(<>) should be quoted in backquotes

quchen updated this revision to Diff 5342.Nov 28 2015, 10:34 AM
quchen edited edge metadata.

Implement @hvr's code review

quchen marked 2 inline comments as done.Nov 28 2015, 10:35 AM
bgamari accepted this revision.Nov 29 2015, 3:59 PM
bgamari edited edge metadata.

Looks good to me. I'll take care of the minor documentation issue while merging.

utils/mkUserGuidePart/Options/Warnings.hs
165
s/??/``?/
This revision was automatically updated to reflect the committed changes.