eliom
eliom copied to clipboard
Use module aliases for Eliom_content?
I'm wondering whether it would be possible to use module aliases for Eliom_content, in order to avoid loading the interfaces of the three variants F, D and R of the SVG and HTML Tyxml modules when only a few variants are used.
In fact, we have not three but six copies (!) of the Tyxml signature, with the F.Raw, D.Raw and R.Raw submodules...
One issue is that we have the following definition:
module Make(Xml : Xml_sigs.T with type ('a, 'b) W.ft = ('a -> 'b))
: Svg_sigs.Make(Xml).T
with type +'a elt = Xml.elt
and type +'a attrib = Xml.attrib
We want to apply this functor several times, exporting the resulting modules from distinct files, remembering that all the 'a elt are the same, while hiding the fact that they are equal to Xml.elt...
I guess one way to achieve that is to have a file containing a definition type +'a elt = Xml.elt and not export the corresponding cmi file.
Well, if we do not export the cmi file, we no longer have access to the variance information...
As far as I can see, the best we can do is to put the three instantiations F, D and R of the Raw submodules into a same file, with the appropriate interface. But then, we don't save much beside separating Svg from Html: the Raw interfaces are always loaded (as type elt is declared in the same file), the F one is loaded most of the time, and the D one is often loaded as well.
Alternatively, we can just separate Svg and Html, and only export in the Raw submodules the few values that are otherwise overriden.
@Drup, @vasilisp, any comment or idea?
Iirc, the compiler expands the signature in the .cmi only because of the with ... constraints and module type of. If it was a path, only that would be stored. So we don't need to factor out the implementation, just the module type, that should be much easier (since all the interfaces are exactly the same).
This doesn't prevent linking everything, but that's a different problem.
OCaml should probably work a bit harder in this case. Bug report here: https://caml.inria.fr/mantis/view.php?id=7436
@Drup, that's a good point. Modules F.Raw and D.Raw, as well as modules F and D have the same type. This still leaves some duplication though.
Is it not simpler to have Eliom_html instead of Eliom_content.Html?