proposal for trailing comma and semicolon
Ben Millwood
haskell at benmachine.co.uk
Sat May 18 16:21:37 CEST 2013
On Fri, May 17, 2013 at 11:37:29AM -0700, Greg Weber wrote:
>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.
I'm interested in this idea. We should make sure we think it through and
there are no weird cases, but if it all works out I'd be in favour.
This looks a bit too much like a GADT to my eyes:
data Point = MkPoint
x :: Rational
y :: Rational
Maybe the recommended style would be:
data Point =
MkPoint
x :: Rational
y :: Rational
But I suppose pattern-matching, update syntax and so forth would
probably still have to use explicit braces and commas. That
inconsistency is probably a bit unpleasant.
I'd say import and export lists at least are probably fine with a
layout-based rule.
>On Fri, May 17, 2013 at 11:23 AM, Tillmann Rendel <
>rendel at 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 at haskell.org
>> http://www.haskell.org/**mailman/listinfo/haskell-prime<http://www.haskell.org/mailman/listinfo/haskell-prime>
>>
>_______________________________________________
>Haskell-prime mailing list
>Haskell-prime at haskell.org
>http://www.haskell.org/mailman/listinfo/haskell-prime
More information about the Haskell-prime
mailing list