
24 Jan
2009
24 Jan
'09
8:28 a.m.
Francesco Bochicchio
It worked well ... unitil yesterday. Then I discovered that this piece of code (1) is illegal in askell (ghc gives the 'rigid type variable' error)
a :: Num n => n a = 3 :: Integer
A way to understand the type of a is that it has an implicit parameter: a :: {n:Type} -> Num n -> n Now we can see why the definition you gave doesn't work - the type n is provided by the caller of your function which *must* return a value of that type. If your function was called with a {Float} _ 0.0 then you must return a Float. Your definition specifically declares you return an integer, which is wrong. Hope this helps, Eric