-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathPatch.hs
40 lines (35 loc) · 1.23 KB
/
Patch.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
{-# LANGUAGE CPP #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-|
Description:
This module defines the 'Group' class, and reexports the other modules.
-}
module Data.Patch
( module Data.Patch
, module X
) where
#if !MIN_VERSION_base(4,11,0)
import Data.Semigroup (Semigroup (..))
#endif
import Data.Semigroup.Commutative as X
import Data.Patch.Class as X
import Data.Patch.DMap as X hiding (getDeletions)
import Data.Patch.DMapWithMove as X
( PatchDMapWithMove, const2PatchDMapWithMoveWith, mapPatchDMapWithMove
, patchDMapWithMoveToPatchMapWithMoveWith
, traversePatchDMapWithMoveWithKey, unPatchDMapWithMove
, unsafePatchDMapWithMove, weakenPatchDMapWithMoveWith
)
import Data.Patch.IntMap as X hiding (getDeletions)
import Data.Patch.Map as X
import Data.Patch.MapWithMove as X
( PatchMapWithMove, patchMapWithMoveNewElements
, patchMapWithMoveNewElementsMap, unPatchMapWithMove
, unsafePatchMapWithMove
)
-- | The elements of an 'Commutative' 'Semigroup' can be considered as patches of their own type.
newtype AdditivePatch p = AdditivePatch { unAdditivePatch :: p }
instance Commutative p => Patch (AdditivePatch p) where
type PatchTarget (AdditivePatch p) = p
apply (AdditivePatch p) q = Just $ p <> q