Noncanonical `mappend` definition [GHC-50928]

Flag: -Wnoncanonical-monoid-instances
Enabled by default

As part of the Semigroup Monoid proposal, the Semigroup class is now a superclass of Monoid. Now, the mappend function is redundant and should always do exactly the same as the (<>) function of the Semigroup instance. In the future, the mappend function may even be removed completely.

So, you should adapt to these changes by either:

Examples

Noncanonical `mappend` definition.

Error Message

NoncanonicalMappend.hs:10:3: warning: [GHC-50928] [-Wnoncanonical-monoid-instances]
    Noncanonical ‘mappend’ definition detected
    in the instance declaration for ‘Monoid A’.
    ‘mappend’ will eventually be removed in favour of ‘(<>)’
    Suggested fix:
      Either remove definition for ‘mappend’ (recommended) or define as ‘mappend = (<>)’
      See also: https://gitlab.haskell.org/ghc/ghc/-/wikis/proposal/semigroup-monoid
   |
10 |   mappend A A = A
   |   ^^^^^^^^^^^^^^^
NoncanonicalMappend.hs
Before
module NoncanonicalMappend where

data A = A

instance Semigroup A where
  A <> A = A

instance Monoid A where
  mempty = A
  mappend A A = A

After
module NoncanonicalMappend where

data A = A

instance Semigroup A where
  A <> A = A

instance Monoid A where
  mempty = A
  mappend = (<>)