News for hackers. Stuff that matters.
Re:Dhall: A Non-Repetitive Alternative to YAML by nikolay on Thursday July 04, 2019 @01:54PM (#20356445)
Dhall keeps popping up on HN. Here what I don't like about it:

- Why use '=' instead of ':' for attributes? If you used ':', then '=' could be variable assignment and eliminate the need for 'let'.

- Why is there a need for commas?

- Why quote via ticks?! Gee!

- What's with the '{-' and '-}' for comments?! It's like its author decided to differ at any price!

In general, good ideas, but it's too weird and unnecessarily deviates from common syntax.

Re:Dhall: A Non-Repetitive Alternative to YAML by duijf on Thursday July 04, 2019 @02:00PM (#20356500)
Dhall heavily borrows both ideas and syntax from the ML family of languages. E.g. Haskell, OCaml, Elm, Purescript

Colons are used for type signatures.

Commas are presumably required because you can have multi line and nested records. (don't quote me on this, not a parser expert)

The comment syntax is from Haskell.

Not saying this syntax is familiar to everyone, but it is familiar to some. The lineage of the syntax might help you understand where the language is coming from

Re:Dhall: A Non-Repetitive Alternative to YAML by dymk on Thursday July 04, 2019 @02:03PM (#20356528)
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?
Re:Dhall: A Non-Repetitive Alternative to YAML by duijf on Thursday July 04, 2019 @02:22PM (#20356685)
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

Re:Dhall: A Non-Repetitive Alternative to YAML by Vosporos on Thursday July 04, 2019 @02:23PM (#20356690)
So? They live in the same solution domain for the same problem. Moreover, Dhall can generate (typechecked) YAML and JSON.
Re:Dhall: A Non-Repetitive Alternative to YAML by dymk on Thursday July 04, 2019 @02:57PM (#20356897)
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".

Re:Dhall: A Non-Repetitive Alternative to YAML by Jeff_Brown on Thursday July 04, 2019 @03:14PM (#20357000)
> 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.

Re:Dhall: A Non-Repetitive Alternative to YAML by LoSboccacc on Thursday July 04, 2019 @04:56PM (#20357719)
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

Re:Dhall: A Non-Repetitive Alternative to YAML by StreamBright on Thursday July 04, 2019 @03:35PM (#20357114)
>> 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?

Re:Dhall: A Non-Repetitive Alternative to YAML by dymk on Thursday July 04, 2019 @04:24PM (#20357479)
How many languages have an Dhall implementation? One?
Re:Dhall: A Non-Repetitive Alternative to YAML by nightkoder on Thursday July 04, 2019 @04:51PM (#20357685)
As far as I know Clojure, Haskell, Ruby, Rust in various stages of completion..
Re:Dhall: A Non-Repetitive Alternative to YAML by singpolyma3 on Friday July 05, 2019 @08:38PM (#20366986)
Both Clojure and Eta bindings should allow really anything on the JVM to consume directly.
Re:Dhall: A Non-Repetitive Alternative to YAML by codebje on Thursday July 04, 2019 @04:52PM (#20357687)
Six or seven, or thereabouts.
Re:Dhall: A Non-Repetitive Alternative to YAML by ben509 on Thursday July 04, 2019 @05:05PM (#20357790)
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...

Re:Dhall: A Non-Repetitive Alternative to YAML by londt8 on Thursday July 04, 2019 @02:15PM (#20356630)
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.
Re:Dhall: A Non-Repetitive Alternative to YAML by owl57 on Thursday July 04, 2019 @02:35PM (#20356772)
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.
Re:Dhall: A Non-Repetitive Alternative to YAML by nikolay on Thursday July 04, 2019 @02:13PM (#20356613)
Yeah, but how is this relevant? YAML, for example, makes JSON a subset, which lets it consume existing JSON without any need for conversion. It's easy to learn, and readable. Leading commas are eyesores. Plus, not everybody is a fan of ML! These are not mass market languages.
Re:Dhall: A Non-Repetitive Alternative to YAML by ljm on Thursday July 04, 2019 @03:26PM (#20357059)
Not everybody’s a fan of C++, yet still...

YAML has its detractors and many of the criticisms against it are valid. It’s ambiguous and confusing and deeply nested significant white space, with odd indentation rules and optional syntax, is incredibly hard to follow as a human.

Re:Dhall: A Non-Repetitive Alternative to YAML by ben509 on Thursday July 04, 2019 @05:12PM (#20357845)
Honestly, having wrestled with YAML, I find it's easy to write YAML and a bear to process it, in that it seems to be a "read-only" format for machines.

Given some YAML file, making any kind of automated change generally nukes the formatting entirely, let alone the comments. I'm sure there are some libraries that do it right, but there seem to be far more that are just awful.

One nice thing about Dhall is that there's a reference implementation written in Haskell where they have very good pretty printing libraries so it's likely that programs would be able to do automated updates to configuration.

Re:Dhall: A Non-Repetitive Alternative to YAML by ff_ on Thursday July 04, 2019 @05:36PM (#20358003)
Yep, we use the Haskell implementation as a library in Spago [0] and automatically migrating the configuration from old versions is a breeze as we can just manipulate the AST by pattern matching on it, e.g. see [1]

The above is quite standard in JSON/YAML too though, but an awesome thing you can do in Dhall is that - since you have functions - you can write migrations for Dhall data in Dhall itself, e.g. see [2]

[0]: https://github.com/spacchetti/spago [1]: https://github.com/spacchetti/spago/blob/a77b869edcfddd592f4... [2]: http://www.haskellforall.com/2017/11/semantic-integrity-chec...

Re:Dhall: A Non-Repetitive Alternative to YAML by mcaruso on Thursday July 04, 2019 @03:14PM (#20356999)
Seems like you're criticizing it just because it's different from what you're used to.
Re:Dhall: A Non-Repetitive Alternative to YAML by hk__2 on Thursday July 04, 2019 @03:44PM (#20357182)
> Seems like you're criticizing it just because it's different from what you're used to.

This is a valid criticism. There are already widely-used data formats; if you do something different it should be justified.

Re:Dhall: A Non-Repetitive Alternative to YAML by mcaruso on Thursday July 04, 2019 @05:15PM (#20357877)
I don't really see why the author needs to justify it. New languages with new syntax come out all the time, some become popular some do not. Sometimes a new language comes out with a different syntax and becomes popular, creating a new norm.

But in any case Dhall does actually follow a norm rather closely, just a different norm than the grandparent is used to. Namely, ML and other functional languages/research. Which makes sense since Dhall is a product of that community.

Re:Dhall: A Non-Repetitive Alternative to YAML by nikolay on Thursday July 04, 2019 @03:36PM (#20357122)
Yeah, it deviates from the norm and the expectations of most people, most of who are not even developers - lots of BAs today configure apps via such files.
Re:Dhall: A Non-Repetitive Alternative to YAML by GordonS on Thursday July 04, 2019 @06:31PM (#20358318)
Sorry, "BAs"?
Re:Dhall: A Non-Repetitive Alternative to YAML by nikolay on Thursday July 04, 2019 @06:44PM (#20358392)
Business Analysts
Re:Dhall: A Non-Repetitive Alternative to YAML by Thorrez on Thursday July 04, 2019 @04:58PM (#20357742)
None of the examples show quoting via ticks, that seems to be a pretty obscure feature.
Re:Dhall: A Non-Repetitive Alternative to YAML by nikolay on Thursday July 04, 2019 @06:28PM (#20358299)
Actually, at least one does and for the wrong reason (an attribute named True, for example, needs to be quoted):

  { -- Unlike YAML, Dhall does not accept YES|NO|ON|OFF
    validDhallBools = [ True, False ]
      , someNumbers = [ 1
    ,
  -- Dhall is not indentation-sensitive
  2, 3 ]
    -- Field names that conflict with reserved identifiers must be quoted
  , `True` = True
  , version = "9.3"  {- Strings must be quoted

                        All Dhall literals have unambiguous types -}
  }
Re:Dhall: A Non-Repetitive Alternative to YAML by Thorrez on Thursday July 04, 2019 @11:14PM (#20359562)
Thanks, I'm surprised I missed that!