Now that packages are more fine grained and upgradeable we're commonly getting situations where we build a package that uses two other packages that were built against different versions of another common package.
The most common example in the wild at the moment is people installing bytestring-0.9.0.4 in addition to the bytestring-0.9.0.1 that came with ghc-6.8.2 and then half their packages are built against one version and half against the other and when they try to use packages built against different versions we get a type error about bytestring-0.9.0.1:Data.ByteString.ByteString not being the same as bytestring-0.9.0.4:Data.ByteString.ByteString.
Cabal could and should detect this situation, and cabal-install should plan around it in its dependency resolution algorithm. However in both cases we require the dependency information of the existing installed packages.
See http://hackage.haskell.org/trac/ghc/ticket/1839
The simplest thing is to get the full InstalledPackageInfo for all the packages in the package databases. From that we can find all the dependencies.
When we do find this situation it is not guaranteed to cause a compiler error, it's just rather likely. So it's not obvious if Cabal should warn or error. cabal-install could try to fix up inconsistencies but in general only by re-installing existing packages against different versions of their dependencies.
The longer term solution is to allow installing multiple instances of the same versions of a package built against different versions of its dependencies. This is the functional Nix approach however it would probably also require support from ghc.