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 syntax sugar for nested sigma-types #183

Merged
merged 8 commits into from
May 2, 2024

Conversation

geffk2
Copy link
Collaborator

@geffk2 geffk2 commented Apr 19, 2024

Closes #140.
Implemented syntax sugar allowing Sigma-types to accept more than one parameter in the parentheses with Rzk.TypeSigmaNested.
It will always desugar to left-associativity, i.e:

  • Σ (a : A , b : B) , C a b desugars to Σ ( ( a , b) : Σ (a : A) , B) , C a b
  • Σ ( a : A , b : B , c : C) , D a b c desugars roughly to Σ ((x , c) : Σ ((a , b) : Σ (a : A) , B) , C) , D (first x) (second x) c

@geffk2 geffk2 linked an issue Apr 19, 2024 that may be closed by this pull request
@geffk2
Copy link
Collaborator Author

geffk2 commented Apr 19, 2024

The sigma type part seems to work, tested with the following:

#lang rzk-1

#define test1
  ( A B : U)
  ( C : A → B → U)
  : ( Σ ( ( a , b) : Σ (a : A) , B) , C a b) = (Σ (a : A , b : B) , C a b)
  := refl

#define test2
  ( A B C : U)
  ( D : A → B → C → U)
  : ( Σ ( a : A , b : B , c : C) , D a b c) = (Σ ((x , c) : Σ ((a , b) : Σ (a : A) , B) , C) , D (first x) (second x) c)
  := refl

Not sure how to proceed with patterns, as adding syntax rules would either break existing stuff or warrant changes to semantic highlighting(I might be misunderstanding how it works).

@geffk2
Copy link
Collaborator Author

geffk2 commented Apr 19, 2024

What are we calling those by the way? Not sure if "nested sigma types" is quite correct

rzk/grammar/Syntax.cf Outdated Show resolved Hide resolved
@@ -78,6 +78,10 @@ ParamVarShapeDeprecated. ParamDecl ::= "{" "(" Pattern ":" Term ")" "|" Term "}"
paramVarShapeDeprecated. ParamDecl ::= "{" Pattern ":" Term "|" Term "}" ;
define paramVarShapeDeprecated pat cube tope = ParamVarShapeDeprecated pat cube tope ;

-- Parameter declaration for Sigma types
SigmaParam. SigmaParam ::= Pattern ":" Term ;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally, I would like to reuse Param, but I think this should be a separate change, since Param allows shapes and we do not support shape types yet (see #50).

@fizruk
Copy link
Member

fizruk commented Apr 19, 2024

What are we calling those by the way? Not sure if "nested sigma types" is quite correct

Perhaps, Σ-tuples?

@fizruk
Copy link
Member

fizruk commented Apr 19, 2024

Not sure how to proceed with patterns

Here's a sketch: d8302a5

@fizruk fizruk marked this pull request as ready for review May 2, 2024 07:24
@fizruk fizruk merged commit 7a78f52 into rzk-lang:develop May 2, 2024
1 of 4 checks passed
@fizruk fizruk mentioned this pull request Aug 17, 2024
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

Successfully merging this pull request may close these issues.

Syntax sugar for nested Sigma types
2 participants