Proposal: Add `restriction` to Data.Map and Data.IntMap

David Feuer david.feuer at gmail.com
Mon Jul 25 19:45:56 UTC 2016


I'm not sure yet, but I suspect it might be possible to implement
partitionByKeySet more efficiently than the naive way. But to do so,
it will have to construct both pieces eagerly, meaning that using only
part of its result will waste time and allocation.

On Mon, Jul 25, 2016 at 3:34 PM, Andreas Abel <abela at chalmers.se> wrote:
> Seems like the partition function would subsume the others?!
>
>   partitionByKeys :: Ord k => Set k -> Map k a -> (Map k a, Map k a)
>
> Would there be impressive speed gains for a native
>
>   fst . partitionByKeys set
>
> ?
>
>
> On 25.07.2016 20:59, David Feuer wrote:
>>
>> A final question:
>>
>> Both `restrictKeys` and `withoutKeys` are special cases of
>> `filterWithKey` (although they should be considerably more efficient
>> than implementations using that function). Do we also want a
>> `partition` special case, in which a map is partitioned into the keys
>> that are in a set and the ones that are not?
>>
>> On Mon, Jul 25, 2016 at 1:10 PM, Edward Kmett <ekmett at gmail.com> wrote:
>>>
>>> Good enough for me.
>>>
>>> On Mon, Jul 25, 2016 at 12:11 PM, David Feuer <david.feuer at gmail.com>
>>> wrote:
>>>>
>>>>
>>>> I got distracted from this discussion for a bit. Based on input from
>>>> the list, and Ross Paterson's remark about argument order, I'm
>>>> currently thinking
>>>>
>>>> restrictKeys :: Ord k => Map k a -> Set k -> Map k a
>>>>
>>>> and
>>>>
>>>> withoutKeys :: Ord k => Map k a -> Set k -> Map k a
>>>>
>>>> Are there any major objections?
>>>>
>>>> On Thu, Jul 14, 2016 at 12:54 PM, Alexey Vagarenko <vagarenko at gmail.com>
>>>> wrote:
>>>>>
>>>>> How about `keepKeys`?
>>>>>
>>>>> 2016-07-14 21:36 GMT+05:00 Daniel Trstenjak
>>>>> <daniel.trstenjak at gmail.com>:
>>>>>>
>>>>>>
>>>>>> On Thu, Jul 14, 2016 at 12:02:51PM -0400, David Feuer wrote:
>>>>>>>
>>>>>>> If you name it, it will come!
>>>>>>
>>>>>>
>>>>>> intersectKeys and differentiateKeys
>>>>>>
>>>>>> or
>>>>>>
>>>>>> intersectionWithSet and differenceWithSet
>>>>>>
>>>>>> or ;)
>>>>>>
>>>>>> intersectionOfKeys and differenceOfKeys
>>>>>>
>>>>>>
>>>>>> Greetings,
>>>>>> Daniel
>>>>>> _______________________________________________
>>>>>> 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
>>>
>>>
>>>
>> _______________________________________________
>> Libraries mailing list
>> Libraries at haskell.org
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>>
>
>
> --
> Andreas Abel  <><      Du bist der geliebte Mensch.
>
> Department of Computer Science and Engineering
> Chalmers and Gothenburg University, Sweden
>
> andreas.abel at gu.se
> http://www2.tcs.ifi.lmu.de/~abel/
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries


More information about the Libraries mailing list