我编写了这个小函数来检索列表的尾部:
let getTail l = if length l > 0 then tail l else "empty list"
传递[]
给getTail
返回empty list
但传递[1,2,3]
给出以下错误:
<interactive>:1:14:
No instance for (Num Char)
arising from the literal `3'
Possible fix: add an instance declaration for (Num Char)
In the expression: 3
In the first argument of `getTail', namely `[1, 2, 3]'
In the expression: getTail [1, 2, 3]
我不明白那个错误是什么意思。问题是什么?使用 GHCi 7.0.4