Support promoted type applications. #376
Open
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.
Closes #370.
Up to GHC 8.10,
was a valid type application. In GHC 9 it's not, which means brittany needs to allow
which it now does.
The reason the space was needed was to allow a promoted type variable at the head of a type-level list. That is,
is invalid syntax, because it initially parses as the character
'['
. So the promoted type variable was always given a separator at the beginning, and we'd getwhich was valid. Now we handle this case by specifically examining the head of a type-level list; if it's promoted we introduce spaces, so
I've added tests for this and some related cases. In doing so I noticed that unnecessary spaces get added in front of commas in these lists; I believe that's a separate bug, and I've written a comment explaining why it happens, but I haven't tried to fix it.
I'm not sure when the first alternates in the
FirstLastSingleton
andFirstLast
branches would ever be hit, so I'm not entirely sure if the separators are necessary there. But sincedocSeparator
disappears at the end of a line and merges with adjacent separators, they should be harmless.