[Haskell-cafe] A wish for relaxed layout syntax

John Meacham john at repetae.net
Wed Mar 28 19:17:14 EDT 2007


On Wed, Mar 28, 2007 at 10:21:08PM +0200, Benjamin Franksen wrote:
> Hi,
> 
> I often run into the following issue: I want to write a list of lengthy
> items like this
> 
> mylist = [
>   quite_lengthy_list_item_number_one,
>   quite_lengthy_list_item_number_two,
>   quite_lengthy_list_item_number_three
> ]
> 
> With the current layout rules this is a parse error (at the closing
> bracket). Normally I avoid this by indenting everything one level more as
> in
> 
> mylist = [
>     quite_lengthy_list_item_number_one,
>     quite_lengthy_list_item_number_two,
>     quite_lengthy_list_item_number_three
>   ]
> 
> but I think this is a little ugly.
> 
> Same issue comes up with parenthesized do-blocks, I would like to write
> 
> when (condition met) (do
>   first thing
>   second thing
> )
> 
> So my wish is for a revised layout rule that allows closing brackets (of all
> sorts: ']', ')', '}') to be on the same indent level as the start of the
> definition/expression that contains the corresponding opening bracket.

this would be fairly simple by adding a rule to the parser grammer like
so

list := '[' item* ';'? ']'

as in, allow an optional semicolon before any bracketing closing token.


as for the other example, I tend to do

when (condition met) $ do
  first thing
  second thing

though, the semicolon thing above would allow the layout you want too.


        John

-- 
John Meacham - ⑆repetae.net⑆john⑈


More information about the Haskell-Cafe mailing list