title: Why does length return 1 for a tuple with 2 elements, and gives an error for a tuple with more elements?
body: <p>I'm studying Haskell using the book "<a href="http://haskellbook.com/" rel="noreferrer">Haskell Programming from First Principles</a>", and towards the end of Chapter 4, "Basic datatypes", I've come across something that confused me. The book mentions a function <code>length</code> and says that it works on <code>Lists</code>s. Everything is fine with that, but when I try this <code>length</code> function with various <code>Tuple</code>s, what I see confused me:</p>
  
  <p>First, let's see the type of <code>length</code>:</p>
  
  <pre><code>:t length
  length :: Foldable t =&gt; t a -&gt; Int
  </code></pre>
  
  <p>OK, so I read above as "takes a Foldable, which I think as a list for convenience, and returns an Int, that is the number of elements in the list." Hence my first confusion: Why does the the following work at all:</p>
  
  <pre><code>length (1, 1)
  1
  </code></pre>
  
  <p>Because to me, it seems like I've just passed a tuple with two elements to <code>length</code>, and it returned 1. Is tuple a list? Is tuple Foldable? And of course, why <code>1</code>? </p>
  
  <p>Now I go one step further:</p>
  
  <pre><code>length (1, 1, 1)
  
  &lt;interactive&gt;:6:1:
      No instance for (Foldable ((,,) t0 t1))
        arising from a use of ‘length’
      In the expression: length (1, 1, 1)
      In an equation for ‘it’: it = length (1, 1, 1)
  
  &lt;interactive&gt;:6:9:
      No instance for (Num t0) arising from the literal ‘1’
      The type variable ‘t0’ is ambiguous
      Note: there are several potential instances:
        instance Num Integer -- Defined in ‘GHC.Num’
        instance Num Double -- Defined in ‘GHC.Float’
        instance Num Float -- Defined in ‘GHC.Float’
        ...plus two others
      In the expression: 1
      In the first argument of ‘length’, namely ‘(1, 1, 1)’
      In the expression: length (1, 1, 1)
  
  &lt;interactive&gt;:6:12:
      No instance for (Num t1) arising from the literal ‘1’
      The type variable ‘t1’ is ambiguous
      Note: there are several potential instances:
        instance Num Integer -- Defined in ‘GHC.Num’
        instance Num Double -- Defined in ‘GHC.Float’
        instance Num Float -- Defined in ‘GHC.Float’
        ...plus two others
      In the expression: 1
      In the first argument of ‘length’, namely ‘(1, 1, 1)’
      In the expression: length (1, 1, 1)
  </code></pre>
  
  <p>Another try:</p>
  
  <pre><code>length (1::Int, 1::Int, 1::Int)
  
  &lt;interactive&gt;:7:1:
      No instance for (Foldable ((,,) Int Int))
        arising from a use of ‘length’
      In the expression: length (1 :: Int, 1 :: Int, 1 :: Int)
      In an equation for ‘it’: it = length (1 :: Int, 1 :: Int, 1 :: Int)
  </code></pre>
  
  <p>But the following works:</p>
  
  <pre><code>length (1::Int, 1::Int)
  1
  </code></pre>
  
  <p>Is there any good explanation for the behavior I'm observing above? Am I misreading the type of <code>length</code>? Or is there something else going on behind the scenes? </p>