[nhc-bugs] Type checker bug
Simon Marlow
simonmar@microsoft.com
Mon, 18 Feb 2002 14:37:38 -0000
The following module should elicit a type error:
type T a =3D Int
class C a where
f :: a -> T a
g :: T a -> a
instance C Char
main =3D print (g (f 'a'))
but nhc98 compiles it without complaint. GHC & Hugs both emit an
unresolved overloading error:
test187.hs:9:
Ambiguous type variable(s) `a' in the constraint `C a'
arising from use of `g' at test187.hs:9
In the first argument of `print', namely `(g (f 'a'))'
In the definition of `main': print (g (f 'a'))
test187.hs:9:
Ambiguous type variable(s) `a' in the constraint `Show a'
arising from use of `print' at test187.hs:9
In the definition of `main': print (g (f 'a'))
I believe nhc98's Binary library makes use of the same trick in its
definition of the Bin type. The type synonym in the example should
really be a newtype.
Cheers,
Simon