[GHC] #10807: PatternGuards and MultiWayIf layout rules

#10807: PatternGuards and MultiWayIf layout rules -------------------------------------+------------------------------------- Reporter: htebalaka | Owner: Type: task | Status: new Priority: lowest | Milestone: Component: Compiler | Version: 7.10.2 (Parser) | Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: Documentation Unknown/Multiple | bug Test Case: | Blocked By: Blocking: | Related Tickets: Differential Revisions: | -------------------------------------+------------------------------------- The layout rules for MultiWayIf currently require any lines starting with a comma to be further indented than the lines starting with a pipe when used in conjunction with PatternGuards. This is inconsistent with the examples given in [https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/syntax- extns.html#pattern-guards]. For instance, we can't use the same indentation in the second example as in the first without triggering a parser error. {{{#!hs {-# LANGUAGE PatternGuards, MultiWayIf fine a pred | Just x <- a , pred x = True | otherwise = False notFine a pred = if | Just x <- a , pred x -> True | otherwise -> False }}} Though the documentation isn't ''incorrect'', if this intentional it could be pointed out, since it's counterintuitive. Otherwise, if there's no reason for MulitWayIf to require further indentation that should be fixed. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10807 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10807: PatternGuards and MultiWayIf layout rules -------------------------------------+------------------------------------- Reporter: htebalaka | Owner: Type: bug | Status: new Priority: lowest | Milestone: Component: Compiler | Version: 7.10.2 (Parser) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Documentation | Unknown/Multiple bug | Test Case: Blocked By: | Blocking: Related Tickets: #7783 | Differential Revisions: -------------------------------------+------------------------------------- Changes (by thomie): * type: task => bug * related: => #7783 Old description:
The layout rules for MultiWayIf currently require any lines starting with a comma to be further indented than the lines starting with a pipe when used in conjunction with PatternGuards. This is inconsistent with the examples given in [https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/syntax- extns.html#pattern-guards]. For instance, we can't use the same indentation in the second example as in the first without triggering a parser error.
{{{#!hs {-# LANGUAGE PatternGuards, MultiWayIf
fine a pred | Just x <- a , pred x = True | otherwise = False
notFine a pred = if | Just x <- a , pred x -> True | otherwise -> False }}}
Though the documentation isn't ''incorrect'', if this intentional it could be pointed out, since it's counterintuitive. Otherwise, if there's no reason for MulitWayIf to require further indentation that should be fixed.
New description: The layout rules for MultiWayIf currently require any lines starting with a comma to be further indented than the lines starting with a pipe when used in conjunction with PatternGuards. This is inconsistent with the examples given in [https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/syntax- extns.html#pattern-guards]. For instance, we can't use the same indentation in the second example as in the first without triggering a parser error. {{{#!haskell {-# LANGUAGE PatternGuards, MultiWayIf #} fine a pred | Just x <- a , pred x = True | otherwise = False notFine a pred = if | Just x <- a , pred x -> True | otherwise -> False }}} Though the documentation isn't ''incorrect'', if this intentional it could be pointed out, since it's counterintuitive. Otherwise, if there's no reason for MulitWayIf to require further indentation that should be fixed. -- Comment: Looks like a parser bug to me. The following comment in `Parser.y` (introduced in #7783) seems to hint at the problem: {{{ -- layout for MultiWayIf doesn't begin with an open brace, because it's hard to -- generate the open brace in addition to the vertical bar in the lexer, and -- we don't need it. }}} With braces the example compiles fine: {{{#!haskell fineAgain a pred = if { | Just x <- a , pred x -> True | otherwise -> False } }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10807#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10807: PatternGuards and MultiWayIf layout rules -------------------------------------+------------------------------------- Reporter: htebalaka | Owner: Type: bug | Status: new Priority: lowest | Milestone: Component: Compiler | Version: 7.10.2 (Parser) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Documentation | Unknown/Multiple bug | Test Case: Blocked By: | Blocking: Related Tickets: #7783 | Differential Revisions: -------------------------------------+------------------------------------- Description changed by thomie: Old description:
The layout rules for MultiWayIf currently require any lines starting with a comma to be further indented than the lines starting with a pipe when used in conjunction with PatternGuards. This is inconsistent with the examples given in [https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/syntax- extns.html#pattern-guards]. For instance, we can't use the same indentation in the second example as in the first without triggering a parser error.
{{{#!haskell {-# LANGUAGE PatternGuards, MultiWayIf #}
fine a pred | Just x <- a , pred x = True | otherwise = False
notFine a pred = if | Just x <- a , pred x -> True | otherwise -> False }}}
Though the documentation isn't ''incorrect'', if this intentional it could be pointed out, since it's counterintuitive. Otherwise, if there's no reason for MulitWayIf to require further indentation that should be fixed.
New description: The layout rules for MultiWayIf currently require any lines starting with a comma to be further indented than the lines starting with a pipe when used in conjunction with PatternGuards. This is inconsistent with the examples given in [https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/syntax- extns.html#pattern-guards]. For instance, we can't use the same indentation in the second example as in the first without triggering a parser error. {{{#!haskell {-# LANGUAGE PatternGuards, MultiWayIf #-} fine a pred | Just x <- a , pred x = True | otherwise = False notFine a pred = if | Just x <- a , pred x -> True | otherwise -> False }}} Though the documentation isn't ''incorrect'', if this intentional it could be pointed out, since it's counterintuitive. Otherwise, if there's no reason for MulitWayIf to require further indentation that should be fixed. -- -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10807#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10807: PatternGuards and MultiWayIf layout rules -------------------------------------+------------------------------------- Reporter: htebalaka | Owner: Type: bug | Status: new Priority: lowest | Milestone: Component: Compiler | Version: 7.10.2 (Parser) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Documentation | Unknown/Multiple bug | Test Case: Blocked By: | Blocking: Related Tickets: #7783 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by osa1): I agree that this is a parser bug. For another example, in this program `f1` and `f3` work but `f2` fails: {{{#!haskell {-# LANGUAGE MultiWayIf #-} f1 x = case () of _ | even x , notZero x -> True | otherwise -> False f2 x = if | even x , notZero x -> True | otherwise -> False f3 x = if { | even x , notZero x -> True ; | otherwise -> False } notZero = (/=) 0 }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10807#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10807: PatternGuards and MultiWayIf layout rules -------------------------------------+------------------------------------- Reporter: htebalaka | Owner: Type: bug | Status: new Priority: lowest | Milestone: Component: Compiler | Version: 7.10.2 (Parser) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Documentation | Unknown/Multiple bug | Test Case: Blocked By: | Blocking: Related Tickets: #7783 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by osa1): (patch is on the way) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10807#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10807: PatternGuards and MultiWayIf layout rules -------------------------------------+------------------------------------- Reporter: htebalaka | Owner: Type: bug | Status: new Priority: lowest | Milestone: Component: Compiler | Version: 7.10.2 (Parser) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Documentation | Unknown/Multiple bug | Test Case: Blocked By: | Blocking: Related Tickets: #7783 | Differential Rev(s): Phab:D2524 Wiki Page: | -------------------------------------+------------------------------------- Changes (by osa1): * differential: => Phab:D2524 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10807#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10807: PatternGuards and MultiWayIf layout rules
-------------------------------------+-------------------------------------
Reporter: htebalaka | Owner:
Type: bug | Status: new
Priority: lowest | Milestone:
Component: Compiler | Version: 7.10.2
(Parser) |
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: Documentation | Unknown/Multiple
bug | Test Case:
Blocked By: | Blocking:
Related Tickets: #7783 | Differential Rev(s): Phab:D2524
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Ömer Sinan Ağacan

#10807: PatternGuards and MultiWayIf layout rules -------------------------------------+------------------------------------- Reporter: htebalaka | Owner: Type: bug | Status: merge Priority: lowest | Milestone: Component: Compiler | Version: 7.10.2 (Parser) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Documentation | Unknown/Multiple bug | Test Case: Blocked By: | Blocking: Related Tickets: #7783 | Differential Rev(s): Phab:D2524 Wiki Page: | -------------------------------------+------------------------------------- Changes (by osa1): * status: new => merge -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10807#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10807: PatternGuards and MultiWayIf layout rules -------------------------------------+------------------------------------- Reporter: htebalaka | Owner: Type: bug | Status: merge Priority: lowest | Milestone: Component: Compiler | Version: 7.10.2 (Parser) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Documentation | Unknown/Multiple bug | Test Case: Blocked By: | Blocking: Related Tickets: #7783 | Differential Rev(s): Phab:D2524 Wiki Page: | -------------------------------------+------------------------------------- Comment (by bgamari): comment:6 merged to `ghc-8.0` as cb03d1ccd87a683cb7816a9d2d89a7722040c614. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10807#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10807: PatternGuards and MultiWayIf layout rules -------------------------------------+------------------------------------- Reporter: htebalaka | Owner: Type: bug | Status: closed Priority: lowest | Milestone: Component: Compiler | Version: 7.10.2 (Parser) | Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Documentation | Unknown/Multiple bug | Test Case: Blocked By: | Blocking: Related Tickets: #7783 | Differential Rev(s): Phab:D2524 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: merge => closed * resolution: => fixed -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10807#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10807: PatternGuards and MultiWayIf layout rules -------------------------------------+------------------------------------- Reporter: htebalaka | Owner: Type: bug | Status: closed Priority: lowest | Milestone: 8.0.2 Component: Compiler | Version: 7.10.2 (Parser) | Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Documentation | Unknown/Multiple bug | Test Case: Blocked By: | Blocking: Related Tickets: #7783 | Differential Rev(s): Phab:D2524 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * milestone: => 8.0.2 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10807#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10807: PatternGuards and MultiWayIf layout rules
-------------------------------------+-------------------------------------
Reporter: htebalaka | Owner: (none)
Type: bug | Status: closed
Priority: lowest | Milestone: 8.0.2
Component: Compiler | Version: 7.10.2
(Parser) |
Resolution: fixed | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: Documentation | Unknown/Multiple
bug | Test Case:
Blocked By: | Blocking:
Related Tickets: #7783 | Differential Rev(s): Phab:D2524
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Ben Gamari
participants (1)
-
GHC