Add `filterKeys`
Hi All,
A more general form of restrictKeys would be filterKeys, implemented thusly:
filterKeys :: (k -> Bool) -> Map k a -> Map k a
filterKeys p = filterWithKey (const . p)
Which would allow restrictKeys to be implemented simply as
restrictKeys :: Set k -> Map k a -> Map k a
restrictKeys s = filterKeys (`Set.member` s)
Is there an appetite for this kind of change? filterKeys is a pretty generally useful function, and restrictKeys tends to be a little too specialized too suit my needs. Since the change would arguably improve the existing functions, I think it's worth a thought.
restrictKeys exists because it can be particularly efficient.
alright, but what about the addition of filterKeys then? (assuming we leave restrictKeys alone)
I don't feel strongly about it. I guess it adds symmetry, balancing filter.
I'll go do the needful then. Additionally, I'm finding somethings are used internally, with full haddocks that would be useful to export, but are not (e.g. filterWithKeyA). Can we export those as well?
filterWithKeyA would be a good one, yeah. Maybe some more mergeA machinery too.
I'll raise separate PRs to not dirty the history