1
當我嘗試使用ghci中載入我的代碼,它給了我這個錯誤:哈斯克爾誤差在約束非類型變量參數:民[C]
Asig1.hs:4:1:
Non type-variable argument in the constraint: Num [c]
(Use FlexibleContexts to permit this)
When checking that ‘f’ has the inferred type
f :: forall c (t :: * -> *).
(Num c, Num [c], Foldable t) =>
[c] -> [c] -> t [c] -> ([c], [c])
我不明白我做錯了什麼。 這是我的代碼:
module Asig1 where
f as ys x = (s,z)
where
ws = zipWith (*) as ys
s = foldl (+) ws x
z = s
如果添加了一個類型簽名'F'(也許'[INT] - > [Int] - > Int - >(Int,Int)'),那麼您將幫助編譯器瞭解程序的哪個部分是錯誤的,並且您可能會得到更有幫助的錯誤。 –