<div dir="auto">Well said Andreas, I emphatically agree with your latter point: </div><div dir="auto"><br></div><div dir="auto">We need to ground proposal need / utility with statistical information about actual code out in the world. </div><div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Dec 6, 2020 at 1:38 PM Andreas Abel <<a href="mailto:andreas.abel@ifi.lmu.de">andreas.abel@ifi.lmu.de</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;padding-left:1ex;border-left-color:rgb(204,204,204)">I have reservations against this proposal:<br>
<br>
1. `pop` seems to be below the Fairbairn threshold.<br>
<br>
> pop :: Int -> IntMap a -> (Maybe a, IntMap a)<br>
> pop = updateLookupWithKey (\_ _ -> Nothing)<br>
<br>
It specializes the Swiss knife `updateLookupWithKey` without involving <br>
any other map-specific function.<br>
<br>
2. Addition of `pop` would require a similar function in all other <br>
standard collections, to keep their interfaces in sync.<br>
<br>
3. Is there sufficient evidence that `pop` is a strongly user-demanded <br>
feature? One way to quantify this is to look on hackage for the pattern <br>
`updateLookupWithKey (\_ _ -> Nothing)` (and variants) and maybe even on <br>
how often this pattern has been given a name.<br>
<br>
(The latter would be a more scientific way to develop our libraries in <br>
general. Instead of randomly adding functionality based on <br>
non-representative discussions on this list, we could scan hackage for <br>
common patterns---especially, mine popular utility libraries. Harvest <br>
the intelligence of the masses...)<br>
<br>
While I would not recommend to add `pop`, I would recommend to enhance <br>
the documentation of `updateLookupWithKey` to include `pop` as a use <br>
case. This would also ensure the discoverability of the present solution.<br>
<br>
I seem to recall that we have given this recommendation to similar <br>
proposals in the past ("similar" in terms of the Fairbairn threshold).<br>
<br>
Cheers,<br>
Andreas<br>
<br>
On 2020-12-06 19:04, Oleg Grenrus wrote:<br>
> NonEmptySeq could be. NonEmptySet almost (it could have extract).<br>
> <br>
> - Oleg<br>
> <br>
> On 6.12.2020 20.02, David Feuer wrote:<br>
>> None of these types are comonads, so it doesn't seem *that* confusing.<br>
>><br>
>> On Sun, Dec 6, 2020, 12:59 PM Bob Ippolito <<a href="mailto:bob@redivi.com" target="_blank">bob@redivi.com</a> <br>
>> <mailto:<a href="mailto:bob@redivi.com" target="_blank">bob@redivi.com</a>>> wrote:<br>
>><br>
>> `extract` overlaps with the Comonad typeclass (extract, duplicate,<br>
>> extend)<br>
>><br>
>> On Sun, Dec 6, 2020 at 9:34 AM Tom Ellis<br>
>> <<a href="mailto:tom-lists-haskell-cafe-2017@jaguarpaw.co.uk" target="_blank">tom-lists-haskell-cafe-2017@jaguarpaw.co.uk</a><br>
>> <mailto:<a href="mailto:tom-lists-haskell-cafe-2017@jaguarpaw.co.uk" target="_blank">tom-lists-haskell-cafe-2017@jaguarpaw.co.uk</a>>> wrote:<br>
>><br>
>> I really like `extract`!<br>
>><br>
>> On Sun, Dec 06, 2020 at 05:29:40PM +0000, Alexey Kuleshevich<br>
>> wrote:<br>
>> > `extract` is the name that I would suggest. I also agree<br>
>> with David<br>
>> > that `pop` is a bit too confusing in a non-stack/queue data<br>
>> > structure. If all languages named it pop, then it would be good<br>
>> > argument for the name, but we don't need to copy python. The<br>
>> only<br>
>> > thing that pyhon has that I wish we had in Haskell is the<br>
>> popularity<br>
>> > ;)<br>
>> ><br>
>> > ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐<br>
>> > On Sunday, December 6, 2020 8:16 PM, Carter Schonwald<br>
>> <<a href="mailto:carter.schonwald@gmail.com" target="_blank">carter.schonwald@gmail.com</a><br>
>> <mailto:<a href="mailto:carter.schonwald@gmail.com" target="_blank">carter.schonwald@gmail.com</a>>> wrote:<br>
>> ><br>
>> > > LookupThenRemove seems like a more descriptive name.<br>
>> Though I guess I can see why pop has appeal.<br>
>> > ><br>
>> > > On Sun, Dec 6, 2020 at 11:44 AM David Feuer<br>
>> <<a href="mailto:david.feuer@gmail.com" target="_blank">david.feuer@gmail.com</a> <mailto:<a href="mailto:david.feuer@gmail.com" target="_blank">david.feuer@gmail.com</a>>> wrote:<br>
>> > ><br>
>> > >> I suggest you add a version for Data.Sequence combining<br>
>> lookup with deleteAt. I wanted that for something fairly recently.<br>
>> > >><br>
>> > >> On Sun, Dec 6, 2020, 11:41 AM Martijn Bastiaan via<br>
>> Libraries <<a href="mailto:libraries@haskell.org" target="_blank">libraries@haskell.org</a><br>
>> <mailto:<a href="mailto:libraries@haskell.org" target="_blank">libraries@haskell.org</a>>> wrote:<br>
>> > >><br>
>> > >>> Yeah, Python's `pop` made me call it `pop`. I had hoped<br>
>> to find other<br>
>> > >>> examples, but Java, Rust, and Ruby don't seem to offer<br>
>> `pop`-like<br>
>> > >>> functions for their (hash)maps.<br>
>> > >>><br>
>> > >>> On 12/6/20 5:29 PM, Tom Ellis wrote:<br>
>> > >>>> On Sun, Dec 06, 2020 at 11:25:33AM -0500, David Feuer<br>
>> wrote:<br>
>> > >>>>> The name pop makes me think of a stack. Is this use of<br>
>> the word common?<br>
>> > >>>> Python uses that name, which is why I'm familiar with it:<br>
>> > >>>><br>
>> > >>>>>>> d = {'a': 1, 'b': 2}<br>
>> > >>>>>>> d.pop('b')<br>
>> > >>>> 2<br>
>> > >>>>>>> d<br>
>> > >>>> {'a': 1}<br>
>> > >>>> _______________________________________________<br>
>> > >>>> Libraries mailing list<br>
>> > >>>> <a href="mailto:Libraries@haskell.org" target="_blank">Libraries@haskell.org</a> <mailto:<a href="mailto:Libraries@haskell.org" target="_blank">Libraries@haskell.org</a>><br>
>> > >>>><br>
>> <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a><br>
>> <<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a>><br>
>> > >>> _______________________________________________<br>
>> > >>> Libraries mailing list<br>
>> > >>> <a href="mailto:Libraries@haskell.org" target="_blank">Libraries@haskell.org</a> <mailto:<a href="mailto:Libraries@haskell.org" target="_blank">Libraries@haskell.org</a>><br>
>> > >>><br>
>> <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a><br>
>> <<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a>><br>
>> > >><br>
>> > >> _______________________________________________<br>
>> > >> Libraries mailing list<br>
>> > >> <a href="mailto:Libraries@haskell.org" target="_blank">Libraries@haskell.org</a> <mailto:<a href="mailto:Libraries@haskell.org" target="_blank">Libraries@haskell.org</a>><br>
>> > >><br>
>> <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a><br>
>> <<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a>><br>
>><br>
>> > _______________________________________________<br>
>> > Libraries mailing list<br>
>> > <a href="mailto:Libraries@haskell.org" target="_blank">Libraries@haskell.org</a> <mailto:<a href="mailto:Libraries@haskell.org" target="_blank">Libraries@haskell.org</a>><br>
>> > <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a><br>
>> <<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a>><br>
>><br>
>> _______________________________________________<br>
>> Libraries mailing list<br>
>> <a href="mailto:Libraries@haskell.org" target="_blank">Libraries@haskell.org</a> <mailto:<a href="mailto:Libraries@haskell.org" target="_blank">Libraries@haskell.org</a>><br>
>> <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a><br>
>> <<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a>><br>
>><br>
>> _______________________________________________<br>
>> Libraries mailing list<br>
>> <a href="mailto:Libraries@haskell.org" target="_blank">Libraries@haskell.org</a> <mailto:<a href="mailto:Libraries@haskell.org" target="_blank">Libraries@haskell.org</a>><br>
>> <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a><br>
>> <<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a>><br>
>><br>
>><br>
>> _______________________________________________<br>
>> Libraries mailing list<br>
>> <a href="mailto:Libraries@haskell.org" target="_blank">Libraries@haskell.org</a><br>
>> <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a><br>
> <br>
> _______________________________________________<br>
> Libraries mailing list<br>
> <a href="mailto:Libraries@haskell.org" target="_blank">Libraries@haskell.org</a><br>
> <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a><br>
> <br>
_______________________________________________<br>
Libraries mailing list<br>
<a href="mailto:Libraries@haskell.org" target="_blank">Libraries@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a><br>
</blockquote></div></div>