git.iko.soy/typeable/refined-containers
on main help sign in
Work around a bug in mergeWithKey
commit9cac37a09ac0bc69ba1bd5b157fe8fafcbcc4597 authormniip <mniip@mniip.com> dateThu 21 Dec 2023, 12:55 (3 years ago) parent72837d4
4 files changed+30−8
src/Data/IntMap/Common/Refined.hs+7−2 src/Data/IntMap/Strict/Refined.hs+9−2 src/Data/Map/Common/Refined.hs+7−2 src/Data/Map/Strict/Refined.hs+7−2
src/Data/IntMap/Common/Refined.hs+7−2
@@ -241,8 +241,13 @@ zipWithKey
241241 -> IntMap s c
242242zipWithKey f (IntMap m1) (IntMap m2) = IntMap
243243 $ IntMap.mergeWithKey (\k x y -> Just $ f (unsafeKey k) x y)
244− (error "zipWithKey: bug: Data.IntMap.Refined has been subverted")
245− (error "zipWithKey: bug: Data.IntMap.Refined has been subverted")
244+ (\m -> if IntMap.null m
245+ then IntMap.empty
246+ else error "zipWithKey: bug: Data.IntMap.Refined has been subverted")
247+ (\m -> if IntMap.null m
248+ then IntMap.empty
249+ else error "zipWithKey: bug: Data.IntMap.Refined has been subverted")
250+ -- ^ Work around https://github.com/haskell/containers/issues/979
246251 m1
247252 m2
248253
src/Data/IntMap/Strict/Refined.hs+9−2
@@ -236,8 +236,15 @@ zipWithKey
236236 -> IntMap s c
237237zipWithKey f (IntMap m1) (IntMap m2) = IntMap
238238 $ IntMap.mergeWithKey (\k x y -> Just $ f (unsafeKey k) x y)
239− (error "zipWithKey: bug: Data.IntMap.Strict.Refined has been subverted")
240− (error "zipWithKey: bug: Data.IntMap.Strict.Refined has been subverted")
239+ (\m -> if IntMap.null m
240+ then IntMap.empty
241+ else
242+ error "zipWithKey: bug: Data.IntMap.Strict.Refined has been subverted")
243+ (\m -> if IntMap.null m
244+ then IntMap.empty
245+ else
246+ error "zipWithKey: bug: Data.IntMap.Strict.Refined has been subverted")
247+ -- ^ Work around https://github.com/haskell/containers/issues/979
241248 m1
242249 m2
243250
src/Data/Map/Common/Refined.hs+7−2
@@ -241,8 +241,13 @@ zipWithKey
241241 => (Key s k -> a -> b -> c) -> Map s k a -> Map s k b -> Map s k c
242242zipWithKey f (Map m1) (Map m2) = Map
243243 $ Map.mergeWithKey (\k x y -> Just $ f (unsafeKey k) x y)
244− (error "zipWithKey: bug: Data.Map.Refined has been subverted")
245− (error "zipWithKey: bug: Data.Map.Refined has been subverted")
244+ (\m -> if Map.null m
245+ then Map.empty
246+ else error "zipWithKey: bug: Data.Map.Refined has been subverted")
247+ (\m -> if Map.null m
248+ then Map.empty
249+ else error "zipWithKey: bug: Data.Map.Refined has been subverted")
250+ -- ^ Work around https://github.com/haskell/containers/issues/979
246251 m1
247252 m2
248253
src/Data/Map/Strict/Refined.hs+7−2
@@ -244,8 +244,13 @@ zipWithKey
244244 => (Key s k -> a -> b -> c) -> Map s k a -> Map s k b -> Map s k c
245245zipWithKey f (Map m1) (Map m2) = Map
246246 $ Map.mergeWithKey (\k x y -> Just $ f (unsafeKey k) x y)
247− (error "zipWithKey: bug: Data.Map.Strict.Refined has been subverted")
248− (error "zipWithKey: bug: Data.Map.Strict.Refined has been subverted")
247+ (\m -> if Map.null m
248+ then Map.empty
249+ else error "zipWithKey: bug: Data.Map.Strict.Refined has been subverted")
250+ (\m -> if Map.null m
251+ then Map.empty
252+ else error "zipWithKey: bug: Data.Map.Strict.Refined has been subverted")
253+ -- ^ Work around https://github.com/haskell/containers/issues/979
249254 m1
250255 m2
251256