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

diffing for nested MapEntry replaces the top level entry #20

Open
den1k opened this issue May 25, 2021 · 4 comments
Open

diffing for nested MapEntry replaces the top level entry #20

den1k opened this issue May 25, 2021 · 4 comments
Labels
enhancement New feature or request

Comments

@den1k
Copy link

den1k commented May 25, 2021

This contains an update path:

(e/diff [1 [2 [3 4]]]
        [1 [2 [3 "🤔🤔🤔"]]])
=> [[[1 1 1] :r "🤔🤔🤔"]]

This replaces the top level MapEntry:

(ns user
  (:import (clojure.lang MapEntry)))

(e/diff (MapEntry/create 1 (MapEntry/create 2 (MapEntry/create 3 4)))
        (MapEntry/create 1 (MapEntry/create 2 (MapEntry/create 3 "🤔🤔🤔"))))
=> [[[] :r [1 [2 [3 "🤔🤔🤔"]]]]]

Running into this issue using https://github.com/metosin/malli#parsing-values where parts of the parse-tree are MapEntries.

@huahaiy
Copy link
Contributor

huahaiy commented Jun 30, 2021

Currently, a MapEntry is treated as a data value :val.

Is it desirable to treat it as a data type of its own? If the use case is common enough, we can do that.

@den1k
Copy link
Author

den1k commented Jul 1, 2021

Context for my case is that https://github.com/metosin/malli#value-transformation returns a sequence of MapEntries: https://github.com/metosin/malli/blob/4671ea3a670dda6289f550ff557e10abea799329/src/malli/core.cljc#L1747

I think it's desirable solely for the reason that it would be more correct the diffing for MapEntry is currently broken. If this is low effort and performance hit is negligible I think it would be great to have this.

@huahaiy
Copy link
Contributor

huahaiy commented Jul 11, 2021

Sounds reasonable. I will get to it when I get some time.

@huahaiy
Copy link
Contributor

huahaiy commented Sep 9, 2021

Maybe think about ways to make this extensible.

@huahaiy huahaiy added the enhancement New feature or request label Nov 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants