<div dir="auto">I want the Maybe on the outside if we do this at all.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Dec 6, 2020, 11:20 AM Martijn Bastiaan via Libraries <<a href="mailto:libraries@haskell.org">libraries@haskell.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi all,<br>
<br>
Proposal:<br>
<br>
* Add `pop` and `popWithDefault` to `Data.Map` and `Data.IntMap`.<br>
* See <a href="https://github.com/haskell/containers/pull/757" rel="noreferrer noreferrer" target="_blank">https://github.com/haskell/containers/pull/757</a> for exact definition<br>
<br>
Why:<br>
<br>
* They're useful functions I expected to be in `Data.Map` and<br>
`Data.IntMap`. (This might be influenced by the fact that<br>
they're defined on Python's `dict`.)<br>
<br>
* Their implementations (~ `updateLookupWithKey (\_ _ -> Nothing)`)<br>
are harder to parse than a simple `pop`, which should help Haskell<br>
codebases become a bit cleaner :).<br>
<br>
* Their implementations are a bit non-obvious. My first instinct was<br>
to write `(Map.lookup ..., Map.delete ...)`, which would have done<br>
two traversals. Having "properly" implemented functions in the lib<br>
would prevent people from writing their own suboptimal ones.<br>
<br>
Details and implementation:<br>
<br>
* <a href="https://github.com/haskell/containers/pull/757" rel="noreferrer noreferrer" target="_blank">https://github.com/haskell/containers/pull/757</a><br>
<br>
Kind regards,<br>
Martijn Bastiaan<br>
_______________________________________________<br>
Libraries mailing list<br>
<a href="mailto:Libraries@haskell.org" target="_blank" rel="noreferrer">Libraries@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" rel="noreferrer noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a><br>
</blockquote></div>