[英]haskell parse error (possibly incorrect indentation or mismatched brackets) in control statement
[英]“Possibly incorrect indentation” in Haskell case statement
我已经在这个缩进上摆弄了一段时间,但是对我来说似乎是正确的。 谁能看到我要去哪里错了?
deposit :: NodeType -> NodeType -> Amount -> Node
deposit (Income income) (Account bal grow) amount =
Account (bal + transfer) grow where transfer = case amount of
AbsoluteAmount amount -> min income amount -- This is line 34
RelativeAmount percent -> (min 1.0 percent) * income
我收到的错误消息是:
Prelude> :load BudgetFlow.hs
[1 of 1] Compiling Main ( BudgetFlow.hs, interpreted )
BudgetFlow.hs:34:5: parse error (possibly incorrect indentation)
Failed, modules loaded: none.
第34行(具有解析错误的行)是从AbsoluteAmount
开始的行(我在上面用注释标记了它)。 我试图把case
声明在自己的行和完全缩进两种情况的正确of
关键字,但我仍然得到同样的错误消息。 非常感谢您的帮助!
将where
子句放在自己的行上。
deposit :: NodeType -> NodeType -> Amount -> Node
deposit (Income income) (Account bal grow) amount = Account (bal + transfer) grow
where
transfer = case amount of
AbsoluteAmount amount -> min income amount -- This is line 34
RelativeAmount percent -> (min 1.0 percent) * income
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.