我是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
Run Code Online (Sandbox Code Playgroud)
Haskell回应:
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': …Run Code Online (Sandbox Code Playgroud)