Simon Peyton Jones pushed to branch wip/spj-reinstallable-base at Glasgow Haskell Compiler / GHC

Commits:

17 changed files:

Changes:

  • compiler/GHC/Iface/Load.hs
    ... ... @@ -250,12 +250,14 @@ checkKnownKeyNamesIface known_key_names_occ_map
    250 250
     *                                                                      *
    
    251 251
     ********************************************************************* -}
    
    252 252
     
    
    253
    -lookupGlobalName :: Name ->  IfM lcl (MaybeErr IfaceMessage TyThing)
    
    253
    +lookupGlobalName :: HasDebugCallStack
    
    254
    +                 => Name ->  IfM lcl (MaybeErr IfaceMessage TyThing)
    
    254 255
     -- Only works for External Names that have a Module
    
    255 256
     lookupGlobalName name = loadGlobalName name (nameModule name)
    
    256 257
     
    
    257 258
     loadGlobalName :: forall lcl.
    
    258
    -                  Name
    
    259
    +                  HasDebugCallStack
    
    260
    +               => Name
    
    259 261
                    -> Module  -- Use this for non-External Names (maybe Backpack-related?)
    
    260 262
                    -> IfM lcl (MaybeErr IfaceMessage TyThing)
    
    261 263
     loadGlobalName name mod
    

  • compiler/GHC/Rename/Env.hs
    ... ... @@ -2385,7 +2385,7 @@ lookupSyntaxName :: HasDebugCallStack
    2385 2385
     lookupSyntaxName std_uniq
    
    2386 2386
       = do { rebind <- xoptM LangExt.RebindableSyntax
    
    2387 2387
            ; if not rebind
    
    2388
    -         then do { nm <- tcLookupKnownKeyName std_uniq
    
    2388
    +         then do { nm <- rnLookupKnownKeyName std_uniq
    
    2389 2389
                      ; return (nm, emptyFVs) }
    
    2390 2390
              else do { nm <- lookupOccRnNone $ mkRdrUnqual $
    
    2391 2391
                              knownKeyOccName std_uniq
    
    ... ... @@ -2401,8 +2401,8 @@ lookupSyntax :: KnownKeyNameKey -- The standard name
    2401 2401
                  -> RnM (SyntaxExpr GhcRn, FreeVars) -- Possibly a non-standard
    
    2402 2402
                                                      -- name
    
    2403 2403
     lookupSyntax std_uniq
    
    2404
    -  = do { (name, fvs) <- lookupSyntaxName std_uniq
    
    2405
    -       ; return (mkRnSyntaxExpr name, fvs) }
    
    2404
    +  = do { (expr, fvs) <- lookupSyntaxExpr std_uniq
    
    2405
    +       ; return (SyntaxExprRn expr, fvs) }
    
    2406 2406
     
    
    2407 2407
     {-
    
    2408 2408
     Note [QualifiedDo]
    

  • compiler/GHC/Rename/Expr.hs
    ... ... @@ -28,7 +28,7 @@ import GHC.Prelude hiding (head, init, last, scanl, tail)
    28 28
     import GHC.Hs
    
    29 29
     
    
    30 30
     import GHC.Tc.Errors.Types
    
    31
    -import GHC.Tc.Utils.Env ( isBrackLevel, tcLookupKnownKeyName )
    
    31
    +import GHC.Tc.Utils.Env ( isBrackLevel )
    
    32 32
     import GHC.Tc.Utils.Monad
    
    33 33
     
    
    34 34
     import GHC.Rename.Bind ( rnLocalBindsAndThen, rnLocalValBindsLHS, rnLocalValBindsRHS
    
    ... ... @@ -76,7 +76,6 @@ import Control.Monad
    76 76
     import qualified Data.Foldable as Partial (maximum)
    
    77 77
     import Data.List (unzip4)
    
    78 78
     import Data.List.NonEmpty ( NonEmpty(..), head, init, last, nonEmpty, scanl, tail )
    
    79
    -import Control.Arrow (first)
    
    80 79
     import Data.Ord
    
    81 80
     import Data.Array
    
    82 81
     import GHC.Driver.Env (HscEnv)
    
    ... ... @@ -497,6 +496,7 @@ rnExpr (HsDo _ do_or_lc (L l stmts))
    497 496
                 (\ _ -> return ((), emptyFVs))
    
    498 497
           ; (pp_stmts, fvs2) <- postProcessStmtsForApplicativeDo do_or_lc stmts1
    
    499 498
           ; return ( HsDo noExtField do_or_lc (L l pp_stmts), fvs1 `plusFV` fvs2 ) }
    
    499
    +
    
    500 500
     -- ExplicitList: see Note [Handling overloaded and rebindable constructs]
    
    501 501
     rnExpr (ExplicitList _ exps)
    
    502 502
       = do  { (exps', fvs) <- rnExprs exps
    
    ... ... @@ -1253,7 +1253,7 @@ rnStmt :: AnnoBody body
    1253 1253
     rnStmt ctxt rnBody (L loc (LastStmt _ (L lb body) noret _)) thing_inside
    
    1254 1254
       = do  { (body', fv_expr) <- rnBody body
    
    1255 1255
             ; (ret_op, fvs1) <- if isMonadCompContext ctxt
    
    1256
    -                            then lookupStmtName ctxt returnMClassOpKey
    
    1256
    +                            then lookupQualifiedDoStmtName ctxt returnMClassOpKey
    
    1257 1257
                                 else return (noSyntaxExpr, emptyFVs)
    
    1258 1258
                                 -- The 'return' in a LastStmt is used only
    
    1259 1259
                                 -- for MonadComp; and we don't want to report
    
    ... ... @@ -1266,10 +1266,11 @@ rnStmt ctxt rnBody (L loc (LastStmt _ (L lb body) noret _)) thing_inside
    1266 1266
     
    
    1267 1267
     rnStmt ctxt rnBody (L loc (BodyStmt _ (L lb body) _ _)) thing_inside
    
    1268 1268
       = do  { (body', fv_expr) <- rnBody body
    
    1269
    -        ; (then_op, fvs1)  <- lookupQualifiedDoStmtName ctxt thenMClassOpKey
    
    1269
    +        ; (then_op, fvs1)  <- pprTrace "rnStmt" (ppr loc $$ ppr ctxt) $
    
    1270
    +                              lookupQualifiedDoStmtName ctxt thenMClassOpKey
    
    1270 1271
     
    
    1271 1272
             ; (guard_op, fvs2) <- if isComprehensionContext ctxt
    
    1272
    -                              then lookupStmtName ctxt guardMIdKey
    
    1273
    +                              then lookupQualifiedDoStmtName ctxt guardMIdKey
    
    1273 1274
                                   else return (noSyntaxExpr, emptyFVs)
    
    1274 1275
                                   -- Only list/monad comprehensions use 'guard'
    
    1275 1276
                                   -- Also for sub-stmts of same eg [ e | x<-xs, gd | blah ]
    
    ... ... @@ -1336,9 +1337,9 @@ rnStmt ctxt rnBody (L loc (RecStmt { recS_stmts = L _ rec_stmts })) thing_inside
    1336 1337
                      , fvs `plusFV` fvs1 `plusFV` fvs2 `plusFV` fvs3) } }
    
    1337 1338
     
    
    1338 1339
     rnStmt ctxt _ (L loc (ParStmt _ segs _ _)) thing_inside
    
    1339
    -  = do  { (mzip_op, fvs1)   <- lookupStmtNamePoly ctxt mzipIdKey
    
    1340
    -        ; (bind_op, fvs2)   <- lookupStmtName ctxt bindMClassOpKey
    
    1341
    -        ; (return_op, fvs3) <- lookupStmtName ctxt returnMClassOpKey
    
    1340
    +  = do  { (mzip_op, fvs1)   <- lookupQualifiedDoStmtNameE ctxt mzipIdKey
    
    1341
    +        ; (bind_op, fvs2)   <- lookupQualifiedDoStmtName  ctxt bindMClassOpKey
    
    1342
    +        ; (return_op, fvs3) <- lookupQualifiedDoStmtName  ctxt returnMClassOpKey
    
    1342 1343
             ; ((segs', thing), fvs4) <- rnParallelStmts (ParStmtCtxt ctxt) return_op segs thing_inside
    
    1343 1344
             ; return (([(L loc (ParStmt noExtField segs' mzip_op bind_op), fvs4)], thing)
    
    1344 1345
                      , fvs1 `plusFV` fvs2 `plusFV` fvs3 `plusFV` fvs4) }
    
    ... ... @@ -1361,11 +1362,11 @@ rnStmt ctxt _ (L loc (TransStmt { trS_stmts = stmts, trS_by = by, trS_form = for
    1361 1362
                        ; return ((by', used_bndrs, thing), fvs) }
    
    1362 1363
     
    
    1363 1364
            -- Lookup `return`, `(>>=)` and `liftM` for monad comprehensions
    
    1364
    -       ; (return_op, fvs3) <- lookupStmtName ctxt returnMClassOpKey
    
    1365
    -       ; (bind_op,   fvs4) <- lookupStmtName ctxt bindMClassOpKey
    
    1365
    +       ; (return_op, fvs3) <- lookupQualifiedDoStmtName ctxt returnMClassOpKey
    
    1366
    +       ; (bind_op,   fvs4) <- lookupQualifiedDoStmtName ctxt bindMClassOpKey
    
    1366 1367
            ; (fmap_op,   fvs5) <- case form of
    
    1367 1368
                                     ThenForm -> return (noExpr, emptyFVs)
    
    1368
    -                                _        -> lookupStmtNamePoly ctxt fmapClassOpKey
    
    1369
    +                                _        -> lookupQualifiedDoStmtNameE ctxt fmapClassOpKey
    
    1369 1370
     
    
    1370 1371
            ; let all_fvs  = fvs1 `plusFV` fvs2 `plusFV` fvs3
    
    1371 1372
                                  `plusFV` fvs4 `plusFV` fvs5
    
    ... ... @@ -1417,37 +1418,30 @@ rnParallelStmts ctxt return_op segs thing_inside
    1417 1418
     
    
    1418 1419
         dupErr vs = addErr $ TcRnListComprehensionDuplicateBinding (NE.head vs)
    
    1419 1420
     
    
    1420
    -lookupQualifiedDoStmtName :: HsStmtContextRn -> KnownKeyNameKey -> RnM (SyntaxExpr GhcRn, FreeVars)
    
    1421
    --- Like lookupStmtName, but respects QualifiedDo
    
    1421
    +lookupQualifiedDoStmtName :: HasDebugCallStack => HsStmtContextRn
    
    1422
    +                          -> KnownKeyNameKey -> RnM (SyntaxExpr GhcRn, FreeVars)
    
    1422 1423
     lookupQualifiedDoStmtName ctxt n
    
    1423
    -  = case qualifiedDoModuleName_maybe ctxt of
    
    1424
    -      Nothing -> lookupStmtName ctxt n
    
    1425
    -      Just modName ->
    
    1426
    -        first mkRnSyntaxExpr <$> lookupNameWithQualifier n modName
    
    1427
    -
    
    1428
    -lookupStmtName :: HsStmtContextRn -> KnownKeyNameKey -> RnM (SyntaxExpr GhcRn, FreeVars)
    
    1429
    --- Like lookupSyntax, but respects contexts
    
    1430
    -lookupStmtName ctxt key
    
    1431
    -  | rebindableContext ctxt
    
    1432
    -  = lookupSyntax key
    
    1433
    -  | otherwise
    
    1434
    -  = do { nm <- tcLookupKnownKeyName key
    
    1435
    -       ; return (mkRnSyntaxExpr nm, emptyFVs) }
    
    1436
    -
    
    1437
    -lookupStmtNamePoly :: HsStmtContextRn -> KnownKeyNameKey -> RnM (HsExpr GhcRn, FreeVars)
    
    1438
    -lookupStmtNamePoly ctxt key
    
    1439
    -  | rebindableContext ctxt
    
    1440
    -  = do { rebind <- xoptM LangExt.RebindableSyntax
    
    1441
    -       ; if not rebind
    
    1442
    -         then not_rebindable
    
    1443
    -         else do { nm <- lookupOccRnNone $ mkRdrUnqual $
    
    1444
    -                         knownKeyOccName key
    
    1445
    -                 ; return (genHsVar nm, unitFV nm) } }
    
    1424
    +  -- For GRHSs (ctxt=PatGuard), list comprehensions, etc, we don't need
    
    1425
    +  -- return, >>=, >> etc. Looking them up is a waste of time; and early
    
    1426
    +  -- ghc-internal modules (e.g. GHC.Internal.CString) those functions
    
    1427
    +  -- don't even exist
    
    1428
    +  | not (rebindableContext ctxt)
    
    1429
    +  = return (noSyntaxExpr, emptyFVs)
    
    1430
    +
    
    1446 1431
       | otherwise
    
    1447
    -  = not_rebindable
    
    1448
    -  where
    
    1449
    -    not_rebindable = do { nm <- tcLookupKnownKeyName key
    
    1450
    -                        ; return (genHsVar nm, emptyFVs) }
    
    1432
    +  = do { (expr, fvs) <- lookupQualifiedDoStmtNameE ctxt n
    
    1433
    +       ; return (SyntaxExprRn expr, fvs) }
    
    1434
    +
    
    1435
    +lookupQualifiedDoStmtNameE :: HasDebugCallStack => HsStmtContextRn
    
    1436
    +                           -> KnownKeyNameKey -> RnM (HsExpr GhcRn, FreeVars)
    
    1437
    +lookupQualifiedDoStmtNameE ctxt key
    
    1438
    +  -- Respect QualifiedDo
    
    1439
    +  | Just mod_name <- qualifiedDoModuleName_maybe ctxt
    
    1440
    +  = do { (nm, fvs) <- lookupNameWithQualifier key mod_name
    
    1441
    +       ; return (genHsVar nm, fvs) }
    
    1442
    +
    
    1443
    +  | otherwise  -- Respect -XRebindableSyntax
    
    1444
    +  = lookupSyntaxExpr key
    
    1451 1445
     
    
    1452 1446
     -- | Is this a context where we respect RebindableSyntax?
    
    1453 1447
     -- but ListComp are never rebindable
    
    ... ... @@ -1455,19 +1449,17 @@ lookupStmtNamePoly ctxt key
    1455 1449
     rebindableContext :: HsStmtContextRn -> Bool
    
    1456 1450
     rebindableContext ctxt = case ctxt of
    
    1457 1451
       HsDoStmt flavour -> rebindableDoStmtContext flavour
    
    1458
    -  ArrowExpr -> False
    
    1459
    -  PatGuard {} -> False
    
    1460
    -
    
    1461
    -
    
    1462
    -  ParStmtCtxt   c -> rebindableContext c     -- Look inside to
    
    1463
    -  TransStmtCtxt c -> rebindableContext c     -- the parent context
    
    1452
    +  ArrowExpr        -> False
    
    1453
    +  PatGuard {}      -> False
    
    1454
    +  ParStmtCtxt   c  -> rebindableContext c     -- Look inside to
    
    1455
    +  TransStmtCtxt c  -> rebindableContext c     -- the parent context
    
    1464 1456
     
    
    1465 1457
     rebindableDoStmtContext :: HsDoFlavour -> Bool
    
    1466 1458
     rebindableDoStmtContext flavour = case flavour of
    
    1467
    -  ListComp -> False
    
    1468
    -  DoExpr m -> isNothing m
    
    1469
    -  MDoExpr m -> isNothing m
    
    1470
    -  MonadComp -> True
    
    1459
    +  ListComp     -> False
    
    1460
    +  DoExpr {}    -> True
    
    1461
    +  MDoExpr {}   -> True
    
    1462
    +  MonadComp    -> True
    
    1471 1463
       GhciStmtCtxt -> True   -- I suppose?
    
    1472 1464
     
    
    1473 1465
     {-
    
    ... ... @@ -2508,7 +2500,7 @@ mkApplicativeStmt
    2508 2500
       -> RnM ([ExprLStmt GhcRn], FreeVars)
    
    2509 2501
     mkApplicativeStmt ctxt args need_join body_stmts
    
    2510 2502
       = do { (fmap_op, fvs1) <- lookupQualifiedDoStmtName (HsDoStmt ctxt) fmapClassOpKey
    
    2511
    -       ; (ap_op, fvs2) <- lookupQualifiedDoStmtName (HsDoStmt ctxt) apAClassOpKey
    
    2503
    +       ; (ap_op, fvs2)   <- lookupQualifiedDoStmtName (HsDoStmt ctxt) apAClassOpKey
    
    2512 2504
            ; (mb_join, fvs3) <-
    
    2513 2505
                if need_join then
    
    2514 2506
                  do { (join_op, fvs) <- lookupQualifiedDoStmtName (HsDoStmt ctxt) joinMIdKey
    

  • compiler/GHC/Rename/HsType.hs
    ... ... @@ -62,7 +62,7 @@ import GHC.Rename.Unbound ( notInScopeErr, WhereLooking(WL_LocalOnly) )
    62 62
     import GHC.Tc.Errors.Types
    
    63 63
     import GHC.Tc.Errors.Ppr ( pprHsDocContext )
    
    64 64
     import GHC.Tc.Utils.Monad
    
    65
    -import GHC.Tc.Utils.Env( tcLookupKnownKeyName )
    
    65
    +import GHC.Tc.Utils.Env( rnLookupKnownKeyName )
    
    66 66
     
    
    67 67
     import GHC.Types.Name.Reader
    
    68 68
     import GHC.Types.Hint ( UntickedPromotedThing(..) )
    
    ... ... @@ -1637,7 +1637,7 @@ lookupFixityOp :: OpName -> RnM Fixity
    1637 1637
     lookupFixityOp (NormalOp n)  = lookupFixityRn (getName n)
    
    1638 1638
     lookupFixityOp (UnboundOp u) = lookupFixityRn (mkUnboundName (occName u))
    
    1639 1639
     lookupFixityOp (RecFldOp f)  = lookupFieldFixityRn f
    
    1640
    -lookupFixityOp NegateOp      = do { nm <- tcLookupKnownKeyName negateClassOpKey
    
    1640
    +lookupFixityOp NegateOp      = do { nm <- rnLookupKnownKeyName negateClassOpKey
    
    1641 1641
                                       ; lookupFixityRn nm }
    
    1642 1642
     
    
    1643 1643
     -- Precedence-related error messages
    

  • compiler/GHC/Rename/Pat.hs
    ... ... @@ -68,6 +68,7 @@ import GHC.Types.SourceText
    68 68
     import GHC.Data.FastString ( uniqCompareFS )
    
    69 69
     import GHC.Data.List.SetOps( removeDups )
    
    70 70
     
    
    71
    +import GHC.Utils.Outputable
    
    71 72
     import GHC.Utils.Misc
    
    72 73
     import GHC.Utils.Panic.Plain
    
    73 74
     import GHC.Types.SrcLoc
    

  • compiler/GHC/Tc/Deriv/Generate.hs
    ... ... @@ -213,7 +213,7 @@ produced don't get through the typechecker.
    213 213
     gen_Eq_binds :: SrcSpan -> DerivInstTys -> TcM (LHsBinds GhcPs, Bag AuxBindSpec)
    
    214 214
     gen_Eq_binds loc dit@(DerivInstTys{ dit_rep_tc = tycon
    
    215 215
                                       , dit_rep_tc_args = tycon_args }) = do
    
    216
    -    do { eq_RDR <- tcLookupKnownKeyRdr eqClassOpKey
    
    216
    +    do { eq_RDR <- rnLookupKnownKeyRdr eqClassOpKey
    
    217 217
            ; return ([mk_eq_bind eq_RDR], emptyBag) }
    
    218 218
       where
    
    219 219
         all_cons = getPossibleDataCons tycon tycon_args
    
    ... ... @@ -650,7 +650,7 @@ gen_Enum_binds loc (DerivInstTys{dit_rep_tc = tycon}) = do
    650 650
         -- See Note [Auxiliary binders]
    
    651 651
         tag2con_RDR <- new_tag2con_rdr_name loc tycon
    
    652 652
         maxtag_RDR  <- new_maxtag_rdr_name  loc tycon
    
    653
    -    eq_RDR      <- tcLookupKnownKeyRdr eqClassOpKey
    
    653
    +    eq_RDR      <- rnLookupKnownKeyRdr eqClassOpKey
    
    654 654
     
    
    655 655
         return ( method_binds eq_RDR tag2con_RDR maxtag_RDR
    
    656 656
                , aux_binds    tag2con_RDR maxtag_RDR )
    

  • compiler/GHC/Tc/Module.hs
    ... ... @@ -2302,8 +2302,8 @@ tcUserStmt (L loc (BodyStmt _ expr _ _))
    2302 2302
             ; uniq <- newUnique
    
    2303 2303
             ; let loc' = noAnnSrcSpan $ locA loc
    
    2304 2304
             ; interPrintName <- getInteractivePrintName
    
    2305
    -        ; bindIOName     <- tcLookupKnownKeyName bindIOIdKey
    
    2306
    -        ; thenIOName     <- tcLookupKnownKeyName thenIOIdKey
    
    2305
    +        ; bindIOName     <- rnLookupKnownKeyName bindIOIdKey
    
    2306
    +        ; thenIOName     <- rnLookupKnownKeyName thenIOIdKey
    
    2307 2307
             ; let fresh_it  = itName uniq (locA loc)
    
    2308 2308
                   matches   = [mkMatch (mkPrefixFunRhs (L loc' fresh_it) noAnn) (noLocA []) rn_expr
    
    2309 2309
                                        emptyLocalBinds]
    
    ... ... @@ -2461,8 +2461,8 @@ tcUserStmt rdr_stmt@(L loc _)
    2461 2461
     
    
    2462 2462
            ; opt_pr_flag <- goptM Opt_PrintBindResult
    
    2463 2463
            ; ghciStep   <- getGhciStepIO
    
    2464
    -       ; printName  <- tcLookupKnownKeyName printIdKey
    
    2465
    -       ; thenIOName <- tcLookupKnownKeyName thenIOIdKey
    
    2464
    +       ; printName  <- rnLookupKnownKeyName printIdKey
    
    2465
    +       ; thenIOName <- rnLookupKnownKeyName thenIOIdKey
    
    2466 2466
            ; let gi_stmt | (L loc (BindStmt x pat expr)) <- rn_stmt
    
    2467 2467
                          = L loc $ BindStmt x pat (nlHsApp ghciStep expr)
    
    2468 2468
                          | otherwise
    

  • compiler/GHC/Tc/Utils/Env.hs
    ... ... @@ -30,7 +30,7 @@ module GHC.Tc.Utils.Env(
    30 30
             failIllegalTyCon, failIllegalTyVar,
    
    31 31
     
    
    32 32
             tcLookupKnownKeyGlobal, tcLookupKnownKeyTyCon, tcLookupKnownKeyClass,
    
    33
    -        tcLookupKnownKeyId, tcLookupKnownKeyName, tcLookupKnownKeyRdr,
    
    33
    +        tcLookupKnownKeyId, rnLookupKnownKeyName, rnLookupKnownKeyRdr,
    
    34 34
     
    
    35 35
             -- Local environment
    
    36 36
             tcExtendKindEnv, tcExtendKindEnvList,
    
    ... ... @@ -506,23 +506,33 @@ to bring the data constructor A into scope. We thus emit the following message:
    506 506
     ************************************************************************
    
    507 507
     -}
    
    508 508
     
    
    509
    +getKnownKeySource :: TcRn KnownKeyNameSource
    
    510
    +-- Used by both renamer and typechecker and renamer
    
    511
    +getKnownKeySource
    
    512
    +  = do { rebindable_path <- goptM Opt_RebindableKnownKeyNames
    
    513
    +       ; if rebindable_path
    
    514
    +         then KKNS_InScope <$> getGlobalRdrEnv
    
    515
    +         else return KKNS_FromModule }
    
    516
    +
    
    517
    +rnLookupKnownKeyName :: HasDebugCallStack => KnownKeyNameKey -> RnM Name
    
    518
    +rnLookupKnownKeyName uniq
    
    519
    +  = do { kk_source <- getKnownKeySource
    
    520
    +       ; initIfaceTcRn (lookupKnownKeyName kk_source uniq) }
    
    521
    +
    
    522
    +rnLookupKnownKeyRdr :: HasDebugCallStack => KnownKeyNameKey -> RnM RdrName
    
    523
    +rnLookupKnownKeyRdr uniq
    
    524
    +  = do { nm <- rnLookupKnownKeyName uniq
    
    525
    +       ; return (nameRdrName nm) }
    
    526
    +
    
    509 527
     tcLookupKnownKeyGlobal :: HasDebugCallStack => KnownKeyNameKey -> TcM TyThing
    
    510 528
     tcLookupKnownKeyGlobal uniq
    
    511
    -  = do { rebindable_path <- goptM Opt_RebindableKnownKeyNames
    
    512
    -       ; mb_rdr_env <- if rebindable_path
    
    513
    -                       then KKNS_InScope <$> getGlobalRdrEnv
    
    514
    -                       else return KKNS_FromModule
    
    515
    -       ; traceTc "tcLookupKnownKeyGlobal" (ppr rebindable_path $$ ppr mb_rdr_env)
    
    516
    -       ; mb_thing <- initIfaceTcRn (lookupKnownKeyThing mb_rdr_env uniq)
    
    529
    +  = do { kk_source <- getKnownKeySource
    
    530
    +       ; traceTc "tcLookupKnownKeyGlobal" (ppr kk_source)
    
    531
    +       ; mb_thing <- initIfaceTcRn (lookupKnownKeyThing kk_source uniq)
    
    517 532
            ; case mb_thing of
    
    518 533
                Succeeded thing -> return thing
    
    519 534
                Failed msg      -> failWithTc (TcRnInterfaceError msg) }
    
    520 535
     
    
    521
    -tcLookupKnownKeyName :: HasDebugCallStack => KnownKeyNameKey -> TcM Name
    
    522
    -tcLookupKnownKeyName uniq
    
    523
    -  = do { thing <- tcLookupKnownKeyGlobal uniq
    
    524
    -       ; return (getName thing) }
    
    525
    -
    
    526 536
     tcLookupKnownKeyClass :: HasDebugCallStack => KnownKeyNameKey -> TcM Class
    
    527 537
     tcLookupKnownKeyClass uniq
    
    528 538
       = do { thing <- tcLookupKnownKeyGlobal uniq
    
    ... ... @@ -545,11 +555,6 @@ tcLookupKnownKeyId uniq
    545 555
                AnId id -> return id
    
    546 556
                _  -> wrongThingErr WrongThingClass (AGlobal thing) (getName thing) }
    
    547 557
     
    
    548
    -tcLookupKnownKeyRdr :: HasDebugCallStack => KnownKeyNameKey -> TcM RdrName
    
    549
    -tcLookupKnownKeyRdr uniq
    
    550
    -  = do { thing <- tcLookupKnownKeyGlobal uniq
    
    551
    -       ; return (getRdrName thing) }
    
    552
    -
    
    553 558
     
    
    554 559
     {- *********************************************************************
    
    555 560
     *                                                                      *
    

  • compiler/GHC/Tc/Utils/Monad.hs
    ... ... @@ -2394,14 +2394,12 @@ initIfaceTcRn thing_inside
    2394 2394
                   -- When we are instantiating a signature,
    
    2395 2395
                   -- we DEFINITELY do not want to knot tie.
    
    2396 2396
                   is_instantiate = fromMaybe False (isHomeUnitInstantiating <$> mhome_unit)
    
    2397
    -        ; let { if_env = IfGblEnv {
    
    2398
    -                            if_doc = text "initIfaceTcRn",
    
    2399
    -                            if_rec_types =
    
    2400
    -                                if is_instantiate
    
    2401
    -                                    then emptyKnotVars
    
    2402
    -                                    else readTcRef <$> knot_vars
    
    2403
    -                            }
    
    2404
    -                         }
    
    2397
    +
    
    2398
    +              if_env = IfGblEnv { if_doc = text "initIfaceTcRn"
    
    2399
    +                                , if_rec_types = if is_instantiate
    
    2400
    +                                                 then emptyKnotVars
    
    2401
    +                                                 else readTcRef <$> knot_vars }
    
    2402
    +
    
    2405 2403
             ; setEnvs (if_env, ()) thing_inside }
    
    2406 2404
     
    
    2407 2405
     -- | 'initIfaceLoad' can be used when there's no chance that the action will
    

  • compiler/Language/Haskell/Syntax/Expr.hs
    ... ... @@ -1435,7 +1435,7 @@ data HsStmtContext fn
    1435 1435
       | PatGuard (HsMatchContext fn)      -- ^ Pattern guard for specified thing
    
    1436 1436
       | ParStmtCtxt (HsStmtContext fn)    -- ^ A branch of a parallel stmt
    
    1437 1437
       | TransStmtCtxt (HsStmtContext fn)  -- ^ A branch of a transform stmt
    
    1438
    -  | ArrowExpr                         -- ^ do-notation in an arrow-command context
    
    1438
    +  | ArrowExpr                         -- ^ Do-notation in an arrow-command context
    
    1439 1439
     
    
    1440 1440
     -- | Haskell arrow match context.
    
    1441 1441
     data HsArrowMatchContext
    

  • libraries/ghc-internal/src/GHC/Internal/Base.hs
    ... ... @@ -1755,7 +1755,11 @@ instance Applicative [] where
    1755 1755
     -- | @since base-2.01
    
    1756 1756
     instance Monad []  where
    
    1757 1757
         {-# INLINE (>>=) #-}
    
    1758
    -    xs >>= f             = [y | x <- xs, y <- f x]
    
    1758
    +    xs >>= f = [y | x <- xs, y <- f x]
    
    1759
    +      -- Tricky! Here we use a list comprehension, so we are
    
    1760
    +      -- relying it being desugared directly, and /not/ desugared
    
    1761
    +      -- into calls of (>>=), else we'd get an infinite loop!
    
    1762
    +
    
    1759 1763
         {-# INLINE (>>) #-}
    
    1760 1764
         (>>) = (*>)
    
    1761 1765
     
    

  • libraries/ghc-internal/src/GHC/Internal/Bignum/Backend/Native.hs
    ... ... @@ -27,6 +27,7 @@ import GHC.Internal.Bignum.WordArray
    27 27
     import GHC.Internal.Bignum.Primitives
    
    28 28
     import GHC.Internal.Prim
    
    29 29
     import GHC.Internal.Types
    
    30
    +import GHC.Internal.Base( (>>) )
    
    30 31
     
    
    31 32
     -- See W1 of Note [Tracking dependencies on primitives] in GHC.Internal.Base
    
    32 33
     -- (This module uses the empty tuple () and string literals.)
    

  • libraries/ghc-internal/src/GHC/Internal/Bignum/Integer.hs
    ... ... @@ -1381,12 +1381,12 @@ integerRecipMod# x m
    1381 1381
     
    
    1382 1382
     integerPowMod# :: Integer -> Integer -> Natural -> (# Natural | () #)
    
    1383 1383
     integerPowMod# !b !e !m
    
    1384
    -   | naturalIsZero m  = (# | () #)
    
    1385
    -   | naturalIsOne  m  = (# naturalZero | #)
    
    1386
    -   | integerIsZero e  = (# naturalOne  | #)
    
    1384
    +   | naturalIsZero m         = (# | () #)
    
    1385
    +   | naturalIsOne  m         = (# naturalZero | #)
    
    1386
    +   | integerIsZero e         = (# naturalOne  | #)
    
    1387 1387
        | integerIsZero b
    
    1388
    -     && integerGt e 0 = (# naturalZero | #)
    
    1389
    -   | integerIsOne  b  = (# naturalOne  | #)
    
    1388
    +   , integerGt e integerZero = (# naturalZero | #)
    
    1389
    +   | integerIsOne  b         = (# naturalOne  | #)
    
    1390 1390
          -- when the exponent is negative, try to find the modular multiplicative
    
    1391 1391
          -- inverse and use it instead
    
    1392 1392
        | integerIsNegative e = case integerRecipMod# b m of
    

  • libraries/ghc-internal/src/GHC/Internal/Num.hs-boot
    ... ... @@ -8,7 +8,7 @@ module GHC.Internal.Num (Num (..)) where
    8 8
     -- For why this file exists
    
    9 9
     -- See Note [Semigroup stimes cycle] in GHC.Internal.Base
    
    10 10
     
    
    11
    -import GHC.Internal.Bignum.Integer (Integer)
    
    11
    +import GHC.Internal.Bignum.Integer (Integer, integerZero)
    
    12 12
     
    
    13 13
     infixl 7  *
    
    14 14
     infixl 6  +, -
    
    ... ... @@ -23,4 +23,4 @@ class Num a where
    23 23
         fromInteger         :: Integer -> a
    
    24 24
     
    
    25 25
         x - y               = x + negate y
    
    26
    -    negate x            = 0 - x
    26
    +    negate x            = fromInteger integerZero - x

  • libraries/ghc-internal/src/GHC/Internal/Real.hs-boot
    ... ... @@ -11,7 +11,8 @@ module GHC.Internal.Real (Integral (..)) where
    11 11
     import GHC.Internal.Classes (Ord)
    
    12 12
     import GHC.Internal.Bignum.Integer (Integer)
    
    13 13
     
    
    14
    -import {-# SOURCE #-} GHC.Internal.Num (Num)
    
    14
    +import {-# SOURCE #-} GHC.Internal.Num (Num, fromInteger)
    
    15
    +  -- fromInteger needed for the "1" literal
    
    15 16
     import {-# SOURCE #-} GHC.Internal.Enum (Enum)
    
    16 17
     
    
    17 18
     data Ratio a
    

  • libraries/ghc-internal/src/GHC/Internal/Stack/Types.hs
    ... ... @@ -51,7 +51,7 @@ import cycle,
    51 51
         which imports ‘GHC.Base‘ (libraries/base/GHC/Base.hs)
    
    52 52
     -}
    
    53 53
     
    
    54
    -import GHC.Internal.Classes (Eq)
    
    54
    +import GHC.Internal.Classes (Eq( (==) ))
    
    55 55
     import GHC.Internal.Types (Char, Int)
    
    56 56
     
    
    57 57
     default ()
    

  • libraries/ghc-internal/src/GHC/Internal/Tuple.hs
    1 1
     {-# LANGUAGE Trustworthy #-}
    
    2
    -{-# LANGUAGE NoImplicitPrelude, PatternSynonyms, ExplicitNamespaces #-}
    
    2
    +{-# LANGUAGE NoImplicitPrelude, PatternSynonyms, ExplicitNamespaces, MagicHash #-}
    
    3 3
     -----------------------------------------------------------------------------
    
    4 4
     -- |
    
    5 5
     -- Module      :  GHC.Internal.Tuple
    
    ... ... @@ -31,7 +31,7 @@ module GHC.Internal.Tuple (
    31 31
     ) where
    
    32 32
     
    
    33 33
     -- See W1 of Note [Tracking dependencies on primitives] in GHC.Internal.Base
    
    34
    -import GHC.Internal.Types (Int)
    
    34
    +import GHC.Internal.Types (Int(..))
    
    35 35
     
    
    36 36
     default () -- Double and Integer aren't available yet
    
    37 37
     
    
    ... ... @@ -601,4 +601,7 @@ data Tuple64 a b c d e f g h i j k l m n o p q r s t u v w x y z a1 b1 c1 d1 e1
    601 601
          r1,s1,t1,u1,v1,w1,x1,y1,z1,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2)
    
    602 602
     
    
    603 603
     maxTupleSize :: Int
    
    604
    -maxTupleSize = 64
    604
    +maxTupleSize = I# 64#
    
    605
    +  -- Tricky: avoid using plain "64" because that's an overloaded literal,
    
    606
    +  -- and so desugars into (fromInteger (64::Integer)); but `fromInteger`
    
    607
    +  -- has not not yet been defined.