
15 Feb
2013
15 Feb
'13
7:33 a.m.
Hi, I was puzzled by the following little program. sum' [] = [] sum' (x:xs) = x + sum' xs I thought the GHC type checker will report a type error. However, the type checker accepts this program and gives the type Num [a] => [[a]] -> [a] When I add type annotation to the program sum' :: Num [a] => [[a]] -> [a] sum' [] = [] sum' (x:xs) = x + sum' xs The GHC asks me to add FlexibleContexts language extension. I would appreciate explanation on this issue. Thanks, Sheng