Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Feature Request: Non-Recursive Deep Record Merges #340
config: propertyB: new meta: name: name version: version
config: propertyA: default propertyB: new meta: name: name version: version
Desired expression for new functionality:
Use case : it's common to evaluate a Dhall expression with a type of a complex, deeply nested record, where many of the deeply nested values are of type Optional. To avoid needing to specify large amounts of Optional boilerplate, for each instantiation of such a complex type, it is common to create a function which creates a "default" instantiation which sets all of the Optional fields to None (commonly in
@ari-becker: The main reason that Dhall doesn't have this feature is that it would complicate the standard semantics because you would now have to interleave type-checking and normalization.
The secondary reason is that even with support for this it's not sufficiently general to handle cases where the inner record is nested within a
See a similar discussion here: #114 (comment)
However, what I can do is document this common idiom in the FAQ
@Gabriel439 I do think that it would be a good idea to document the idiom that you pointed out in #114 in the FAQ, which, while unwieldy, still attempts to address the issue of how to selectively insert values in complex nested records.
In general, I think that effort should be paid to trying to improve the experience of working with defaults for types, which is where this feature request is really coming from.
@ari-becker: Yeah, one way I'm thinking about approaching this problem is adding built-in support for nested-updates (i.e. similar to Haskell's lenses/traversals), rather than changing the behavior of the
set config.propertyB "new" preexistingDefaultRecord
... or if the record containing
set config.*.propertyB "new" preexistingDefaultRecord
However, that's a large enough extension to the language that I'm holding off on it until there are more language bindings