Haskell: converting a list of (a, b) key-value pairs (with possibly repeated keys) to a list of (a, [b]) grouped by key
问题 I'm a Haskell beginner. Let's suppose I want to write a function convertKVList that takes a flat list of key-value pairs, where some of the keys might be repeated, and turns it into a mapping from keys to lists of values where all of the keys are unique. For instance, on a list of pairs of Int s, I want this behavior: > convertKVList [(1, 2), (1, 4), (1, 3), (2, 3)] [(1,[3,4,2]),(2,[3])] This seems like a common enough task that there ought to be a library function available to do what I want