Rename Backpack packages to units
After today's weekly Backpack call, we have come to the conclusion that we have two different types of "packages" in the Backpack world:
- Cabal packages, which have a single
.cabal
file and are a unit of distribution which get uploaded to Hackage, and - Backpack packages, of which there may be multiple defined in a Backpack file shipped with a Cabal package; and are the building blocks for modular development in the small.
It's really confusing to have both of these called packages: thus, we propose to rename all occurrences of Backpack package to unit. A Cabal package may contain MULTIPLE Backpack units, and old-style Cabal files will only define one unit. Every Cabal package has a distinguished unit (with the same name as the package) that serves as the publically visible unit.
A Cabal package remains
- The unit of distribution
- The unit that Hackage handles
- The unit of versioning
- The unit of ownership (who maintains it etc)
Here are some of the consequences:
- The "installed package database" no longer maintains a one-to-one mapping between Cabal packages and entries in the database. This invariant is being dropped for two reasons: (1) With a Nix-style database, a package
foo-0.1
may be installed many times with different dependencies / source code, all of which live in the installed package database. (2) With Backpack, a package containing a Backpack file may install multiple units. To avoid having to rename *everything*, we'll keep calling this the installed package database, but really it's more like an installed *unit* database. - We rename
PackageKey
toUnitKey
, as it identifies a unit rather than a Cabal package. (I think this actually makes the function of these identifiers clearer.) We'll also distinguish Cabal-file levelPackageName
s from Backpack-fileUnitName
s. Installed units are identified by anInstalledUnitId
instead of anInstalledPackageId
. - The source-level syntax of Backpack files will use
unit
in place of wherepackage
was used before. - For old-style packages, Cabal will continue to write and register a single entry in the installed package database. For Backpack packages, Cabal will register as many entries as is necessary to install a package. The entry with the same
UnitName
asPackageName
is publically visible to other packages. If a Backpack file defines other packages, those packages are registered with differentUnitName
s (giving them differentInstalledPackageId
s) which are not publically visible. The non-publically visible packages will have their description/URL/etc fields blank, and have a pointer to the "real" package. - If when installing a unit, we discover that it is already present in the database, we check if the ABI hashes are the same. If they are, we simply skip installing the unit but otherwise proceed. If the ABI hashes are not the same, we error: the units we are installing need to be recompiled against the unit present in the database.
- Dependency tracking should be fine-grained within a PACKAGE, and coarse-grained outside. So we need to let interface files track module dependencies for files which are not in the same unit, but are in the same package.