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

Alexey Kuleshevich alexey at kuleshevi.ch
Sun Dec 6 17:29:40 UTC 2020


`extract` is the name that I would suggest. I also agree with David that `pop` is a bit too confusing in a non-stack/queue data structure. If all languages named it pop, then it would be good argument for the name, but we don't need to copy python. The only thing that pyhon has that I wish we had in Haskell is the popularity ;)
+1 on the function itself from me, I've needed it multiple occasions.

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Sunday, December 6, 2020 8:16 PM, Carter Schonwald <carter.schonwald at gmail.com> wrote:

> LookupThenRemove seems like a more descriptive name. Though I guess I can see why pop has appeal.
>
> On Sun, Dec 6, 2020 at 11:44 AM David Feuer <david.feuer at gmail.com> wrote:
>
>> I suggest you add a version for Data.Sequence combining lookup with deleteAt. I wanted that for something fairly recently.
>>
>> On Sun, Dec 6, 2020, 11:41 AM Martijn Bastiaan via Libraries <libraries at haskell.org> wrote:
>>
>>> Yeah, Python's `pop` made me call it `pop`. I had hoped to find other
>>> examples, but Java, Rust, and Ruby don't seem to offer `pop`-like
>>> functions for their (hash)maps.
>>>
>>> On 12/6/20 5:29 PM, Tom Ellis wrote:
>>>> On Sun, Dec 06, 2020 at 11:25:33AM -0500, David Feuer wrote:
>>>>> The name pop makes me think of a stack. Is this use of the word common?
>>>> Python uses that name, which is why I'm familiar with it:
>>>>
>>>>>>> d = {'a': 1, 'b': 2}
>>>>>>> d.pop('b')
>>>> 2
>>>>>>> d
>>>> {'a': 1}
>>>> _______________________________________________
>>>> Libraries mailing list
>>>> Libraries at haskell.org
>>>> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>>> _______________________________________________
>>> Libraries mailing list
>>> Libraries at haskell.org
>>> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>>
>> _______________________________________________
>> 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/6d7e3134/attachment.html>


More information about the Libraries mailing list