title: Couldn't match expected type `Int' with actual type `Integer'
body: <p>I have the following Haskell code:</p>
  
  <pre><code>-- Problem 69
  
  import ProjectEuler
  
  phi :: Integer -&gt; Integer
  phi n = n * product [p - 1 | p &lt;- primeDivisors n] `div` product [p | p &lt;- primeDivisors n]
  -- primeDivisors n is a list of the prime divisors of n
  
  maxRatio :: (Int, Int, Double) -&gt; (Int, Int, Double) -&gt; (Int, Int, Double)
  maxRatio t1@(_, _, x) t2@(_, _, y)
    | x &gt; y = t1
    | otherwise = t2
  
  main = print (foldl
                  maxRatio
                  (0, 0, 0.0)
                  [(n, phi n, ratio) | n &lt;- [2..max], let ratio = fromIntegral n / (fromIntegral (phi n))]
                )
      where max = 1000
  </code></pre>
  
  <p>which gives the following error:</p>
  
  <pre><code>Couldn't match expected type `Int' with actual type `Integer'
  In the expression: n
  In the expression: (n, phi n, ratio)
  In the third argument of `foldl', namely
    `[(n, phi n, ratio) |
        n &lt;- [2 .. max],
        let ratio = fromIntegral n / (fromIntegral (phi n))]'
  </code></pre>
  
  <p>I suspect that in the triple <code>(0, 0, 0.0)</code> the 0's are type <code>Int</code>. Is <code>0</code> always type <code>Int</code> or is ghci deducing the type as <code>Int</code> in this case? If the later, how do I force it to be type <code>Integer</code> instead? Or is there something else that causes this error?</p>