小编use*_*227的帖子

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
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)

haskell types where-clause

3
推荐指数
1
解决办法
264
查看次数

标签 统计

haskell ×1

types ×1

where-clause ×1