on b3a8b00 help sign in
patch/src/Data/Patch.hs
40 lines 1.3 kB history raw
1{-# LANGUAGE CPP #-}
2{-# LANGUAGE TypeOperators #-}
3{-# LANGUAGE TypeFamilies #-}
4-- |
5-- Module:
6-- Data.Patch
7-- Description:
8-- This module defines the 'Patch' class.
9module Data.Patch
10 ( module Data.Patch
11 , module X
12 ) where
14#if !MIN_VERSION_base(4,11,0)
15import Data.Semigroup (Semigroup (..))
16#endif
18import Data.Semigroup.Additive as X
19import Data.Patch.Class as X
20import Data.Patch.DMap as X hiding (getDeletions)
21import Data.Patch.DMapWithMove as X
22 ( PatchDMapWithMove, const2PatchDMapWithMoveWith, mapPatchDMapWithMove
23 , patchDMapWithMoveToPatchMapWithMoveWith
24 , traversePatchDMapWithMoveWithKey, unPatchDMapWithMove
25 , unsafePatchDMapWithMove, weakenPatchDMapWithMoveWith
26 )
27import Data.Patch.IntMap as X hiding (getDeletions)
28import Data.Patch.Map as X
29import Data.Patch.MapWithMove as X
30 ( PatchMapWithMove, patchMapWithMoveNewElements
31 , patchMapWithMoveNewElementsMap, unPatchMapWithMove
32 , unsafePatchMapWithMove
33 )
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