Data.Map.mapKeysMonotonic is a misleading name

Andreas Abel andreas.abel at
Thu Apr 4 06:58:35 UTC 2019

I am not sure this subtlety is worth the breakage and annoyance to users 
coming with the name change.
If you think about it, renaming the keys while preserving the tree 
structure cannot work if two old keys map to the same new key.

On 2019-04-03 17:13, Elliot Cameron wrote:
> Yeah the clearest names seem to be really long ones: 
> mapKeysMonotonicDistinct, mapKeysInjectiveIncreasing, 
> mapKeysReferToDocs, etc.
> On Wed, Apr 3, 2019 at 11:11 AM David Feuer <david.feuer at 
> <mailto:david.feuer at>> wrote:
>     We can't use "increasing" because mathematically that usually means
>     non-strictly increasing. Using "ascending" gets us in trouble with
>     the other functions in the module that use the word in a non-strict
>     sense.
>     On Wed, Apr 3, 2019, 10:46 AM Elliot Cameron <eacameron at
>     <mailto:eacameron at>> wrote:
>         Hello!
>         In some recent analysis I ran into a subtlety that caught me by
>         surprise: Data.Map.mapKeysMonotonic has a misleading name.
>         A monotonic function is not a strictly /increasing/ function,
>         but merely non-decreasing. However, |mapKeysMonotonic| requires
>         that it's mapping function be injective, which means it really
>         only supports /increasing/ functions.
>         valid (mapKeysMonotonic (\x->  if  x`elem`  [1,2]then  2  else  x) (fromList [(1,"a"), (2,"b"), (3,"c")]))==  False
>         The docs hint at this with "This means that @f
>         <>@ maps distinct original keys to distinct
>         resulting keys."
>         However, I'd propose that we deprecate this name and rename to
>         something like |mapKeysIncreasing|or |mapKeysAsc| (to follow the
>         pattern of other *Asc functions). We should also clarify the docs.
>          From
>         _______________________________________________
>         Libraries mailing list
>         Libraries at <mailto:Libraries at>
> _______________________________________________
> Libraries mailing list
> Libraries at

More information about the Libraries mailing list