on develop help sign in
add *WithIndex instances
852ac18Joe Betz
src/Data/Patch/IntMap.hs+6
@@ -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
9
9
10+import Control.Lens
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
36
37
38+instance FunctorWithIndex Int PatchIntMap
39+instance FoldableWithIndex Int PatchIntMap
40+instance TraversableWithIndex Int PatchIntMap where
41+ itraversed = _Wrapped . itraversed . traversed
42+
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