
24 Sep
2008
24 Sep
'08
10:15 a.m.
Chris Kuklewicz wrote:
I conjecture that the logic, if any exists, behind having the two names is so that the Data.Map API can be applied to several implementations. And in another implementation it may be most efficient or most lazy to return elements in unsorted order. So there is a "toList" which asks for the easiest conversion to a list, and a "toAscList" which asks for the sorted version.
if "toList" returned "elements in unsorted order" it would break the abstraction: equal maps could return different list. So toList must either be toAscList or toDescList.
As for this proposal, I vote to have toDescList and foldlWithKey. This would likely simplify one of my uses of Data.Map.
+1 and foldrWithKey. Christian