我写了下面的代码在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