diff options
author | Herbert Valerio Riedel <hvr@gnu.org> | 2017-08-30 01:29:55 +0200 |
---|---|---|
committer | Herbert Valerio Riedel <hvr@gnu.org> | 2017-08-31 09:45:11 +0200 |
commit | c0feee90118333dac817cfad6f2dedc0a886d1bd (patch) | |
tree | f1e7bd59e0c8452d9e51f359d504606a8a346bf0 /compiler/rename/RnEnv.hs | |
parent | 2c133b67df374c73bc8069cefd7d57e1d2a14fc3 (diff) | |
download | haskell-c0feee90118333dac817cfad6f2dedc0a886d1bd.tar.gz |
Add missing Semigroup instances to compiler
This is a pre-requisite for implementing the Semigroup/Monoid proposal.
The instances have been introduced in a way to minimise warnings.
Diffstat (limited to 'compiler/rename/RnEnv.hs')
-rw-r--r-- | compiler/rename/RnEnv.hs | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/compiler/rename/RnEnv.hs b/compiler/rename/RnEnv.hs index 298de54168..175cb6b518 100644 --- a/compiler/rename/RnEnv.hs +++ b/compiler/rename/RnEnv.hs @@ -78,6 +78,7 @@ import RnUnbound import RnUtils import Data.Functor (($>)) import Data.Maybe (isJust) +import qualified Data.Semigroup as Semi {- ********************************************************* @@ -584,24 +585,27 @@ instance Outputable DisambigInfo where ppr (DisambiguatedOccurrence gre) = text "DiambiguatedOccurrence:" <+> ppr gre ppr (AmbiguousOccurrence gres) = text "Ambiguous:" <+> ppr gres -instance Monoid DisambigInfo where - mempty = NoOccurrence +instance Semi.Semigroup DisambigInfo where -- This is the key line: We prefer disambiguated occurrences to other -- names. - _ `mappend` DisambiguatedOccurrence g' = DisambiguatedOccurrence g' - DisambiguatedOccurrence g' `mappend` _ = DisambiguatedOccurrence g' + _ <> DisambiguatedOccurrence g' = DisambiguatedOccurrence g' + DisambiguatedOccurrence g' <> _ = DisambiguatedOccurrence g' - - NoOccurrence `mappend` m = m - m `mappend` NoOccurrence = m - UniqueOccurrence g `mappend` UniqueOccurrence g' + NoOccurrence <> m = m + m <> NoOccurrence = m + UniqueOccurrence g <> UniqueOccurrence g' = AmbiguousOccurrence [g, g'] - UniqueOccurrence g `mappend` AmbiguousOccurrence gs + UniqueOccurrence g <> AmbiguousOccurrence gs = AmbiguousOccurrence (g:gs) - AmbiguousOccurrence gs `mappend` UniqueOccurrence g' + AmbiguousOccurrence gs <> UniqueOccurrence g' = AmbiguousOccurrence (g':gs) - AmbiguousOccurrence gs `mappend` AmbiguousOccurrence gs' + AmbiguousOccurrence gs <> AmbiguousOccurrence gs' = AmbiguousOccurrence (gs ++ gs') + +instance Monoid DisambigInfo where + mempty = NoOccurrence + mappend = (Semi.<>) + -- Lookup SubBndrOcc can never be ambiguous -- -- Records the result of looking up a child. |