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

Constructors of the same name confuse Agda #5

Open
aerskine opened this issue Dec 14, 2013 · 6 comments
Open

Constructors of the same name confuse Agda #5

aerskine opened this issue Dec 14, 2013 · 6 comments

Comments

@aerskine
Copy link

I get a lot of confusing yellow highlighting when using HoTT-Agda, which I initially ascribed to inability on my part, but have now reduced to a simple example which has left me just as confused, yet not so assured of my guilt:

https://gist.github.com/aerskine/7962608

When I load this file with Agda 2.3.2.1 the S m == S n term is highlighted yellow, with missing metadata as indicated in the comments.

However, upon commenting out the import statements and replacing with the cut / pasted code from HoTT-Agda the problem vanishes.

@aerskine
Copy link
Author

If anyone is interested, this problem is being caused by the definition of truncation level:

data TLevel : Type₀ where
⟨-2⟩ : TLevel
S : (n : TLevel) → TLevel

The use of S for succ is confusing Agda.

Perhaps consider renaming this S to STLevel or sucT for example... the occasional highlighting errors it causes can be very distracting!

@pthariensflame
Copy link
Contributor

In the meantime, you can use the following instead of open import HoTT to help fix it:

open import HoTT hiding (module TLevel)
open TLevel renaming (S to sucT)

@favonia
Copy link
Contributor

favonia commented Mar 13, 2014

@aerskine Sorry that I wasn't very responsive. One reason is that I am not personally using Emacs mode and was waiting for others. Does this always happen with the constructors with the same name? I thought Agda will fully parse the whole file before highlighting it, which means that this could be an Agda bug. Did I miss something here?

@favonia
Copy link
Contributor

favonia commented May 5, 2016

@aerskine @pthariensflame Hi, I am wondering if newer Agda renders the overloaded constructors correctly. Personally I am not using Emacs so I need feedback from you. Thanks.

@mikeshulman
Copy link
Contributor

I'm using Emacs and I just tried out the sample linked to in the report and see the same behavior with Agda 2.5.1.1.

Commenting out the imports and replacing them with the commented lines doesn't work though; it complains "Duplicate binding for built-in thing LEVEL, previous binding to .Agda.Primitive.Level"

@favonia
Copy link
Contributor

favonia commented May 11, 2017

I feel this issue is lingering for too long so I installed Emacs for myself to see what is going on. This is not about highlighting at all---the code simply fails to compile because Agda is unable to resolve S n by just looking at the type of n; it has to know the entire expression S n is a natural number first. Therefore, the real issue is whether we want constructors of the same name.

@mikeshulman The error message is due to a recent change in Agda. Here is a self-contained fragment that exposes the issue.

data _==_ {A : Set} (a : A) : A  Set where
  idp : a == a

data  : Set where
  O :S : (n : ℕ) data TLevel : Set where
  ⟨-2⟩ : TLevel
  S : (n : TLevel)  TLevel

S= : {m n : ℕ}  m == n  S m == S n
S= idp = idp

@favonia favonia changed the title Confusing syntax highlighting using the HoTT-Agda Nat type Constructors of the same name confuse Agda May 11, 2017
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

4 participants