Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Resolution of constructor names #402

Open
favonia opened this issue Oct 16, 2018 · 2 comments
Open

Resolution of constructor names #402

favonia opened this issue Oct 16, 2018 · 2 comments

Comments

@favonia
Copy link
Collaborator

favonia commented Oct 16, 2018

Proposal

NameRes should associate each constructor name to a list of {datatype : Name.t; clbl : string} which represents all possible interpretations. This will automatically support renaming, namespaces, shadowing, etc., correctly. A type checker should first consult the name resolver and then use typing information to disambiguate overloaded constructors if needed.

favonia: I think the following example should be forbidden due to self-shadowing:

data tt where tt

Spec of shadowing

These should work:

data bool where tt | ff
def tt : bool = ff
def x : [i] bool [i=0 -> tt | i=1 -> ff] = refl
data bool where tt | ff
def mybool : type = bool
def bool : type^1 = type
def x : mybool = tt

These should not work:

data bool where tt | ff
def tt : type^1 = type
data unit where tt
def x : bool = tt

These I do not know:

data bool where tt | ff
data tt where tt
def x : bool = tt

Thoughts? @ecavallo @jonsterling @cangiuli

@favonia favonia changed the title specification of shadowing Specification of shadowing Oct 17, 2018
@favonia favonia changed the title Specification of shadowing Specification of shadowing of constructors Nov 2, 2018
@favonia favonia changed the title Specification of shadowing of constructors Resolution of constructor names Nov 9, 2018
@clayrat
Copy link
Contributor

clayrat commented Nov 9, 2018

This also comes up when defining something like:

def prop/unit (A : type) (A/prop : is-prop A) (x0 : A) : equiv A unit = 
  iso→equiv A unit (λ _ → ★, λ _ → x0, unit/prop ★, A/prop x0)

def foo (A : type) (A/prop : is-prop A) (a : A) (i : 𝕀) : 
  ua A unit (prop/unit A A/prop a) i = 
  let uu : unit = ★ in `(vin i a uu)

Would be nice if the last line could be written directly as

`(vin i a ★)

@favonia
Copy link
Collaborator Author

favonia commented Nov 9, 2018

Would be nice if the last line could be written directly as

`(vin i a ★)

This would be possible if the name resolver can confirm that ★ is a constructor used by only one data type. @jonsterling I wonder if you have anything to say?

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

No branches or pull requests

2 participants