Proposal and discussion: Deprecate Data.Set.mapMonotonic and Data.Map.mapKeysMonotonic; add correctly named functions

David Feuer david.feuer at gmail.com
Sat Jul 9 00:28:34 UTC 2016


On Jul 8, 2016 7:18 PM, "Ivan Lazar Miljenovic" <ivan.miljenovic at gmail.com>
wrote:
>
> On 9 July 2016 at 03:49, David Feuer <david.feuer at gmail.com> 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20160708/aec5e607/attachment.html>


More information about the Libraries mailing list