Does Dhall make sense as a "better config format" in Python?

My situation is, I currently have a relatively extensive configuration file in yaml format. My application is written in Python. The yaml format is untyped, of course, and I have to validate the format in Python and convert to the corresponding Python types (in the case of enums, for example).

Is dhall something that can even help here? I can rewrite my configuration in dhall, and there are the dhall bindings in Python. But if I cannot transfer my Dhall types to Python (or vice-versa), so I have to validate and convert just the same. Albeit with a little less effort, since dhall ensures certain invariants.

From my point of view, what dhall gives me, mainly, is the ability to write functions to make the configuration a bit more straightforward and possibly less error-prone. Am I missing something? Is somebody else using Dhall in Python?

1 Like

I would say that Dhall still helps in that case, although it might require more clarification about your use case to say for sure.

Specifically, one of the advantages of Dhall is that if you can encode your invariants in the Dhall types, then the host language does not need to perform any additional validation.

Also, even if you still prefer to do additional validation in Python, you can still make use of Dhall’s support for eliminating error-prone repetition, which you can’t do in plain YAML.

1 Like

It might be possible to implement a compiler, similar to what mypy-protobuf does for protobuf message, to provides python type annotation stubs for a given dhall schema.
Since that might be useful for other languages, perhaps dhall could provides a dhallc tool similar to protoc?

Though that sounds like a lot of work.

Depending on how much you are writing the config, maybe? It can be rendered to a hashmap or whatnot fairly nicely (see dhall-json for instance!)