Maybe ghc-pkg register should unregister packages with "incompatible" signatures
Consider the following situation:
- I register package 'p-0.1-inplace' instantiated with 'P = base:Data.Map'
- I register package 'p-0.1-inplace' instantiated with 'P = base:Control.Monad'
Even though the IPID of these two packages is the same, we clearly want to keep both of them in the database. This thus motivates the following lines in ghc-pkg
removes = [ RemovePackage p
| not multi_instance,
p <- packages db_to_operate_on,
mungedId p == mungedId pkg,
-- Only remove things that were instantiated the same way!
instantiatedWith p == instantiatedWith pkg ]
OK... now consider the following situation
- I register package 'p-0.1-inplace' instantiated with 'P = base:Data.Map'
- I register package 'p-0.1-inplace', instantiated with nothing (I have edited 'p' such that it has no more signatures)
So... ghc-pkg is going to keep both of these packages (per the logic above). But is that really what we want? Now the package database is in a half-consistent state, where the instances of 'p-0.1-inplace' are not consistent with the number of holes they are supposed to have. So let us suggest an invariant:
INVARIANT: All packages which have the same IPID in a package database are self-consistent with each other.
OK, so given this invariant, what do we have to do in step 2? It would seem that when we get a prospective package to register, we must *find all packages which are incompatible with it*, and remove them from the package database. So, given a package with a set of holes H, we must remove all packages with holes H' such that H = H'
I'm not completely convinced this is a good idea. Usually ghc-pkg only removes a single package in response to a new registration, and this behavior could result in lots of packages getting unregistered, more than you might expect. On the other hand, if you think of the package database in a more hierarchical manner, it makes sense that changing the root registration would invalidate all the children.
Trac metadata
Trac field | Value |
---|---|
Version | 8.4.3 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | ghc-pkg |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | int-index |
Operating system | |
Architecture |