tyxml
tyxml copied to clipboard
Covariance issues with wrapping
While working with the ppx, I noticed something ... strange.
# let x = Html5.Xml.W.nil () ;;
val x : '_a list = []
# let x : _ list = Html5.Xml.W.nil () ;;
val x : 'a list = []
Apparently, the functor stack hides the covariance, since Xml_wrap.S.tlist
is not marked covariant.
@vasilisp Do you think we could turn it covariant ? Are all the wrapper we have covariants ? Given the heavy use of subtyping, It would seems natural to enforce that.
As a limited fix, only for the native tyxml implementation, I did https://github.com/ocsigen/tyxml/pull/107/commits/85c62cdcdd2448743aa481bbde9f8929a2002781
Unfortunately, I much doubt that we can do it. To begin with, React.S.t
is not marked covariant. Basically all our wrappers use mutation all over the place.
Mantis bug report: http://caml.inria.fr/mantis/view.php?id=7212
@vasilisp That is unfortunate. Remind me to check that mixing variances like that is actually sound (HTML-wise).