Proposal for containers: Add 'pop' function to Data.Map

David Feuer david.feuer at gmail.com
Sun Dec 6 21:25:39 UTC 2020


I want the Maybe on the outside if we do this at all.

On Sun, Dec 6, 2020, 11:20 AM Martijn Bastiaan via Libraries <
libraries at haskell.org> wrote:

> Hi all,
>
> Proposal:
>
>    * Add `pop` and `popWithDefault` to `Data.Map` and `Data.IntMap`.
>    * See https://github.com/haskell/containers/pull/757 for exact
> definition
>
> Why:
>
>    * They're useful functions I expected to be in `Data.Map` and
>      `Data.IntMap`. (This might be influenced by the fact that
>      they're defined on Python's `dict`.)
>
>    * Their implementations (~ `updateLookupWithKey (\_ _ -> Nothing)`)
>      are harder to parse than a simple `pop`, which should help Haskell
>      codebases become a bit cleaner :).
>
>    * Their implementations are a bit non-obvious. My first instinct was
>      to write `(Map.lookup ..., Map.delete ...)`, which would have done
>      two traversals. Having "properly" implemented functions in the lib
>      would prevent people from writing their own suboptimal ones.
>
> Details and implementation:
>
>    * https://github.com/haskell/containers/pull/757
>
> Kind regards,
> Martijn Bastiaan
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20201206/78f431a1/attachment.html>


More information about the Libraries mailing list