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
(_:x)
matches _ with the head and x with the tail of the list. The type of tail of a list is [a]. You are trying to return [a]' where as the function declaration specifies return type as a.
myLast (_:x) = x
If you want to match last element take a look at this answer - Can you use pattern matching to bind the last element of a list?