title: declare function type in function definition in haskell
body: <p>I just began to learn haskell recently. I have some confusion of declare function type in the function definition. For example if we want to define a foldr function:</p>
  
  <pre><code>foldr :: (a-&gt;b-&gt;b)-&gt;b-&gt;[a]-&gt;b
  foldr f v [] = v
  foldr f v (x:xs) = f x (foldr f v xs)
  </code></pre>
  
  <p>Thus,  foldr (+) 0 [1,2,3,4] = sum [1,2,3,4] = 10.</p>
  
  <p>My question is: can I just change it to something like :</p>
  
  <pre><code>foldr :: (a-&gt;a-&gt;a)-&gt;a-&gt;[a]-&gt;a
   OR:
  foldr :: (a-&gt;b-&gt;c)-&gt;x-&gt;[y]-&gt;z
  </code></pre>
  
  <p>I didn't find a place to explain the choice/requirements of letters in the definition. Thanks!</p>
  
  <hr>
  
  <p>Update:
  I tested it with:</p>
  
  <pre><code> foldr :: (a-&gt;b-&gt;c)-&gt;x-&gt;[y]-&gt;z
  </code></pre>
  
  <p>Got the following err:</p>
  
  <pre><code>   Couldn't match type `y' with `a'
    `y' is a rigid type variable bound by
        the type signature for folderr :: (a -&gt; b -&gt; c) -&gt; x -&gt; [y] -&gt; z
        at test.hs:3:1
    `a' is a rigid type variable bound by
        the type signature for folderr :: (a -&gt; b -&gt; c) -&gt; x -&gt; [y] -&gt; z
        at test.hs:3:1
  </code></pre>
  
  <p>If changed everything to a, it works. I must have missing some points here.</p>
  
  <hr>
  
  <p>As explained in @sepp2k's comments. I tested using the following simple example:</p>
  
  <pre><code>     folderr :: (a-&gt;b-&gt;b)-&gt;b-&gt;[a]-&gt;b
       folderr f v [] = v
       folderr f v (x:xs) = f x (folderr f v xs)
  
  
       myop :: Int -&gt; Bool -&gt; Bool
       myop x y | x &gt; 0 = True &amp;&amp; y
                | otherwise = False &amp;&amp; y
  </code></pre>
  
  <p>folderr (myop) True [3,3,222]   -> True
  folderr (myop) True [3,2,-1] -> False</p>
  
  <p>So a,b just means the types are different or not.</p>