-
Notifications
You must be signed in to change notification settings - Fork 364
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
Should the parameters be marked as erased in the types of constructors and projections? #4786
Comments
When originally implementing erasure, I did not have the guts to make parameters erased. In particular, to not confront users with errors concerning erasure if they did not use erasure at all. |
I don't see a conflict between making parameters erased for projections while leaving them non-erased for definitions in the record module. |
The projections are defined in the record module, and the module's telescope is built using the parameters. |
Apparently you can build a record module in such a way that the parameters are not erased in the telescope, but when you open the module you get projections with erased parameters. With my attempted fix of this issue (16f1118) the following code is accepted: record R (A : Set) : Set where
field
x : A
open R
_ : (@0 A : Set) → R A → A
_ = λ A → x {A = A}
_ : (@0 A : Set) → R A → A
_ = λ A → R.x {A = A} However, the following code is rejected: open module R′ (@0 A : Set) (r : R A) = R {A = A} r I wonder if the code that generates composition operations for data and record types needs to be changed. @Saizan, can you take a look at this? |
Perhaps something should be done about the code that generates composition operations.
Perhaps something should be done about the code that generates composition operations.
@wenkokke, do you discuss how parameters affect the types of constructors or projections in PLFA? If so this change might "break" the text. As an example, the statement that the constructor data D (A : Set) : Set where
c : D |
Put erasure under a flag. ( |
@wenkokke, if this change is only active when |
The option One idea is to generate such arguments, but only print data D (@0 A : Set) : Set where
c : D A Is it possible to observe the difference between f : (@0 A : Set) → D A
f A = c {A = A} Is there a risk that a meta-variable is created in an erased context, and thus cannot be used in a non-erased context? This could perhaps be addressed by ensuring that meta-variables are never created in an erased context when |
@nad the code for the composition operations still gets the parameter telescope from the datatype, so it's fine. The |
Thanks. If we take the approach that I speculate above, where |
One option is to not have a Consider the following code: data D (A : Set) : Set where
c : D A
record R (A : Set) : Set where
constructor c
field
f : A If you infer the type of
For
|
Perhaps something should be done about the code that generates composition operations.
According to Andrea Vezzosi nothing needs to be done about the code that generates composition operations.
@nad it doesn't, why would it make sense? if you transport along |
I'm not familiar with the computation rules for the composition operations, that's why I asked you. If the parameters are (supposed to be) used for run-time computations, then it makes sense to not mark them as erased. |
I suggest that we merge my implementation of this variant now, and see if anyone complains. Any objections? |
There were no objections, so I merged my changes. |
commit 0ab714c Author: EDT4 <36039342+EDT4@users.noreply.github.com> Date: Tue Dec 20 04:44:31 2022 +0100 Allow quantified names when applying named arguments. Example: variable {l} : Agda.Primitive.Level variable {T} : Set l postulate x : let _ = T in Set₁ y = test{T.l = Agda.Primitive.lzero} {T = Set} commit 03466cc Author: Nils Anders Danielsson <nad@cse.gu.se> Date: Mon Dec 12 12:48:11 2022 +0100 [ agda#4786 ] Modified the changelog entry.
Parameters are currently not marked as erased in the types of constructors and projections. Perhaps they should be.
It is sometimes possible to create variants of the constructors and projections with erased type arguments:
However, these variants cannot be used as patterns/copatterns. Furthermore this trick does not work for record types with
no-eta-equality
unlesspattern
is also used.I imagine that this change is straightforward for constructors. For projections there is a complication: some definition in the record module might use the parameters in a non-erased context. Perhaps we could fall back to the current behaviour if there is a non-trivial record module.
Currently one also has the option to explicitly mark the parameters as erased, but this seems to lead to a problem (#4784).
I guess that this change is not backwards compatible.
The text was updated successfully, but these errors were encountered: