Hacker News new | ask | show | jobs
by regnat 3281 days ago
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

1 comments

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.
Made legal in ES2017.
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.

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.
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.
How so?