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

Need better long string diff #43

Open
yaitskov opened this issue Jan 5, 2021 · 4 comments
Open

Need better long string diff #43

yaitskov opened this issue Jan 5, 2021 · 4 comments

Comments

@yaitskov
Copy link

yaitskov commented Jan 5, 2021

The library does just what I was looking for, but it is to complicated to use it in existing project for app config type, because it contains dozens of types spread across submodules and 3rd packages. To much work to make 1 test failure more readable. I would like to use ediffEq for Showable types. ediffEq doesn't look inside strings and it is not obvious what is different when long strings are compared.

@phadej
Copy link
Collaborator

phadej commented Jan 5, 2021

Patches are welcome

@phadej
Copy link
Collaborator

phadej commented Jan 5, 2021

Sorry, now as I read properly, you want tree-diff to work with just Show? I don't see how it is possible (maybe via https://hackage.haskell.org/package/pretty-simple?) but I wont work on that myself (it probably better to be prototyped in separate).

@yaitskov
Copy link
Author

yaitskov commented Jan 7, 2021

After some search on hackage, google doesn't get what I want by "diff", I found "Diff" package. There is getGroupedDiff function taking 2 equable lists and returns list of same/left/right chunks. I think it would help tree-diff too to deal with long text.

@phadej
Copy link
Collaborator

phadej commented Mar 16, 2021

There is already list diffing algorithm in tree-diff. it's just not used on String types. Partly because we need to think how to represent these diffs. Currently the diff (and representation) is line based:

*Data.TreeDiff> ansiWlEditExprCompact $ ediff (unlines ["first", "second", "third"]) (unlines ["first", "third"])
concat
  [
    "first\n",
    -"second\n",
    "third\n"]

And I'm not convinced that complicating that further to make cases like

*Data.TreeDiff> ansiWlEditExprCompact $ ediff (unlines ["first", "second", "third"]) (unlines ["first", "sec", "third"])
concat
  [
    "first\n",
    -"second\n",
    +"sec\n",
    "third\n"]

shown like on GitHub (e.g. highlighted what the difference between these two) is worth the trouble if there isn't some elegant solution.


Ideas and patches welcome.

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

No branches or pull requests

2 participants