Hacker News new | ask | show | jobs
by dtwhitney 3281 days ago
I could not agree with you more! I use nix daily, and every time I go to edit it a nix file a voice in the back of my head says, "you should really start that Haskell to Nix compiler you've been thinking about." [edit] ha! just notice the next comment talking about hnix. Great minds... :)
2 comments

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

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?

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

Go solves this problem by permitting

    foo := Foo{
        x: 10,
        y: 24,
    }
Also Perl, Python, Javascript and Rust.
JavaScript doesn't (didn't?) let you put a trailing comma in function parameter lists, annoyingly.
Python does this, too.
How about allowing for bloody danging commas?
Is there any real disadvantage to comma-first, other than aesthetics (which is entirely a personal preference)?
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.

The wrath of God that it imposes on people who think it's acceptable, for one...
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.
It makes git diffs inaccurate compared to trailing commas.
Wow, I'm doing the opposite where I'm staring at all these other DSLs and configuration files and have to hold myself back from writing a bunch of nix to autogenerate them from.
Haha same here, I've been considering writing Nix expressions for window manager configurations for quite some time now, but some config files are so complex that it would take ages.