I'm looking for a function of type

`[[(a, b)]] -> [(a, [b])]`

and [Hoogle tells me there isn't one](http://www.haskell.org/hoogle/?hoogle=%5b%5b%28a%2C+b%29%5d%5d+-%3E+%5b%28a%2C+%5bb%5d%29%5d), so I've written this:

```
transpose :: (Eq a) => [[(a, b)]] -> [(a, [b])]
transpose alists = uncurry zip $ foldl combine ([], []) alists
    where combine memo new = foldl tally memo new
          tally ([], []) (k, v) = ([k], [[v]])
          tally ((ksHead:ksRest), (vsHead:vsRest)) (k, v) = 
              if k == ksHead
              then (ksHead:ksRest, (v:vsHead):vsRest)
              else (ksHead:ks, vsHead:vs)
                  where (ks, vs) = tally (ksRest, vsRest) (k, v)

```

In order of importance:

1. Is there actually a built-in for this that Hoogle doesn't know about?
2. Is `transpose` the right name for this thing?
3. Is there a better (more readable and/or more performant) way of writing this?

**EDIT**

Since someone's interested in the flavor:

I'm writing a stack ranking app, and ballots from the user come in in the form of `[(Candidate, Rank)]`. In order to compute the winner by, for example, [Borda count](https://en.wikipedia.org/wiki/Borda_count), I need to tally the ranking of each `Candidate` by combining those ballots. Comments on the more general problem are also welcome.