unionWith +containers

unionWith :: (a -> a -> a) -> IntMap a -> IntMap a -> IntMap a
containers Data.IntMap.Strict, containers Data.IntMap.Lazy
O(n+m). The union with a combining function. > unionWith (++) (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == fromList [(3, "b"), (5, "aA"), (7, "C")]
unionWith :: Ord k => (a -> a -> a) -> Map k a -> Map k a -> Map k a
containers Data.Map.Lazy, containers Data.Map.Strict
O(n+m). Union with a combining function. The implementation uses the efficient hedge-union algorithm. > unionWith (++) (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == fromList [(3, "b"), (5, "aA"), (7, "C")]
unionWithKey :: (Key -> a -> a -> a) -> IntMap a -> IntMap a -> IntMap a
containers Data.IntMap.Strict, containers Data.IntMap.Lazy
O(n+m). The union with a combining function. > let f key left_value right_value = (show key) ++ ":" ++ left_value ++ "|" ++ right_value > unionWithKey f (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == fromList [(3, "b"), (5, "5:a|A"), (7, "C")]
unionWithKey :: Ord k => (k -> a -> a -> a) -> Map k a -> Map k a -> Map k a
containers Data.Map.Lazy, containers Data.Map.Strict
O(n+m). Union with a combining function. The implementation uses the efficient hedge-union algorithm. > let f key left_value right_value = (show key) ++ ":" ++ left_value ++ "|" ++ right_value > unionWithKey f (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == fromList [(3, "b"), (5, "5:a|A"), (7, "C")]