[GHC] #7783: MultiWayIf should start a new layout

#7783: MultiWayIf should start a new layout -----------------------------+---------------------------------------------- Reporter: exbb2 | Owner: Type: bug | Status: new Priority: normal | Component: Compiler Version: 7.6.2 | Keywords: Os: Unknown/Multiple | Architecture: Unknown/Multiple Failure: None/Unknown | Blockedby: Blocking: | Related: #4359 -----------------------------+---------------------------------------------- Currently, MultiWayIf doesn't fully replace old {{{case () of _}}} form. This outputs 3: {{{ {-# LANGUAGE MultiWayIf #-} x = case () of _ | False -> case () of _ | False -> 1 | False -> 2 | True -> 3 main = print (x :: Int) }}} but this errors out: {{{ {-# LANGUAGE MultiWayIf #-} x = if | False -> if | False -> 1 | False -> 2 | True -> 3 main = print (x :: Int) }}} Every other syntax introducing guards starts a layout; MultiWayIf's current behavior leads to subtle logic bugs for those unaware that MultiWayIf is special. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7783 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7783: MultiWayIf should start a new layout ---------------------------------+------------------------------------------ Reporter: exbb2 | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.6.2 Keywords: | Os: Unknown/Multiple Architecture: Unknown/Multiple | Failure: None/Unknown Difficulty: Unknown | Testcase: Blockedby: | Blocking: Related: #4359 | ---------------------------------+------------------------------------------ Changes (by simonpj): * difficulty: => Unknown Old description:
Currently, MultiWayIf doesn't fully replace old {{{case () of _}}} form. This outputs 3:
{{{ {-# LANGUAGE MultiWayIf #-} x = case () of _ | False -> case () of _ | False -> 1 | False -> 2 | True -> 3
main = print (x :: Int) }}}
but this errors out:
{{{ {-# LANGUAGE MultiWayIf #-} x = if | False -> if | False -> 1 | False -> 2 | True -> 3
main = print (x :: Int) }}}
Every other syntax introducing guards starts a layout; MultiWayIf's current behavior leads to subtle logic bugs for those unaware that MultiWayIf is special.
New description: Currently, MultiWayIf doesn't fully replace old {{{case () of _}}} form. This outputs 3: {{{ {-# LANGUAGE MultiWayIf #-} x = case () of _ | False -> case () of _ | False -> 1 | False -> 2 | True -> 3 main = print (x :: Int) }}} but this errors out: {{{ {-# LANGUAGE MultiWayIf #-} x = if | False -> if | False -> 1 | False -> 2 | True -> 3 main = print (x :: Int) }}} because it parses like this: {{{ x = if | False -> if | False -> 1 | False -> 2 | True -> 3 }}} Every other syntax introducing guards starts a layout; MultiWayIf's current behavior leads to subtle logic bugs for those unaware that MultiWayIf is special. -- -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7783#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7783: MultiWayIf should start a new layout ---------------------------------+------------------------------------------ Reporter: exbb2 | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.6.2 Keywords: | Os: Unknown/Multiple Architecture: Unknown/Multiple | Failure: None/Unknown Difficulty: Unknown | Testcase: Blockedby: | Blocking: Related: #4359 | ---------------------------------+------------------------------------------ Description changed by simonpj: Old description:
Currently, MultiWayIf doesn't fully replace old {{{case () of _}}} form. This outputs 3:
{{{ {-# LANGUAGE MultiWayIf #-} x = case () of _ | False -> case () of _ | False -> 1 | False -> 2 | True -> 3
main = print (x :: Int) }}}
but this errors out:
{{{ {-# LANGUAGE MultiWayIf #-} x = if | False -> if | False -> 1 | False -> 2 | True -> 3
main = print (x :: Int) }}} because it parses like this: {{{ x = if | False -> if | False -> 1 | False -> 2 | True -> 3 }}} Every other syntax introducing guards starts a layout; MultiWayIf's current behavior leads to subtle logic bugs for those unaware that MultiWayIf is special.
New description: Currently, `MultiWayIf` doesn't fully replace old {{{case () of _}}} form. This outputs 3: {{{ {-# LANGUAGE MultiWayIf #-} x = case () of _ | False -> case () of _ | False -> 1 | False -> 2 | True -> 3 main = print (x :: Int) }}} but this errors out: {{{ {-# LANGUAGE MultiWayIf #-} x = if | False -> if | False -> 1 | False -> 2 | True -> 3 main = print (x :: Int) }}} because it parses like this: {{{ x = if | False -> if | False -> 1 | False -> 2 | True -> 3 }}} Every other syntax introducing guards starts a layout; `MultiWayIf`'s current behavior leads to subtle logic bugs for those unaware that `MultiWayIf` is special. -- -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7783#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7783: MultiWayIf should start a new layout ---------------------------------+------------------------------------------ Reporter: exbb2 | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.6.2 Keywords: | Os: Unknown/Multiple Architecture: Unknown/Multiple | Failure: None/Unknown Difficulty: Unknown | Testcase: Blockedby: | Blocking: Related: #4359 | ---------------------------------+------------------------------------------ Comment(by simonpj): Good point. I think you expectation is that, with layout braces inserted, it'd look like this: {{{ x = if { | False -> if { | False -> 1 | False -> 2 } | True -> 3 } }}} No semicolons (there are no semicolons between the guards of a multi-way case. Now it is quite unambiguous, even if it was written all on one line. This looks reasonable to me, if someone would like to try it. Simon -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7783#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7783: MultiWayIf should start a new layout ---------------------------------+------------------------------------------ Reporter: exbb2 | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.6.2 Keywords: | Os: Unknown/Multiple Architecture: Unknown/Multiple | Failure: None/Unknown Difficulty: Unknown | Testcase: Blockedby: | Blocking: Related: #4359 | ---------------------------------+------------------------------------------ Comment(by igloo): See also the last few comments of #4359 -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7783#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7783: MultiWayIf should start a new layout ----------------------------------+----------------------------------------- Reporter: exbb2 | Owner: Type: bug | Status: new Priority: normal | Milestone: 7.8.1 Component: Compiler (Parser) | Version: 7.6.2 Keywords: | Os: Unknown/Multiple Architecture: Unknown/Multiple | Failure: None/Unknown Difficulty: Unknown | Testcase: Blockedby: | Blocking: Related: #4359 | ----------------------------------+----------------------------------------- Changes (by igloo): * component: Compiler => Compiler (Parser) * milestone: => 7.8.1 -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7783#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC