-
Notifications
You must be signed in to change notification settings - Fork 696
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
Per-cabal-file constraints
#8912
Comments
Should this also include transitive dependencies? Like if component |
I was thinking it would be a top-level stanza, so:
so it applies to everything in the cabal file. I think that does what you want? |
It could only apply to dependencies that are listed for components in the package, so that it's still equivalent to the existing build-depends. So they're not constraints in the same way as they are in cabal.project files (which can be global). IIRC, internally it's the difference between a constraint of the form "foo >= x.y" vs "bar => (foo >= x.y)". The latter says you only get the constraint if you pick bar. |
Yes, that's what I'd want. Tricky. Example:
If we only depend on bar that shouldn't incur the constraint on So I guess they're a bit less like the |
Wouldn't it be reasonable to have the following?
With the intended meaning that "any base bounds not specified are defaulted by the
That would be a "simple" sed-like. If no bounds are specified and there are default bounds, apply them. It would also have no effect in those "transitivity" problems you mention. Just pure syntactic sugar |
I note that if we had a per-stanza version of "constraint this package, but only if it appears in the build-depends" then we don't need the per-file version, because at that point common stanzas do the job, i.e.
Is it possible to have a constraint of the form |
Actually I take it back:
|
I'm too lazy to check --- what happens if I add |
If a component doesn't depend on
|
For example, cabal-cache takes the This could be rewritten as:
Which I think is much more informative, namely the dependencies still appear in the |
Adding a package to |
I got convinced. It also solves the problem "I have many components with the same deps. In which component do I specify the bounds? Or do I copy paste to all?". |
It is possible to have a lot of components in a package. This is especially true once you start to make use of support for multiple public libraries, since this allows merging what have in the past been forced to be separate packages.
However, you then end up in this situation:
etc.
If you stare hard at your dependencies, you can sometimes cut this down by finding a single component that the others depend on, and then only putting the constraint there. But this is manual and error-prone. And duplicating the constraints everywhere is also manual and tedious.
One workaround is to use lots of common stanzas:
and include it everywhere. See cabal-cache for an example in the wild. This is... okay-ish, but still a bit clumsy.
What I would like to be able to say is:
foo
,bar
, andbaz
depend onbase
base
in this cabal file have the following constraint on it, i.e. something similar to theconstraints
stanza in acabal.project
fileThat seems to me to be a somewhat viable proposal: allow a
constraints
stanza in.cabal
files, behaving just the same as incabal.project
files. I think that would be fairly intuitive and pretty useful.The text was updated successfully, but these errors were encountered: