title: Haskell - Removing adjacent duplicates from a list
body: <p>I'm trying to learn haskell by solving some online problems and training exercises.</p>
  
  <p>Right now I'm trying to make a function that'd remove adjacent duplicates from a list.</p>
  
  <blockquote>
    <p>Sample Input</p>
    
    <p>"acvvca"</p>
    
    <p>"1456776541"</p>
    
    <p>"abbac"</p>
    
    <p>"aabaabckllm"</p>
    
    <hr>
    
    <p>Expected Output</p>
    
    <p>""</p>
    
    <p>""</p>
    
    <p>"c"</p>
    
    <p>"ckm"</p>
  </blockquote>
  
  <p>My first though was to make a function that'd simply remove first instance of adjacent duplicates and restore the list.</p>
  
  <pre><code>module Test where
  
  removeAdjDups :: (Eq a) =&gt; [a] -&gt; [a]
  removeAdjDups []           =  []
  removeAdjDups [x]          =  [x]
  removeAdjDups (x : y : ys)
    | x == y = removeAdjDups ys
    | otherwise = x : removeAdjDups (y : ys)
  </code></pre>
  
  <hr>
  
  <pre><code>*Test&gt; removeAdjDups "1233213443"
  "122133"
  </code></pre>
  
  <hr>
  
  <p>This func works for first found pairs.</p>
  
  <p>So now I need to apply same function over the result of the function.</p>
  
  <p>Something I think foldl can help with but I don't know how I'd go about implementing it.</p>
  
  <p>Something along the line of</p>
  
  <pre><code>removeAdjDups' xs = foldl (\acc x -&gt; removeAdjDups x acc) xs
  </code></pre>
  
  <hr>
  
  <p>Also is this approach the best way to implement the solution or is there a better way I should be thinking of? </p>