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

GHC ghc-devs at haskell.org
Thu Sep 29 10:48:27 UTC 2016


#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


More information about the ghc-tickets mailing list