@@ -22,6 +22,7 @@ import qualified Data.Dependent.Map as DMap
22import Data.Dependent.Sum (ShowTag (..), EqTag (..))
22import Data.Dependent.Sum (ShowTag (..), EqTag (..))
23import Data.Functor.Constant
23import Data.Functor.Constant
24import Data.Functor.Misc
24import Data.Functor.Misc
25+import Data.Functor.Product
25import Data.GADT.Compare (GEq (..))
26import Data.GADT.Compare (GEq (..))
26import Data.GADT.Show (GShow (..))
27import Data.GADT.Show (GShow (..))
27import qualified Data.Map as Map
28import qualified Data.Map as Map
@@ -266,10 +267,8 @@ instance GCompare k => Patch (PatchDMapWithMove k v) where
266 From_Delete -> Just $ Constant ()
267 From_Delete -> Just $ Constant ()
267 _ -> Nothing
268 _ -> Nothing
269−-- | Get the values that will be deleted if the given patch is applied to the
270+-- | Get the values that will be deleted or moved if the given patch is applied
270−-- given 'DMap'
271+-- to the given 'DMap'.
271−getDeletions :: GCompare k => PatchDMapWithMove k v -> DMap k v' -> DMap k v'
272+getDeletionsAndMoves :: GCompare k => PatchDMapWithMove k v -> DMap k v' -> DMap k (Product v' (ComposeMaybe k))
272−getDeletions (PatchDMapWithMove p) m = DMap.mapMaybeWithKey (\_ -> getComposeMaybe) $ DMap.intersectionWithKey f p m
273+getDeletionsAndMoves (PatchDMapWithMove p) m = DMap.intersectionWithKey f m p
273− where f _ ni v = ComposeMaybe $ case getComposeMaybe $ _nodeInfo_to ni of
274+ where f _ v ni = Pair v $ _nodeInfo_to ni