Skip to content

Commit 852ac18

Browse files
committed
add *WithIndex instances
1 parent eb6b6e5 commit 852ac18

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/Data/Patch/IntMap.hs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
-- insert/update or delete of associations.
88
module Data.Patch.IntMap where
99

10+
import Control.Lens
1011
import Data.IntMap.Strict (IntMap)
1112
import qualified Data.IntMap.Strict as IntMap
1213
import Data.Maybe
@@ -34,6 +35,11 @@ instance Semigroup (PatchIntMap v) where
3435
-- PatchMap is idempotent, so stimes n is id for every n
3536
stimes = stimesIdempotentMonoid
3637

38+
instance FunctorWithIndex Int PatchIntMap
39+
instance FoldableWithIndex Int PatchIntMap
40+
instance TraversableWithIndex Int PatchIntMap where
41+
itraversed = _Wrapped . itraversed . traversed
42+
3743
-- | Map a function @Int -> a -> b@ over all @a@s in the given @'PatchIntMap' a@
3844
-- (that is, all inserts/updates), producing a @PatchIntMap b@.
3945
mapIntMapPatchWithKey :: (Int -> a -> b) -> PatchIntMap a -> PatchIntMap b

0 commit comments

Comments
 (0)