@@ -7,6 +7,7 @@
7-- insert/update or delete of associations.
7-- insert/update or delete of associations.
8module Data.Patch.IntMap where
8module Data.Patch.IntMap where
10import Data.IntMap.Strict (IntMap)
11import Data.IntMap.Strict (IntMap)
11import qualified Data.IntMap.Strict as IntMap
12import qualified Data.IntMap.Strict as IntMap
12import Data.Maybe
13import Data.Maybe
@@ -34,6 +35,11 @@ instance Semigroup (PatchIntMap v) where
34 -- PatchMap is idempotent, so stimes n is id for every n
35 -- PatchMap is idempotent, so stimes n is id for every n
35 stimes = stimesIdempotentMonoid
36 stimes = stimesIdempotentMonoid
38+instance FunctorWithIndex Int PatchIntMap
39+instance FoldableWithIndex Int PatchIntMap
40+instance TraversableWithIndex Int PatchIntMap where
41+ itraversed = _Wrapped . itraversed . traversed
37-- | Map a function @Int -> a -> b@ over all @a@s in the given @'PatchIntMap' a@
43-- | Map a function @Int -> a -> b@ over all @a@s in the given @'PatchIntMap' a@
38-- (that is, all inserts/updates), producing a @PatchIntMap b@.
44-- (that is, all inserts/updates), producing a @PatchIntMap b@.
39mapIntMapPatchWithKey :: (Int -> a -> b) -> PatchIntMap a -> PatchIntMap b
45mapIntMapPatchWithKey :: (Int -> a -> b) -> PatchIntMap a -> PatchIntMap b