Name: Anonymous 2013-07-07 16:04
Hey /prog/. I have the following Haskell program (a simplified example, obviously):
and when I load it in ghci, it complains about overlapping
What I want to know is, why is it using the
Thanks.
{-# LANGUAGE FlexibleInstances, UndecidableInstances #-}
class C a
instance C a => Show aand when I load it in ghci, it complains about overlapping
Show instances:*Main> 1
<interactive>:2:1:
Ambiguous type variable `a0' in the constraints:
(Num a0) arising from the literal `1' at <interactive>:2:1
(Show a0) arising from a use of `print' at <interactive>:2:1
Probable fix: add a type signature that fixes these type variable(s)
In the expression: 1
In an equation for `it': it = 1
*Main> 1 :: Int
<interactive>:3:1:
Overlapping instances for Show Int
arising from a use of `print'
Matching instances:
instance Show Int -- Defined in `GHC.Show'
instance C a => Show a -- Defined at tc.hs:5:10
In a stmt of an interactive GHCi command: print itWhat I want to know is, why is it using the
Show instance I defined? I haven't defined any instances of C, so the constraints aren't satisfied for Int (or any type) and there should be no ambiguity. Does it not even attempt to check because of the extensions I'm using?Thanks.