I was able to execute the following code flawlessly

myLast :: [a] -> a
myLast [] = error "Can't call myLast on an empty list!"
myLast (x:_) = x

but I'm getting this error Couldn't match expected type `a' with actual type `[a]'. `a' is a rigid type variable bound by the type signature for myLast :: [a] -> a for the following code:

myLast :: [a] -> a
myLast [] = error "Can't call myLast on an empty list!"
myLast (_:x) = x

I'm a beginner in Haskell and the error message is too greek and latin for me. From what I can understand, the compiler is not able infer the type in the second case. Can someone point me to what is actually happening here?

Edit
Report