[Haskell-cafe] Type error with simple list function
Ketil Malde
ketil+haskell at ii.uib.no
Thu Nov 8 08:04:13 EST 2007
Fernando Rodriguez <frr149 at easyjob.net> writes:
> f :: [a] ->[a] ->[a]
> f (w : ws) = ws : w
> Couldn't match expected type `[a] -> [a]'
> against inferred type `[[a]]'
> In the expression: ws : w
> In the definition of `f': f (w : ws) = ws : w
> What's Haskell trying to tell me? I'm a newby so please forgive my ignorance.
First that your type signature doesn't match the definition - you
claim in the signature that f will take two parameters, but you give
it only one (a list) in the definition. That wouldn't be illegal if
the right hand side was a function, but it isn't.
When you fix that, Haskell will go on to tell you something about the
type of (:). :-)
-k
--
If I haven't seen further, it is by standing in the footprints of giants
More information about the Haskell-Cafe
mailing list