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

Automatic hole detection (comby diff) #192

Open
abitrolly opened this issue Jul 25, 2020 · 2 comments
Open

Automatic hole detection (comby diff) #192

abitrolly opened this issue Jul 25, 2020 · 2 comments

Comments

@abitrolly
Copy link
Contributor

I'm always frustrated when I need to write redundant rules manually.

Describe the solution you'd like
Given two versions of a file, create a minimal rule that extracts changed part.

Additional context
Given.

<time datetime="2019-09-02T08:31:02.637Z">Sep 2, 2019</time>

Then.

<time datetime="2020-07-16T09:06:01.005Z">Jul 16</time>

Calculate a template that will extract hole1="2020-07-16T09:06:01.005Z" and hole2="Jul 16" for the second file.

@rvantonder
Copy link
Member

Hey @abitrolly! I'm a bit slow on this one :-) This is a really great idea and I've thought about it a little. The problem comes down to inferring a transformation based on the common and different parts of a tree. This is, in general, a hard thing to do, mostly because there are multiple ways to express a tree difference. For example, if you had:

foo(bar) => foo(bar, baz) it is possible to express the change as:

  • foo(:[1]) => foo(:[1], baz) OR
  • :[f](:[1]) => :[f](:[1], baz) OR
  • :[f](bar) => :[f](bar, baz)

This is just a simple example for the foo(bar) case, and the possibilities only grow the larger the tree gets (i.e., the more code you have). It might seem obvious which one is best above, but in general it's hard to just do right (or it might be expensive to compute).

But, for simple cases (like yours), I think it's very possible to infer one or more plausible transformations. I don't have a good idea for tackling this at the moment, but I'll leave the issue open.

@abitrolly
Copy link
Contributor Author

For foo(bar) => foo(bar, baz) the inferred template would be foo(:[f1]), because the whole content of foo node is changed - instead of single bar leaf there is now a subtree with two siblings bar and baz. I omitted comma from the tree, because the comma is a representation of this sibling relationship when the tree is written as code line.

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