on develop help sign in
Simplify itraverse{d} to not care about exact shape of newtypes
commit9da0ce0721a65b1a88b8ae0c9f5b688076bba932 authorJohn Ericson <John.Ericson@Obsidian.Systems> dateFri 17 Jan 2020, 15:26 (7 years ago) parentc6216d3
3 files changed+6−3
src/Data/Patch/IntMap.hs+2−1 src/Data/Patch/Map.hs+2−1 src/Data/Patch/MapWithMove.hs+2−1
src/Data/Patch/IntMap.hs+2−1
@@ -45,7 +45,8 @@ instance Patch (PatchIntMap a) where
4545instance FunctorWithIndex Int PatchIntMap
4646instance FoldableWithIndex Int PatchIntMap
4747instance TraversableWithIndex Int PatchIntMap where
48− itraversed = _Wrapped . itraversed . traversed
48+ itraverse = itraversed . Indexed
49+ itraversed = _Wrapped .> itraversed <. traversed
4950
5051-- | Map a function @Int -> a -> b@ over all @a@s in the given @'PatchIntMap' a@
5152-- (that is, all inserts/updates), producing a @PatchIntMap b@.
src/Data/Patch/Map.hs+2−1
@@ -54,7 +54,8 @@ instance Ord k => Patch (PatchMap k v) where
5454instance FunctorWithIndex k (PatchMap k)
5555instance FoldableWithIndex k (PatchMap k)
5656instance TraversableWithIndex k (PatchMap k) where
57− itraverse f (PatchMap x) = PatchMap <$> itraverse (traverse . f) x
57+ itraverse = itraversed . Indexed
58+ itraversed = _Wrapped .> itraversed <. traversed
5859
5960-- | The empty 'PatchMap' contains no insertions or deletions
6061instance Ord k => Monoid (PatchMap k v) where
src/Data/Patch/MapWithMove.hs+2−1
@@ -68,7 +68,8 @@ makeWrapped ''PatchMapWithMove
6868instance FunctorWithIndex k (PatchMapWithMove k)
6969instance FoldableWithIndex k (PatchMapWithMove k)
7070instance TraversableWithIndex k (PatchMapWithMove k) where
71− itraverse f (PatchMapWithMove x) = PatchMapWithMove <$> itraverse (traverse . f) x
71+ itraverse = itraversed . Indexed
72+ itraversed = _Wrapped .> itraversed <. traversed
7273
7374-- | Create a 'PatchMapWithMove', validating it
7475patchMapWithMove :: Ord k => Map k (NodeInfo k v) -> Maybe (PatchMapWithMove k v)