What indentation is required for a case statement within a let statement?

前端 未结 2 1099
我在风中等你
我在风中等你 2020-11-27 22:54

Working in haskell, found odd behavior, stripped it down to bare bones

This Works

a :: Bool
a = case True of
    True -> True
    False -> Fals         


        
2条回答
  •  误落风尘
    2020-11-27 23:24

    I don't have the exact wording from the spec, but this Wikibook page explains the issue quite clearly.

    The reason why it works like this is simple: to support binding multiple variables via a single let-group, such as:

    c = do
        let c' = …
            d  = …
            e  = …
        return c'
    

    Your True -> … and False -> … are mistakenly interpreted as additional variables to be bound.

提交回复
热议问题