-
Notifications
You must be signed in to change notification settings - Fork 217
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
Diff list values #450
Diff list values #450
Conversation
Issue dhall-lang#431 Make the diff of two lists actually show the diff of the values inside. For example with `example1.dhall`: ```dhall { a = [1, 2, 3, 4, 5] , b = [1, 2, 3, 4, 5] : List Natural , c = [1, 2, 3, 4, 5] : List Natural , d = [] : List Natural , e = [] : List Natural , f = [1, 2, 3, 4, 5] : List Natural } ``` And `example2.dhall`: ```dhall { a = [1, 6, 7, 4, 5] , b = [1, 2, 3] : List Natural , c = [2, 3, 4, 5] , d = [] : List Natural , e = [] : List Integer , f = [+1, +2, +3, +4, +5] : List Integer } ``` The diff looks as follows: ```sh ➜ dhall diff "./example1.dhall" "./example2.dhall" { a = [ … , - 2 , - 3 , + 6 , + 7 , … ] , b = [ … , - 4 , - 5 ] , c = [ - 1 , … ] , d = - [ … ] + [ … ] : … … , e = - [ … ] + [ … ] : … - Natural + Integer , f = - [ … ] + [ … ] } ``` Signed-off-by: Basile Henry <[email protected]>
8aeae2b
to
32cb9fa
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome work! Just one minor suggestion
Also, I added you as a collaborator so that you can merge your pull request yourself
src/Dhall/Diff.hs
Outdated
| otherwise = False | ||
|
||
-- Render a single element of a list using an extra rendering function | ||
prettyElems f = foldMap (pure . f . token . Internal.prettyExpr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can do prettyElems f = map (f . token . Internal.prettyExpr)
here
Signed-off-by: Basile Henry <[email protected]>
Signed-off-by: Basile Henry <[email protected]>
Signed-off-by: Basile Henry <[email protected]>
Fixes #1211 The original implementation of diffing two lists in #450 attempted to add a special case in the logic for when the list had no common elements. However, this led to a bug where the two lists would display different if they were both empty. lists would never render. This change fixes that by removing the special case. The new output for the linked example is: ``` Use "dhall --explain" for detailed errors Error: Assertion failed [ … , - 1 , … , + 55 ] 16│ assert : fibs 10 ≡ [ 0, 1, 2, 3, 5, 8, 13, 21, 34, 55 ] 17│ (stdin):16:16 ```
Fixes #1211 The original implementation of diffing two lists in #450 attempted to add a special case in the logic for when the list had no common elements. However, this led to a bug where the two lists would display different if they were both empty. lists would never render. This change fixes that by removing the special case. The new output for the linked example is: ``` Use "dhall --explain" for detailed errors Error: Assertion failed [ … , - 1 , … , + 55 ] 16│ assert : fibs 10 ≡ [ 0, 1, 2, 3, 5, 8, 13, 21, 34, 55 ] 17│ (stdin):16:16 ```
Fixes #1211 The original implementation of diffing two lists in #450 attempted to add a special case in the logic for when the list had no common elements. However, this led to a bug where the two lists would display different if they were both empty. lists would never render. This change fixes that by removing the special case. The new output for the linked example is: ``` Use "dhall --explain" for detailed errors Error: Assertion failed [ … , - 1 , … , + 55 ] 16│ assert : fibs 10 ≡ [ 0, 1, 2, 3, 5, 8, 13, 21, 34, 55 ] 17│ (stdin):16:16 ```
Issue #431
Make the diff of two lists actually show the diff of the values inside.
For example with
example1.dhall
:And
example2.dhall
:The diff looks as follows: