簡體   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