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

Jake McArthur jake.mcarthur at gmail.com
Thu Jul 14 12:45:17 UTC 2016


I like the function, but I'd like to bikeshed a bit. The name "restriction"
seems confusing to me, or at least I don't understand the etymology. As of
now I'd prefer something like "filterMember". filterMember is to (filter .
flip member) as concatMap is to (concat . map). That's not perfectly
consistent due to the flip, but I think it's close enough to motivate the
name.

On Thu, Jul 14, 2016, 5:39 AM Andreas Abel <abela at chalmers.se> wrote:

> +1.
>
> On 14.07.2016 06:45, David Feuer 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.
> >
> > David Feuer
> > _______________________________________________
> > 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20160714/88f714be/attachment.html>


More information about the Libraries mailing list