brittany cannot parse parentheses #219
Labels
No Label
blocked: dependency
blocked: info-needed
bug
duplicate
enhancement
fixed in HEAD
help wanted
hs:arrows
hs:brackets
hs:classes
hs:comments
hs:do-notation
hs:guards
hs:lists
hs:operators
hs:patterns
hs:records
hs:types
invalid
language extension support
layouting
needs confirmation
priority: high
priority: low
question
revisit before next release
wontfix
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: hexagoxel/brittany#219
Loading…
Reference in New Issue
There is no content yet.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may exist for a short time before cleaning up, in most cases it CANNOT be undone. Continue?
There seems to be a couple of presumably related bugs in this area:
For this case specifically:
There have been many issues related to infix functions with backticks. Most recently #234.
I did a bit of digging here. It looks like the parenthesis in these LHS binds are not represented in the AST.
I dumped the full AST for
(f >=> g) k = f k >>= g
, the bit to focus on is the annotations ofMatch
.ghc-exactprint
is representingAnnOpenP
andAnnCloseP
in itsKeywordId
annotations. This type of parenthesized bind doesn't end up in the normal AST viaParPat
. To fix thisbrittany
will have to change its pattern layouter to takeghc-exactprint
annotations into account.The full dumped AST is here:
This code from type signature layouting seems mildly related.
hasAnnKeyword ltype AnnOpenP
might come handy here too.Although this is all not very well tested (Nesting? Can you nest parentheses?):
988d5b4353/src/Language/Haskell/Brittany/Internal/Layouters/Type.hs (L619-L667)
The following two lines have the same syntax-tree and the exact same annotations:
So I am mildly certain that exactprint does not give us enough information to retain redundant parentheses. This is a strong indicator that we should just "normalize" LHS parentheses (dropping any redundant ones): Ignore any annotations, and do the minimum to make the output syntactically valid.
This should also be the easiest approach to implement :p
Agreed on normalizing. 👍