Skip to content
  • Edward Z. Yang's avatar
    Distinguish between component ID and unit ID. · ef41f44e
    Edward Z. Yang authored
    
    
    GHC 8.0 is switching the state sponsored way to specify
    linker names from -this-package-key to -this-unit-id, so
    it behooves us to use the right one.  But it didn't make
    much sense to pass ComponentIds to a flag named UnitId,
    so I went ahead and finished a (planned) refactoring
    to distinguish ComponentIds from UnitIds.
    
    At the moment, there is NO difference between a ComponentId
    and a UnitId; they are identical.  But semantically, a
    component ID records what sources/flags we chose (giving us enough
    information to typecheck a package), whereas a unit ID records
    the component ID as well as how holes were instantiated
    (giving us enough information to build it.)  MOST code
    in the Cabal library wants unit IDs, but there are a few
    places (macros and configuration) where we really do
    want a component ID.
    
    Some other refactorings that got caught up in here:
    
        - Changed the type of componentCompatPackageKey to String, reflecting the
          fact that it's not truly a UnitId or ComponentId.
    
        - Changed the behavior of CURRENT_PACKAGE_KEY to unconditionally
          give the compatibility package key, which is actually what you
          want if you're using it for the template Haskell trick.  I also
          added a CURRENT_COMPONENT_ID macro for the actual component ID,
          which is something that the Cabal test-suite will find useful.
    
        - Added the correct feature test for GHC 8.0 ("Uses unit IDs").
    
    Signed-off-by: default avatarEdward Z. Yang <ezyang@cs.stanford.edu>
    ef41f44e