Simon Hengel pushed to branch wip/sol/MultiWayIf-docs at Glasgow Haskell Compiler / GHC

Commits:

1 changed file:

Changes:

  • docs/users_guide/exts/multiway_if.rst
    ... ... @@ -10,7 +10,7 @@ Multi-way if-expressions
    10 10
     
    
    11 11
         Allow the use of multi-way-``if`` syntax.
    
    12 12
     
    
    13
    -With :extension:`MultiWayIf` extension GHC accepts conditional expressions with
    
    13
    +With the :extension:`MultiWayIf` extension GHC accepts conditional expressions with
    
    14 14
     multiple branches: ::
    
    15 15
     
    
    16 16
           if | guard1 -> expr1
    
    ... ... @@ -24,12 +24,12 @@ which is roughly equivalent to ::
    24 24
             ...
    
    25 25
             _ | guardN -> exprN
    
    26 26
     
    
    27
    -Multi-way if expressions introduce a new layout context. So the example
    
    27
    +Multi-way if expressions introduce a new kind of layout context that does not generate semicolons. The example
    
    28 28
     above is equivalent to: ::
    
    29 29
     
    
    30 30
           if { | guard1 -> expr1
    
    31
    -         ; | ...
    
    32
    -         ; | guardN -> exprN
    
    31
    +           | ...
    
    32
    +           | guardN -> exprN
    
    33 33
              }
    
    34 34
     
    
    35 35
     The following behaves as expected: ::
    
    ... ... @@ -41,14 +41,14 @@ The following behaves as expected: ::
    41 41
     because layout translates it as ::
    
    42 42
     
    
    43 43
           if { | guard1 -> if { | guard2 -> expr2
    
    44
    -                          ; | guard3 -> expr3
    
    44
    +                            | guard3 -> expr3
    
    45 45
                               }
    
    46
    -         ; | guard4 -> expr4
    
    46
    +           | guard4 -> expr4
    
    47 47
              }
    
    48 48
     
    
    49 49
     Layout with multi-way if works in the same way as other layout contexts,
    
    50
    -except that the semi-colons between guards in a multi-way if are
    
    51
    -optional. So it is not necessary to line up all the guards at the same
    
    50
    +except that desugaring does not insert semicolons.
    
    51
    +So it is not necessary to line up all the guards at the same
    
    52 52
     column; this is consistent with the way guards work in function
    
    53 53
     definitions and case expressions.
    
    54 54