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

Ivan Lazar Miljenovic ivan.miljenovic at gmail.com
Thu Jul 14 07:42:21 UTC 2016


On 14 July 2016 at 14:45, David Feuer <david.feuer at gmail.com> wrote:
> Cale Gibbard proposes the following:
>
> Data.IntMap.restriction :: IntSet -> IntMap a -> IntMap a
> Data.Map.restriction :: Ord k => Set k -> Map k a -> Map k a
>
> In each case, the map is filtered to contain only the keys that are
> also found in the set. This can be implemented efficiently using a
> slightly stripped-down version of Data.Map.intersection.

+1

I've bodged up similar things in the past, so this would be appreciated.

-- 
Ivan Lazar Miljenovic
Ivan.Miljenovic at gmail.com
http://IvanMiljenovic.wordpress.com


More information about the Libraries mailing list