-
Notifications
You must be signed in to change notification settings - Fork 430
Refactor Dune_lang.Package
#11555
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
Refactor Dune_lang.Package
#11555
Conversation
This is not a bug but expected behavior. What behavior did you expect instead? As for the refactoring, the exact approach depends on features or bug fixes that we'd like to achieve. So it's hard to evaluate without knowing what concrete goal you have in mind. After a brief glance, I don't see anything particularly wrong but neither something that is especially necessary. Probably because it's quite a large change so it's hard for me to evaluate it all at once. Maybe some of the code moves can be done separately? I will say that a good guiding principle is that this distinction between the types of packages (opam vs dune) is not something to be leaked. It should be something that we isolate to a single place as much as possible, so that the rest of the code isn't burdened with needing to remember all these details. I don't think the current state of the code achieves this goal properly, but a good change will move towards that. |
I think in general Dune co-exists with OPAM fairly well, so from a user perspective I would have expected that if there isn't any dependencies declared in This also seems to be how some project in the wild are set up and it doesn't strike me as unreasonable.
I think my goal is to have a better way to have package definitions coexist at the same time. At the moment this is done in an sort of C-ish union type This PR changes it into an ADT where a project is either one or the other and will return roughly correct data when both ways do declare a project offer the same information, but also allows to specifically require one of them if the action only makes sense using one of them (
I agree, and generally I try to avoid it (e.g.
I can definitely split this up into more digestable sizes if we agree on the direction. Especially as this PR evolved as I tried to get it to compile again and learn what issues crop up. |
I think that encourages users to split their package definitions across the dune and the opam format. In addition to just being confusing, it also requires us to think about resolving conflicts between the metadata defined in both places at once. In general, it's easy to think about packages as being either strictly dune's or strictly opam's. Allowing for chimeras is not to our advantage. It at least shouldn't be done without some strong justification on why it's necessary (beyond convenience) |
I generally would like to encourage people to migrate their data to the The alternative is to try to detect the case where there are no dependencies in |
but if dune can't express their dependency specification, then dune can't build their dependencies either. So what's the point of moving to the dune-project file?
It's not really about the length but the steering the users to express their intents in a clear way. Chimera mode just creates a whole bunch of intermediate states for us to guess the meaning of. I think we already allow them to upgrade things gradually by transitioning things per package. I think that's accommodative enough. I do agree that having better warnings and errors is good though. It seems like a logical thing to me never mix and match two sources of truth for a single logical object in the workspace, I just wonder why would users knowingly to obfuscate things this way. |
Only the solver needs to support it (and it does, because we can typically find solutions for opam files). Once the solver has a solution it is just a list of package names and versions.
Ok, fair I'll work on that in #11573.
Generally I think it is due to a general lack of understanding what |
While working on the bug where we ignore dependencies from OPAM file if there is a
package
definition in thedune-project
when locking, I ran across a weird behavior:Dune_lang.Package.t
contains a lot of fields which have very little to do with parsing apackage
stanza and is overloaded with tons of stuff that is either only relevant when thePackage.t
has been created from an OPAM file or read from adune-project
(as evident by theencode
/decode
functions which ignore a lot of fields and a lot of accessor functions where data is set after thepackage
stanza has been decoded).This also leads to the strange behavior that an OPAM file is read, a
Package.t
is created with mostly invalid/empty data, containing the originalopam
file content as an attachment. When we attempt to lock, we ignore all these invalid fields and parse the opam file again.This seemed all a bit messy, so in this PR I'm trying to split this up a bit. I've moved the
Dune_lang.Package
toDune_lang.Dune_package
and created a new wrapperPackage
type that can be created from eitherdune-project
or anopam
file. I generally think that whateverPackage
is doing should probably be moved toDune_rules.Package
(andDune_lang.Dune_package
should becomeDune_lang.Package
again) but I first wanted to see how big the impact is on the testsuite. There is a bit of breakage but I am reasonably certain it can be fixed fairly easily.But before polishing it up I'd like to ask whether this direction is something that makes sense or whether I am missing something crucial and whether it creates a lot of issues. @rgrinberg could you please comment whether the plan makes sense to you?