layout was Re: Proposal: ArgumentDo

C Maeder chr.maeder at web.de
Fri Jul 8 12:37:04 UTC 2016


Hi,

the layout language options are hard to find (at least in the user
guide). Therefore I try to give an overview here. The relevant options
I've found by using ghc-7.10.3 with option --supported-languages are:

NondecreasingIndentation
DoAndIfThenElse

RelaxedLayout
AlternativeLayoutRule
AlternativeLayoutRuleTransitional

I ignore the last 3 options since these seem to be candidates for
removal: https://ghc.haskell.org/trac/ghc/ticket/11359.

The default option is NondecreasingIndentation, that is

  do
  x
  do
  y

is legal and parsed as a single expression "do {x ; do y}". With
-XNoNondecreasingIndentation one gets an "Empty 'do' block" for the
second do (and this error would not change with ArgumentDo!).

DoAndIfThenElse is not switched on by default and requires the keywords
"then" and "else" to be further indented for an "if" within a "do".

So I believe these options do not interfere with ArgumentDo, but maybe
this should be discussed more and maybe mentioned on the wiki page.

Surely a single space (inserted before x or removed before the second
"do") makes a difference between one or two argument expressions in the
example below.

HTH Christian

Am 08.07.2016 um 11:20 schrieb C Maeder:
> Surely layout can bite you:
> 
>   f
>   do
>   x
>   do
>   y
> 
> and I'm having difficulties to find the documentation for the various
> layout options.
> 
> But this is no argument against this proposal!
> 
> Improper use of white spaces can always be used to obfuscate code!
> Style guides are important. Furthermore, a wrong/unintended parse tree
> (due to layout) will - in many cases - result in a typing error.
> 
> Christian



More information about the Glasgow-haskell-users mailing list