Skip to content

Commit

Permalink
Add variance indicator to type variables.
Browse files Browse the repository at this point in the history
Just the grammar, no interpretation yet.
  • Loading branch information
skaller committed Jul 19, 2022
1 parent 4e13dab commit 69759f8
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/packages/grammar.fdoc
Original file line number Diff line number Diff line change
Expand Up @@ -4766,12 +4766,17 @@ syntax statements {
//$ No constraint!
seqorin:= sepsilon =># "'NoConstraint";

// variance spec: + covariant, - contravariant, nothing: invariant
svariance := "+" =># "'covariant";
svariance := "-" =># "'contravariant";
svariance := sepsilon =># "'invariant";

//$ A type variable, possibly with an individual constraint.
stvar := sname seqorin =># """`(,_1 (knd_name "TYPE") ,_2)""";
stvar := svariance sname seqorin =># """`(,_2 (knd_name "TYPE") ,_3 ,_1)""";

//$ A type variable with an individual constraint.
//$ This is usually the same as a predicate.
stvar := sname ":" skindexpr seqorin =># "`(,_1 ,_3 ,_4)";
stvar := svariance sname ":" skindexpr seqorin =># "`(,_2 ,_4 ,_5 ,_1)";

//$ A list of type variables with optional individual constraints.
stvar_comma_list := stvar ("," stvar)* =># "(cons _1 (map second _2))";
Expand Down

0 comments on commit 69759f8

Please sign in to comment.