
hi,
2009/1/23 Francesco Bochicchio
Then I discovered that this piece of code (1) is illegal in askell (ghc gives the 'rigid type variable' error)
Num n => a :: n a = 3 :: Integer
I guess you mean: a :: Num n => n The problem whith your implementation of 'a' a = 3 :: Integer is that it provides too specific result. Its type signature says that its result has to be of the type n for *any* instance of the class Num. But your result is simply Integer that is just *one* specific instance of Num. In other words it has to be possible to specialize ("retype") 'a' to any other instance of Num, which is no longer possible because (3 :: Integer) is already specialized.
I also discovered that this (2) instead is legal:
Num n => a :: n a = 3
It's fine because 3 has the type (Num t) => t:: Prelude> :t 3 3 :: (Num t) => t
because it is implicitely translated into (3):
Num n => a :: n a = fromInteger 3
also fine: Prelude> :t fromInteger fromInteger :: (Num a) => Integer -> a Sincerely, jan.