@@ -23,6 +23,7 @@ import Data.Semigroup (Semigroup (..))
2323#endif
2424import GHC.Generics
2525
26+import Data.Semigroup.Additive as X
2627import Data.Patch.Class as X
2728import Data.Patch.DMap as X hiding (getDeletions)
2829import Data.Patch.DMapWithMove as X
@@ -45,9 +46,6 @@ class (Semigroup q, Monoid q) => Group q where
4546 (~~) :: q -> q -> q
4647 r ~~ s = r <> negateG s
4748
48−-- | An 'Additive' 'Semigroup' is one where (<>) is commutative
49−class Semigroup q => Additive q where
50−
5149-- | The elements of an 'Additive' 'Semigroup' can be considered as patches of their own type.
5250newtype AdditivePatch p = AdditivePatch { unAdditivePatch :: p }
5351
@@ -58,19 +56,15 @@ instance Additive p => Patch (AdditivePatch p) where
5856instance (Ord k, Group q) => Group (MonoidalMap k q) where
5957 negateG = fmap negateG
6058
61−instance (Ord k, Additive q) => Additive (MonoidalMap k q)
62−
6359-- | Trivial group.
6460instance Group () where
6561 negateG _ = ()
6662 _ ~~ _ = ()
67−instance Additive ()
6863
6964-- | Product group. A Pair of groups gives rise to a group
7065instance (Group a, Group b) => Group (a, b) where
7166 negateG (a, b) = (negateG a, negateG b)
7267 (a, b) ~~ (c, d) = (a ~~ c, b ~~ d)
73−instance (Additive a, Additive b) => Additive (a, b)
7468
7569-- See https://gitlab.haskell.org/ghc/ghc/issues/11135#note_111802 for the reason Compose is not also provided.
7670-- Base does not define Monoid (Compose f g a) so this is the best we can
@@ -78,29 +72,24 @@ instance (Additive a, Additive b) => Additive (a, b)
7872instance Group (f (g a)) => Group ((f :.: g) a) where
7973 negateG (Comp1 xs) = Comp1 (negateG xs)
8074 Comp1 xs ~~ Comp1 ys = Comp1 (xs ~~ ys)
81−instance Additive (f (g a)) => Additive ((f :.: g) a)
8275
8376-- | Product of groups, Functor style.
8477instance (Group (f a), Group (g a)) => Group ((f :*: g) a) where
8578 negateG (a :*: b) = negateG a :*: negateG b
8679 (a :*: b) ~~ (c :*: d) = (a ~~ c) :*: (b ~~ d)
87−instance (Additive (f a), Additive (g a)) => Additive ((f :*: g) a)
8880
8981-- | Trivial group, Functor style
9082instance Group (Proxy x) where
9183 negateG _ = Proxy
9284 _ ~~ _ = Proxy
93−instance Additive (Proxy x)
9485
9586-- | Const lifts groups into a functor.
9687deriving instance Group a => Group (Const a x)
97−instance Additive a => Additive (Const a x)
88+
9889-- | Identity lifts groups pointwise (at only one point)
9990deriving instance Group a => Group (Identity a)
100−instance Additive a => Additive (Identity a)
10191
10292-- | Functions lift groups pointwise.
10393instance Group b => Group (a -> b) where
10494 negateG f = negateG . f
10595 (~~) = liftA2 (~~)
106−instance Additive b => Additive (a -> b)