title: Haskell - Counting how many times each distinct element in a list occurs
body: <p>I'm new to Haskell and am just trying to write a list comprehension to calculate the frequency of each distinct value in a list, but I'm having trouble with the last part..</p>
  
  <p>So far i have this:</p>
  
  <pre><code>frequency :: Eq a =&gt; [a] -&gt; [(Int,a)] 
  frequency list = [(count y list,y) | y &lt;- rmdups ]
  </code></pre>
  
  <p>Something is wrong with the last part involving rmdups.</p>
  
  <p>The count function takes a character and then a list of characters and tells you how often that character occurs, the code is as follows..</p>
  
  <pre><code>count :: Eq a =&gt; a -&gt; [a] -&gt; Int
  count x [] = 0
  count x (y:ys) | x==y = 1+(count x ys)
                 | otherwise = count x ys
  </code></pre>
  
  <p>Thank-you in advance.</p>