Inferred type is not general enough
08 Aug 2001 13:18:52 +0200
"Cagdas Ozgenc" <email@example.com> 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.
If I haven't seen further, it is by standing in the footprints of giants