-
Notifications
You must be signed in to change notification settings - Fork 412
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: single-context Universal Libraries #10630
Comments
Am I correct that this is going to look as
(just want to clarify that I understand the proposal correctly). May I also request to modify the preprocessing pipeline for Melange to This would be useful so that the same preprocessor could automatically adjust
How that part is going to be implemented? One thing I like about the multicontext proposal is that the context is user |
Yup. this is what it'd look like.
I think this makes total sense. Thanks for suggesting.
I'm not entirely sure. I think the idea is to communicate to Merlin what the sources are for a given module, rather than just the prefix and the |
I wonder about how Maybe there could be a new version of
Is this strictly necessary? I was thinking one could use different flags depending if it's I am not saying we shouldn't add this feature, just that Dune already has a lot of complexity, so everything introduced needs to be well evaluated.
Currently we have this logic to decide if we should point merlin to either melange or ocaml sources. iiuc it works like this:
Maybe we could add a flag to let the users decide how it works. |
I would say it will be a big pro of not having to pass the |
Some thoughts about this RFC after giving it some time. The issues we found with the current approach to "universal libs" using multi-context are (this kind of repeats what's been mentioned in issue description, but for the sake of completion): a) have to use Issues a) and b) have been the main blockers to adopt multi-context at Ahrefs. As far as I understand, this proposal would solve all the issues above: a) No more need to use I don't see at the moment which disadvantages the proposal would bring, besides the extra complexity added in Dune codebase? |
my understanding is that this is the biggest downside of this proposal, as such setting is going to cascade through many tools (dune, ocamllsp, editor extensions) and at the same time it is melange specific regarding a) and b), are we sure that the amount/kind of work required for this proposal is not similar to what's required to specialise part of multi context mechanism to melange and solve a) and b) there? I still see multi context proposal superior even if it is required to introduce a specialisation for melange (e.g. implicit melange context controlled by
|
Could you expand on what changes would be required? Besides those in Dune that are being commented here. The way I see it, things for ocamllsp and editor extensions would keep working as they do now. If you define a library with
Worst case, if this RFC was to be implemented, we could leave that setting as is, and Dune would always point merlin to OCaml artifacts for universal libraries. This would require zero changes in tooling upstream and everything would keep working normally. We could optionally add some flag (just in Dune) to allow users to select which artifacts are picked for universal libraries, e.g. in dune-project:
|
Another thing this RFC might have to consider is error handling. In the multi-context approach, we ended up adding some custom error handling for |
Context
(using melange 0.1)
allows writing Melange / OCaml code together with limitationsenabled_if
Problems
library
stanzas end up duplicated for any non-trivial use cases, and(enabled_if (= %{context} melange))
is infectious (melange libraries only work within themelange
context)Requirements:
mode
mode
mode
Proposed solution
libraries
,preprocess
,flags
,modules
in(library ..)
melange.compile_flags
(modes melange)
falls back to the fields already supported before this change.copy_files
problem" by having shared module sources and mode-specific sources in the same directory, with different extensions. Example:Slightly unrelated: this proposal is likely backwards-compatible with
(using melange 0.1)
; after adopting it successfully in universal library projects such as Ahrefs, I propose we mark the Melange extensions stable in dune (1.0
).Implementation details
.melange-sources
folder after setting up rules for the implementation-specific module sources<lib-root>/<pkg-name>/melange
. We can install the Melange sources there, too.Caveats / further work
It's likely we'll have to change Merlin to map a module name to its source file. This is desirable in general even without this proposal: Merlin currently guesses what module source corresponds to a module, and implementing this mapping would be a benefit for most OCaml projects and editor tooling.
The text was updated successfully, but these errors were encountered: