containers icon indicating copy to clipboard operation
containers copied to clipboard

Data.Map.mergeWithKey doesn't match documentation

Open mniip opened this issue 1 year ago • 0 comments

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.

mniip avatar Dec 21 '23 11:12 mniip