Overloaded `&`: make non-dependent tuple whenever possible
Hi,
Recently in a Slack conversation about deprecating the * operator for tuples in favor of the overloaded & operator, @TWal pointed out that the & operator sometimes makes dependent tuples when it is not necessary. Quoting him:
TWal: I sometimes had legitimate use of
*, for example for the pairx:a{p x} & b, F* makes it a dependent pair so the fix I found was to writex:a{p x} * b
This PR makes the & operator desugar to a non-dependent tuple whenever it is possible.
It only desugars to dependent tuples if there is actually a dependency.
We chatted about some options today:
- Taking this patch, which can be a breaking change
- Using a different symbol for non-dependent and dependent tuples (
&and&>?) - Having the user write tuple2/dtuple2 (one of the two) to disambiguate, and keep
&for the other. - Desugaring to dtuple2 and displaying a warning when the variable does not appear in the right type.
- Desugaring this to dtuple2, and enclosing the left type in parentheses to make it a tuple2, (so
x:a{p x} & bis dependent, but(x:a{p x}) & bis not). I tried it here and here and regressions seem minor.
Personally I'm in favor of the last point you're mentionning Guido. It's a purely syntactic thing, the rule is easy to understand and I think it is quite intuitive. I think we should close this PR in favor of that parenthesis rule change
I ended up implementing the parenthesis option in #3317. Closing. Thanks Lucas and Théophile for bringing up the issue!