[GHC] #10807: PatternGuards and MultiWayIf layout rules

GHC ghc-devs at haskell.org
Fri Aug 28 22:25:41 UTC 2015


#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


More information about the ghc-tickets mailing list