Cabal freeze qualifies all package constraints with any
I was trying to add private-dependencies (#4035, wip at #9743) support to cabal freeze.
It looks like the constraints populating the freeze file for every package always use the any qualifier. Here's an example of a package in the testsuite:
active-repositories: test-local-repo:merge
constraints: any.array ==0.5.6.0,
any.base ==4.19.0.0,
any.binary ==0.8.9.1,
any.bytestring ==0.12.0.2,
any.containers ==0.6.8,
any.deepseq ==1.5.0.0,
any.directory ==1.3.8.1,
any.exceptions ==0.10.7,
any.filepath ==1.4.100.4,
any.ghc-bignum ==1.3,
any.ghc-boot-th ==9.8.1,
any.ghc-prim ==0.11.0,
any.lib01 ==0.1.0.0 || ==0.2.0.0,
any.mtl ==2.3.1,
any.pretty ==1.1.3.6,
any.process ==1.6.18.0,
any.rts ==1.0.2,
any.stm ==2.5.2.1,
any.template-haskell ==2.21.0.0,
any.time ==1.12.2,
any.transformers ==0.6.1.0,
any.unix ==2.8.3.0
index-state: HEAD
I think that this design is incompatible with private dependencies, because any qualified package constraints will apply to all scopes (be them the top-level scope, setup-component scopes, independent goals, or private scopes...).
Is there any reason for this being so? I believe the right way forward here is to properly qualify the packages in the freeze file according to their qualifier in the package. This would allow private dependencies to introduce qualified constraints on packages for packages in a specific private scope, and would ensure top-level constraints do not apply unnecessarily to private scopes.
cc @grayjay
I was surprised by the many anys in the freeze file the first time I saw them. There's very little written about these qualifiers in the docs, just a small note and example;
tools. To explicitly apply a constraint to a setup or build
tool dependency, you can add a qualifier ``setup`` or ``any``
to the constraint as follows:
::
# Example use of the 'any' qualifier. This constraint
# applies to package bar anywhere in the dependency graph.
$ cabal install --constraint="any.bar == 1.0"
::
# Example uses of 'setup' qualifiers.
# This constraint applies to package bar when it is a
# dependency of any Setup.hs script.
$ cabal install --constraint="setup.bar == 1.0"
# This constraint applies to package bar when it is a
# dependency of the Setup.hs script of package foo.
$ cabal install --constraint="foo:setup.bar == 1.0"
.. TODO: Uncomment this example once we decide on a syntax for 'exe'.
.. # Example use of the 'exe' (executable build tool)
# qualifier. This constraint applies to package baz when it
# is a dependency of the build tool bar being used to
# build package foo.
$ cabal install --constraint="foo:bar:exe.baz == 1.0"