haskell / containers

Assorted concrete container types
https://hackage.haskell.org/package/containers
314 stars 177 forks source link

Data.Map.mergeWithKey doesn't match documentation #979

Open mniip opened 6 months ago

mniip commented 6 months ago

The documentation for Data.Map.Lazy.mergeWithKey states:

  • a nonempty subtree present only in the first map is passed to only1 and the output is added to the result;
  • a nonempty subtree present only in the second map is passed to only2 and the output is added to the result.

Yet this example shows otherwise:

M.mergeWithKey
  (\k x y -> traceShow ("merge", k, x, y) $ Just x)
  (\m -> traceShow ("left", m) M.empty)
  (\m -> traceShow ("right", m) M.empty)
  M.empty
  M.empty
  `seq` ()
("right",fromList [])
()

The same isssue exists in the Strict version, and in both IntMap versions.