Rodrigo Mesquita pushed to branch wip/spj-reinstallable-base2 at Glasgow Haskell Compiler / GHC

Commits:

2 changed files:

Changes:

  • compiler/GHC/Builtin.hs
    ... ... @@ -372,6 +372,11 @@ Wrinkles
    372 372
        keeps types and classes in the global type envt, but `Id`s in the local type envt.
    
    373 373
        (Ids move to the global type env during zonking; see `zonkTopDecls`.)
    
    374 374
     
    
    375
    +(KN5) If we are not using -frebindable-known-names, yet GHC.Essentials is still not
    
    376
    +  in scope, then we don't add the `default Num (Integer, Double)` declaration
    
    377
    +  to the module being compiled. This relaxation makes it possible for a library
    
    378
    +  which does not use any known-key at all (namely: `composition`) to compile
    
    379
    +  successfully without a dependency on base nor ghc-internal.
    
    375 380
     
    
    376 381
     Note [Recipe for adding a known-occ name]
    
    377 382
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    

  • compiler/GHC/Tc/Utils/Env.hs
    ... ... @@ -1121,6 +1121,7 @@ tcGetDefaultTys
    1121 1121
       = do  { dflags <- getDynFlags
    
    1122 1122
             ; hsc_env <- getTopEnv
    
    1123 1123
             ; let ovl_strings = xopt LangExt.OverloadedStrings dflags
    
    1124
    +              rebindable_kn = gopt Opt_RebindableKnownNames dflags
    
    1124 1125
                   extended_defaults = xopt LangExt.ExtendedDefaultRules dflags
    
    1125 1126
                                             -- See also #1974
    
    1126 1127
                   builtinDefaults cls tys = ClassDefaults{ cd_class = cls
    
    ... ... @@ -1133,9 +1134,9 @@ tcGetDefaultTys
    1133 1134
             ; this_module <- tcg_mod <$> getGblEnv
    
    1134 1135
             ; let this_unit = moduleUnit this_module
    
    1135 1136
             ; found_essentials <- liftIO $ findImportedModule hsc_env eSSENTIALS_NAME NoPkgQual
    
    1136
    -        ; case found_essentials of
    
    1137
    -            NotFound{} ->
    
    1138
    -              -- If GHC.Essentials isn't available at all (e.g. -hide-all-packages),
    
    1137
    +        ; case (found_essentials, rebindable_kn) of
    
    1138
    +            (NotFound{}, False) -> -- See Wrinkle (KN5) in Note [Overview of known entities]
    
    1139
    +              -- If GHC.Essentials isn't available at all when -fno-rebindable-known-names
    
    1139 1140
                   -- don't add the built-in defaulting, bc e.g. Num is a known-entity.
    
    1140 1141
                   return (user_defaults, extended_defaults)
    
    1141 1142
                 _ | this_unit == ghcInternalUnit ->