I think Tilmann's way is the right way (because it is very clear when a comma is missing since they align, unlike trailing commas), although the original proposal is the popular way. I would rather get rid of commas altogether (make them optional actually) and just have a newline + consistent indentation signal a new list item: coffee-script does that.


On Fri, May 17, 2013 at 11:23 AM, Tillmann Rendel <rendel@informatik.uni-marburg.de> wrote:
Hi,

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 indented).

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.

  Tillmann

_______________________________________________
Haskell-prime mailing list
Haskell-prime@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-prime