-
Notifications
You must be signed in to change notification settings - Fork 416
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
[RFC] Define a ROOT module with toplevel module #3865
Comments
Will the ROOT module be written by the user or generated by dune? If the module is user written, what is the difference between such a module and a module without any dependencies? E.g:
|
The incentive to solve the issue of ppx + runtime libraries seems nice, but I don't quite see how this proposal addresses it. As far as I see, the ppx needs to ask dune for a ROOT module that:
|
The |
I don't see how this fixes the ppx runtime dependency problem. It does help with "renaming" library deps, though, so that part seems fine. By the way, I couldn't understand the section where you say "So the choice of what is a toplevel module is important" followed by bullet-points. Maybe you could expand each bullet-point a bit? |
Perhaps just having a convention that this module cannot be shadowed is good enough? We could even call it something like |
If we want to be cautious we can write a ppx which check that we never have And at the end the feature in dune can be just an experiment for a futur feature in the compiler. For that direction we can fix the name of the root module: Ok I'm expanding the bullet point. |
Oh, got it (I still had to re-read it, like, 3 times though). a.cmi you're asking if we should only have I think definitely the former. The only supported way to access wrapped libraries is through their public renaming module, so that's the only thing we should expose. |
I agree that it is better for wrapped library. But it means we do it only for wrapped dune libraries. Or for non-dune libraries we can do the latter. Sorry for the complicated explanation. |
I'm not very familiar with non-wrapped libraries, but I expect that for them we'll want to indeed have one alias per .cmi they expose. |
Here's another problem with having the ROOT module: the user can Consider code like this:
What the code prints may depend on whether or not you depend on a library A. The problem becomes potentially more confusing if you consider how |
Interesting, forbidding |
I'm moving to postponing this issue, except if it is found urgent by some. |
I'd be interested in exploring this proposal in the short term to get an idea if #3825 is going to be necessary. @bobot @aalekseyev I'd like to use #3825 or something similar in the short term, but I'm not against implementing this proposal or even |
#3825 can be put behind an experimental flag, and is harmless. The problem with this ROOT proposal for me is choosing what is the set of toplevel libraries. If a ppx use In conclusion the ppx case shouldn't be considered in this proposal, as I did at first, I believe we should focus on the developer case. |
I agree that we should shelve the ppx use case for now. How about I quickly turn #3825 into:
The machinery to do all of this is basically done in #3825. I think this is a little more elegant than my proposal. I'll also mention that I discussed this proposal with Jeremie briefly, and he's fine with it, but strongly against introducing any reserved identifiers that aren't chosen explicitly by the user. |
I'm ok with that. |
I'm afraid that
What name do we choose for |
Can we do it only for dune wrapped library? This possible constraint arose in the conversation. |
We can, but I think that silently skipping unwrapped libraries is bad. At least the other approach can be adapted to support unwrapped libraries. |
In case of dune unwrapped library, can we just add the modules? So in your example |
Yeah, I suppose that would be fine and not too surprising for the user. @aalekseyev do you agree? |
This was implemented |
Desired Behavior
When discussing #3825 we realized that dune can help with the absence of a
ROOT
module which contains the toplevel module before any open by being able to generate one. However the name to use as always been a problem for adding this feature to the compiler. Dune has the hability through thedune-project
file to activate the feature or allow to change the name. Also what are toplevel modules is not exactly defined. Dune by having a more highlevel view can better define them.Sought advantage of having a
ROOT
module:So the choice of what is a toplevel module is important:
name
field of a library).Finally we need a way to indicate the toplevel name to ppx.
ppxlib
can help by giving a simple API which use theROOT
module if available otherwise use directly the module.Example
TODO
The text was updated successfully, but these errors were encountered: