diff options
author | David Luposchainsky <dluposchainsky@gmail.com> | 2015-11-29 22:59:57 +0100 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2015-11-29 23:00:48 +0100 |
commit | 290def72f54db7969258b4541aaefc87b54ce448 (patch) | |
tree | 5843028d9666626e3becb897e21e8caa007fd8c2 /compiler/utils | |
parent | bcd55a94f234f5efa4bb4fd24429dafc79d93106 (diff) | |
download | haskell-290def72f54db7969258b4541aaefc87b54ce448.tar.gz |
Implement warnings for Semigroups as parent of Monoid
This patch is similar to the AMP patch (#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.
Reviewers: hvr, ekmett, austin, bgamari
Reviewed By: hvr, ekmett, bgamari
Subscribers: ekmett, thomie
Differential Revision: https://phabricator.haskell.org/D1539
GHC Trac Issues: #11139
Diffstat (limited to 'compiler/utils')
-rw-r--r-- | compiler/utils/OrdList.hs | 9 | ||||
-rw-r--r-- | compiler/utils/UniqFM.hs | 9 |
2 files changed, 18 insertions, 0 deletions
diff --git a/compiler/utils/OrdList.hs b/compiler/utils/OrdList.hs index 4591b55978..f5362bb27f 100644 --- a/compiler/utils/OrdList.hs +++ b/compiler/utils/OrdList.hs @@ -21,6 +21,10 @@ import Outputable #if __GLASGOW_HASKELL__ < 709 import Data.Monoid ( Monoid(..) ) #endif +#if __GLASGOW_HASKELL__ > 710 +import Data.Semigroup ( Semigroup ) +import qualified Data.Semigroup as Semigroup +#endif infixl 5 `appOL` infixl 5 `snocOL` @@ -38,6 +42,11 @@ data OrdList a instance Outputable a => Outputable (OrdList a) where ppr ol = ppr (fromOL ol) -- Convert to list and print that +#if __GLASGOW_HASKELL__ > 710 +instance Semigroup (OrdList a) where + (<>) = appOL +#endif + instance Monoid (OrdList a) where mempty = nilOL mappend = appOL diff --git a/compiler/utils/UniqFM.hs b/compiler/utils/UniqFM.hs index db578c37d0..fa556fb2b1 100644 --- a/compiler/utils/UniqFM.hs +++ b/compiler/utils/UniqFM.hs @@ -84,6 +84,10 @@ import Data.Data #if __GLASGOW_HASKELL__ < 709 import Data.Monoid #endif +#if __GLASGOW_HASKELL__ > 710 +import Data.Semigroup ( Semigroup ) +import qualified Data.Semigroup as Semigroup +#endif {- ************************************************************************ @@ -202,6 +206,11 @@ ufmToList :: UniqFM elt -> [(Unique, elt)] ************************************************************************ -} +#if __GLASGOW_HASKELL__ > 710 +instance Semigroup (UniqFM a) where + (<>) = plusUFM +#endif + instance Monoid (UniqFM a) where mempty = emptyUFM mappend = plusUFM |