News for hackers. Stuff that matters.
Re:Typing Nix by regnat on Friday June 23, 2017 @10:06AM (#14619224)
You might be interested in dhall[0] and dhal-to-nix[1] which provides a really neat haskell-like language that compiles to nix.

[0]: https://github.com/Gabriel439/Haskell-Dhall-Library [1]: https://github.com/Gabriel439/Haskell-Dhall-Library

Re:Typing Nix by atemerev on Friday June 23, 2017 @10:15AM (#14619276)
If only Haskellers knew that "a blog post" and "type definitions in Hackage" are not documentation...

Also, the comma-first syntax like

{ foo = "bar"

, baz = "qux"

}

drives me nuts. In the name of all good things in the world, why?

Re:Typing Nix by radarsat1 on Friday June 23, 2017 @10:44AM (#14619512)
> comma-first syntax

oooh but this is one of those trivial things that I really liked in my brief days of using Haskell, and that has sometimes carried over to my C++, e.g. in initializer lists. I find it super useful because everything lines up nicely, and from the point of view of version control you don't have to edit the previous line to change '}' to ',' when adding a new line.

Re:Typing Nix by weberc2 on Friday June 23, 2017 @12:23PM (#14620326)
Go solves this problem by permitting

    foo := Foo{
        x: 10,
        y: 24,
    }
Re:Typing Nix by mercurial on Friday June 23, 2017 @03:13PM (#14621925)
Also Perl, Python, Javascript and Rust.
Re:Typing Nix by weberc2 on Friday June 23, 2017 @05:56PM (#14623085)
JavaScript doesn't (didn't?) let you put a trailing comma in function parameter lists, annoyingly.
Re:Typing Nix by Arnavion on Friday June 23, 2017 @07:45PM (#14623590)
Made legal in ES2017.
Re:Typing Nix by teddyh on Tuesday July 04, 2017 @08:12AM (#14695369)
But not in JSON, since that is based on ECMA-262 3rd Edition from December 1999.
Re:Typing Nix by teddyh on Friday June 23, 2017 @03:10PM (#14621896)
Python does this, too.
Re:Typing Nix by coldtea on Friday June 23, 2017 @11:24AM (#14619800)
How about allowing for bloody danging commas?
Re:Typing Nix by wereHamster on Friday June 23, 2017 @11:54AM (#14620053)
Is there any real disadvantage to comma-first, other than aesthetics (which is entirely a personal preference)?
Re:Typing Nix by ykler on Friday June 23, 2017 @12:30PM (#14620413)
Yes, when the commas are at the beginning of the line they are really obvious. I have used commas-first style in JavaScript, and it definitely reduced the amount of times I forgot a comma.

I wonder if people's aversion to commas first has something to do with the fact that commas have a very familiar use in ordinary writing, and there they always follow a word. It is very common to see BNF grammars written with leading vertical bars, and no one seems to mind that -- in fact it would be unusual to use trailing vertical bars.

By the way, a bunch of languages permit a trailing comma after the last element of a list. This is also nice because it means that if you put each list item on a line, the list items all have the same format (thing plus comma). With the Haskell syntax, you lose this, but there is no reason a language couldn't support a leading comma before the first element of a list.

Re:Typing Nix by icebraining on Friday June 23, 2017 @01:28PM (#14620958)
My aversion has to do with the fact that the first element doesn't have one. The irregularity is annoying not just aesthetically, but also if you want to swap lines around, etc.
Re:Typing Nix by cwyers on Friday June 23, 2017 @03:55PM (#14622243)
But there's always a line without a comma -- comma-last has it on the last line instead of the first. So you can have the same line-swapping problem in either arrangement. Comma first just makes it easier to spot.
Re:Typing Nix by icebraining on Friday June 23, 2017 @04:19PM (#14622420)
But there's always a line without a comma -- comma-last has it on the last line instead of the first.

Not if the language allows trailing commas on the last line, like Python and Go do.

Re:Typing Nix by coldtea on Saturday June 24, 2017 @06:20AM (#14625104)
Not if you allow dangling commas (trailing commas as the sibling comment calls them, I think it's the more generic term)...

Then you have a comma at the end in ALL lines, including the last one, without an issue. That was what I proposed above (and lots of languages do it, I think JS is adding it too).

Re:Typing Nix by coldtea on Friday June 23, 2017 @12:40PM (#14620499)
The wrath of God that it imposes on people who think it's acceptable, for one...
Re:Typing Nix by weberc2 on Friday June 23, 2017 @12:30PM (#14620409)
It's another thing to learn, and the total learning curve is the product of all of these idiosyncrasies (and features) (not the sum). And there's absolutely no advantage to comma-first.
Re:Typing Nix by Jweb_Guru on Friday June 23, 2017 @02:29PM (#14621480)
It makes git diffs inaccurate compared to trailing commas.
Re:Typing Nix by mbrock on Friday June 23, 2017 @02:58PM (#14621772)
How so?
Re:Typing Nix by viraptor on Friday June 23, 2017 @09:19PM (#14623895)
Inserting a new element with comma-first changes 2 lines:

   - { old-one
   + { new-one
   + , old-one
While trailing commas allow you to insert an element anywhere with just one line addition.

This doesn't break anything, but it makes looking at "git blame" so much easier.

Re:Typing Nix by dragonwriter on Friday June 23, 2017 @09:37PM (#14623957)
This is only true if you insert at the head. And it's not really leading comma placement but the choice to put the first element in the line with the brace that is the culprit, though both are typical of comma-first.
Re:Typing Nix by viraptor on Saturday June 24, 2017 @05:20AM (#14624992)
With separating comma, it either affects the first or the last position, depending on where you put the commas. But those are the most common places you modify lists.