
11 Jan
2009
11 Jan
'09
4:22 p.m.
As Brandon explained, since 1 is polymorphic, and print is polymorphic in its argument, the compiler doesn't know which type to choose. You could fix it, for example, like this:
------------ import Data.Typeable
main= print (typeOf (1 :: Integer)) ------------
You might protest, what is the point of using typeOf if you have to actually put in the type annotation anyway? Well, this is a rather contrived example; usually in a real program GHC would be able to infer the type and an annotation would be unnecessary. -Brent