
On Jul 8, 2016 7:18 PM, "Ivan Lazar Miljenovic"
On 9 July 2016 at 03:49, David Feuer
wrote:
Data.Set: mapStrictlyIncreasing and mapStrictlyDecreasing Data.Map: mapKeysStrictlyIncreasing and mapKeysStrictlyDecreasing
With the latter function also flipping the underlying tree structure?
I'm not quite sure what you mean, but I think the answer is yes. mapKeysStrictlyDecreasing (\x -> -x) (fromList [1..10]) === fromList [(-10) .. (-1)]
Data.Map presents another possibility, however. We could make the replacements more general, giving them types
Ord k => (k -> v -> (k', v')) -> Map k v -> Map k' v'
and allowing the user to map over both keys and values in one pass.
Though IIUC this provides no way of specifying that "I'm sure this function has a 1-1 monotonic relationship so you can just update the keys without changing the structure" (in the sense of there's no way to distinguish between the increasing and decreasing sense).
That is the pre-condition. There still needs to be one for strictly increasing functions and another for strictly decreasing ones, since they lead to reversed tree structures.
Overall, I'm about +0.5 from the naming sense of the current functions, but have used these in the past.
I don't understand this statement.