@@ -78,6 +78,7 @@ module Data.Map.Strict.Refined
7878 , Common.disjoint
7979 , DisjointProof(..)
8080 -- * Combine
81+ , zipWith
8182 , zipWithKey
8283 , bind
8384 , Common.union
@@ -160,7 +161,7 @@ import Data.Proxy
160161import Data.Reflection
161162import Data.Traversable
162163import Data.Type.Coercion
163−import Prelude hiding (lookup, map, null)
164+import Prelude hiding (lookup, map, null, zipWith)
164165import Refined
165166import Refined.Unsafe
166167
@@ -355,6 +356,24 @@ updateLookupWithKey f k (Map m)
355356
356357-- | Given two maps proven to have the same keys, for each key apply the
357358-- function to the associated values, to obtain a new map with the same keys.
359+zipWith
360+ :: forall s k a b c. Ord k
361+ => (a -> b -> c) -> Map s k a -> Map s k b -> Map s k c
362+zipWith f (Map m1) (Map m2) = Map
363+ $ Map.mergeWithKey (\_ x y -> Just $ f x y)
364+ (\m -> if Map.null m
365+ then Map.empty
366+ else error "zipWith: bug: Data.Map.Strict.Refined has been subverted")
367+ (\m -> if Map.null m
368+ then Map.empty
369+ else error "zipWith: bug: Data.Map.Strict.Refined has been subverted")
370+ -- ^ Work around https://github.com/haskell/containers/issues/979
371+ m1
372+ m2
373+
374+-- | Given two maps proven to have the same keys, for each key apply the
375+-- function to the associated values and the key, to obtain a new map with the
376+-- same keys.
358377zipWithKey
359378 :: forall s k a b c. Ord k
360379 => (Key s k -> a -> b -> c) -> Map s k a -> Map s k b -> Map s k c