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

⌨️ Add deftype #381

Open
TOTBWF opened this issue Jun 6, 2022 · 5 comments
Open

⌨️ Add deftype #381

TOTBWF opened this issue Jun 6, 2022 · 5 comments

Comments

@TOTBWF
Copy link
Collaborator

TOTBWF commented Jun 6, 2022

Motivation

Currently, the only way to define types is via def foo : type := ..., which has some interesting ramifications regarding fibrancy. In particular, we can't define record types with fields of type I -> A, and instead have to resort to some weird hacks like ext i => A with [], which I think we can all agree is suboptimal. We should probably think about adding a way of defining honest-to-god types, rather than only codes.

Proposal

The proposed syntax is as follows

deftype <typename> <cells> := <definition>

The cells would then desugar to a pi type.

We can just inline these during elaboration to avoid having to change the core, but perhaps there's some value in adding these to the core with some unfolding rules.

@jonsterling
Copy link
Collaborator

Hmm, I don't yet see why deftype addresses the way that we can't have records with fields of type I->A. Can you an example?

@TOTBWF
Copy link
Collaborator Author

TOTBWF commented Jun 24, 2022

Consider

def example : type :=
  sig (p : 𝕀 → ℕ)

This will elaborate to a code, which will then require all of the fields of the CodeSignature to also be codes, but there's no code for 𝕀!

@jonsterling
Copy link
Collaborator

What I meant was, can I have an example of how your proposed deftype helps with this?

@TOTBWF
Copy link
Collaborator Author

TOTBWF commented Jun 24, 2022

Sorry, misunderstood your request!

With deftype, we'd elaborate this as a Signature, which should allow us to elaborate the fields as types, which solves the problem.

@jonsterling
Copy link
Collaborator

jonsterling commented Oct 11, 2022 via email

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

2 participants