私は 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
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': total = price * qty
In an equation for `threshold':
... repeats function definition
問題は、どういうわけか Haskell に total の型を伝え、それを型クラス Show に関連付ける必要があることだと思いますが、それを達成する方法がわかりません。助けてくれてありがとう。