mirror of
https://github.com/corn-config/corn.git
synced 2026-07-11 05:16:10 +01:00
[GH-ISSUE #30] Support for deep object merging #12
Labels
No labels
bug
bug
documentation
enhancement
enhancement
pull-request
tooling
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
corn-config/corn#12
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @JakeStanger on GitHub (Nov 6, 2023).
Original GitHub issue: https://github.com/corn-config/corn/issues/30
Currently object merging only takes the immediate children into account.
There may be utility in changing this, or adding additional syntax, to perform a 'deep merge', running the merge against every child object.
Issue originates from the below discussion, which compares the feature to Nix's 'attrset merge':
Discussed in https://github.com/orgs/corn-config/discussions/29
Originally posted by fbewivpjsbsby November 6, 2023
corn-cli 0.9.2
Windows 10
Description
It is like nixos module, config will merge when you imports config, use
//operators or use mkMerge.Corn is override attrsets now.
Steps to reproduce
corn [your corn file name].corn -t jsonIt is override by $policies_theme:@jficz commented on GitHub (Apr 16, 2025):
I'd suggest
...operator for deep merge and keep..with current shallow merge behavior. Both have utility.@JakeStanger commented on GitHub (Jun 22, 2025):
I'm not a fan of
...because it's too similar to... It'd be easy to miss, and it's not obvious what the difference is.@jficz commented on GitHub (Jun 26, 2025):
fail point. I couldn't find any existing prior art for deep merge operator (didn't dig too much) but I got a few more ideas in no particular order:
I don't like any of those very much, most of them have an established meaning in other languages, except perhaps
+>,.>and>.@JakeStanger commented on GitHub (Jun 26, 2025):
Perhaps it could be considered a "union merge" and copy the Typescript
&union operator (or&&).A nix-style
//is also an option, but only if it's not confusing.@jficz commented on GitHub (Jun 26, 2025):
ha, I forgot about nix's
//. Shame on me :)Since corn is inspired by Nix in many ways (at least that's what it looks like to me), I think
//is a good idea. I think any operator will be confusing to some and keeping some level of consistency with "close relatives" is imho the best compromise@jficz commented on GitHub (Aug 28, 2025):
yeah, except
//is used for comments in cornlang@JakeStanger commented on GitHub (Aug 28, 2025):
Very good point, forgot about that. My preference would probably still be for a
&@jficz commented on GitHub (Aug 31, 2025):
In this case I'd agree with
&as opposed to&&which is imho better typographically but at the same time more confusing logically. Happy to do the testing but code-wise not sure I can help much, rust isn't exactly a language I understand (at this point) :(