Ticket #1460 (closed proposal: fixed)

Opened 6 years ago

Last modified 4 years ago

Problem with Monoid instance of Data.Map

Reported by: ahey@… Owned by:
Priority: normal Milestone: Not GHC
Component: libraries/base Version: 6.6.1
Keywords: Data.Map Monoid Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Difficulty: Easy (less than 1 hour)
Test Case: Blocked By:
Blocking: Related Tickets:

Description

See..

 http://www.haskell.org/pipermail/libraries/2007-May/007491.html

Data.Map Monoid instance is currently..

instance (Ord k) => Monoid (Map k v) where
    mempty  = empty
    mappend = union
    mconcat = unions

..but probably should be..

instance (Ord k, Monoid v) => Monoid (Map k v) where
 mempty            = empty
 mappend map0 map1 = unionWith mappend map0 map1
 mconcat maps      = foldr (unionWith mappend) empty maps

Adrian Hey

Change History

Changed 6 years ago by SamB

I'm inclined to agree, though I recognize that the other way may well be useful too. There ought to be a way to warn people when you've changed instances like this... release notes, maybe?

Changed 6 years ago by igloo

  • milestone set to Not GHC

Changed 5 years ago by igloo

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

This proposal seems to be abandoned

Changed 5 years ago by simonmar

  • architecture changed from Multiple to Unknown/Multiple

Changed 5 years ago by simonmar

  • os changed from Multiple to Unknown/Multiple

Changed 4 years ago by simonmar

  • difficulty changed from Easy (1 hr) to Easy (less than 1 hour)
Note: See TracTickets for help on using tickets.