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

RecordEquiv reflection doesn't seem to handle implicit field arguments #995

Open
Trebor-Huang opened this issue Mar 8, 2023 · 6 comments

Comments

@Trebor-Huang
Copy link
Contributor

MWE:

{-# OPTIONS --cubical #-}
module test where
open import Cubical.Reflection.RecordEquiv using (declareRecordIsoΣ)

postulate
  Bar : Set
  Baz : Bar  Set

record Foo : Set where
  field
    foo :  {A}  Baz A

unquoteDecl FooΣ = declareRecordIsoΣ FooΣ (quote Foo)

This shows for me

Cannot instantiate the metavariable _A_9 to solution A
since it contains the variable A
which is not in scope of the metavariable
when checking that the expression _ has type Baz A

I'm on Agda somewhere around HEAD.

@Trebor-Huang
Copy link
Contributor Author

I might help debug when I have time, but I'm going to sleep for now.

@maxsnew
Copy link
Collaborator

maxsnew commented Jun 5, 2023

This is my number 1 most wanted feature right now.

@cmcmA20
Copy link

cmcmA20 commented Jul 8, 2023

@maxsnew
It works if you explicitly write the signature

  foo-iso : Iso Foo ({A : Bar} → Baz A)
  unquoteDef foo-iso = define-record-iso foo-iso (quote Foo)

(and change the macro to provide a definition, not a declaration)

@maxsnew
Copy link
Collaborator

maxsnew commented Jul 10, 2023

Can you share the code @cmcmA20 ?

@cmcmA20
Copy link

cmcmA20 commented Jul 11, 2023

defineRecordIsoΣ' : R.Name → ΣFormat → R.Name → R.TC Unit
defineRecordIsoΣ' idName σ recordName =
  recordName→isoTy recordName σ >>= λ isoTy →
  R.defineFun idName (recordIsoΣClauses σ)

defineRecordIso : R.Name → R.Name → R.TC Unit
defineRecordIso idName recordName =
  R.getDefinition recordName >>= λ where
  (R.record-type _ fs) →
    let σ = List→ΣFormat (List.map (λ {(R.arg _ n) → n}) fs) in
    defineRecordIsoΣ' idName σ recordName
  _ →
    R.typeError (R.strErr "Not a record type name:" ∷ R.nameErr recordName ∷ [])

module _ where private
  Bar : Type
  Bar = ℕ

  private variable Z : Bar

  Baz : Bar → Type
  Baz 0 = Unit
  Baz _ = ℕ

  record Foo : Type where
    field
      foo : Baz Z

  foo-iso : Iso Foo (∀{A} → Baz A)
  unquoteDef foo-iso = defineRecordIso foo-iso (quote Foo)

@cmcmA20
Copy link

cmcmA20 commented Jul 14, 2023

@maxsnew
Feel free to merge it yourself, I don't have time to refactor/clean it up properly

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

No branches or pull requests

3 participants