
2009/1/23 Jan Jakubuv
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
Yes. I'm not _that_ beginner :-) (although I tend to make this mistake quite often ).
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.
Uhm. Now I think I start to get it ... You are saying that if a value is a Num, it shall be possible to convert it in _any_ of the num instances?
Sincerely, jan.
Ciao ------- FB