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
[ #4560 ] pattern attribute for no-eta-equality inductive records #4611
Conversation
This error seems to have no semantic effect.
The old noPatternMatchingOnCodata was a separate pass after splitting was done. We can more eagerly disallow splits on coinductive constructors. We do so for other types of disallowed splits already. This refactoring saves an extra traversal on the internal patterns. In connection with this refactoring, I split Syntax.Common.DataOrRecord into its different uses: 1. Syntax.Scope.Base.DataOrRecordModule 2. TypeChecking.DataTypes.DataOrRecord 3. TypeChecking.Rules.LHS.DataOrRecord with extra information
The fix of agda/agda#4560 in PR agda/agda#4611 requires the record directive 'pattern' if you want to pattern match on a record constructor that does not have eta-equality. Eta-equality is automatically turned off for some recursive records, such as the present one. Alternatively, we could add 'eta-equality' instead of 'pattern'.
The fix of agda/agda#4560 in PR agda/agda#4611 requires the record directive 'pattern' if you want to pattern match on a record constructor that does not have eta-equality. Eta-equality is automatically turned off for some recursive records, such as the present one. Here, we turn eta on to be compatible with Agda without the PR. Alternatively, we could add 'pattern' instead of 'eta-equality'.
Having both pattern and copattern matching for records without eta-equality breaks subject reduction. If you want to pattern match on the constructor for a no-eta record, you have to declare it 'pattern'. The default is copattern matching. The attribute 'pattern' is ignored for 'coinductive' or 'eta-equality' records. Recursive records might be declared as no-eta by the positivity checker; thus, we need to remember the attribute 'pattern' until the positivity checker has run. It is stored in the new field recPatternMatching :: PatternOrCopattern of the Record alternative of TCM.Defn. Ultimately, the choice of PatternMatching or CopatternMatching is integrated in the field recEtaEquality' :: HasEta This change to Agda affects a dozen test cases and also the standard library at one place. The standard library has been patched to be compatible with this commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be good to have tests for copatterns being allowed with a no-eta-equality
record.
Such tests already exist, e.g. agda/test/Succeed/Issue2968.agda Lines 7 to 30 in c0b4c61
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm happy with the design that came out of the discussion!
Pushed to master. |
[ fixed #4560 ]
pattern
attributeno-eta-equality
inductive
records.Having both pattern and copattern matching for records without eta-equality breaks subject reduction.
If you want to pattern match on the constructor for a no-eta record, you have to declare it 'pattern'. The default is copattern matching.
The attribute 'pattern' is ignored for 'coinductive' or 'eta-equality' records. Recursive records might be declared as no-eta by the positivity checker; thus, we need to remember the attribute 'pattern' until the positivity checker has run. It is stored in the new field
of the
Record
alternative ofTCM.Defn
. Ultimately, the choice ofPatternMatching
orCopatternMatching
is integrated in the fieldThis change to Agda affects a dozen test cases and also the standard library at some places.
TODO: