2
我一直在縮進這一段時間,但它看起來對我來說是正確的。任何人都可以看到我要去哪裏嗎?Haskell案例陳述中的「可能不正確的縮進」
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
(I標記它帶有註釋以上)的行。我試着將case
聲明放在自己的行上,並將這兩種情況完全縮進到of
關鍵字的右側,但我仍然收到相同的錯誤消息。非常感謝您的幫助!
這樣做。非常感謝! –
準確地說:'case'引入的塊必須比'where'引入的塊更加深入。任何符合這個標準的變化都會發揮作用 - 不需要在某個行上單獨使用「where」。 –