@@ -82,6 +82,7 @@ module Data.HashMap.Strict.Refined
8282 , UnionProof(..)
8383 , Common.difference
8484 , DifferenceProof(..)
85+ , differenceWith
8586 , differenceWithKey
8687 , PartialDifferenceProof(..)
8788 , intersectionWithKey
@@ -375,8 +376,20 @@ unionWithKey f (HashMap m1) (HashMap m2) = SomeHashMapWith
375376 (HashMap $ HashMap.unionWithKey (f . reallyUnsafeRefine) m1 m2)
376377 $ UnionProof unsafeSubset unsafeSubsetWith2
377378
378−-- | For keys that appear in both maps, the given function decides whether the
379−-- key is removed from the first map.
379+-- | Return the first map, but for keys that appear in both maps, the given
380+-- function decides whether the key is removed.
381+differenceWith
382+ :: forall s t k a b. Hashable k
383+ => (a -> b -> Maybe a)
384+ -> HashMap s k a
385+ -> HashMap t k b
386+ -> SomeHashMapWith (PartialDifferenceProof 'Hashed s t) k a
387+differenceWith f (HashMap m1) (HashMap m2) = SomeHashMapWith
388+ (HashMap $ HashMap.differenceWith f m1 m2)
389+ $ PartialDifferenceProof unsafeSubset unsafeSubset
390+
391+-- | Return the first map, but for keys that appear in both maps, the given
392+-- function decides whether the key is removed.
380393--
381394-- You can use 'andLeft' and 'andRight' to obtain @'Key' s k@ and @'Key' t k@
382395-- respectively.