explain the syntax change for variance (by #13820)#14126
Conversation
|
What do you think should be added? @Octachron |
|
is there a definition anywhere in the manual on what bivariance means? (and/or maybe some example?) |
| "+", "-", "+-", or "-+" to indicate that the type constructor has a specific | ||
| variance with respect this parameter. | ||
| A parameter with "+" is covariant, "-" contravariant, | ||
| and "+-" (or "-+") bivariant. |
There was a problem hiding this comment.
We can inline the definition of bivariant here:
A parameter prefixed with "+" is covariant, one prefixed with "-" is contravariant.
A parameter can be both covariant and contravariant, also known as bivariant, with either
a "+-" or "-+" prefix.
|
@t6s, if you don't have the time currently, would you mind if I were to take care of updating the manual? |
|
@Octachron Thank you for the reminder, and sorry for leaving this issue for a long time. I have been about to come back to this issue around Aug 15. If it needs to be hurried, please take it over. |
| '+' | ||
| | '-' | ||
| | '+-' | ||
| | '-+' |
There was a problem hiding this comment.
This could be vertically aligned with the - case.
There was a problem hiding this comment.
Argh, they are TAB characters. I will replace them by spaces in the next commit.
Octachron
left a comment
There was a problem hiding this comment.
The current explanation looks good to me. (Note that we are missing the description in the man pages but I propose to update them in a subsequent PR).
| variance information is used to decide subtyping relations when | ||
| The type variables appearing as type parameters can optionally be prefixed by | ||
| "+", "-", "+-", or "-+" to indicate that the type constructor has a specific | ||
| variance with respect this parameter. |
There was a problem hiding this comment.
"with respect this ..." ⇒ "with respect to this"
#13820 introduced the bivariance indicators (
+-,-+) in the syntax.This PR documents them.