繁体   English   中英

Haskell案例陈述中的“可能不正确的缩进”

[英]“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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM