diff options
author | Benjamin Barenblat <bbarenblat@gmail.com> | 2022-01-19 13:11:40 -0500 |
---|---|---|
committer | Benjamin Barenblat <bbarenblat@gmail.com> | 2022-01-19 13:31:05 -0500 |
commit | a9b9e5d0d72c2348580dbac5533b89a45abd8938 (patch) | |
tree | 0f8113e86df43616baec8570b07acb1537497885 /Types/Difference.hs | |
parent | c79473051a8e1647b14f351b72768b74301acc33 (diff) |
Deal with the Semigroup/Monoid proposal
base-4.11 made Semigroup a superclass of Monoid. Provide Semigroup
implementations for Monoids.
Diffstat (limited to 'Types/Difference.hs')
-rw-r--r-- | Types/Difference.hs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/Types/Difference.hs b/Types/Difference.hs index 4abc75c44..8516a3df7 100644 --- a/Types/Difference.hs +++ b/Types/Difference.hs @@ -1,6 +1,7 @@ {- git-annex repository differences - - Copyright 2015 Joey Hess <id@joeyh.name> + - Copyright 2022 Benjamin Barenblat <bbarenblat@gmail.com> - - Licensed under the GNU GPL version 3 or higher. -} @@ -67,14 +68,16 @@ instance Eq Differences where , oneLevelBranchHash ] -instance Monoid Differences where - mempty = Differences False False False - mappend a@(Differences {}) b@(Differences {}) = a +instance Semigroup Differences where + a@(Differences {}) <> b@(Differences {}) = a { objectHashLower = objectHashLower a || objectHashLower b , oneLevelObjectHash = oneLevelObjectHash a || oneLevelObjectHash b , oneLevelBranchHash = oneLevelBranchHash a || oneLevelBranchHash b } - mappend _ _ = UnknownDifferences + _ <> _ = UnknownDifferences + +instance Monoid Differences where + mempty = Differences False False False readDifferences :: String -> Differences readDifferences = maybe UnknownDifferences mkDifferences . readish |