我是Haskell的新手,遇到类型系统问题。我有以下功能:Haskell类型声明
threshold price qty categorySize
| total < categorySize = "Total: " ++ total ++ " is low"
| total < categorySize*2 = "Total: " ++ total ++ " is medium"
| otherwise = "Total: " ++ total ++ " is high"
where total = price * qty
哈斯克尔与回应:
No instance for (Num [Char])
arising from a use of `*'
Possible fix: add an instance declaration for (Num [Char])
In the expression: price * qty
In an equation for `total': total = price * qty
In an equation for `threshold':
... repeats function definition
我认为这个问题是我需要以某种方式告诉哈斯克尔总的类型,也许这与类型类展会关联,但我不知道该如何实现。谢谢你的帮助。