Ticket #3002 (closed bug: fixed)

Opened 4 years ago

Last modified 4 years ago

Documentation for Data.Map.unionWithKey makes reference to "new" and "old" values which have no meaning in a union.

Reported by: guest Owned by: igloo
Priority: normal Milestone: 6.10.2
Component: libraries (other) Version: 6.10.1
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description (last modified by igloo) (diff)

The example given for unionWithKey uses rather odd names "new_value" and "old_value" for the values in the two maps. Perhaps more appropriate names would be leftValue and rightValue. This has been commented on in #haskell that where the values come from is not clear.

let f key new_value old_value = (show key) ++ ":" ++ new_value ++ "|" ++ old_value
unionWithKey f (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == fromList [(3, "b"), (5, "5:a|A"), (7, "C")]

Change History

Changed 4 years ago by igloo

  • difficulty set to Unknown
  • description modified (diff)

Changed 4 years ago by igloo

  • owner set to igloo
  • milestone set to 6.10.2

Thanks for the report.

Changed 4 years ago by igloo

  • status changed from new to closed
  • resolution set to fixed

Fixed in HEAD and 6.10-branch:

Sun Feb  8 11:21:32 PST 2009  Ian Lynagh <igloo@earth.li>
  * Use left/right rather than old/new to describe the arguments to unionWithKey
  Fixes trac #3002.
Note: See TracTickets for help on using tickets.