@@ -291,6 +291,9 @@ Pragmas
291
291
> '{-# COMPLETE' { Loc $$ COMPLETE }
292
292
> '#- }' { Loc $$ PragmaEnd } -- 139
293
293
294
+ Utility
295
+
296
+ > NEVER { Loc $$@SrcSpan{srcSpanStartLine= -1 } _ } -- never-matching terminal of type SrcSpan
294
297
295
298
> %monad { P }
296
299
> %lexer { lexer } { Loc _ EOF }
@@ -941,57 +944,70 @@ Type equality contraints need the TypeFamilies extension.
941
944
> : dtype {% checkType $1 }
942
945
943
946
> dtype :: { PType L }
944
- > : btype { splitTilde $1 }
945
- > | btype qtyconop dtype { TyInfix ($1 <> $3 ) $1 $2 $3 }
946
- > | btype qtyvarop dtype { TyInfix ($1 <> $3 ) $1 (UnpromotedName (ann $2 ) $2 ) $3 } -- FIXME
947
- > | btype '->' ctype { TyFun ($1 <> $3 <** [$2 ]) (splitTilde $1 ) $3 }
948
- | btype '~' btype {% do { checkEnabledOneOf [TypeFamilies, GADTs] ;
949
- let {l = $1 <> $3 <** [$2 ]};
950
- return $ TyPred l $ EqualP l $1 $3 } }
947
+ > : dtype_('*',NEVER) { $1 }
948
+
949
+ > dtype_(ostar,kstar) :: { PType L }
950
+ > : btype_(ostar,kstar) { splitTilde $1 }
951
+ > | btype_(ostar,kstar) qtyconop dtype_(ostar,kstar) { TyInfix ($1 <> $3 ) $1 $2 $3 }
952
+ > | btype_(ostar,kstar) qtyvarop_(ostar) dtype_(ostar,kstar) { TyInfix ($1 <> $3 ) $1 (UnpromotedName (ann $2 ) $2 ) $3 } -- FIXME
953
+ > | btype_(ostar,kstar) '->' ctype_(ostar,kstar) { TyFun ($1 <> $3 <** [$2 ]) (splitTilde $1 ) $3 }
954
+ | btype_(ostar,kstar) '~' btype_(ostar,kstar) {% do { checkEnabledOneOf [TypeFamilies, GADTs] ;
955
+ let {l = $1 <> $3 <** [$2 ]};
956
+ return $ TyPred l $ EqualP l $1 $3 } }
951
957
952
958
Implicit parameters can occur in normal types, as well as in contexts.
953
959
954
960
> truetype :: { Type L }
955
961
> : type {% checkType $1 }
956
962
957
963
> type :: { PType L }
958
- > : ivar '::' dtype { let l = ($1 <> $3 <** [$2 ]) in TyPred l $ IParam l $1 $3 }
959
- > | dtype { $1 }
964
+ > : type_('*',NEVER) { $1 }
965
+
966
+ > type_(ostar,kstar) :: { PType L }
967
+ > : ivar '::' dtype_(ostar,kstar) { let l = ($1 <> $3 <** [$2 ]) in TyPred l $ IParam l $1 $3 }
968
+ > | dtype_(ostar,kstar) { $1 }
960
969
961
970
> truebtype :: { Type L }
962
971
> : btype {% checkType (splitTilde $1 ) }
963
972
> trueatype :: { Type L }
964
973
> : atype {% checkType $1 }
965
974
966
975
> btype :: { PType L }
967
- > : btype atype { TyApp ($1 <> $2 ) $1 $2 }
968
- > | atype { $1 }
976
+ > : btype_('*',NEVER) { $1 }
977
+
978
+ > btype_(ostar,kstar) :: { PType L }
979
+ > : btype_(ostar,kstar) atype_(ostar,kstar) { TyApp ($1 <> $2 ) $1 $2 }
980
+ > | atype_(ostar,kstar) { $1 }
969
981
970
982
UnboxedTuples requires the extension, but that will be handled through
971
983
the (# and #) lexemes. Kinds will be handled at the kind rule.
972
984
973
985
> atype :: { PType L }
974
- > : gtycon { TyCon (ann $1 ) $1 }
986
+ > : atype_('*',NEVER) { $1 }
987
+
988
+ > atype_(ostar,kstar) :: { PType L }
989
+ > : kstar { TyStar (nIS $1 ) }
990
+ > | gtycon_(ostar) { TyCon (ann $1 ) $1 }
975
991
> | tyvar {% checkTyVar $1 }
976
992
> | strict_mark atype { let (mstrict, mupack) = $1
977
993
> in bangType mstrict mupack $2 }
978
- > | '(' types ')' { TyTuple ($1 <^^> $3 <** ($1 :reverse ($3 :snd $2 ))) Boxed (reverse (fst $2 )) }
979
- > | '(#' types_bars2 '#)' { TyUnboxedSum ($1 <^^> $3 <** ($1 : reverse ($3 : snd $2 ))) (reverse (fst $2 )) }
980
- > | '(#' types1 '#)' { TyTuple ($1 <^^> $3 <** ($1 :reverse ($3 :snd $2 ))) Unboxed (reverse (fst $2 )) }
981
- > | '[' type ']' { TyList ($1 <^^> $3 <** [$1 ,$3 ]) $2 }
982
- > | '[:' type ':]' { TyParArray ($1 <^^> $3 <** [$1 ,$3 ]) $2 }
983
- > | '(' ctype ')' { TyParen ($1 <^^> $3 <** [$1 ,$3 ]) $2 }
984
- > | '(' ctype '::' kind ')' { TyKind ($1 <^^> $5 <** [$1 ,$3 ,$5 ]) $2 $4 }
994
+ > | '(' types_(ostar,kstar) ')' { TyTuple ($1 <^^> $3 <** ($1 :reverse ($3 :snd $2 ))) Boxed (reverse (fst $2 )) }
995
+ > | '(#' types_bars2(ostar,kstar) '#)' { TyUnboxedSum ($1 <^^> $3 <** ($1 : reverse ($3 : snd $2 ))) (reverse (fst $2 )) }
996
+ > | '(#' types1_(ostar,kstar) '#)' { TyTuple ($1 <^^> $3 <** ($1 :reverse ($3 :snd $2 ))) Unboxed (reverse (fst $2 )) }
997
+ > | '[' type_(ostar,kstar) ']' { TyList ($1 <^^> $3 <** [$1 ,$3 ]) $2 }
998
+ > | '[:' type_(ostar,kstar) ':]' { TyParArray ($1 <^^> $3 <** [$1 ,$3 ]) $2 }
999
+ > | '(' ctype_(ostar,kstar) ')' { TyParen ($1 <^^> $3 <** [$1 ,$3 ]) $2 }
1000
+ > | '(' ctype_(ostar,kstar) '::' kind ')' { TyKind ($1 <^^> $5 <** [$1 ,$3 ,$5 ]) $2 $4 }
985
1001
> | '$(' trueexp ')' { let l = ($1 <^^> $3 <** [$1 ,$3 ]) in TySplice l $ ParenSplice l $2 }
986
1002
> | IDSPLICE { let Loc l (THIdEscape s) = $1 in TySplice (nIS l) $ IdSplice (nIS l) s }
987
1003
> | '_' { TyWildCard (nIS $1 ) Nothing }
988
1004
> | QUASIQUOTE { let Loc l (THQuasiQuote (n,q)) = $1 in TyQuasiQuote (nIS l) n q }
989
- > | ptype { % checkEnabled DataKinds >> return (TyPromoted (ann $1 ) $1 ) }
1005
+ > | ptype_(ostar,kstar) { % checkEnabled DataKinds >> return (TyPromoted (ann $1 ) $1 ) }
990
1006
991
- > ptype :: { Promoted L }
992
- > : VARQUOTE gcon_nolist {% fmap (PromotedCon (nIS $1 <++> ann $2 <** [$1 ]) True) (pexprToQName $2 ) }
993
- > | VARQUOTE '[' types1 ']' {% PromotedList ($1 <^^> $4 <** ($1 :reverse($4 :snd $3 ))) True . reverse <\$> mapM checkType (fst $3 ) }
994
- > | '[' types ']' {% PromotedList ($1 <^^> $3 <** ($1 :reverse($3 :snd $2 ))) False . reverse <\$> mapM checkType (fst $2 ) }
1007
+ > ptype_(ostar,kstar) :: { Promoted L }
1008
+ > : VARQUOTE gcon_nolist {% fmap (PromotedCon (nIS $1 <++> ann $2 <** [$1 ]) True) (pexprToQName $2 ) }
1009
+ > | VARQUOTE '[' types1_(ostar,kstar) ']' {% PromotedList ($1 <^^> $4 <** ($1 :reverse($4 :snd $3 ))) True . reverse <\$> mapM checkType (fst $3 ) }
1010
+ > | '[' types_(ostar,kstar) ']' {% PromotedList ($1 <^^> $3 <** ($1 :reverse($3 :snd $2 ))) False . reverse <\$> mapM checkType (fst $2 ) }
995
1011
> | VARQUOTE '[' ']' { PromotedList ($1 <^^> $3 <** [$1 , $3 ]) True [] }
996
1012
| '[' ']' {% PromotedList ($1 <^^> $2 <** [$1 , $2 ]) False [] }
997
1013
> | VARQUOTE '(' types1 ')' {% PromotedTuple ($1 <^^> $4 <** ($1 :reverse($4 :snd $3 ))) . reverse <\$> mapM checkType (fst $3 ) }
@@ -1014,7 +1030,10 @@ the (# and #) lexemes. Kinds will be handled at the kind rule.
1014
1030
1015
1031
1016
1032
> gtycon :: { QName L }
1017
- > : otycon { $1 }
1033
+ > : gtycon_('*') { $1 }
1034
+
1035
+ > gtycon_(ostar) :: { QName L }
1036
+ > : otycon_(ostar) { $1 }
1018
1037
> | '(' ')' { unit_tycon_name ($1 <^^> $2 <** [$1 ,$2 ]) }
1019
1038
> | '(' '->' ')' { fun_tycon_name ($1 <^^> $3 <** [$1 ,$2 ,$3 ]) }
1020
1039
> | '[' ']' { list_tycon_name ($1 <^^> $2 <** [$1 ,$2 ]) }
@@ -1023,9 +1042,12 @@ the (# and #) lexemes. Kinds will be handled at the kind rule.
1023
1042
> | '(#' commas '#)' { tuple_tycon_name ($1 <^^> $3 <** ($1 :reverse $2 ++ [$3 ])) Unboxed (length $2 ) }
1024
1043
1025
1044
> otycon :: { QName L }
1045
+ > : otycon_('*') { $1 }
1046
+
1047
+ > otycon_(ostar) :: { QName L }
1026
1048
> : qconid { $1 }
1027
1049
> | '(' gconsym ')' { updateQNameLoc ($1 <^^> $3 <** [$1 , srcInfoSpan (ann $2 ), $3 ]) $2 }
1028
- > | '(' qvarsym ')' { updateQNameLoc ($1 <^^> $3 <** [$1 , srcInfoSpan (ann $2 ), $3 ]) $2 }
1050
+ > | '(' qvarsym_(ostar) ')' { updateQNameLoc ($1 <^^> $3 <** [$1 , srcInfoSpan (ann $2 ), $3 ]) $2 }
1029
1051
1030
1052
These are for infix types
1031
1053
@@ -1051,25 +1073,37 @@ is any of the keyword-enabling ones, except ExistentialQuantification.
1051
1073
> : ctype {% checkType $1 }
1052
1074
1053
1075
> ctype :: { PType L }
1054
- > : 'forall' ktyvars '.' ctype { mkTyForall (nIS $1 <++> ann $4 <** [$1 ,$3 ]) (Just (reverse (fst $2 ))) Nothing $4 }
1055
- > | context ctype { mkTyForall ($1 <> $2 ) Nothing (Just $1 ) $2 }
1056
- > | type { $1 }
1076
+ > : ctype_('*',NEVER) { $1 }
1077
+
1078
+ > ctype_(ostar,kstar) :: { PType L }
1079
+ > : 'forall' ktyvars '.' ctype_(ostar,kstar) { mkTyForall (nIS $1 <++> ann $4 <** [$1 ,$3 ]) (Just (reverse (fst $2 ))) Nothing $4 }
1080
+ > | context_(ostar,kstar) ctype_(ostar,kstar) { mkTyForall ($1 <> $2 ) Nothing (Just $1 ) $2 }
1081
+ > | type_(ostar,kstar) { $1 }
1057
1082
1058
1083
Equality constraints require the TypeFamilies extension.
1059
1084
1060
1085
> context :: { PContext L }
1061
- > : btype '=>' {% checkPContext $ (amap (\l -> l <++> nIS $2 <** (srcInfoPoints l ++ [$2 ]))) (splitTilde $1 ) }
1086
+ > : context_('*',NEVER) { $1 }
1087
+
1088
+ > context_(ostar,kstar) :: { PContext L }
1089
+ > : btype_(ostar,kstar) '=>' {% checkPContext $ (amap (\l -> l <++> nIS $2 <** (srcInfoPoints l ++ [$2 ]))) (splitTilde $1 ) }
1062
1090
1063
1091
> types :: { ([PType L],[S]) }
1064
- > : types1 ',' ctype { ($3 : fst $1 , $2 : snd $1 ) }
1092
+ > : types_('*',NEVER) { $1 }
1093
+
1094
+ > types_(ostar,kstar) :: { ([PType L],[S]) }
1095
+ > : types1_(ostar,kstar) ',' ctype_(ostar,kstar) { ($3 : fst $1 , $2 : snd $1 ) }
1065
1096
1066
1097
> types1 :: { ([PType L],[S]) }
1067
- > : ctype { ([$1 ],[]) }
1068
- > | types1 ',' ctype { ($3 : fst $1 , $2 : snd $1 ) }
1098
+ > : types1_('*',NEVER) { $1 }
1069
1099
1070
- > types_bars2 :: { ([PType L],[S]) }
1071
- > : ctype '|' ctype { ([$3 , $1 ], [$2 ]) }
1072
- > | types_bars2 '|' ctype { ($3 : fst $1 , $2 : snd $1 ) }
1100
+ > types1_(ostar,kstar) :: { ([PType L],[S]) }
1101
+ > : ctype_(ostar,kstar) { ([$1 ],[]) }
1102
+ > | types1_(ostar,kstar) ',' ctype_(ostar,kstar) { ($3 : fst $1 , $2 : snd $1 ) }
1103
+
1104
+ > types_bars2(ostar,kstar) :: { ([PType L],[S]) }
1105
+ > : ctype_(ostar,kstar) '|' ctype_(ostar,kstar) { ([$3 , $1 ], [$2 ]) }
1106
+ > | types_bars2(ostar,kstar) '|' ctype_(ostar,kstar) { ($3 : fst $1 , $2 : snd $1 ) }
1073
1107
1074
1108
> ktyvars :: { ([TyVarBind L],Maybe L) }
1075
1109
> : ktyvars ktyvar { ($2 : fst $1 , Just (snd $1 <?+> ann $2 )) }
@@ -1210,32 +1244,7 @@ Kinds
1210
1244
> : kind1 {% checkEnabled KindSignatures >> return $1 }
1211
1245
1212
1246
> kind1 :: { Kind L }
1213
- > : bkind { $1 }
1214
- > | bkind '->' kind1 { KindFn ($1 <> $3 <** [$2 ]) $1 $3 }
1215
-
1216
- > bkind :: { Kind L }
1217
- > : akind { $1 }
1218
- > | bkind akind { KindApp ($1 <> $2 ) $1 $2 }
1219
-
1220
- > akind :: { Kind L }
1221
- > : '*' { KindStar (nIS $1 ) }
1222
- > | '(' kind1 ')' { KindParen ($1 <^^> $3 <** [$1 ,$3 ]) $2 }
1223
- > | pkind {% checkKind $1 >> return $1 }
1224
- > | qvarid {% checkEnabled PolyKinds >> return (KindVar (ann $1 ) $1 ) }
1225
-
1226
- KindParen covers 1 -tuples, KindVar l while KindTuple is for pairs
1227
-
1228
- > pkind :: { Kind L }
1229
- > : qtyconorcls { KindVar (ann $1 ) $1 }
1230
- > | '(' ')' { let l = $1 <^^> $2 in KindVar l (unit_tycon_name l) }
1231
- > | '(' kind ',' comma_kinds1 ')'
1232
- > { KindTuple ($1 <^^> $5 <** ($1 :$3 :reverse ($5 :snd $4 ))) ($2 :reverse (fst $4 )) }
1233
- > | '[' kind ']' { KindList (($1 <^^> $3 ) <** [$1 , $3 ]) $2 }
1234
-
1235
- > comma_kinds1 :: { ([Kind L], [S]) }
1236
- > : kind1 { ([$1 ], []) }
1237
- > | kind1 ',' comma_kinds1 { ($1 : (fst $3 ), $2 : (snd $3 )) }
1238
-
1247
+ > : dtype_(NEVER,'*') {% checkType $1 }
1239
1248
1240
1249
> optkind :: { (Maybe (Kind L), [S]) }
1241
1250
> : {-empty-} { (Nothing,[]) }
@@ -2002,22 +2011,31 @@ Implicit parameter
2002
2011
> : CONSYM { let Loc l (ConSym c) = $1 in Symbol (nIS l) c }
2003
2012
2004
2013
> qvarsym :: { QName L }
2005
- > : varsym { UnQual (ann $1 ) $1 }
2014
+ > : qvarsym_('*') { $1 }
2015
+
2016
+ > qvarsym_(ostar) :: { QName L }
2017
+ > : varsym_(ostar) { UnQual (ann $1 ) $1 }
2006
2018
> | qvarsym1 { $1 }
2007
2019
2008
2020
> qvarsymm :: { QName L }
2009
2021
> : varsymm { UnQual (ann $1 ) $1 }
2010
2022
> | qvarsym1 { $1 }
2011
2023
2012
2024
> varsym :: { Name L }
2013
- > : varsymm { $1 }
2025
+ > : varsym_('*') { $1 }
2026
+
2027
+ > varsym_(ostar) :: { Name L }
2028
+ > : varsymm_(ostar) { $1 }
2014
2029
> | '-' { minus_name (nIS $1 ) }
2015
2030
2016
- > varsymm :: { Name L } -- varsym not including '-'
2031
+ > varsymm :: { Name L }
2032
+ > : varsymm_('*') { $1 }
2033
+
2034
+ > varsymm_(ostar) :: { Name L } -- varsym not including '-'
2017
2035
> : VARSYM { let Loc l (VarSym v) = $1 in Symbol (nIS l) v }
2018
2036
> | '!' { bang_name (nIS $1 ) }
2019
2037
> | '.' { dot_name (nIS $1 ) }
2020
- > | '*' { star_name (nIS $1 ) }
2038
+ > | ostar { star_name (nIS $1 ) }
2021
2039
2022
2040
> qvarsym1 :: { QName L }
2023
2041
> : QVARSYM { let {Loc l (QVarSym q) = $1 ; nis = nIS l} in Qual nis (ModuleName nis (fst q)) (Symbol nis (snd q)) }
@@ -2155,14 +2173,14 @@ Miscellaneous (mostly renamings)
2155
2173
| 'forall' { forall_name (nIS $1 ) }
2156
2174
| 'family' { family_name (nIS $1 ) }
2157
2175
2158
- > qtyvarop :: { QName L }
2159
- > qtyvarop : '`' tyvar '`' { UnQual ($1 <^^> $3 <** [$1 , srcInfoSpan (ann $2 ), $3 ]) $2 }
2160
- > | tyvarsym { UnQual (ann $1 ) $1 }
2176
+ > qtyvarop_(ostar) :: { QName L }
2177
+ > qtyvarop_ : '`' tyvar '`' { UnQual ($1 <^^> $3 <** [$1 , srcInfoSpan (ann $2 ), $3 ]) $2 }
2178
+ > | tyvarsym_(ostar) { UnQual (ann $1 ) $1 }
2161
2179
2162
- > tyvarsym :: { Name L }
2180
+ > tyvarsym_(ostar) :: { Name L }
2163
2181
> tyvarsym : VARSYM { let Loc l (VarSym x) = $1 in Symbol (nIS l) x }
2164
2182
> | '-' { Symbol (nIS $1 ) " -" }
2165
- > | '*' { Symbol (nIS $1 ) " *" }
2183
+ > | ostar { Symbol (nIS $1 ) " *" }
2166
2184
2167
2185
> impdeclsblock :: { ([ImportDecl L],[S],L) }
2168
2186
> : '{' optsemis impdecls optsemis '}' { let (ids, ss) = $3 in (ids, $1 : reverse $2 ++ ss ++ reverse $4 ++ [$5 ], $1 <^^> $5 ) }
0 commit comments