title: Haskell - Ambiguous type variable, why?
body: <p>Why does the following compile:</p>
  
  <pre><code>{-# LANGUAGE FlexibleInstances #-}
  {-# LANGUAGE OverlappingInstances #-}
  
  class IsList a where
    isList :: a -&gt; Bool
  
  instance IsList a where
    isList x = False
  
  instance IsList [a] where
    isList x = True
  
  main = print (isList 'a') &gt;&gt; print (isList ['a'])  
  </code></pre>
  
  <p>But changing <code>main</code> to <a href="http://ideone.com/ldZYbV" rel="noreferrer">this</a>:</p>
  
  <pre><code>main = print (isList 42) &gt;&gt; print (isList [42])  
  </code></pre>
  
  <p>Gives the following error:</p>
  
  <pre><code>Ambiguous type variable `a0' in the constraints:
    (Num a0) arising from the literal `42' at prog.hs:13:22-23
    (IsList a0) arising from a use of `isList' at prog.hs:13:15-20
  Probable fix: add a type signature that fixes these type variable(s)
  In the first argument of `isList', namely `42'
  In the first argument of `print', namely `(isList 42)'
  In the first argument of `(&gt;&gt;)', namely `print (isList 42)'
  </code></pre>
  
  <p><code>isList</code> surely isn't in the <code>Num</code> class is it? And if not, why the ambiguity?</p>