Skip to content

[RFC] default-package-bounds #9569

Closed as not planned
Closed as not planned
@jasagredo

Description

@jasagredo

Obsoletes #9477

Problem this solves

When describing a package in a .cabal file, multiple components can declare the same dependency in their build-depends sections. There can be two flavors of this:

  1. Components actually depend on different versions of the dependency, for example if we are using one version of aeson in one test-suite and a different version in another, in order to test backwards compatibility always.
  2. Components depend on the same version of the dependency.

It is to case (2) that we turn our attention in this RFC. On the one hand it feels redundant and error-prone to repeat the version bound in all components. On the other hand, in order to make sure you are building with the same version regardless of what subset of those components is enabled one has to perform a topological-sort of the components and assign the version bound in the bottom-most component.

A different solution is to use common stanzas as done by some packages but this leads to a weird syntax, where the import section of a component is importing both configurations and build-depends sections.

Proposed solution

Implement a new section in the .cabal package file named default-package-bounds which contains a list of dependencies in the same format as a build-depends.

For each of the unqualified dependencies in the default-package-bounds, whenever a dependency on the same package appears in a build-depends section of a component without a specified version bound, the version bound from default-package-bounds will be used. For each qualified dependencies in the default-package-bounds, whenever a dependency on the same package appears in a build-tool-depends section of a component without a specified version bound, the version bound from default-package-bounds will be used.

In particular default-package-bounds: foo >2 will be applied to both build-depends: foo, foo:bar, and default-package-bounds: foo:baz >2 will be applied to build-tool-depends: foo:baz.

For specific cases like (1) above, the user should not include such a special dependency in these default-package-bounds section.

This will be just a syntactic sugar and will have no influence in:

  • transitive dependencies (as opposed to constraints in cabal.project)
  • pkgconfig-depends

Backwards compatibility

This change would be fully backwards-compatible as there existed no field with this name before and omitting it would work the same way as before this change, i.e. it is an optional field.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions