[GHC] #12641: Indentation works differently for multi-way if than for guards when using comma-separate view patterns

#12641: Indentation works differently for multi-way if than for guards when using comma-separate view patterns -------------------------------------+------------------------------------- Reporter: ahmadsalim | Owner: Type: bug | Status: new Priority: lowest | Milestone: Component: Compiler | Version: 8.0.1 (Parser) | Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: Other Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- When trying to parse the following piece of code: {{{#!hs {-# LANGUAGE MultiWayIf #-} module Test where data AB = A | B aAndB :: AB -> AB -> Bool aAndB ab1 ab2 = if | A <- ab1 , B <- ab2 -> True | otherwise -> False }}} I get the following error {{{ test.hs:9:6: error: parse error (possibly incorrect indentation or mismatched brackets) }}} This is as currently is inconsistent with how guards are parsed, e.g.: {{{#!hs aAndB2 :: AB -> AB -> Bool aAndB2 ab1 ab2 | A <- ab1 , B <- ab2 = True | otherwise = False }}} works perfectly fine. Note, that if I indent the comma a bit in aAndB, the following will parse correctly: {{{#!hs aAndB :: AB -> AB -> Bool aAndB ab1 ab2 = if | A <- ab1 , B <- ab2 -> True | otherwise -> False }}} Of course, this is far from a major issue, but I thought it would probably be beneficial to report the issue nonetheless. It also looks likely less neat with the comma indented. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12641 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12641: Indentation works differently for multi-way if than for guards when using comma-separate view patterns -------------------------------------+------------------------------------- Reporter: ahmadsalim | Owner: Type: bug | Status: closed Priority: lowest | Milestone: Component: Compiler | Version: 8.0.1 (Parser) | Resolution: invalid | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by goldfire): * status: new => closed * resolution: => invalid Comment: This is by design. Note that the [https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/glasgow_exts... #multi-way-if-expressions manual] says that a multi-way `if` introduces a layout context. This is unlike normal pattern guards, which do not need layout for disambiguation of nesting. Personally, I've never liked this design choice, but I don't have a better one to suggest (then or now). There is some recent discussion [https://github.com/haskell/rfcs/pull/4 here]. In any case, there's no misbehavior here, so I am closing. Thanks very much for reporting, however! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12641#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12641: Indentation works differently for multi-way if than for guards when using comma-separate view patterns -------------------------------------+------------------------------------- Reporter: ahmadsalim | Owner: Type: bug | Status: closed Priority: lowest | Milestone: Component: Compiler | Version: 8.0.1 (Parser) | Resolution: invalid | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by ahmadsalim): Thanks for taking a look at it! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12641#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC