@@ -11,14 +11,11 @@ module Data.Patch
1111 , module X
1212 ) where
1313
14−import Data.Functor.Const (Const (..))
15−import Data.Functor.Identity
16−import Data.Proxy
1714#if !MIN_VERSION_base(4,11,0)
1815import Data.Semigroup (Semigroup (..))
1916#endif
20−import GHC.Generics
2117
18+import Data.Semigroup.Additive as X
2219import Data.Patch.Class as X
2320import Data.Patch.DMap as X hiding (getDeletions)
2421import Data.Patch.DMapWithMove as X
@@ -35,37 +32,9 @@ import Data.Patch.MapWithMove as X
3532 , unsafePatchMapWithMove
3633 )
3734
38−-- | An 'Additive' 'Semigroup' is one where (<>) is commutative
39−class Semigroup q => Additive q where
40−
4135-- | The elements of an 'Additive' 'Semigroup' can be considered as patches of their own type.
4236newtype AdditivePatch p = AdditivePatch { unAdditivePatch :: p }
4337
4438instance Additive p => Patch (AdditivePatch p) where
4539 type PatchTarget (AdditivePatch p) = p
4640 apply (AdditivePatch p) q = Just $ p <> q
47−
48−-- | Trivial group.
49−instance Additive ()
50−
51−-- | Product group. A Pair of groups gives rise to a group
52−instance (Additive a, Additive b) => Additive (a, b)
53−
54−-- See https://gitlab.haskell.org/ghc/ghc/issues/11135#note_111802 for the reason Compose is not also provided.
55−-- Base does not define Monoid (Compose f g a) so this is the best we can
56−-- really do for functor composition.
57−instance Additive (f (g a)) => Additive ((f :.: g) a)
58−
59−-- | Product of groups, Functor style.
60−instance (Additive (f a), Additive (g a)) => Additive ((f :*: g) a)
61−
62−-- | Trivial group, Functor style
63−instance Additive (Proxy x)
64−
65−-- | Const lifts groups into a functor.
66−instance Additive a => Additive (Const a x)
67−-- | Ideitnty lifts groups pointwise (at only one point)
68−instance Additive a => Additive (Identity a)
69−
70−-- | Functions lift groups pointwise.
71−instance Additive b => Additive (a -> b)