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
Expose module signature when typing implementation #10007
Conversation
While working on a new backend for OCaml to generate Erlang sources, I found the need to read the .cmi file back into a `Types.signature` value. @Drup spotted that I was reading the file and pointed out this value was already being read during the type checking process. A quick check at the `Typedtree.module_coercion` showed us that it would be difficul to extract the same information that is readily available in the signature value. This change will expose the signature value directly, so other backends relying on this signature information do not need to do the extra work of reading it again.
Naive questions:
|
In this case I just went for the smallest change, but I'd be happy to introduce a record like: type typed_impl = {
structure: Typedtree.structure;
coercion: Typedtree.module_coercion;
signature: Types.signature
} What do you think? |
I think that this would be better than the current PR, yes. It doesn't really answer my question about why we want to pass the signature to the later passes (maybe because it makes sense that they could use it?), but at least it makes it completely transparent/implicit in a pleasing way. While we are at it: I would prefer it the signature was defined and documented before the coercion, as the explanation of the coercion mentions the signature. |
@gasche Regarding your question about passing the signature to the later passes: it doesn't make sense right now for the existing later passes in the backends here. So I've deferred to pattern-matching on the record and reconstructing the tuple of values they actually use. |
After trying to use a record defined in Name is still up for discussion, just let me know what you think :) |
I think that the field names are natural and they work well. I initially expected the record to be defined in |
No change entry needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the new Typedtree.implementation
type. I see no other information to propagate right now, but it'll be useful if we ever need to, which is nice. Just need a bit of documenting and this will be good to go.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is a stamp of approval: this is good to go once we have converged on the documentation. Thanks for your contribution.
It seems I missed the deadline 😅 -- nevermind this! |
This is not a bugfix, thus it can wait for the next release. |
Merged, thanks! (I forgot to squash, so the history is a bit messier, but oh well.) |
While working on a new backend for OCaml to generate Erlang sources, I
found the need to read the .cmi file back into a
Types.signature
value.
@Drup spotted that I was reading the file and pointed out this value was
already being read during the type checking process.
A quick check at the
Typedtree.module_coercion
showed us that it wouldbe difficul to extract the same information that is readily available in
the signature value.
This change will expose the signature value directly, so other backends
relying on this signature information do not need to do the extra work
of reading it again.