我尝试使用data.maybe类型,但失败。当我尝试在ghci中运行它时,它告诉我:“构造函数'Ramen'应该没有参数,但已经给出了1。”。我该如何解决它?执行ghc-modi`type`命令时出错:
data Product = Ramen | Chips
totalPrice :: Product -> Integer -> Float
totalPrice product = case product of
Ramen x
| x >= 200 -> 1.35*x
| x <= 200 -> 1.4*x
| x <= 100 -> 1.5*x
| x <= 30 -> 1.8*x
| x <= 10 -> 2.0*x
| otherwise -> error "Something's wrong."
Chips x
| x >= 21 -> 2.35*x
| x <= 20 -> 2.5*x
| x <= 10 -> 2.7*x
| x <= 5 -> 2.95*x
| x >= 1 && x <= 2 -> 3.0*x
|otherwise -> error "Something's wrong."
很好的回答!为我工作。感谢您的建议。 –