cooltt icon indicating copy to clipboard operation
cooltt copied to clipboard

⌨️ Add `deftype`

Open TOTBWF opened this issue 3 years ago • 5 comments
trafficstars

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.

TOTBWF avatar Jun 06 '22 22:06 TOTBWF

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?

jonsterling avatar Jun 24 '22 13:06 jonsterling

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 𝕀!

TOTBWF avatar Jun 24 '22 17:06 TOTBWF

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

jonsterling avatar Jun 24 '22 17:06 jonsterling

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.

TOTBWF avatar Jun 24 '22 18:06 TOTBWF

Oh I see. I’m ok with it

On Jun 24, 2022, at 2:02 PM, Reed Mullanix @.***> wrote:

 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.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.

jonsterling avatar Oct 11 '22 09:10 jonsterling