lean4 icon indicating copy to clipboard operation
lean4 copied to clipboard

feat: `pp.parens` option to pretty print with all parentheses

Open kmill opened this issue 7 months ago • 4 comments

This was a feature in the Lean 3 community edition.

Right now this is over-parenthesizing expressions compared to the Lean 3 version. Before, numerals and identifiers were not parenthesized. (Example output)

kmill avatar Nov 21 '23 00:11 kmill

@Kha What do you think about this implementation? Do you have any ideas how to make it not parenthesize atomic syntax? In particular, is there some condition that implies parentheses are never needed?

kmill avatar Nov 21 '23 01:11 kmill

  • ❗ Mathlib CI can not be attempted yet, as the 'nightly-testing-2023-11-20' branch does not exist there yet. We will retry when you push more commits. It may be necessary to rebase onto 'nightly' tomorrow. (2023-11-21 01:57:36)

Perhaps something like (← read).forceParens && prec < maxPrec? That is, if the precedence of the thing to be parenthesized is already at least the precedence of parens, there is no need to do it.

Kha avatar Nov 21 '23 08:11 Kha

@Kha I've tried a few variations on that, but they didn't seem to have any effect. I think I've spent my time budget on this feature -- maybe if it the basic version of the feature exists, someone who is keen on having it prettier will figure out a solution?

kmill avatar Nov 21 '23 17:11 kmill