Haskell和一个整数列表



最近我一直在尝试学习Haskell,现在我被困在以下问题:

-- sumList
sumList :: List -> Integer
sumList l = sum l

现在我在VS Code中得到以下错误信息:

{
"resource": "/home/santino/Studium_Informatik/Studium_Informatik/UnitTest/unittest.hs",
"owner": "Haskell0",
"code": "-Wdeferred-type-errors",
"severity": 8,
"message": "• Couldn't match type ‘List’ with ‘t0 Integer’n  Expected type: List -> Integern    Actual type: t0 Integer -> Integern• In the expression: sumn  In an equation for ‘sumList’: sumList = sum",
"source": "typecheck",
"startLineNumber": 22,
"startColumn": 11,
"endLineNumber": 22,
"endColumn": 14
}

我试过用谷歌搜索这个问题,但我只得到从整数到整数的结果,而不是从列表到整数。提前感谢!

sumList :: [Integer] -> Integer
sumList l = sum l

根据错误消息提示,您需要向sum提供一个数字列表。这是sum的签名:

λ> :t sum
sum :: (Foldable t, Num a) => t a -> a

Nums的Foldable,返回Num