Allow all annotations to take full expressions #1230
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Instead of just application expressions, since some annotations were allowed to take full expressions, it makes sense to allow them all to do so.
Otherwise there are weird corner cases like
merge { x = λ(y : Bool) → y } < x >.x : (∀(y : Bool) → Bool)
parses as a merge-with-annotation while
merge { x = λ(y : Bool) → y } < x >.x : ∀(y : Bool) → Bool
parses as a merge-without-annotation plus annotation, just like
(merge { x = λ(y : Bool) → y } < x >.x) : ∀(y : Bool) → Bool
(from https://github.com/dhall-lang/dhall-lang/blob/1907a1d1a6dff9ff8638547f7bc49d6b5135bcdf/tests/type-inference/success/unit/MergeOneWithAnnotation1A.dhall)
Now the second will parse like the first, instead of like the last.
Of course we should discuss whether this is a breaking change, but I think the actual user-facing effects will be minimal, since the difference in annotations are normalized away.
This came up in fixing my pretty printer – I don't think there's a good way for me to disambiguate the old way correctly within my current system of precedence.
I also removed trailing spaces in a separate commit and noticed that the file uses CRLF line endings which is very weird. Happy to revert that commit if you want …