Proposal: add full complement of support for decreasing things in Data.Map

Data.Map offers functions to convert from ascending lists to maps, and also offers a function to map an increasing function over the keys of a map. Equivalents for descending lists and decreasing functions are missing. I think we should add them. Any objections?

Hi David,
Can't this be done simply by using Data.Ord.Down wrapper for the keys?
Kind regards,
Nick
On Thu, 19 May 2016 at 17:00 David Feuer
Data.Map offers functions to convert from ascending lists to maps, and also offers a function to map an increasing function over the keys of a map. Equivalents for descending lists and decreasing functions are missing. I think we should add them. Any objections? _______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

Yes, but no. Once you do that, the whole map is Down. Aside from the
inconvenience factor, such a map can't be combined with one in the usual
order using union, intersection, etc. We could add conversion functions,
but they'd copy the whole structure and really only be special cases of the
hypothetical mapKeysDescending.
On May 19, 2016 10:40 AM, "Nickolay Kudasov"
Hi David,
Can't this be done simply by using Data.Ord.Down wrapper for the keys?
Kind regards, Nick
On Thu, 19 May 2016 at 17:00 David Feuer
wrote: Data.Map offers functions to convert from ascending lists to maps, and also offers a function to map an increasing function over the keys of a map. Equivalents for descending lists and decreasing functions are missing. I think we should add them. Any objections? _______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

I see, thank you for clarification!
Kind regards,
Nick
On Thu, 19 May 2016 at 17:44 David Feuer
Yes, but no. Once you do that, the whole map is Down. Aside from the inconvenience factor, such a map can't be combined with one in the usual order using union, intersection, etc. We could add conversion functions, but they'd copy the whole structure and really only be special cases of the hypothetical mapKeysDescending. On May 19, 2016 10:40 AM, "Nickolay Kudasov"
wrote: Hi David,
Can't this be done simply by using Data.Ord.Down wrapper for the keys?
Kind regards, Nick
On Thu, 19 May 2016 at 17:00 David Feuer
wrote: Data.Map offers functions to convert from ascending lists to maps, and also offers a function to map an increasing function over the keys of a map. Equivalents for descending lists and decreasing functions are missing. I think we should add them. Any objections? _______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries

On Thu, May 19, 2016 at 10:00 AM, David Feuer
Data.Map offers functions to convert from ascending lists to maps, and also offers a function to map an increasing function over the keys of a map. Equivalents for descending lists and decreasing functions are missing. I think we should add them. Any objections?
+1. They're a lot more performant to do directly rather than (a) reversing the ascending lists, or (b) constructing the mirror image (Map (Down k) a) so that "ascending" is in the right order. -- Live well, ~wren
participants (3)
-
David Feuer
-
Nickolay Kudasov
-
wren romano