title: Haskell equivalent to Scala's groupBy
body: <p>Scala has a function <code>groupBy</code> on lists that accepts a function for extracting keys from list items, and returns another list where the items are tuples consisting of the key and the list of items producing that key. In other words, something like this:</p>
  
  <pre><code>List(1,2,3,4,5,6,7,8,9).groupBy(_ % 2)
  // List((0, List(2,4,6,8)), (1, List(1,3,5,7,9)))
  </code></pre>
  
  <p>(Actually, it looks like in current versions it provides a <code>Map</code> instead, but that's not important). C# has an even more useful version that lets you map the values at the same time (very useful if, say, your key function is just extracting part of a tuple).</p>
  
  <p>Haskell has a <code>groupBy</code>, but it's somewhat different - it groups runs of things according to some comparison function.</p>
  
  <p>Before I go and write it, is there an equivalent of Scala's <code>groupBy</code> in Haskell? Hoogle doesn't have anything for what I'd expect the signature to look like (below), but I may have just got it wrong.</p>
  
  <pre><code>Eq b =&gt; (a -&gt; b) -&gt; [a] -&gt; [(b,[a])]
  </code></pre>