There are some obvious specialisations for Data.Semialign.Diff.diff and Data.Semialign.Diff.diffNoEq, using the high-perfomance interface in Data.Map.Merge.Lazy:
diffMap
:: ( AsEmpty p
, At p
, Eq a
, Index p ~ k
, IxValue p ~ Maybe a
, Ord k
)
=> Map k a
-> Map k a
-> p
diffMapToMap :: (Ord k, Eq a) => Map k a -> Map k a -> Map k (Maybe a)
And some rewrite rules:
{-# NOINLINE [0] diff #-}
{-# RULES
"diff/MapToMap" [2]
forall (m :: Ord k => Map k a) n.
diff m n = diffMapToMap m n
"diff/Map" [1]
forall (m :: Ord k => Map k a) n.
diff m n = diffMap m n
#-}
Using inspection-testing and this code:
test :: Map String (Maybe Int)
test = diff (Map.fromList [("a", 1), ("b", 2)]) (Map.fromList [("a", 3), ("c", 4)])
$(inspect $ coreOf 'test)
It appears that neither rewrite rule is firing.
There are likely similar rules available for patching maps using maps, if I can get them to fire.
There are some obvious specialisations for
Data.Semialign.Diff.diffandData.Semialign.Diff.diffNoEq, using the high-perfomance interface inData.Map.Merge.Lazy:And some rewrite rules:
Using
inspection-testingand this code:It appears that neither rewrite rule is firing.
There are likely similar rules available for patching maps using maps, if I can get them to fire.