-
Notifications
You must be signed in to change notification settings - Fork 7
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: Scheme for revising bounds to eliminate corners of the version cartesian products #213
Comments
Just to be clear: can't you use nested conditionals in the example, at the cost of a potential explosion of expression size? I.e. Edit: oh wait, I guess that syntax isn't allowed, sigh. |
Ok, so for the "future" idea, I'd really like to have sugar to let conditionals be inlined into build-depends, so we could write: |
Why isn’t || allowed? |
The general scheme is its a disjoint list of packages, each with a range. The range itself can use && and || both. But each package specifies its range independently. Herbert just explained to me offline one key thing -- this means that when each package version is fixed and when each flag is also fixed, there's no "degree of freedom" since expressions have a unique solution. Otherwise, overlapping |
Talking to herbert some more, I think that we can simplify his proposal and just allow anyone to add auto flags in revisions, full stop. That means that we don't need a whole bunch of special revision rules here, and instead we just increase slightly the revision surface area as a whole. It does mean that those flags can now be altered to manual (which is a one-way op) even when we wouldn't want them to be -- but this is already the case with allowing other flags that were set as auto to be altered to manual, so we're no worse off. |
Problem Statement
The basic abstracted problem can be demonstrated with two dependencies,
foo
andbar
and each with two major API versions. For the general case, these two packages shall be considered independent of each other, i.e. neither depends upon the respective other.Their exported API is
And now consider a consumer of
bar
andfoo
, i.e.and combines
g
andf
like soLet's assume this definition is semantically sound when it typechecks.
However, only two out of 4 combinations of
foo
andbar
are valid:foo-1.1
foo-1.2
bar-0.1
bar-0.2
This is just one example; another situation that's commonly encountered is something like
foo-1.1
foo-1.2
doo-0.1
doo-0.2
or any rotation of these two. (NB: if only one out of four quadrants is "OK", it's trivial to resolve via revisions)
Solutions to the Problem
The real problem now is how to fix an package description which contains the inaccurate
dependency specification without forbidding any of all the previously reachable sound quadrants.
A solution.
Indirect solution by introducing extra dummy packages
A possible solution would be to use the
network-uri-flag
hack, which involves creating a dummy package with an empty library like shown below to encode the valid combinations offoo
andbar
:and then this package
foo-bar-compatibility
needs to be added to the whitelisted packages allowed to be added retroactively via revisions intobuild-depends
in the hackage-server revision validation logic. Consequently, the package consumingfoo
andbar
would need to be revised intoHowever, while this approach is possible, it comes at with a couple of obvious downsides:
Direct solution
A more direct solution is to extend the hackage revision rules to allow the introduction of new automatic cabal flags via metadata revisions, with the following machine-checked limitations:
x-rev-
prefix (or another prefix that doesn't yet occur in 01-index.tar at time of deployment)x-rev-
must bemanual: False
(Hackage will enforce this invariant during revisions)x-rev-
prefixed flag names; this is to ensure that non-trustees cannot create immutablex-rev-
flags by accident.Since these are automatic cabal flags which the cabal spec provides for the very purpose to express these kind of either/or dependency specifications involving multiple packages.
Direct solution for future
cabal-version
sIf, in a future cabal version, the cabal format provides a flag-less way to express, such as e.g.
the revision logic would be adapted to allow introducing
if lib-version(...)
-conditionals forcabal-version:
s which support this predicate; while also disallowing the flag-introduction from the previous section forcabal-version:
s which provide this more idiomatic construct.The text was updated successfully, but these errors were encountered: