1{-# LANGUAGE TypeFamilies #-}
6-- This module defines the 'Patch' class.
12import Data.Patch.Class as X
13import Data.Patch.DMap as X hiding (getDeletions)
14import Data.Patch.DMapWithMove as X (PatchDMapWithMove, const2PatchDMapWithMoveWith, mapPatchDMapWithMove,
15 patchDMapWithMoveToPatchMapWithMoveWith,
16 traversePatchDMapWithMoveWithKey, unPatchDMapWithMove,
17 unsafePatchDMapWithMove, weakenPatchDMapWithMoveWith)
18import Data.Patch.IntMap as X hiding (getDeletions)
19import Data.Patch.Map as X
20import Data.Patch.MapWithMove as X (PatchMapWithMove, patchMapWithMoveNewElements,
21 patchMapWithMoveNewElementsMap, unPatchMapWithMove,
22 unsafePatchMapWithMove)
23import Data.Map.Monoidal (MonoidalMap)
24import Data.Semigroup (Semigroup (..), (<>))
26-- | A 'Group' is a 'Monoid' where every element has an inverse.
27class (Semigroup q, Monoid q) => Group q where
30 r ~~ s = r <> negateG s
32-- | An 'Additive' 'Semigroup' is one where (<>) is commutative
33class Semigroup q => Additive q where
35-- | The elements of an 'Additive' 'Semigroup' can be considered as patches of their own type.
36newtype AdditivePatch p = AdditivePatch { unAdditivePatch :: p }
38instance Additive p => Patch (AdditivePatch p) where
39 type PatchTarget (AdditivePatch p) = p
40 apply (AdditivePatch p) q = Just $ p <> q
42instance (Ord k, Group q) => Group (MonoidalMap k q) where
43 negateG = fmap negateG
45instance (Ord k, Additive q) => Additive (MonoidalMap k q)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list