intersectionSet, differenceSet

Henning Thielemann lemming at henning-thielemann.de
Thu Nov 15 11:34:36 CET 2012


When using the new Data.Map.fromSet function I encountered that I use it 
many times in connection with Map.intersection and Map.difference like so

   Map.intersection m (Map.fromSet (const ()) s)
   Map.difference m (Map.fromSet (const ()) s)

Actually the element types of the second operands of Map.intersection and 
Map.difference are completely independent and the values of these maps are 
not touched. Thus I think that intersection and difference with a Set are 
the more natural operation. How about adding

   Map.intersectionSet :: Ord k => Map k a -> Set k -> Map k a
   Map.differenceSet :: Ord k => Map k a -> Set k -> Map k a

to Data.Map?



More information about the Libraries mailing list