Open aryairani opened 4 years ago
I'm looking into the approach presented here: https://victorcmiraldo.github.io/data/icfp2019.pdf ; there's a Haskell implementation here
I think it'd be a really good fit for Unison because:
After a quick read, here's my summary of the algorithm:
diff a b
a
and b
, and their intersection.a
and b
There are some complications regarding nested common subtrees, but they're handled with post-processing steps in the paper and the implementation for us.
Pretty-printing these diffs in a readable fashion will be a separate challenge, but this should give us diff trees with all the information we need to do so.
Cool!
I couldn’t tell from a brief skim of the paper whether they support moves on top of inserts, deletes, copies, but I think we would want that eventually.
It identifies common subtrees by metavariables and you can compare positions in the old and new diffs, so yeah I'm pretty sure we could detect moves using this.
On further inspection it looks like the hdiff
library would require us to use generics-mrsop
classes, which are a bit gnarly, and might not give us the flexibility we need, so I think it might be in our best interests to implement the algorithm bespokely for our ABTs, which seems pretty do-able from the paper 😄 . That also would allow us to graft-in any custom functionality we need, e.g. detecting that a changed hash is just an "update" to a named term.
Maybe I'll try implementing it over JSON first to make sure I know what I'm talking about 😋