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

1-field-record Typeclass syntax does not support implicit parameters #15148

Open
RalfJung opened this issue Nov 8, 2021 · 3 comments
Open

1-field-record Typeclass syntax does not support implicit parameters #15148

RalfJung opened this issue Nov 8, 2021 · 3 comments
Labels
difficulty: hard kind: bug An error, flaw, fault or unintended behaviour. part: parser part: typeclasses The typeclass mechanism.

Comments

@RalfJung
Copy link
Contributor

RalfJung commented Nov 8, 2021

Description of the problem

This code works:

Class MRet (M : Type -> Type) := mret A: A -> M A.

but this one does not:

Class MRet (M : Type -> Type) := mret {A}: A -> M A.

That is quite surprising, given that usually {...} works whenever one defines a sequence of binders.

We currently use this as a work-around:

Class MRet (M : Type -> Type) := mret: forall {A}, A -> M A.

Coq Version

8.13.2

@SkySkimmer
Copy link
Contributor

It's getting confused with the record syntax.
You see, Class foo := bla : t parses like a 1-constructor inductive.
but with the { the parser thinks it's parsing a record constructor and does not backtrack.
You can workaround by adding a |: Class MRet (M : Type -> Type) := | mret A: A -> M A.

Not sure if it's possible to fix this, cc @coq/parsing-maintainers

@SkySkimmer
Copy link
Contributor

The only way to find out that something like Class MRet (M : Type -> Type) := mret {A:Type} : A -> M A. isn't a record with field A is to be ambiguous until the : so definitely seems hard to fix.

@RalfJung
Copy link
Contributor Author

RalfJung commented Nov 8, 2021

Ah indeed, this works:

Class MRet (M : Type -> Type) := | mret {A}: A -> M A.

Interesting.

@Alizter Alizter added kind: bug An error, flaw, fault or unintended behaviour. part: parser part: typeclasses The typeclass mechanism. labels Nov 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty: hard kind: bug An error, flaw, fault or unintended behaviour. part: parser part: typeclasses The typeclass mechanism.
Projects
None yet
Development

No branches or pull requests

3 participants