tyxml icon indicating copy to clipboard operation
tyxml copied to clipboard

Covariance issues with wrapping

Open Drup opened this issue 8 years ago • 3 comments

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.

Drup avatar Apr 02 '16 18:04 Drup

As a limited fix, only for the native tyxml implementation, I did https://github.com/ocsigen/tyxml/pull/107/commits/85c62cdcdd2448743aa481bbde9f8929a2002781

Drup avatar Apr 02 '16 18:04 Drup

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.

vasilisp avatar Apr 04 '16 11:04 vasilisp

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).

Drup avatar Apr 07 '16 09:04 Drup