Open SebastianKG opened 3 years ago
Thanks for writing up this detailed report!
This was originally added in https://github.com/timbertson/dhall-render/commit/f10494d09ebec352ca7a22888e6401e4d28ae8db, so it's definitely intentional. Well, the failure on an empy array isn't, that sucks 😞
The associated PR is https://github.com/timbertson/dhall-render/pull/5, although I modified the original contribution. It used a new YAMLStream
type, instead of assuming a yaml with a toplevel array should be output as a stream. Perhaps it'd be worth reintroducing that distinction, although maybe YAMLDocuments
or YAMLMulti
would be a better name.
At the time I justified it because if you really want a toplevel array, you could output JSON (all JSON is valid YAML). Would that work for your use case?
The fact that JSON is a subset of YAML is a good point that I hadn't considered, but I do still want that YAML human-readability from my output files so I don't think that would be acceptable for my use case. My preference would be a secondary type as that PR introduced, so that I could just use YAMLFile as it functioned before.
Sounds fair, if you'd like to submit a PR reintroducing that separate type I'd be happy with that. But let's call it YAMLDocuments
. @davidreuss you added this feature in the first place, does that sound good to you?
sounds good to me! 👍
The Problem
I have a YAML configuration structure I would like to describe that uses top-level arrays in some files. However,
dhall-render
breaks in one case, and handles top-level arrays in unexpected ways in other cases.Sample Code
With a directory structure of:
...and
files.dhall
having contents:Actual Results
When I run the following command and get the following error:
So it clearly fails on an empty array. Now, if we remove the line with the "empty.yaml" definition:
...I get the following two files:
one.yaml
many.yaml
...but these aren't top-level arrays, they're separate documents.
Expected Result
empty.yaml
one.yaml
many.yaml
Notes
JSON does not suffer from this issue. All three files are rendered as expected as
JSONFile
s. Thanks for your help,dhall-render
is super cool and a great help when working with Dhall on large projects.