Convert union alternatives to directory tree #1757
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This change adds the ability to convert union alternatives with non-nullary constructors of appropriate type into directory trees.
The commit message describes the details of the change, but my motivation here is that I'd like to build s6-rc service directories using Dhall as a source format. The
s6-rc
service directory format is described here.There are three types of
s6-rc
service directory: "longrun", "oneshot" and "bundle". I've modelled these as below (with some simplification and details omitted for brevity):I've then defined a
Service
type, which is a sum type over the above types.I'd like to be able to construct an expression of the
Service
type for each service in my database, and construct a record representing the database, e.g.:At this point it would be really convenient to feed the record definition into
dhall to-directory-tree
in order to automatically generate the service database directory tree, however the union type means that (without the change in this commit) I need to convert theService
type into some suitable record type, with only (Optional
)Text
fields, and not all combinations of these fields may be valid.Hence, it would be really useful for my case to be able to convert (appropriately-typed) union types into directory trees.