Inferred type is not general enough
Ketil Malde
ketil@ii.uib.no
08 Aug 2001 13:18:52 +0200
"Cagdas Ozgenc" <co19@cornell.edu> writes:
> The following function generates a type error.
>
> headColumnwise :: [a] -> a
> headColumnwise line = [ head line | line <- p ]
Surely, the parameter should be "p"?
> ERROR ch6ex1.hs:14 - Inferred type is not general enough
> *** Expression : headColumnwise
> *** Expected type : [a] -> a
> *** Inferred type : [[a]] -> [a]
> it compiles fine. Isn't [a]->a the most general type here?
If p is [a], then line (drawn from p) must be of type a. But you do
"head line", which implies that line (and thus a) is a list.
-kzm
--
If I haven't seen further, it is by standing in the footprints of giants