Skip to content

Commit

Permalink
Work around a bug in mergeWithKey
Browse files Browse the repository at this point in the history
  • Loading branch information
mniip committed Dec 21, 2023
1 parent 72837d4 commit 9cac37a
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 8 deletions.
9 changes: 7 additions & 2 deletions src/Data/IntMap/Common/Refined.hs
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,13 @@ zipWithKey
-> IntMap s c
zipWithKey f (IntMap m1) (IntMap m2) = IntMap
$ IntMap.mergeWithKey (\k x y -> Just $ f (unsafeKey k) x y)
(error "zipWithKey: bug: Data.IntMap.Refined has been subverted")
(error "zipWithKey: bug: Data.IntMap.Refined has been subverted")
(\m -> if IntMap.null m
then IntMap.empty
else error "zipWithKey: bug: Data.IntMap.Refined has been subverted")
(\m -> if IntMap.null m
then IntMap.empty
else error "zipWithKey: bug: Data.IntMap.Refined has been subverted")
-- ^ Work around https://github.com/haskell/containers/issues/979
m1
m2

Expand Down
11 changes: 9 additions & 2 deletions src/Data/IntMap/Strict/Refined.hs
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,15 @@ zipWithKey
-> IntMap s c
zipWithKey f (IntMap m1) (IntMap m2) = IntMap
$ IntMap.mergeWithKey (\k x y -> Just $ f (unsafeKey k) x y)
(error "zipWithKey: bug: Data.IntMap.Strict.Refined has been subverted")
(error "zipWithKey: bug: Data.IntMap.Strict.Refined has been subverted")
(\m -> if IntMap.null m
then IntMap.empty
else
error "zipWithKey: bug: Data.IntMap.Strict.Refined has been subverted")
(\m -> if IntMap.null m
then IntMap.empty
else
error "zipWithKey: bug: Data.IntMap.Strict.Refined has been subverted")
-- ^ Work around https://github.com/haskell/containers/issues/979
m1
m2

Expand Down
9 changes: 7 additions & 2 deletions src/Data/Map/Common/Refined.hs
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,13 @@ zipWithKey
=> (Key s k -> a -> b -> c) -> Map s k a -> Map s k b -> Map s k c
zipWithKey f (Map m1) (Map m2) = Map
$ Map.mergeWithKey (\k x y -> Just $ f (unsafeKey k) x y)
(error "zipWithKey: bug: Data.Map.Refined has been subverted")
(error "zipWithKey: bug: Data.Map.Refined has been subverted")
(\m -> if Map.null m
then Map.empty
else error "zipWithKey: bug: Data.Map.Refined has been subverted")
(\m -> if Map.null m
then Map.empty
else error "zipWithKey: bug: Data.Map.Refined has been subverted")
-- ^ Work around https://github.com/haskell/containers/issues/979
m1
m2

Expand Down
9 changes: 7 additions & 2 deletions src/Data/Map/Strict/Refined.hs
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,13 @@ zipWithKey
=> (Key s k -> a -> b -> c) -> Map s k a -> Map s k b -> Map s k c
zipWithKey f (Map m1) (Map m2) = Map
$ Map.mergeWithKey (\k x y -> Just $ f (unsafeKey k) x y)
(error "zipWithKey: bug: Data.Map.Strict.Refined has been subverted")
(error "zipWithKey: bug: Data.Map.Strict.Refined has been subverted")
(\m -> if Map.null m
then Map.empty
else error "zipWithKey: bug: Data.Map.Strict.Refined has been subverted")
(\m -> if Map.null m
then Map.empty
else error "zipWithKey: bug: Data.Map.Strict.Refined has been subverted")
-- ^ Work around https://github.com/haskell/containers/issues/979
m1
m2

Expand Down

0 comments on commit 9cac37a

Please sign in to comment.