Hacker News new | ask | show | jobs
by dymk 2540 days ago
Weird that it's billed as an alternative to YAML, but effectively has zero roots or influence from YAML. Looks more like an alternative to... whatever configuration language is popular in ML language projects?
4 comments

There aren't too many standard onrs. Most people seem to either write a custom (embedded) DSL for their tool or go with something more widely known.

If people are curious about examples of DSLs in Haskell projects, they can look at cabal files, persistent's entity syntax, and servant's type level DSL for API definitions. These go on a scale from "fully separate" to "embedded in the language". (Persistent is in between, it uses something called Template Haskell)

The stack Haskell build/project management tool uses YAML files.

- - -

I think Dhall's power is not that it is an alternative syntax to YAML. It's more about the typesystem than anything else. If you're sold on types, then Dhall is definitely worth a look

So? They live in the same solution domain for the same problem. Moreover, Dhall can generate (typechecked) YAML and JSON.
It's not even in the same solution space. I can't replace my YAML with Dhall and consume it directly. I have to now depend on the converter to go from Dhall -> YAML/JSON. All I did was add another layer of complexity into my config.

Maybe you'll benefit from the added abstraction; I see the value in having "typed" configs that are semi-scriptable but not turing complete. But it's in no way a "replacement".

> All I did was add another layer of complexity

If that was in fact all you had done, it would not be worth it. But it might remove a ton of boilerplate from your YAML.

or, one can eliminate boilerplate in code so that configuration stays simple and the logic in the application

I mean what's the role of configuration? is so that installer can tune or match environments. if configuration becomes as hard as your program to understand then installation won't ever scale

>> I can't replace my YAML with Dhall and consume it directly.

Sorry I don't get it. Why not? Because your favorite languages do not support it?

How many languages have an Dhall implementation? One?
As far as I know Clojure, Haskell, Ruby, Rust in various stages of completion..
Both Clojure and Eta bindings should allow really anything on the JVM to consume directly.
Six or seven, or thereabouts.
I disagree that it has zero roots. It's not whitespace sensitive, so it does throw out a ton of YAML's distinctive syntax.

What you're left with is YAML's core expressiveness, which is that within a text file you can express the basic structures of maps, sequences, some atoms and user-typed [1] nodes.

YAML also has some limited facilities for avoiding repetition, such as aliases and anchors[2]. And a YAML parser can use tags to simulate functions[3].

Dhall is preserving all those capabilities, and then adds real functions and type declarations to further expand the ability to avoid repetition and to avoid mistakes. It's also using a proper type system rather than basically returning a parse tree back.

And whereas these advanced features in YAML are rarely useful because the parser has to go out of its way to support them, it seems like Dhall may be able to make them work properly. So I'd say seeing another project attempt something and then trying to do it right is definitely being influenced by it.

[1]: https://yaml.org/spec/1.2/spec.html#id2761292 [2]: https://yaml.org/spec/1.2/spec.html#id2786196 [3]: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGui...

Its more like an alternative to scripts generating configuration from templates. they claim that this is better because you cant for example write an infinite loop ruining the script.
Is it a real problem though? If your config generator is complex enough to hide an infinite loop, you probably should be relieved every time it fails obviously and doesn't generate wrong config instead.