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

Cubical Agda: Unquote anonymous copattern involving path #4763

Closed
ecavallo opened this issue Jun 18, 2020 · 3 comments
Closed

Cubical Agda: Unquote anonymous copattern involving path #4763

ecavallo opened this issue Jun 18, 2020 · 3 comments
Assignees
Labels
copatterns Definitions by copattern matching: projections on the LHS cubical Cubical Agda paraphernalia: Paths, Glue, partial elements, hcomp, transp reflection Elaborator reflection, macros, tactic arguments type: bug Issues and pull requests about actual bugs
Milestone

Comments

@ecavallo
Copy link
Contributor

ecavallo commented Jun 18, 2020

{-# OPTIONS --cubical #-}

open import Agda.Builtin.Unit
open import Agda.Builtin.List
open import Agda.Builtin.Cubical.Path 
open import Agda.Builtin.Reflection

record A : Set₀ where
  constructor mk
  field
    out :test : PathP (λ _  A) (mk tt) (mk tt)
test = λ where i .A.out  tt

macro
  mac : Term  Term  TC _
  mac t _ =
    bindTC (normalise t) λ norm 
    bindTC (unquoteTC norm) λ _ 
    returnTC _

b = mac test

raises

An internal error has occurred. Please report this as a bug.
Location of the error: src/full/Agda/TypeChecking/Unquote.hs:442

No issue if the type of test is replaced with I → A.

@gallais gallais added copatterns Definitions by copattern matching: projections on the LHS reflection Elaborator reflection, macros, tactic arguments type: bug Issues and pull requests about actual bugs labels Jun 19, 2020
@gallais
Copy link
Member

gallais commented Jun 19, 2020

Is it the copattern or the PathP? I tried to remove the
--cubical dependency and I am not getting the internal error:

open import Agda.Builtin.Sigma
open import Agda.Builtin.Reflection

id : Σ Set₁ (λ A  A)
id = λ where
  .fst  Set  Set
  .snd  λ x  x

macro
  mac : Term  Term  TC _
  mac t _ =
    bindTC (normalise t) λ norm 
    bindTC {A = Σ Set₁ (λ A  A)} (unquoteTC norm) λ _ 
    returnTC _

b = mac id

@ecavallo
Copy link
Contributor Author

ecavallo commented Jun 19, 2020

Removing the record but leaving the PathP also eliminates the internal error:

{-# OPTIONS --cubical #-}

open import Agda.Builtin.Unit
open import Agda.Builtin.List
open import Agda.Builtin.Cubical.Path 
open import Agda.Builtin.Reflection

test : PathP (λ _  ⊤) tt tt
test = λ where i  tt

macro
  mac : Term  Term  TC _
  mac t _ =
    bindTC (normalise t) λ norm 
    bindTC (unquoteTC norm) λ _ 
    returnTC _

b = mac test

Replacing the PathP by another record removes the internal error as well.

record A : Set₀ where
  constructor mk
  field
    out :record B : Set₀ where
  constructor hi
  field
    bye : A

test : B
test = λ where .B.bye .A.out  tt

[...]

The error does still occur if the order of PathP and record are swapped:

record A : Set₀ where
  constructor mk
  field
    out : PathP (λ _  ⊤) tt tt

test : A
test = λ where .A.out i  tt

[...]

@gallais gallais added the cubical Cubical Agda paraphernalia: Paths, Glue, partial elements, hcomp, transp label Jun 19, 2020
@UlfNorell UlfNorell added this to the 2.6.3 milestone Jan 27, 2021
@plt-amy
Copy link
Member

plt-amy commented Aug 27, 2022

Fascinating! Here's what's going on:

test : PathP (λ _  ⊤) tt tt
test = λ where i  tt

This isn't a pattern-matching lambda, even though it looks like one! It's just a lam, so you can quote/unquote it just fine. This is a pattern-matching lambda:

test₃ : PathP (λ _  ⊤) tt tt
test₃ = λ where
  i  tt
  i  tt

and it also explodes, because Agda can't unquote IApply co/patterns.

@plt-amy plt-amy self-assigned this Aug 27, 2022
@andreasabel andreasabel changed the title Unquote anonymous copattern involving path Cubical Agda: Unquote anonymous copattern involving path Oct 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
copatterns Definitions by copattern matching: projections on the LHS cubical Cubical Agda paraphernalia: Paths, Glue, partial elements, hcomp, transp reflection Elaborator reflection, macros, tactic arguments type: bug Issues and pull requests about actual bugs
Projects
None yet
Development

No branches or pull requests

4 participants