
The name pop makes me think of a stack. Is this use of the word common? On Sun, Dec 6, 2020, 11:20 AM Martijn Bastiaan via Libraries < libraries@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@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries