editscript icon indicating copy to clipboard operation
editscript copied to clipboard

diffing for nested MapEntry replaces the top level entry

Open den1k opened this issue 4 years ago • 4 comments

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.

den1k avatar May 25 '21 15:05 den1k

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.

huahaiy avatar Jun 30 '21 23:06 huahaiy

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.

den1k avatar Jul 01 '21 15:07 den1k

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

huahaiy avatar Jul 11 '21 04:07 huahaiy

Maybe think about ways to make this extensible.

huahaiy avatar Sep 09 '21 21:09 huahaiy