Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconvenient precedences #2531

Open
JacquesCarette opened this issue Dec 20, 2024 · 8 comments
Open

Inconvenient precedences #2531

JacquesCarette opened this issue Dec 20, 2024 · 8 comments

Comments

@JacquesCarette
Copy link
Contributor

As I was setting A3 for my course using PLFA, one of the exercise was:

Prove the following:

⊎-comm :  {A B : Set}  (A ⊎ B) ↔ (B ⊎ A)

where _⊎_ is from Data.Sum.Base and declared infixr 1 _⊎_ and _↔_ is from Function.Bundles and declared infix 3 _↔_. The first is as per README.Design.Fixity but the second doesn't correspond to anything in there.

The problem, of course, is that this leads to needing parens where there really shouldn't be a need for them. The same holds for all the rest of the combinators in Function.Bundles.

Unsurprisingly, PLFA defines all of these combinators to be at level 0 instead.

We should change these. Level 0 seems right. Yes, strictly speaking, this would be a 'breaking' change. Except that I don't think it would break any existing code is current code would have had to put in parentheses (unless they were doing something extremely weird with unions or products of equivalences).

cc: @wenkokke @wadler .

@JacquesCarette
Copy link
Contributor Author

To be clear: I regard this as a bug (a usability bug) that should be fixed, even though it might break some odd code.

@wadler
Copy link

wadler commented Dec 21, 2024 via email

@jamesmckinna
Copy link
Contributor

'Obvious' question(s):

  • what is the precedence of the function space arrow _->_? (Maybe it's too below the surface of syntax even to be exposed as such)
  • Should we regard the proposal/usability argument essentially to amount to saying all such hom-objects should have the same precedence, not just those arising from Function.Bundles?

@JacquesCarette
Copy link
Contributor Author

@wadler : I think PLFA got it right here. (It's not the only place - I've got more issues incoming, when I find the time.)

@jamesmckinna :

  • I don't think it has a 'published' precedence? Reading things here and there, it behaves as if it has arbitrarily low (i.e. -infinity) precedence (and right-associative)
  • I don't know about all 'hom-objects', but certainly all type-level binary relations should have the same precedence (likely 0).

@jamesmckinna
Copy link
Contributor

@JacquesCarette I'm very much in sympathy with the spirit of the proposal, but find it isn't easy to find a consistent live once indexing plays a role: the various indexed analogues of Function.Bundles for eg unary predicates, are all declared at infix 4... (I haven't looked at dependent nodes of the Function hierarchy yet...)

@JacquesCarette
Copy link
Contributor Author

Those were likely "just done", as there is nothing in our guidelines that would tell you what fixity these should have. More legacy.

@jamesmckinna
Copy link
Contributor

jamesmckinna commented Dec 24, 2024

From style-guide under Fixity:

* binary relations of all kinds are `infix 4`
* binary properties `infix 4 _Absorbs_`

So... we did have some sort of guideline in place...the solution would appear to be to add an additional item under Type formers, and to agree whether the 'arrows' under Unary etc. are 'binary properties' or 'type formers'...?

* function-space-like `infixr 0 _↔_`

@JacquesCarette
Copy link
Contributor Author

Yes, I think adding a case under Type formers would make sense.

I definitely see the various kinds of equivalences (defined under Function.Bundles) as being "properties" (even though they, strictly speaking, are 'structure' - but I think the problem here is a confusion between 'property' a la HoTT and how it is used in stdlib).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants