title: Count elements on ordered list
body: <p>I want to do a Haskell function where the input (a list of Strings) is ordered (always. input is valid only if is ordered) and I want to get the number of occurrences of each different string.</p>
  
  <p>Example:</p>
  
  <pre><code>ContaOcs["a", "a", "b", "c", "c", "c", "d"]
  </code></pre>
  
  <p>Should return:</p>
  
  <pre><code>[(2,"a"), (1,"b"), (3,"c"), (1,"d")]
  </code></pre>
  
  <p>Here is What I'm trying to do:</p>
  
  <pre><code>module Main where
  
  contaOcs :: [String] -&gt; [(Int, String)]
  contaOcs [] = [_,_]
  contaOcs [x] = [1,x]
  contaOcs (i, x1:x2:xs)
   | x1 == x2 =  (i+1,(x2:xs))
   | otherwise = (0, (x2:xs))
  </code></pre>
  
  <p>But this code have some errors and I'm not so sure how I should do to accomplish this
  I'm new to functional programing and Haskell. Can anyone help me with some information?</p>
  
  <p>Thanks for any help.</p>