diff options
author | Herbert Valerio Riedel <hvr@gnu.org> | 2017-09-09 13:47:08 +0200 |
---|---|---|
committer | Herbert Valerio Riedel <hvr@gnu.org> | 2017-09-09 14:27:27 +0200 |
commit | dab0e515eadecaee3e9e9f5f8eee3159fa39bb27 (patch) | |
tree | ba23795bfde3c92dd9567fc5d617ac21ad4d97d1 /compiler/utils | |
parent | 400ead81e80f66ad7b1260b11b2a92f25ccc3e5a (diff) | |
download | haskell-dab0e515eadecaee3e9e9f5f8eee3159fa39bb27.tar.gz |
Canonicalise Monoid instances in GHC
IOW, code compiles -Wnoncanonical-monoid-instances clean now
Diffstat (limited to 'compiler/utils')
-rw-r--r-- | compiler/utils/OrdList.hs | 2 | ||||
-rw-r--r-- | compiler/utils/UniqMap.hs | 4 | ||||
-rw-r--r-- | compiler/utils/UniqSet.hs | 10 |
3 files changed, 6 insertions, 10 deletions
diff --git a/compiler/utils/OrdList.hs b/compiler/utils/OrdList.hs index 1660090ba7..90fdefb908 100644 --- a/compiler/utils/OrdList.hs +++ b/compiler/utils/OrdList.hs @@ -41,7 +41,7 @@ instance Semigroup (OrdList a) where instance Monoid (OrdList a) where mempty = nilOL - mappend = appOL + mappend = (Semigroup.<>) mconcat = concatOL instance Functor OrdList where diff --git a/compiler/utils/UniqMap.hs b/compiler/utils/UniqMap.hs index 5bd609e597..c0960dd5b2 100644 --- a/compiler/utils/UniqMap.hs +++ b/compiler/utils/UniqMap.hs @@ -49,7 +49,7 @@ import UniqFM import Unique import Outputable -import Data.Semigroup ( Semigroup(..) ) +import Data.Semigroup as Semi ( Semigroup(..) ) import Data.Coerce import Data.Maybe import Data.Typeable @@ -65,7 +65,7 @@ instance Semigroup (UniqMap k a) where instance Monoid (UniqMap k a) where mempty = emptyUniqMap - mappend = plusUniqMap + mappend = (Semi.<>) instance (Outputable k, Outputable a) => Outputable (UniqMap k a) where ppr (UniqMap m) = diff --git a/compiler/utils/UniqSet.hs b/compiler/utils/UniqSet.hs index fcac865ea8..d09b337d12 100644 --- a/compiler/utils/UniqSet.hs +++ b/compiler/utils/UniqSet.hs @@ -52,7 +52,7 @@ import Data.Coerce import Outputable import Data.Foldable (foldl') import Data.Data -import qualified Data.Semigroup +import qualified Data.Semigroup as Semi -- Note [UniqSet invariant] -- ~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -61,7 +61,8 @@ import qualified Data.Semigroup -- It means that to implement mapUniqSet you have to update -- both the keys and the values. -newtype UniqSet a = UniqSet {getUniqSet' :: UniqFM a} deriving Data +newtype UniqSet a = UniqSet {getUniqSet' :: UniqFM a} + deriving (Data, Semi.Semigroup, Monoid) emptyUniqSet :: UniqSet a emptyUniqSet = UniqSet emptyUFM @@ -186,11 +187,6 @@ unsafeUFMToUniqSet = UniqSet instance Outputable a => Outputable (UniqSet a) where ppr = pprUniqSet ppr -instance Data.Semigroup.Semigroup (UniqSet a) where - (<>) = mappend -instance Monoid (UniqSet a) where - mempty = UniqSet mempty - UniqSet s `mappend` UniqSet t = UniqSet (s `mappend` t) pprUniqSet :: (a -> SDoc) -> UniqSet a -> SDoc pprUniqSet f (UniqSet s) = pprUniqFM f s |