Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Smarter deep merging of maps in sequentials #9

Open
devth opened this issue Nov 12, 2016 · 4 comments
Open

Smarter deep merging of maps in sequentials #9

devth opened this issue Nov 12, 2016 · 4 comments

Comments

@devth
Copy link

devth commented Nov 12, 2016

Not sure if this project aims to address this particular case, but here's an example that didn't work as expected:

(meta-merge
  {:foo [{:bar [1]}]}
  {:foo [{:bar [2]}]})

Result:

 {:foo [{:bar [1]} {:bar [2]}]}

Expected:

 {:foo [{:bar [1 2]}]}
@devth devth changed the title Smarter deep merging of maps in seqs Smarter deep merging of maps in sequentials Nov 12, 2016
@weavejester
Copy link
Owner

The result is the expected behaviour.

Meta-merge aims to be unambiguous in how it merges data sets. Vectors are always concatenated together:

(meta-merge [1 2] [3 4])
=> [1 2 3 4]

In order to support the behaviour you expect, meta-merge would have to try to guess what the user wants depending on how similar elements are.

@devth
Copy link
Author

devth commented Nov 12, 2016

Got it. I wonder if your metadata usage could or should be used to specify desired behavior of more use cases?

Metadata hints can be provided to override the default behavior

Or maybe my use case is just too specific.

@weavejester
Copy link
Owner

Do you have any suggestions for metadata that would support the behaviour you want?

@devth
Copy link
Author

devth commented Nov 12, 2016

I imagine it would just be a named behavior, but it would need to affect the entire tree.

(meta-merge
  {:foo [{:bar [1]}]}
  {:foo ^:merge-sequential [{:bar [2]}]})

I'm not sure, TBH.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants