I once wrote a relatively-small patch for the type-checker that augments the typed AST in such a way that the constructors Texp_let and Tstr_value mention the list of type variables that are universally quantified at the corresponding points.
I wander if anyone thinks that it would be a good idea to integrate this patch into the compiler.
Note: keeping track of where type variables are bound can be useful for source code analysis/transformations/translations. I suspect performance cost to be negligible, yet it would probably make sense to introduce a flag to explicitly request the compiler to keep track of type variables, and preserve the current behavior by default.
In general, if you have some patches to make to the compiler, you can do a pull request on GitHub as a way of showing the patches to the maintainers.
The reason I’m asking the question is that my patch was originally based on a fairly old version of OCaml. What I’m asking is whether is would be useful to invest the time to present a patch based on the current version, or whether nobody would care anyway.
That I can’t tell you, but I can tell you that it seems to be easiest to get a response if you put something in front of the maintainers in the form of a pull request. Sadly I don’t know if the work will be appreciated enough to make the effort to do that worthwhile.
I think a lot of people agree that having the type-level binders explicit in the typedtree would be a good thing. However, given the presence of GADTs and the various more complicated features nowadays, it’s not so easy. I think you should open a question on mantis, where you are more likely to get Jacques’ attention.