Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0007436OCamltypingpublic2016-12-19 19:212017-02-19 18:20
Assigned To 
StatusresolvedResolutionwon't fix 
PlatformOSOS Version
Product Version4.04.0 
Target VersionFixed in Version 
Summary0007436: "with" constraints and "module type of" not stored compactly in cmi files
DescriptionWhen 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.

[1]: [^]
[2]: [^]
Steps To ReproduceAn easy test case, using tyxml alone (compiled with `ocamlfind ocamlc -package tyxml -c`).

module type Foo =
the cmi file is 622o

module type Foo =
  with type 'a wrap = 'a
the cmi file is 199Ko
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
xleroy (administrator)
2017-02-19 18:20

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

- Issue History
Date Modified Username Field Change
2016-12-19 19:21 drup New Issue
2017-02-19 18:20 xleroy Note Added: 0017351
2017-02-19 18:20 xleroy Severity minor => tweak
2017-02-19 18:20 xleroy Status new => resolved
2017-02-19 18:20 xleroy Resolution open => won't fix
2017-02-23 16:45 doligez Category OCaml typing => typing

Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker