<p dir="ltr">I don't really see the problem with lookup. To me, that function always takes a container, an index into that container, and returns the value under than index or fails. It just so happens that sets are indexed by the very values the contain, but I don't find the signature confusing. Sure, I might not use it very often, but it's still clear enough to me what it's doing.</p>
<p dir="ltr">Ollie</p>
<br><div class="gmail_quote"><div dir="ltr">On Tue, 28 Jun 2016, 10:23 a.m. Chris Wong, <<a href="mailto:lambda.fairy@gmail.com">lambda.fairy@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Python uses "intern", so perhaps that can serve as the name.<br>
<br>
(See <a href="https://docs.python.org/2/library/functions.html#intern" rel="noreferrer" target="_blank">https://docs.python.org/2/library/functions.html#intern</a>)<br>
<br>
On Tue, Jun 28, 2016 at 9:47 AM, David Feuer <<a href="mailto:david.feuer@gmail.com" target="_blank">david.feuer@gmail.com</a>> wrote:<br>
> +1 on the function. -1/2 on the name.<br>
><br>
> On Jun 27, 2016 5:45 PM, "Nicolas Godbout" <<a href="mailto:nicolas.godbout@gmail.com" target="_blank">nicolas.godbout@gmail.com</a>><br>
> wrote:<br>
>><br>
>><br>
>> WHAT<br>
>><br>
>> It is proposed to add a ‘lookup' function on 'Set' in the "containers"<br>
>> package. Feedback during the next two weeks is welcome.<br>
>><br>
>> The function<br>
>><br>
>> > lookup :: Ord a => a -> Set a -> Maybe a<br>
>><br>
>> is almost indentical to the 'member' function but, in addition, returns<br>
>> the value<br>
>> stored in the set.<br>
>><br>
>> WHY<br>
>><br>
>> The point of this proposal is to facilitate program-wide data sharing. The<br>
>> 'lookup'<br>
>> function gives access to a pointer to an object already stored in a Set<br>
>> and equal<br>
>> to a given argument. The 'lookup' function is a natural extension to the<br>
>> current<br>
>> 'lookupLT', 'lookupGT', 'lookupLE' and 'lookupGE' functions, with obvious<br>
>> semantics.<br>
>><br>
>> Example use case: In a parser, the memory footprint can be reduced by<br>
>> collapsing<br>
>> all equal strings to a single instance of each string. To achieve this,<br>
>> one needs<br>
>> a way to get a previously seen string (internally, a pointer) equal to a<br>
>> newly<br>
>> parsed string. Amazingly, this is very difficult with the current<br>
>> "containers" library interface.<br>
>> One current option is to use a Map instead, e.g., 'Map String String'<br>
>> which stores twice as many pointers as necessary.<br>
>><br>
>> HOW<br>
>><br>
>> The git pull request at<br>
>> <a href="https://github.com/haskell/containers/pull/291" rel="noreferrer" target="_blank">https://github.com/haskell/containers/pull/291</a><br>
>> contains the straight-forward implementation of the 'lookup’ function on<br>
>> 'Set', with test cases,<br>
>> as a patch against the current containers master branch.<br>
>><br>
>><br>
>> Salutations,<br>
>> Nicolas.<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>
> _______________________________________________<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>
<br>
<br>
--<br>
Chris Wong (<a href="https://lambda.xyz" rel="noreferrer" target="_blank">https://lambda.xyz</a>)<br>
<br>
"I had not the vaguest idea what this meant and when I could not<br>
remember the words, my tutor threw the book at my head, which did not<br>
stimulate my intellect in any way." -- Bertrand Russell<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>