title: Pattern-Matching mixed with guards
body: <p>I wanted to define the function:</p>
  
  <pre><code>accumulate_list' :: Num a =&gt; [a] -&gt; ( a -&gt; a -&gt; a ) -&gt; a
  accumulate_list' l f 
      | [] f = 0
      | (x:xs) f = f x (accumulate_list xs f)
  </code></pre>
  
  <p>but it doesn't compile, complaining that x, xs, x, xs, are Not in scope. </p>
  
  <p>Trying to achieve the same result, I have defined this function</p>
  
  <pre><code>accumulate_list :: Num a =&gt; [a] -&gt; ( a -&gt; a -&gt; a ) -&gt; a
  accumulate_list [] f = 0
  accumulate_list (x:xs) f = f x $ accumulate_list xs f
  </code></pre>
  
  <p>it compiles well, and does like <code>sum</code> does on a list if the functgion passed in parameter is <code>(+)</code>. Yes, I finally found that indeed what I wanted to achieve was already existing in Prelude as the <code>sum</code> function.</p>
  
  <p>However, I don't understand why the first version with mixed guards and pattern matching doesn't compile. What is the problem ?</p>