Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"with" constraints and "module type of" not stored compactly in cmi files #7436

Closed
vicuna opened this issue Dec 19, 2016 · 1 comment
Closed

Comments

@vicuna
Copy link

vicuna commented Dec 19, 2016

Original bug ID: 7436
Reporter: @Drup
Status: resolved (set by @xavierleroy on 2017-02-19T17:20:44Z)
Resolution: won't fix
Priority: normal
Severity: tweak
Version: 4.04.0
Category: typing
Monitored by: @Drup

Bug description

When encountering a with constraints, signatures are expanded in Types.module_type (indeed, there is no Mty_with ..). Same for "module type of".

This cause issues for libraries with a big API surface that is instantiated several time. Tyxml is such example. In the file 1 which can be found in eliom, the same (big) signature is copied 6 time. The size of the resulting cmi is 2.0Mo. The size is such that it slows compilation notably (See 2).

One solution, which we are probably going to adopt, is to factor the module type out and share it among the various instances. It's possible in this case since most constraints are the same.

It would be nice if the cmi format could be compact in this case, by storing the with constraints.

Steps to reproduce

An easy test case, using tyxml alone (compiled with ocamlfind ocamlc -package tyxml -c foo.ml).

module type Foo =
  Html_sigs.Make(Tyxml.Xml)(Tyxml.Svg).T

the cmi file is 622o

module type Foo =
  Html_sigs.Make(Tyxml.Xml)(Tyxml.Svg).T
  with type 'a wrap = 'a 

the cmi file is 199Ko

@vicuna
Copy link
Author

vicuna commented Feb 19, 2017

Comment author: @xavierleroy

"with" constraints are expanded during elaboration to internal module types, in large part because nobody knows how to work with module types (checking subtyping, etc) if "with" constraints were still there. .cmi files contain those internal module types obtained by elaboration. I have zero hope that the compactness of the "with" notation could be recovered a posteriori before writing .cmi files. So, I'm respectfully going to close this feature wish.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant