我有一個簡單的功能,併產生得到一個編譯錯誤,如下列:沒有實例(NUM整數),從字面'0'
fac::[int] -> int
fac [] = 0
fac (x:[]) = x
fac ([xs]) = sum [xs]
編譯錯誤:
No instance for (Num int) arising from the literal `0'
Possible fix:
add (Num int) to the context of
the type signature for fac :: [int] -> int
In the expression: 0
In an equation for `fac': fac [] = 0
是什麼代碼錯誤?