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