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

Commits:

6 changed files:

Changes:

  • compiler/GHC/Builtin/WiredIn/Types.hs
    ... ... @@ -2898,10 +2898,10 @@ pLUGINS :: Module
    2898 2898
     pLUGINS = mkThisGhcModule (fsLit "GHC.Driver.Plugins")
    
    2899 2899
     
    
    2900 2900
     pluginTyConName :: Name
    
    2901
    -pluginTyConName = mkKnownKeyName pluginTyConKey pLUGINS (mkOccName tcName "Plugin") noSrcSpan
    
    2901
    +pluginTyConName = mkExternalName pluginTyConKey pLUGINS (mkOccName tcName "Plugin") noSrcSpan
    
    2902 2902
     
    
    2903 2903
     frontendPluginTyConName :: Name
    
    2904
    -frontendPluginTyConName = mkKnownKeyName frontendPluginTyConKey pLUGINS (mkOccName tcName "FrontendPlugin") noSrcSpan
    
    2904
    +frontendPluginTyConName = mkExternalName frontendPluginTyConKey pLUGINS (mkOccName tcName "FrontendPlugin") noSrcSpan
    
    2905 2905
     
    
    2906 2906
     {-
    
    2907 2907
     ************************************************************************
    

  • libraries/ghc-experimental/src/Data/Sum/Experimental.hs
    1
    -{-# LANGUAGE Trustworthy #-}
    
    1
    +{-# LANGUAGE Safe #-}
    
    2 2
     {-# LANGUAGE NoImplicitPrelude, MagicHash, UnboxedSums, NoListTuplePuns #-}
    
    3 3
     
    
    4 4
     {-
    

  • libraries/ghc-experimental/src/Prelude/Experimental.hs
    1
    +{-# LANGUAGE CPP #-}
    
    2
    +#if __GLASGOW_HASKELL__ >= 1001
    
    3
    +{-# LANGUAGE Safe #-}
    
    4
    +#else
    
    1 5
     {-# LANGUAGE Trustworthy #-}
    
    6
    +#endif
    
    2 7
     {-# LANGUAGE NoImplicitPrelude #-}
    
    3 8
     {-# OPTIONS_HADDOCK not-home #-}
    
    4 9
     
    

  • libraries/ghc-internal/src/GHC/Internal/Data/Typeable/Internal.hs
    ... ... @@ -209,7 +209,7 @@ data TypeRep a where
    209 209
                      -- 'Just and the trKindVars will be [Bool].
    
    210 210
                    , trTyCon :: !TyCon
    
    211 211
                    , trKindVars :: [SomeTypeRep]
    
    212
    -               , trTyConKind :: !(TypeRep k) }  -- See Note [Kind caching]
    
    212
    +               , trTyConKind :: TypeRep k }  -- See Note [Kind caching]
    
    213 213
                 -> TypeRep (a :: k)
    
    214 214
     
    
    215 215
         -- | Invariant: Saturated arrow types (e.g. things of the form @a -> b@)
    
    ... ... @@ -318,14 +318,31 @@ There are two things we need to be careful about when caching kinds.
    318 318
     
    
    319 319
     Wrinkle 1:
    
    320 320
     
    
    321
    -We want to do it eagerly. Suppose we have
    
    321
    +The kind cache must be a /lazy/ field because, otherwise, we get a runtime loop:
    
    322 322
     
    
    323
    -  tf :: TypeRep (f :: j -> k)
    
    324
    -  ta :: TypeRep (a :: j)
    
    323
    +  consider:
    
    324
    +  $tcTYPE = TyCon fp1 fp2 mod "TYPE"# krep01
    
    325
    +  krep01 = KindRepFun (KindRepTyConApp $tcRuntimeRep []) KindRepType
    
    325 326
     
    
    326
    -Then the cached kind of App tf ta should be eagerly evaluated to k, rather
    
    327
    -than being stored as a thunk that will strip the (j ->) off of j -> k if
    
    328
    -and when it is forced.
    
    327
    +  typeRep @TYPE
    
    328
    +    = mkTrCon $tcTYPE
    
    329
    +    = TrTyCon { tc, cachedKrep = instantiateKindRep krep01 }
    
    330
    +
    
    331
    +  evaluating instantiateKindRep (KindRepFun ...) eagerly, will require
    
    332
    +  computing the fingerprint of tyConTYPE:
    
    333
    +
    
    334
    +    tyConTYPE = typeRepTyCon (typeRep @TYPE)
    
    335
    +              = typeRepTyCon (mkTrCon $tcTYPE [])
    
    336
    +
    
    337
    +  which in turn requires computing (mkTrCon $tcTYPE) again, which requires
    
    338
    +  computing the kind cache again, which is where we started. If we don't
    
    339
    +  compute the Kind cache, we can return the $tcTYPE straight away in a TrTyCon.
    
    340
    +
    
    341
    +  Really, if we could say tyConTYPE = $tcTYPE, we would avoid the entire thing.
    
    342
    +
    
    343
    +  This is very delicate, and it is essentially only necessary for TYPE.
    
    344
    +  Making the kind cache lazy suffices, but the overall design could be
    
    345
    +  potentially improved to avoid this subtlessness.
    
    329 346
     
    
    330 347
     Wrinkle 2:
    
    331 348
     
    
    ... ... @@ -338,9 +355,10 @@ But we *do not* want TypeReps to have cyclical structure! Most importantly,
    338 355
     a cyclical structure cannot be stored in a compact region. Secondarily,
    
    339 356
     using :force in GHCi on a cyclical structure will lead to non-termination.
    
    340 357
     
    
    341
    -To avoid this trouble, we use a separate constructor for TypeRep Type.
    
    358
    +To avoid this trouble, we use a separate constructor for TypeRep Type,
    
    359
    +namely, TrType.
    
    342 360
     mkTrApp is responsible for recognizing that TYPE is being applied to
    
    343
    -'LiftedRep and produce trType; other functions must recognize that TrType
    
    361
    +'LiftedRep and produce TrType; other functions must recognize that TrType
    
    344 362
     represents an application.
    
    345 363
     -}
    
    346 364
     
    

  • libraries/ghc-internal/src/GHC/Internal/IO/Encoding/UTF8.hs
    ... ... @@ -47,6 +47,8 @@ import GHC.Internal.Prim (
    47 47
       )
    
    48 48
     import GHC.Internal.Word
    
    49 49
     import GHC.Internal.Data.Bits
    
    50
    +import qualified GHC.Internal.IO.Exception as Rebindable
    
    51
    +import qualified GHC.Internal.Stack.Types as Rebindable
    
    50 52
     
    
    51 53
     utf8 :: TextEncoding
    
    52 54
     utf8 = mkUTF8 ErrorOnCodingFailure
    

  • libraries/template-haskell/Language/Haskell/TH/Lib.hs
    1 1
     {-# LANGUAGE Safe #-}
    
    2
    +{-# LANGUAGE CPP #-}
    
    2 3
     
    
    3 4
     -- |
    
    4 5
     -- Language.Haskell.TH.Lib contains lots of useful helper functions for
    
    ... ... @@ -180,8 +181,10 @@ import GHC.Boot.TH.Lib hiding
    180 181
     
    
    181 182
       , conP
    
    182 183
     
    
    184
    +#if __GLASGOW_HASKELL__ < 1001
    
    183 185
       , Role
    
    184 186
       , InjectivityAnn
    
    187
    +#endif
    
    185 188
       )
    
    186 189
     import qualified GHC.Boot.TH.Lib as Internal
    
    187 190
     import Language.Haskell.TH.Syntax