proposal for trailing comma and semicolon

Tillmann Rendel rendel at
Fri May 17 20:23:02 CEST 2013


Garrett Mitchener wrote:
> There's a weird idiom that I see all the time in Haskell code where
> coders put commas at the beginning of lines:
> data Thing = Thing {
>    x :: Int
>    ,y :: Int
>    ,z :: Int
>    ,foo :: String
> } ...
> items = [
>    "red"
>    ,"blue"
>    ,"green"
> ]

(I don't think this is valid Haskell. The closing } and ] should be more 

I like to put commas at the beginning of lines, because there, I can 
make them line up and it is visually clear that they are all at the same 
nesting level. I like how the commas look a bit like bullet points. For 
example, I would write:

items =
   [ "red"
   , "blue"
   , "green"

Could we extend Garett's proposal to also allow prefixing the first 
element of a list with a comma, to support this style:

items = [
   , "red"
   , "blue"
   , "green"

Allowing an optional extra comma both at the beginning and at the end 
would allow programmers the choice where they want to put their commas.


More information about the Haskell-prime mailing list