Skip to content

Array merging as sets? #1602

Answered by vkleen
pingiun asked this question in Q&A
Sep 14, 2023 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

At the moment Nickel doesn't have a builtin way of merging arrays using &. When overriding was first suggested in RFC001, there was also a proposal to add custom merge functions. Those would be a principled way of achieving what you're asking for. Namely, you would annotate a record field with a custom function that gets passed two values to be merged in the event of a conflict and it would be able to do just about anything with those values; it might be advisable to implement an associative and commutative merge, though.

This commutativity requirement is also one reason why we wouldn't want to implement merging arrays as sets by default. It would only end up being commutative for a (hypo…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@yannham
Comment options

Answer selected by pingiun
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants