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

Minor fix to dhall diff #1006

Merged
merged 2 commits into from
Jun 14, 2019
Merged

Minor fix to dhall diff #1006

merged 2 commits into from
Jun 14, 2019

Conversation

Gabriella439
Copy link
Collaborator

dhall diff slightly misbehaves when diffing the following expression with
itself:

λ(f : List Bool -> Bool)  f ([] : List Bool)

... producing the following diff:

  λ(… :   …
        → …)
→ …@…
  - [ … ] : List …
  + [ … ] : List …

This is because there are two places in the Dhall.Diff module responsible
for comparing lists:

  • Once in diffApplicationExpression, which compares two lists with at least
    one type annotation between them
  • Once in diffPrimitiveExpression, which compares two lists if neither one has
    a type annotation

Those cases exhaustively cover all possible pairs of lists, but there was a
third (incorrect) fallback case that prematurely gave up and displayed them as
different. This fallback would trigger when applying a function to an empty
list, since the diffing algorithm wouldn't have a chance to return back to the
top-level diffExpression and try to compare the lists correctly in
diffApplicationExpression.

After this change, the diff now doesn't include a spurious difference:

  λ(… :   …
        → …)
→ …@…
  …

`dhall diff` slightly misbehaves when diffing the following expression with
itself:

```dhall
λ(f : List Bool -> Bool) → f ([] : List Bool)
```

... producing the following diff:

```
  λ(… :   …
        → …)
→ …@…
  - [ … ] : List …
  + [ … ] : List …
```

This is because there are two places in the `Dhall.Diff` module responsible
for comparing lists:

* Once in `diffApplicationExpression`, which compares two lists with at least
  one type annotation between them
* Once in `diffPrimitiveExpression`, which compares two lists if neither one has
  a type annotation

Those cases exhaustively cover all possible pairs of lists, but there was a
third (incorrect) fallback case that prematurely gave up and displayed them as
different.  This fallback would trigger when applying a function to an empty
list, since the diffing algorithm wouldn't have a chance to return back to the
top-level `diffExpression` and try to compare the lists correctly in
`diffApplicationExpression`.

After this change, the diff now doesn't include a spurious difference:

```
  λ(… :   …
        → …)
→ …@…
  …
```
@Gabriella439 Gabriella439 merged commit b001a61 into master Jun 14, 2019
@Gabriella439 Gabriella439 deleted the gabriel/fix_list_diff branch June 14, 2019 16:43
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

Successfully merging this pull request may close these issues.

None yet

1 participant