fork download
  1. {-# LANGUAGE FlexibleInstances #-}
  2. {-# LANGUAGE OverlappingInstances #-}
  3.  
  4. class IsList a where
  5. isList :: a -> Bool
  6.  
  7. instance IsList a where
  8. isList x = False
  9.  
  10. instance IsList [a] where
  11. isList x = True
  12.  
  13. main = print (isList 42) >> print (isList [42])
  14.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
[1 of 1] Compiling Main             ( prog.hs, prog.o )

prog.hs:13:22:
    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 `(>>)', namely `print (isList 42)'
stdout

Standard output is empty