Skip to content

Progressive enhancement for Cabal files: if cabal(>= 3.14) without upgrading cabal-version #11458

@lf-

Description

@lf-

Describe the feature request
I would like to be able to use new features, including but not limited to PackageInfo_* (which actually now throws an error without setting cabal-version higher #9331), when they are available, but skip them if they're not available on older Cabal versions.

Obviously the best time to have done this is several years ago, but I'm sure that Cabal will keep having more features in the future. Specifically I would like to have something like this work:

cabal-version: 3.12

if cabal(>= 3.14)
    some-new-feature: true

And then have the feature guard for some-new-feature understand that it's running on Cabal 3.14 and not error out because the global cabal-version was too low.

In the context of PackageInfo, that would look like this:

if cabal(>= 3.12) then
     extra-modules: PackageInfo_warp
else
     extra-modules: Paths_warp

Additional context
The reason I'm asking for this is that it currently takes several years to be able to use new features in Cabal since we need to get all users to upgrade their antique toolchains lest they can't use new versions of Hackage packages.

Currently there's a strong tension between "using some nice-to-have Cabal feature that 10% of my library users care about" and "delivering new library features to more users and thus receiving fewer irrelevant bug reports", which is a significant ecosystem problem created by a lack of progressive enhancement in Cabal IMO.

wai had to put a nix-specific hack in their package because they can't use PackageInfo due to the version requirement: yesodweb/wai#1044

If we were to ship this, we could actually start doing stuff like deprecation notices for using version from Paths_* modules.

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