patch applied (ghc): Fix a bug in alternative layout rule

Malcolm Wallace malcolm.wallace at cs.york.ac.uk
Mon Nov 30 21:39:38 EST 2009


> Out of interest, without trying it, what do you think this program
> should print (the only difference between the 3 functions is the
> indentation of the "where" line)?:
>
> main = do print $ f1 1
>         print $ f2 1
>         print $ f3 1

I reckon it would be "layout error" at line 2.  :-)

> f1 x = x + case () of
>          () -> x
>        where x = 5

To be honest, it goes slightly against my intuition that the pattern- 
match against () is accepted by the layout rule at all, because it is  
indented further to the left than the case itself.  Landin's original  
rule was something like "everything strictly to the right and below"  
belongs to the syntactic construct.  This example breaks that principle.

Regards,
    Malcolm



More information about the Cvs-ghc mailing list