Skip to content

Commit 99b2cb6

Browse files
committed
resolve definition ordering
1 parent 33b45fe commit 99b2cb6

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/Data/Patch/IntMap.hs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,6 @@ import Data.Patch.Class
2222
-- and @Nothing@ means delete.
2323
newtype PatchIntMap a = PatchIntMap (IntMap (Maybe a)) deriving (Functor, Foldable, Traversable, Monoid)
2424

25-
-- | Apply the insertions or deletions to a given 'IntMap'.
26-
instance Patch (PatchIntMap a) where
27-
type PatchTarget (PatchIntMap a) = IntMap a
28-
apply (PatchIntMap p) v = if IntMap.null p then Nothing else Just $
29-
let removes = IntMap.filter isNothing p
30-
adds = IntMap.mapMaybe id p
31-
in IntMap.union adds $ v `IntMap.difference` removes
32-
33-
makeWrapped ''PatchIntMap
34-
3525
-- | @a <> b@ will apply the changes of @b@ and then apply the changes of @a@.
3626
-- If the same key is modified by both patches, the one on the left will take
3727
-- precedence.
@@ -40,6 +30,16 @@ instance Semigroup (PatchIntMap v) where
4030
-- PatchMap is idempotent, so stimes n is id for every n
4131
stimes = stimesIdempotentMonoid
4232

33+
makeWrapped ''PatchIntMap
34+
35+
-- | Apply the insertions or deletions to a given 'IntMap'.
36+
instance Patch (PatchIntMap a) where
37+
type PatchTarget (PatchIntMap a) = IntMap a
38+
apply (PatchIntMap p) v = if IntMap.null p then Nothing else Just $
39+
let removes = IntMap.filter isNothing p
40+
adds = IntMap.mapMaybe id p
41+
in IntMap.union adds $ v `IntMap.difference` removes
42+
4343
instance FunctorWithIndex Int PatchIntMap
4444
instance FoldableWithIndex Int PatchIntMap
4545
instance TraversableWithIndex Int PatchIntMap where

0 commit comments

Comments
 (0)