Should the formatter remove any parentheses that are not needed to maintain the same basic syntax tree? There are some restricted cases where we do this today, e.g.:
x <- (\y -> y)
However, here's a case where we don't remove the parens when we actually could:
a < f (x * y)
(That's equivalently a < (f (x * y)), in case that one's confusing)
So right now it's a bit inconsistent.
Thoughts?
personally I've always wanted a formatter that actually inserts parens for arithmetic operators
e.g. x + y * z becomes x + (y * z)
but in the absence of that, I would very much not want the formatter to remove those parens if I've added them :big_smile:
I definitely think the formatter should remove unnecessary double parens
and also inside if/when conditionals
but it's probably fine if those are the only times it removes parens
Interesting, ok
That's easy enough
I would personally want to keep any parentheses that I’ve added around code that works with operators (so also booleans, aside from arithmetic). But other than that, I appreciate all excess parentheses getting removed at least :blush:
I’m not sure about removing them automatically. It could be that I added parens because I know I’ll need them soon, but they aren’t required yet for the current expression I’ve written down. Then I have to type them again if I save the file before adding the final expression
There have been a few times that something like that has happened to me with the formatter and it can be quite frustrating. Unfortunately I don’t think I documented the specific cases
There are some situations (multiple infix operators) where I want parens, and the formatter should add them if I didn't, even if they're not technically necessary to resolve order of operations. There are some situations where I don't want parens and the formatter should remove them.
I think there shouldn't be situations where parens are optional and the formatter leaves parens alone. That would go against the formatting ethos that the programmer shouldn't make case by case decisions on this stuff.
Last updated: Jun 16 2026 at 16:19 UTC