
Hello all, While programming a specific type of map update I came across a great need for a 'traverseKeys' function. I ended up making it myself but it was still less efficient than it needed to be because my traversal function was actually monotonic. I went ahead and added this along with some variants to Data.Map.
traverseKeys :: (Applicative f, Ord k2) => (k1 -> f k2) -> Map k1 a -> f (Map k2 a) traverseKeysWith :: (Applicative f, Ord k2) => (a -> a -> a) -> (k1 -> f k2) -> Map k1 a -> f (Map k2 a) traverseKeysMonotonic :: (Applicative f, Ord k2) => (k1 -> f k2) -> Map k1 a -> f (Map k2 a)
A full patch can be found here: https://github.com/nandykins/containers/commit/a8b0ebd57653bc0a309af69d73235... Let me know what you think, Discussion period: 2 weeks