rescript-lang.org
rescript-lang.org copied to clipboard
Document co / contravariance (`<+a>`, `<-a>`)
This one is definitely an advanced topic.
- What does
+
and-
mean? - What syntax constructs are possible? (type, function, etc.)
- What practical use-cases does it have / Why do we need it?
Things to avoid:
- Complex / too scientific wording
- Too generic examples without practical context
Hints:
- We use a covariant type in
Js.Promise.t
(see it here)
Probably also related to subtyping (#150)
I found that the tour of scala has a great introduction to variance: https://docs.scala-lang.org/tour/variances.html
Flow documentation also has good examples https://flow.org/en/docs/lang/variance/