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

GHC cvs-ghc at haskell.org
Thu Mar 21 16:49:46 CET 2013


#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



More information about the ghc-tickets mailing list