I wrote the following code in Haskell to compute the dot product of two vectors, but cannot compile it due to the following error:
cannot construct infinite type: a = [a] When generalising the type(s) for dot'
dot :: (Num a) => [a] -> [a] -> a
[] `dot` [] = 0
x@[xi,xs] `dot` y@[yi,ys] = xi*yi + (xs `dot` ys)
I've taken a look at this question in advance for guidance. As far as I can tell, the types are correct. x, y and the two []'s are lists, and the function returns a number.
What's wrong?