title: foldr vs foldr1 usage in Haskell
body: <p>If I write:</p>
  
  <pre><code>&gt; let xs = [1,5,19,2,-3,5]
  &gt; foldr max 0 xs
  19
  
  &gt; foldr1 max xs
  19
  </code></pre>
  
  <p>And if I write (I know, the initial value is incorrect here for a generic maximum function...):</p>
  
  <pre><code>&gt; let maximum' = foldr max 0
  &gt; maximum' xs
  19
  </code></pre>
  
  <p>But if I write:</p>
  
  <pre><code>&gt; let maximum2' = foldr1 max
  &gt; maximum2' xs
  </code></pre>
  
  <p>the response is:</p>
  
  <pre><code>&lt;interactive&gt;:61:11:
      Couldn't match expected type `()' with actual type `Integer'
      Expected type: [()]
        Actual type: [Integer]
      In the first argument of maximum2', namely `xs'
      In the expression: maximum2' xs
  </code></pre>
  
  <p>I am new to Haskell. What am I doing wrong? (Can't decipher the error message...) How to use <code>foldr1</code> with <code>max</code>? Thanks.</p>
  
  <p>EDIT (AFTER ACCEPTING ANSWER):</p>
  
  <p>Just to show some more examples of the defaulting rules' effect (the answer explains these, too):</p>
  
  <p>Example 1:</p>
  
  <pre><code>&gt; let max' = max
  &gt; :t max
  max :: Ord a =&gt; a -&gt; a -&gt; a
  
  &gt; :t max' 
  max' :: () -&gt; () -&gt; ()
  </code></pre>
  
  <p>Example 2:</p>
  
  <pre><code>&gt; let plus = (+)
  &gt; :t (+)
  (+) :: Num a =&gt; a -&gt; a -&gt; a
  
  &gt; :t plus 
  plus :: Integer -&gt; Integer -&gt; Integer
  </code></pre>