title: Group consecutive alike elements
body: <p>I'm new to Haskell and here's what I want to do :
  <a href="https://i.stack.imgur.com/hejrv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hejrv.png" alt="enter image description here"></a></p>
  
  <p>So far only compiler errors :</p>
  
  <pre><code>groupElems :: Eq a =&gt; [a] -&gt; [[a]]
  groupElems [] = []
  groupElems (x:xs) = 
      let (a,b) = span (&lt;= x) xs
      in a : (groupElems b)
  </code></pre>
  
  <p>Thank you.</p>
  
  <p>Error :</p>
  
  <pre><code>Could not deduce (Ord a) arising from a use of ‘&lt;=’
  from the context (Eq a)
    bound by the type signature for groupElems :: Eq a =&gt; [a] -&gt; [[a]]
  </code></pre>