Skip to content

Commit

Permalink
Implemented syntactic sugar for nested sigma types
Browse files Browse the repository at this point in the history
  • Loading branch information
geffk2 committed Apr 19, 2024
1 parent 82d3b3f commit f378bca
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 0 deletions.
5 changes: 5 additions & 0 deletions rzk/grammar/Syntax.cf
Original file line number Diff line number Diff line change
Expand Up @@ -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 ;
separator nonempty SigmaParam "," ;
Restriction. Restriction ::= Term "" Term ;
separator nonempty Restriction "," ;
Expand Down Expand Up @@ -106,6 +110,7 @@ RecOrDeprecated. Term7 ::= "recOR" "(" Term "," Term "," Term "," Term ")" ;
-- Types
TypeFun. Term1 ::= ParamDecl "" Term1 ;
TypeSigma. Term1 ::= "Σ" "(" Pattern ":" Term ")" "," Term1 ;
TypeSigmaNested. Term1 ::= "Σ" "(" [SigmaParam] ")" "," Term1 ;
TypeUnit. Term7 ::= "Unit" ;
TypeId. Term1 ::= Term2 "=_{" Term "}" Term2 ;
TypeIdSimple. Term1 ::= Term2 "=" Term2 ;
Expand Down
8 changes: 8 additions & 0 deletions rzk/src/Language/Rzk/Free/Syntax.hs
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,14 @@ toTerm bvars = go
Rzk.TypeSigma _loc pat tA tB ->
TypeSigma (patternVar pat) (go tA) (toScopePattern pat bvars tB)

Rzk.TypeSigmaNested _loc ((Rzk.SigmaParam _ patA tA) : (Rzk.SigmaParam _ patB tB) : ps) tN ->
go (Rzk.TypeSigmaNested _loc ((Rzk.SigmaParam _loc patX tX) : ps) tN)
where
patX = Rzk.PatternPair _loc patA patB
tX = Rzk.TypeSigma _loc patA tA tB
Rzk.TypeSigmaNested _loc [Rzk.SigmaParam _ pat tA] tB -> go (Rzk.TypeSigma _loc pat tA tB)
Rzk.TypeSigmaNested _loc [] tN -> (go tN)

Rzk.Lambda _loc [] body -> go body
Rzk.Lambda _loc (Rzk.ParamPattern _ pat : params) body ->
Lambda (patternVar pat) Nothing (toScopePattern pat bvars (Rzk.Lambda _loc params body))
Expand Down
10 changes: 10 additions & 0 deletions rzk/src/Language/Rzk/Syntax/Abs.hs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions rzk/src/Language/Rzk/Syntax/Doc.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions rzk/src/Language/Rzk/Syntax/Par.y

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions rzk/src/Language/Rzk/Syntax/Print.hs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions rzk/src/Language/Rzk/Syntax/Skel.hs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f378bca

Please sign in to comment.