4 ms·
I've actually come to like a weird style popular in the Haskell world, leading commas: { one = 1 , two = 2 , three = 3 } It's weird, but i
by tikhonj 11y ago
I've actually come to like a weird style popular in the Haskell world, leading commas:
{ one = 1
, two = 2
, three = 3
}
It's weird, but it's actually pretty convenient. I think it has all the same properties the article argues for, but I don't want to figure it out for sure at the moment.
- esturk 11y agoNo way. What you if had to cut and paste the first item?
- ludamad 11y agoI think the argument would be that this is rarer
- dllthomas 11y agoThen it's extremely obvious that it needs fixing, and your cursor is usually right there to make the change. It is marginally more difficult than leaving in trailing commas, but way better than adding missing unaligned commas at EOL.
- ludamad 11y agoFor the love of god though don't suddenly start using this style in a project that doesn't (I've had to deal with it)
- shadeless 11y agoIt's worth mentioning that Elm uses this style: http://elm-lang.org/docs/style-guide#types http://elm-lang.org/docs/style-guide#types I was initially surprised by this but now knowing that the creator comes from a Haskell background, it makes sense that he would prefer it.
- statictype 11y agoI've always found this style a lot better and can't figure out why people don't use it. Adding items to the end of a list, tuples to a dictionary, arguments to a function etc... is more common then adding them to the start.
- T-R 11y agoI like that Data.Sequence bypasses this whole issue by just not doing anything special: empty |> ("one" , 1) |> ("two" , 2) |> ("three", 3) Edit: It's interesting that, when we have things that are supposed to commute, we use infix operators that create a layout that makes it difficult to reorder them.
- tigershark 11y agoIn my eyes this is really awful. Furthermore, if you move the first entry in the last place as is you get a syntax error. So it has all the disadvantages of the code without trailing commas, plus it makes your eyes bleed if you are used to read pretty much anything apart Haskell code.