From 1197dc11db4e93f0eab7fb8bed8a9fdbcbaeb923 Mon Sep 17 00:00:00 2001 From: geffk2 Date: Wed, 1 May 2024 19:02:56 +0300 Subject: [PATCH] Made naming consistent for Sigma Tuples --- rzk/grammar/Syntax.cf | 8 ++++---- rzk/src/Language/Rzk/Free/Syntax.hs | 8 ++++---- rzk/src/Language/Rzk/Syntax/Abs.hs | 12 ++++++------ rzk/src/Language/Rzk/Syntax/Par.y | 6 +++--- rzk/src/Language/Rzk/Syntax/Print.hs | 4 ++-- rzk/src/Language/Rzk/Syntax/Skel.hs | 4 ++-- rzk/src/Language/Rzk/VSCode/Tokenize.hs | 4 ++-- 7 files changed, 23 insertions(+), 23 deletions(-) diff --git a/rzk/grammar/Syntax.cf b/rzk/grammar/Syntax.cf index 65575599f..14dbd2518 100644 --- a/rzk/grammar/Syntax.cf +++ b/rzk/grammar/Syntax.cf @@ -111,7 +111,7 @@ RecOrDeprecated. Term7 ::= "recOR" "(" Term "," Term "," Term "," Term ")" ; -- Types TypeFun. Term1 ::= ParamDecl "→" Term1 ; TypeSigma. Term1 ::= "Σ" "(" Pattern ":" Term ")" "," Term1 ; -TypeSigmaNested. Term1 ::= "Σ" "(" SigmaParam "," [SigmaParam] ")" "," Term1 ; +TypeSigmaTuple. Term1 ::= "Σ" "(" SigmaParam "," [SigmaParam] ")" "," Term1 ; TypeUnit. Term7 ::= "Unit" ; TypeId. Term1 ::= Term2 "=_{" Term "}" Term2 ; TypeIdSimple. Term1 ::= Term2 "=" Term2 ; @@ -156,7 +156,7 @@ ASCII_TopeOr. Term2 ::= Term3 "\\/" Term2 ; ASCII_TypeFun. Term1 ::= ParamDecl "->" Term1 ; ASCII_TypeSigma. Term1 ::= "Sigma" "(" Pattern ":" Term ")" "," Term1 ; -ASCII_TypeSigmaNested. Term1 ::= "Sigma" "(" SigmaParam "," [SigmaParam] ")" "," Term1 ; +ASCII_TypeSigmaTuple. Term1 ::= "Sigma" "(" SigmaParam "," [SigmaParam] ")" "," Term1 ; ASCII_Lambda. Term1 ::= "\\" [Param] "->" Term1 ; ASCII_Restriction. Restriction ::= Term "|->" Term ; @@ -169,6 +169,6 @@ ASCII_Second. Term6 ::= "second" Term7 ; -- Alternative Unicode syntax rules unicode_TypeSigmaAlt. Term1 ::= "∑" "(" Pattern ":" Term ")" "," Term1 ; -- \sum -unicode_TypeSigmaNestedAlt. Term1 ::= "∑" "(" SigmaParam "," [SigmaParam] ")" "," Term1 ; +unicode_TypeSigmaTupleAlt. Term1 ::= "∑" "(" SigmaParam "," [SigmaParam] ")" "," Term1 ; define unicode_TypeSigmaAlt pat fst snd = TypeSigma pat fst snd ; -define unicode_TypeSigmaNestedAlt par pars t = TypeSigmaNested par pars t ; +define unicode_TypeSigmaTupleAlt par pars t = TypeSigmaTuple par pars t ; diff --git a/rzk/src/Language/Rzk/Free/Syntax.hs b/rzk/src/Language/Rzk/Free/Syntax.hs index de249eeef..ad716ed38 100644 --- a/rzk/src/Language/Rzk/Free/Syntax.hs +++ b/rzk/src/Language/Rzk/Free/Syntax.hs @@ -228,7 +228,7 @@ toTerm bvars = go Rzk.ASCII_TypeFun loc param ret -> go (Rzk.TypeFun loc param ret) Rzk.ASCII_TypeSigma loc pat ty ret -> go (Rzk.TypeSigma loc pat ty ret) - Rzk.ASCII_TypeSigmaNested loc p ps tN -> go (Rzk.TypeSigmaNested loc p ps tN) + Rzk.ASCII_TypeSigmaTuple loc p ps tN -> go (Rzk.TypeSigmaTuple loc p ps tN) Rzk.ASCII_Lambda loc pat ret -> go (Rzk.Lambda loc pat ret) Rzk.ASCII_TypeExtensionDeprecated loc shape type_ -> go (Rzk.TypeExtensionDeprecated loc shape type_) Rzk.ASCII_First loc term -> go (Rzk.First loc term) @@ -288,12 +288,12 @@ 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) + Rzk.TypeSigmaTuple _loc (Rzk.SigmaParam _ patA tA) ((Rzk.SigmaParam _ patB tB) : ps) tN -> + go (Rzk.TypeSigmaTuple _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.TypeSigmaTuple _loc (Rzk.SigmaParam _ pat tA) [] tB -> go (Rzk.TypeSigma _loc pat tA tB) Rzk.Lambda _loc [] body -> go body Rzk.Lambda _loc (Rzk.ParamPattern _ pat : params) body -> diff --git a/rzk/src/Language/Rzk/Syntax/Abs.hs b/rzk/src/Language/Rzk/Syntax/Abs.hs index f50d306b4..57bd7ad0e 100644 --- a/rzk/src/Language/Rzk/Syntax/Abs.hs +++ b/rzk/src/Language/Rzk/Syntax/Abs.hs @@ -124,7 +124,7 @@ data Term' a | RecOrDeprecated a (Term' a) (Term' a) (Term' a) (Term' a) | TypeFun a (ParamDecl' a) (Term' a) | TypeSigma a (Pattern' a) (Term' a) (Term' a) - | TypeSigmaNested a (SigmaParam' a) [SigmaParam' a] (Term' a) + | TypeSigmaTuple a (SigmaParam' a) [SigmaParam' a] (Term' a) | TypeUnit a | TypeId a (Term' a) (Term' a) (Term' a) | TypeIdSimple a (Term' a) (Term' a) @@ -155,7 +155,7 @@ data Term' a | ASCII_TopeOr a (Term' a) (Term' a) | ASCII_TypeFun a (ParamDecl' a) (Term' a) | ASCII_TypeSigma a (Pattern' a) (Term' a) (Term' a) - | ASCII_TypeSigmaNested a (SigmaParam' a) [SigmaParam' a] (Term' a) + | ASCII_TypeSigmaTuple a (SigmaParam' a) [SigmaParam' a] (Term' a) | ASCII_Lambda a [Param' a] (Term' a) | ASCII_TypeExtensionDeprecated a (ParamDecl' a) (Term' a) | ASCII_First a (Term' a) @@ -192,8 +192,8 @@ ascii_CubeProduct = \ _a l r -> CubeProduct _a l r unicode_TypeSigmaAlt :: a -> Pattern' a -> Term' a -> Term' a -> Term' a unicode_TypeSigmaAlt = \ _a pat fst snd -> TypeSigma _a pat fst snd -unicode_TypeSigmaNestedAlt :: a -> SigmaParam' a -> [SigmaParam' a] -> Term' a -> Term' a -unicode_TypeSigmaNestedAlt = \ _a par pars t -> TypeSigmaNested _a par pars t +unicode_TypeSigmaTupleAlt :: a -> SigmaParam' a -> [SigmaParam' a] -> Term' a -> Term' a +unicode_TypeSigmaTupleAlt = \ _a par pars t -> TypeSigmaTuple _a par pars t newtype VarIdentToken = VarIdentToken String deriving (C.Eq, C.Ord, C.Show, C.Read, C.Data, C.Typeable, C.Generic, Data.String.IsString) @@ -312,7 +312,7 @@ instance HasPosition Term where RecOrDeprecated p _ _ _ _ -> p TypeFun p _ _ -> p TypeSigma p _ _ _ -> p - TypeSigmaNested p _ _ _ -> p + TypeSigmaTuple p _ _ _ -> p TypeUnit p -> p TypeId p _ _ _ -> p TypeIdSimple p _ _ -> p @@ -343,7 +343,7 @@ instance HasPosition Term where ASCII_TopeOr p _ _ -> p ASCII_TypeFun p _ _ -> p ASCII_TypeSigma p _ _ _ -> p - ASCII_TypeSigmaNested p _ _ _ -> p + ASCII_TypeSigmaTuple p _ _ _ -> p ASCII_Lambda p _ _ -> p ASCII_TypeExtensionDeprecated p _ _ -> p ASCII_First p _ -> p diff --git a/rzk/src/Language/Rzk/Syntax/Par.y b/rzk/src/Language/Rzk/Syntax/Par.y index 13f0c9d56..9089984c0 100644 --- a/rzk/src/Language/Rzk/Syntax/Par.y +++ b/rzk/src/Language/Rzk/Syntax/Par.y @@ -345,17 +345,17 @@ Term1 :: { (Language.Rzk.Syntax.Abs.BNFC'Position, Language.Rzk.Syntax.Abs.Term) Term1 : ParamDecl '→' Term1 { (fst $1, Language.Rzk.Syntax.Abs.TypeFun (fst $1) (snd $1) (snd $3)) } | 'Σ' '(' Pattern ':' Term ')' ',' Term1 { (uncurry Language.Rzk.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.Rzk.Syntax.Abs.TypeSigma (uncurry Language.Rzk.Syntax.Abs.BNFC'Position (tokenLineCol $1)) (snd $3) (snd $5) (snd $8)) } - | 'Σ' '(' SigmaParam ',' ListSigmaParam ')' ',' Term1 { (uncurry Language.Rzk.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.Rzk.Syntax.Abs.TypeSigmaNested (uncurry Language.Rzk.Syntax.Abs.BNFC'Position (tokenLineCol $1)) (snd $3) (snd $5) (snd $8)) } + | 'Σ' '(' SigmaParam ',' ListSigmaParam ')' ',' Term1 { (uncurry Language.Rzk.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.Rzk.Syntax.Abs.TypeSigmaTuple (uncurry Language.Rzk.Syntax.Abs.BNFC'Position (tokenLineCol $1)) (snd $3) (snd $5) (snd $8)) } | Term2 '=_{' Term '}' Term2 { (fst $1, Language.Rzk.Syntax.Abs.TypeId (fst $1) (snd $1) (snd $3) (snd $5)) } | Term2 '=' Term2 { (fst $1, Language.Rzk.Syntax.Abs.TypeIdSimple (fst $1) (snd $1) (snd $3)) } | '\\' ListParam '→' Term1 { (uncurry Language.Rzk.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.Rzk.Syntax.Abs.Lambda (uncurry Language.Rzk.Syntax.Abs.BNFC'Position (tokenLineCol $1)) (snd $2) (snd $4)) } | Term2 { (fst $1, (snd $1)) } | ParamDecl '->' Term1 { (fst $1, Language.Rzk.Syntax.Abs.ASCII_TypeFun (fst $1) (snd $1) (snd $3)) } | 'Sigma' '(' Pattern ':' Term ')' ',' Term1 { (uncurry Language.Rzk.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.Rzk.Syntax.Abs.ASCII_TypeSigma (uncurry Language.Rzk.Syntax.Abs.BNFC'Position (tokenLineCol $1)) (snd $3) (snd $5) (snd $8)) } - | 'Sigma' '(' SigmaParam ',' ListSigmaParam ')' ',' Term1 { (uncurry Language.Rzk.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.Rzk.Syntax.Abs.ASCII_TypeSigmaNested (uncurry Language.Rzk.Syntax.Abs.BNFC'Position (tokenLineCol $1)) (snd $3) (snd $5) (snd $8)) } + | 'Sigma' '(' SigmaParam ',' ListSigmaParam ')' ',' Term1 { (uncurry Language.Rzk.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.Rzk.Syntax.Abs.ASCII_TypeSigmaTuple (uncurry Language.Rzk.Syntax.Abs.BNFC'Position (tokenLineCol $1)) (snd $3) (snd $5) (snd $8)) } | '\\' ListParam '->' Term1 { (uncurry Language.Rzk.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.Rzk.Syntax.Abs.ASCII_Lambda (uncurry Language.Rzk.Syntax.Abs.BNFC'Position (tokenLineCol $1)) (snd $2) (snd $4)) } | '∑' '(' Pattern ':' Term ')' ',' Term1 { (uncurry Language.Rzk.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.Rzk.Syntax.Abs.unicode_TypeSigmaAlt (uncurry Language.Rzk.Syntax.Abs.BNFC'Position (tokenLineCol $1)) (snd $3) (snd $5) (snd $8)) } - | '∑' '(' SigmaParam ',' ListSigmaParam ')' ',' Term1 { (uncurry Language.Rzk.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.Rzk.Syntax.Abs.unicode_TypeSigmaNestedAlt (uncurry Language.Rzk.Syntax.Abs.BNFC'Position (tokenLineCol $1)) (snd $3) (snd $5) (snd $8)) } + | '∑' '(' SigmaParam ',' ListSigmaParam ')' ',' Term1 { (uncurry Language.Rzk.Syntax.Abs.BNFC'Position (tokenLineCol $1), Language.Rzk.Syntax.Abs.unicode_TypeSigmaTupleAlt (uncurry Language.Rzk.Syntax.Abs.BNFC'Position (tokenLineCol $1)) (snd $3) (snd $5) (snd $8)) } Term6 :: { (Language.Rzk.Syntax.Abs.BNFC'Position, Language.Rzk.Syntax.Abs.Term) } Term6 diff --git a/rzk/src/Language/Rzk/Syntax/Print.hs b/rzk/src/Language/Rzk/Syntax/Print.hs index 80c9463f4..ae973872f 100644 --- a/rzk/src/Language/Rzk/Syntax/Print.hs +++ b/rzk/src/Language/Rzk/Syntax/Print.hs @@ -266,7 +266,7 @@ instance Print (Language.Rzk.Syntax.Abs.Term' a) where Language.Rzk.Syntax.Abs.RecOrDeprecated _ term1 term2 term3 term4 -> prPrec i 7 (concatD [doc (showString "recOR"), doc (showString "("), prt 0 term1, doc (showString ","), prt 0 term2, doc (showString ","), prt 0 term3, doc (showString ","), prt 0 term4, doc (showString ")")]) Language.Rzk.Syntax.Abs.TypeFun _ paramdecl term -> prPrec i 1 (concatD [prt 0 paramdecl, doc (showString "\8594"), prt 1 term]) Language.Rzk.Syntax.Abs.TypeSigma _ pattern_ term1 term2 -> prPrec i 1 (concatD [doc (showString "\931"), doc (showString "("), prt 0 pattern_, doc (showString ":"), prt 0 term1, doc (showString ")"), doc (showString ","), prt 1 term2]) - Language.Rzk.Syntax.Abs.TypeSigmaNested _ sigmaparam sigmaparams term -> prPrec i 1 (concatD [doc (showString "\931"), doc (showString "("), prt 0 sigmaparam, doc (showString ","), prt 0 sigmaparams, doc (showString ")"), doc (showString ","), prt 1 term]) + Language.Rzk.Syntax.Abs.TypeSigmaTuple _ sigmaparam sigmaparams term -> prPrec i 1 (concatD [doc (showString "\931"), doc (showString "("), prt 0 sigmaparam, doc (showString ","), prt 0 sigmaparams, doc (showString ")"), doc (showString ","), prt 1 term]) Language.Rzk.Syntax.Abs.TypeUnit _ -> prPrec i 7 (concatD [doc (showString "Unit")]) Language.Rzk.Syntax.Abs.TypeId _ term1 term2 term3 -> prPrec i 1 (concatD [prt 2 term1, doc (showString "=_{"), prt 0 term2, doc (showString "}"), prt 2 term3]) Language.Rzk.Syntax.Abs.TypeIdSimple _ term1 term2 -> prPrec i 1 (concatD [prt 2 term1, doc (showString "="), prt 2 term2]) @@ -297,7 +297,7 @@ instance Print (Language.Rzk.Syntax.Abs.Term' a) where Language.Rzk.Syntax.Abs.ASCII_TopeOr _ term1 term2 -> prPrec i 2 (concatD [prt 3 term1, doc (showString "\\/"), prt 2 term2]) Language.Rzk.Syntax.Abs.ASCII_TypeFun _ paramdecl term -> prPrec i 1 (concatD [prt 0 paramdecl, doc (showString "->"), prt 1 term]) Language.Rzk.Syntax.Abs.ASCII_TypeSigma _ pattern_ term1 term2 -> prPrec i 1 (concatD [doc (showString "Sigma"), doc (showString "("), prt 0 pattern_, doc (showString ":"), prt 0 term1, doc (showString ")"), doc (showString ","), prt 1 term2]) - Language.Rzk.Syntax.Abs.ASCII_TypeSigmaNested _ sigmaparam sigmaparams term -> prPrec i 1 (concatD [doc (showString "Sigma"), doc (showString "("), prt 0 sigmaparam, doc (showString ","), prt 0 sigmaparams, doc (showString ")"), doc (showString ","), prt 1 term]) + Language.Rzk.Syntax.Abs.ASCII_TypeSigmaTuple _ sigmaparam sigmaparams term -> prPrec i 1 (concatD [doc (showString "Sigma"), doc (showString "("), prt 0 sigmaparam, doc (showString ","), prt 0 sigmaparams, doc (showString ")"), doc (showString ","), prt 1 term]) Language.Rzk.Syntax.Abs.ASCII_Lambda _ params term -> prPrec i 1 (concatD [doc (showString "\\"), prt 0 params, doc (showString "->"), prt 1 term]) Language.Rzk.Syntax.Abs.ASCII_TypeExtensionDeprecated _ paramdecl term -> prPrec i 7 (concatD [doc (showString "<"), prt 0 paramdecl, doc (showString "->"), prt 0 term, doc (showString ">")]) Language.Rzk.Syntax.Abs.ASCII_First _ term -> prPrec i 6 (concatD [doc (showString "first"), prt 7 term]) diff --git a/rzk/src/Language/Rzk/Syntax/Skel.hs b/rzk/src/Language/Rzk/Syntax/Skel.hs index 62647e3e0..fb485cc56 100644 --- a/rzk/src/Language/Rzk/Syntax/Skel.hs +++ b/rzk/src/Language/Rzk/Syntax/Skel.hs @@ -119,7 +119,7 @@ transTerm x = case x of Language.Rzk.Syntax.Abs.RecOrDeprecated _ term1 term2 term3 term4 -> failure x Language.Rzk.Syntax.Abs.TypeFun _ paramdecl term -> failure x Language.Rzk.Syntax.Abs.TypeSigma _ pattern_ term1 term2 -> failure x - Language.Rzk.Syntax.Abs.TypeSigmaNested _ sigmaparam sigmaparams term -> failure x + Language.Rzk.Syntax.Abs.TypeSigmaTuple _ sigmaparam sigmaparams term -> failure x Language.Rzk.Syntax.Abs.TypeUnit _ -> failure x Language.Rzk.Syntax.Abs.TypeId _ term1 term2 term3 -> failure x Language.Rzk.Syntax.Abs.TypeIdSimple _ term1 term2 -> failure x @@ -150,7 +150,7 @@ transTerm x = case x of Language.Rzk.Syntax.Abs.ASCII_TopeOr _ term1 term2 -> failure x Language.Rzk.Syntax.Abs.ASCII_TypeFun _ paramdecl term -> failure x Language.Rzk.Syntax.Abs.ASCII_TypeSigma _ pattern_ term1 term2 -> failure x - Language.Rzk.Syntax.Abs.ASCII_TypeSigmaNested _ sigmaparam sigmaparams term -> failure x + Language.Rzk.Syntax.Abs.ASCII_TypeSigmaTuple _ sigmaparam sigmaparams term -> failure x Language.Rzk.Syntax.Abs.ASCII_Lambda _ params term -> failure x Language.Rzk.Syntax.Abs.ASCII_TypeExtensionDeprecated _ paramdecl term -> failure x Language.Rzk.Syntax.Abs.ASCII_First _ term -> failure x diff --git a/rzk/src/Language/Rzk/VSCode/Tokenize.hs b/rzk/src/Language/Rzk/VSCode/Tokenize.hs index f1138bd62..5de819e4b 100644 --- a/rzk/src/Language/Rzk/VSCode/Tokenize.hs +++ b/rzk/src/Language/Rzk/VSCode/Tokenize.hs @@ -126,11 +126,11 @@ tokenizeTerm' varTokenType = go [ mkToken (VarIdent loc "Sigma") SemanticTokenTypes_Class [SemanticTokenModifiers_DefaultLibrary] , tokenizePattern pat , foldMap go [a, b] ] - TypeSigmaNested loc p ps tN -> concat + TypeSigmaTuple loc p ps tN -> concat [ mkToken (VarIdent loc "∑") SemanticTokenTypes_Class [SemanticTokenModifiers_DefaultLibrary] , foldMap tokenizeSigmaParam (p : ps) , go tN ] - ASCII_TypeSigmaNested loc p ps tN -> concat + ASCII_TypeSigmaTuple loc p ps tN -> concat [ mkToken (VarIdent loc "Sigma") SemanticTokenTypes_Class [SemanticTokenModifiers_DefaultLibrary] , foldMap tokenizeSigmaParam (p : ps) , go tN ]