Skip to content

Per-cabal-file constraints #8912

Open
Open
@michaelpj

Description

@michaelpj

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:

library foo
   build-depends: base ^>= 4.17
   ...

library bar
   build-depends: base ^>= 4.17
   ...

library baz
   build-depends: base ^>= 4.17
   ...

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:

common base                           { build-depends: base                           >= 4.7        && < 5      }

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, and baz depend on base
  • All things that depend on base in this cabal file have the following constraint on it, i.e. something similar to the constraints stanza in a cabal.project file

That seems to me to be a somewhat viable proposal: allow a constraints stanza in .cabal files, behaving just the same as in cabal.project files. I think that would be fairly intuitive and pretty useful.

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