我寫了下面的代碼在Haskell計算兩個向量的點積,但無法將其編譯由於以下錯誤:爲什麼Haskell拋出'無法構造無限類型'的錯誤?
cannot construct infinite type: a = [a] When generalising the type(s) for dot'
dot :: (Num a) => [a] -> [a] -> a
[] `dot` [] = 0
[email protected][xi,xs] `dot` [email protected][yi,ys] = xi*yi + (xs `dot` ys)
我已經提前採取一看this question爲指導。據我所知,類型是正確的。 x,y和兩個[]是列表,並且該函數返回一個數字。
怎麼了?
這就是對象引用沒有設置或堆棧溢出的哈斯克爾等價物,你會看到它很多;) – 2009-10-07 09:59:12