[Git][ghc/ghc][master] Misc cleanup

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Sat Jul 22 16:36:58 UTC 2023



Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC


Commits:
a7349217 by Krzysztof Gogolewski at 2023-07-22T12:36:37-04:00
Misc cleanup

- Remove unused RDR names
- Fix typos in comments
- Deriving: simplify boxConTbl and remove unused litConTbl
- chmod -x GHC/Exts.hs, this seems accidental

- - - - -


13 changed files:

- compiler/GHC/Builtin/Names.hs
- compiler/GHC/Builtin/Names/TH.hs
- compiler/GHC/Core.hs
- compiler/GHC/Core/Type.hs
- compiler/GHC/HsToCore/Foreign/JavaScript.hs
- compiler/GHC/Tc/Deriv/Generate.hs
- compiler/GHC/Tc/Gen/HsType.hs
- compiler/GHC/Tc/Gen/Pat.hs
- compiler/GHC/Tc/Instance/FunDeps.hs
- compiler/GHC/Tc/Utils/TcMType.hs
- compiler/GHC/Tc/Utils/TcType.hs
- compiler/GHC/Tc/Zonk/Type.hs
- libraries/base/GHC/Exts.hs


Changes:

=====================================
compiler/GHC/Builtin/Names.hs
=====================================
@@ -716,14 +716,6 @@ ltTag_RDR               = nameRdrName  ordLTDataConName
 eqTag_RDR               = nameRdrName  ordEQDataConName
 gtTag_RDR               = nameRdrName  ordGTDataConName
 
-eqClass_RDR, numClass_RDR, ordClass_RDR, enumClass_RDR, monadClass_RDR
-    :: RdrName
-eqClass_RDR             = nameRdrName eqClassName
-numClass_RDR            = nameRdrName numClassName
-ordClass_RDR            = nameRdrName ordClassName
-enumClass_RDR           = nameRdrName enumClassName
-monadClass_RDR          = nameRdrName monadClassName
-
 map_RDR, append_RDR :: RdrName
 map_RDR                 = nameRdrName mapName
 append_RDR              = nameRdrName appendName
@@ -750,41 +742,10 @@ enumFromTo_RDR          = nameRdrName enumFromToName
 enumFromThen_RDR        = nameRdrName enumFromThenName
 enumFromThenTo_RDR      = nameRdrName enumFromThenToName
 
-ratioDataCon_RDR, integerAdd_RDR, integerMul_RDR :: RdrName
-ratioDataCon_RDR        = nameRdrName ratioDataConName
-integerAdd_RDR          = nameRdrName integerAddName
-integerMul_RDR          = nameRdrName integerMulName
-
-ioDataCon_RDR :: RdrName
-ioDataCon_RDR           = nameRdrName ioDataConName
-
-newStablePtr_RDR :: RdrName
-newStablePtr_RDR        = nameRdrName newStablePtrName
-
-bindIO_RDR, returnIO_RDR :: RdrName
-bindIO_RDR              = nameRdrName bindIOName
-returnIO_RDR            = nameRdrName returnIOName
-
-fromInteger_RDR, fromRational_RDR, minus_RDR, times_RDR, plus_RDR :: RdrName
-fromInteger_RDR         = nameRdrName fromIntegerName
-fromRational_RDR        = nameRdrName fromRationalName
-minus_RDR               = nameRdrName minusName
+times_RDR, plus_RDR :: RdrName
 times_RDR               = varQual_RDR  gHC_NUM (fsLit "*")
 plus_RDR                = varQual_RDR gHC_NUM (fsLit "+")
 
-toInteger_RDR, toRational_RDR, fromIntegral_RDR :: RdrName
-toInteger_RDR           = nameRdrName toIntegerName
-toRational_RDR          = nameRdrName toRationalName
-fromIntegral_RDR        = nameRdrName fromIntegralName
-
-fromString_RDR :: RdrName
-fromString_RDR          = nameRdrName fromStringName
-
-fromList_RDR, fromListN_RDR, toList_RDR :: RdrName
-fromList_RDR = nameRdrName fromListName
-fromListN_RDR = nameRdrName fromListNName
-toList_RDR = nameRdrName toListName
-
 compose_RDR :: RdrName
 compose_RDR             = varQual_RDR gHC_BASE (fsLit ".")
 


=====================================
compiler/GHC/Builtin/Names/TH.hs
=====================================
@@ -1147,29 +1147,7 @@ bndrInvisKey = mkPreludeMiscIdUnique 801
 ************************************************************************
 -}
 
-lift_RDR, liftTyped_RDR, mkNameG_dRDR, mkNameG_vRDR, mkNameG_fldRDR,
-  unsafeCodeCoerce_RDR :: RdrName
+lift_RDR, liftTyped_RDR, unsafeCodeCoerce_RDR :: RdrName
 lift_RDR     = nameRdrName liftName
 liftTyped_RDR = nameRdrName liftTypedName
 unsafeCodeCoerce_RDR = nameRdrName unsafeCodeCoerceName
-mkNameG_dRDR = nameRdrName mkNameG_dName
-mkNameG_vRDR = nameRdrName mkNameG_vName
-mkNameG_fldRDR = nameRdrName mkNameG_fldName
-
--- data Exp = ...
-conE_RDR, litE_RDR, appE_RDR, infixApp_RDR :: RdrName
-conE_RDR     = nameRdrName conEName
-litE_RDR     = nameRdrName litEName
-appE_RDR     = nameRdrName appEName
-infixApp_RDR = nameRdrName infixAppName
-
--- data Lit = ...
-stringL_RDR, intPrimL_RDR, wordPrimL_RDR, floatPrimL_RDR,
-    doublePrimL_RDR, stringPrimL_RDR, charPrimL_RDR :: RdrName
-stringL_RDR     = nameRdrName stringLName
-intPrimL_RDR    = nameRdrName intPrimLName
-wordPrimL_RDR   = nameRdrName wordPrimLName
-floatPrimL_RDR  = nameRdrName floatPrimLName
-doublePrimL_RDR = nameRdrName doublePrimLName
-stringPrimL_RDR = nameRdrName stringPrimLName
-charPrimL_RDR   = nameRdrName charPrimLName


=====================================
compiler/GHC/Core.hs
=====================================
@@ -451,7 +451,7 @@ TL;DR: we relaxed the let/app invariant to become the let-can-float invariant.
 Note [Core top-level string literals]
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 As an exception to the usual rule that top-level binders must be lifted,
-we allow binding primitive string literals (of type Addr#) of type Addr# at the
+we allow binding primitive string literals (of type Addr#) at the
 top level. This allows us to share string literals earlier in the pipeline and
 crucially allows other optimizations in the Core2Core pipeline to fire.
 Consider,
@@ -629,7 +629,7 @@ Note [Representation polymorphism invariants]
 GHC allows us to abstract over calling conventions using **representation polymorphism**.
 For example, we have:
 
-  ($) :: forall (r :: RuntimeRep) (a :: Type) (b :: TYPE r). a -> b -> b
+  ($) :: forall (r :: RuntimeRep) (a :: Type) (b :: TYPE r). (a -> b) -> a -> b
 
 In this example, the type `b` is representation-polymorphic: it has kind `TYPE r`,
 where the type variable `r :: RuntimeRep` abstracts over the runtime representation
@@ -662,14 +662,14 @@ Note that these two invariants require us to check other types than just the
 types of bound variables and types of function arguments, due to transformations
 that GHC performs. For example, the definition
 
-  myCoerce :: forall {r1 r2} (a :: TYPE r1) (b :: TYPE r2). Coercible a b => a -> b
+  myCoerce :: forall {r} (a :: TYPE r) (b :: TYPE r). Coercible a b => a -> b
   myCoerce = coerce
 
 is invalid, because `coerce` has no binding (see GHC.Types.Id.Make.coerceId).
 So, before code-generation, GHC saturates the RHS of 'myCoerce' by performing
 an eta-expansion (see GHC.CoreToStg.Prep.maybeSaturate):
 
-  myCoerce = \ (x :: TYPE r1) -> coerce x
+  myCoerce = \ (x :: TYPE r) -> coerce x
 
 However, this transformation would be invalid, because now the binding of x
 in the lambda abstraction would violate I1.


=====================================
compiler/GHC/Core/Type.hs
=====================================
@@ -828,7 +828,7 @@ runtimeRepLevity_maybe rep
 --  Splitting Levity
 --------------------------------------------
 
--- | `levity_maybe` takes a Type of kind Levity, and returns its levity
+-- | `levityType_maybe` takes a Type of kind Levity, and returns its levity
 -- May not be possible for a type variable or type family application
 levityType_maybe :: LevityType -> Maybe Levity
 levityType_maybe lev


=====================================
compiler/GHC/HsToCore/Foreign/JavaScript.hs
=====================================
@@ -58,7 +58,6 @@ import GHC.Builtin.Types.Prim
 import GHC.Builtin.Names
 
 import GHC.Data.FastString
-import GHC.Data.Pair
 import GHC.Data.Maybe
 
 import GHC.Utils.Outputable
@@ -83,7 +82,7 @@ dsJsFExport
 
 dsJsFExport fn_id co ext_name cconv isDyn = do
     let
-       ty                              = pSnd $ coercionKind co
+       ty                              = coercionRKind co
        (_tvs,sans_foralls)             = tcSplitForAllTyVars ty
        (fe_arg_tys', orig_res_ty)      = tcSplitFunTys sans_foralls
        -- We must use tcSplits here, because we want to see
@@ -242,7 +241,7 @@ dsJsImport
   -> Maybe Header
   -> DsM ([Binding], CHeader, CStub)
 dsJsImport id co (CLabel cid) cconv _ _ = do
-   let ty = pFst $ coercionKind co
+   let ty = coercionLKind co
        fod = case tyConAppTyCon_maybe (dropForAlls ty) of
              Just tycon
               | tyConUnique tycon == funPtrTyConKey ->
@@ -272,7 +271,7 @@ dsJsFExportDynamic :: Id
                  -> DsM ([Binding], CHeader, CStub)
 dsJsFExportDynamic id co0 cconv = do
     let
-      ty                            = pFst (coercionKind co0)
+      ty                            = coercionLKind co0
       (tvs,sans_foralls)            = tcSplitForAllTyVars ty
       ([Scaled arg_mult arg_ty], fn_res_ty)  = tcSplitFunTys sans_foralls
       (io_tc, res_ty)               = expectJust "dsJsFExportDynamic: IO type expected"
@@ -342,7 +341,7 @@ dsJsCall :: Id -> Coercion -> ForeignCall -> Maybe Header
         -> DsM ([(Id, Expr TyVar)], CHeader, CStub)
 dsJsCall fn_id co (CCall (CCallSpec target cconv safety)) _mDeclHeader = do
     let
-        ty                   = pFst $ coercionKind co
+        ty                   = coercionLKind co
         (tv_bndrs, rho)      = tcSplitForAllTyVarBinders ty
         (arg_tys, io_res_ty) = tcSplitFunTys rho
 


=====================================
compiler/GHC/Tc/Deriv/Generate.hs
=====================================
@@ -34,7 +34,7 @@ module GHC.Tc.Deriv.Generate (
         gen_Newtype_fam_insts,
         mkCoerceClassMethEqn,
         genAuxBinds,
-        ordOpTbl, boxConTbl, litConTbl,
+        ordOpTbl, boxConTbl,
         mkRdrFunBind, mkRdrFunBindEC, mkRdrFunBindSE, error_Expr,
 
         getPossibleDataCons,
@@ -2363,7 +2363,7 @@ box ::         String           -- The class involved
             -> Type             -- The argument type
             -> LHsExpr GhcPs    -- Boxed version of the arg
 -- See Note [Deriving and unboxed types] in GHC.Tc.Deriv.Infer
-box cls_str arg arg_ty = assoc_ty_id cls_str boxConTbl arg_ty arg
+box cls_str arg arg_ty = nlHsApp (assoc_ty_id cls_str boxConTbl arg_ty) arg
 
 ---------------------
 primOrdOps :: String    -- The class involved
@@ -2403,23 +2403,22 @@ ordOpTbl
     ,(doublePrimTy, (ltDouble_RDR, leDouble_RDR
      , eqDouble_RDR, geDouble_RDR, gtDouble_RDR)) ]
 
--- A mapping from a primitive type to a function that constructs its boxed
--- version.
-boxConTbl :: [(Type, LHsExpr GhcPs -> LHsExpr GhcPs)]
+-- A mapping from a primitive type to a DataCon of its boxed version.
+boxConTbl :: [(Type, LHsExpr GhcPs)]
 boxConTbl =
-    [ (charPrimTy  , nlHsApp (nlHsVar $ getRdrName charDataCon))
-    , (intPrimTy   , nlHsApp (nlHsVar $ getRdrName intDataCon))
-    , (wordPrimTy  , nlHsApp (nlHsVar $ getRdrName wordDataCon ))
-    , (floatPrimTy , nlHsApp (nlHsVar $ getRdrName floatDataCon ))
-    , (doublePrimTy, nlHsApp (nlHsVar $ getRdrName doubleDataCon))
-    , (int8PrimTy,   nlHsApp (nlHsVar int8DataCon_RDR))
-    , (word8PrimTy,  nlHsApp (nlHsVar word8DataCon_RDR))
-    , (int16PrimTy,  nlHsApp (nlHsVar int16DataCon_RDR))
-    , (word16PrimTy, nlHsApp (nlHsVar word16DataCon_RDR))
-    , (int32PrimTy,  nlHsApp (nlHsVar int32DataCon_RDR))
-    , (word32PrimTy, nlHsApp (nlHsVar word32DataCon_RDR))
-    , (int64PrimTy,  nlHsApp (nlHsVar int64DataCon_RDR))
-    , (word64PrimTy, nlHsApp (nlHsVar word64DataCon_RDR))
+    [ (charPrimTy  , nlHsVar $ getRdrName charDataCon)
+    , (intPrimTy   , nlHsVar $ getRdrName intDataCon)
+    , (wordPrimTy  , nlHsVar $ getRdrName wordDataCon)
+    , (floatPrimTy , nlHsVar $ getRdrName floatDataCon)
+    , (doublePrimTy, nlHsVar $ getRdrName doubleDataCon)
+    , (int8PrimTy,   nlHsVar int8DataCon_RDR)
+    , (word8PrimTy,  nlHsVar word8DataCon_RDR)
+    , (int16PrimTy,  nlHsVar int16DataCon_RDR)
+    , (word16PrimTy, nlHsVar word16DataCon_RDR)
+    , (int32PrimTy,  nlHsVar int32DataCon_RDR)
+    , (word32PrimTy, nlHsVar word32DataCon_RDR)
+    , (int64PrimTy,  nlHsVar int64DataCon_RDR)
+    , (word64PrimTy, nlHsVar word64DataCon_RDR)
     ]
 
 
@@ -2443,26 +2442,6 @@ postfixModTbl
     ,(word64PrimTy, "#Word64")
     ]
 
-litConTbl :: [(Type, LHsExpr GhcPs -> LHsExpr GhcPs)]
-litConTbl
-  = [(charPrimTy  , nlHsApp (nlHsVar charPrimL_RDR))
-    ,(intPrimTy   , nlHsApp (nlHsVar intPrimL_RDR)
-                      . nlHsApp (nlHsVar toInteger_RDR))
-    ,(wordPrimTy  , nlHsApp (nlHsVar wordPrimL_RDR)
-                      . nlHsApp (nlHsVar toInteger_RDR))
-    ,(addrPrimTy  , nlHsApp (nlHsVar stringPrimL_RDR)
-                      . nlHsApp (nlHsApp
-                          (nlHsVar map_RDR)
-                          (compose_RDR `nlHsApps`
-                            [ nlHsVar fromIntegral_RDR
-                            , nlHsVar fromEnum_RDR
-                            ])))
-    ,(floatPrimTy , nlHsApp (nlHsVar floatPrimL_RDR)
-                      . nlHsApp (nlHsVar toRational_RDR))
-    ,(doublePrimTy, nlHsApp (nlHsVar doublePrimL_RDR)
-                      . nlHsApp (nlHsVar toRational_RDR))
-    ]
-
 -- | Lookup `Type` in an association list.
 assoc_ty_id :: HasCallStack => String           -- The class involved
             -> [(Type,a)]       -- The table


=====================================
compiler/GHC/Tc/Gen/HsType.hs
=====================================
@@ -3552,7 +3552,7 @@ filterConstrainedCandidates
   -> TcM CandidatesQTvs
 -- filterConstrainedCandidates removes any candidates that are free in
 -- 'wanted'; instead, it promotes them.  This bit is very much like
--- decideMonoTyVars in GHC.Tc.Solver, but constraints are so much
+-- decidePromotedTyVars in GHC.Tc.Solver, but constraints are so much
 -- simpler in kinds, it is much easier here. (In particular, we never
 -- quantify over a constraint in a type.)
 filterConstrainedCandidates wanted dvs


=====================================
compiler/GHC/Tc/Gen/Pat.hs
=====================================
@@ -1058,7 +1058,7 @@ tcPatSynPat (L con_span con_name) pat_syn pat_ty penv arg_pats thing_inside
           -- 'tcDataConPat'.)
         ; let
             bad_arg_tys :: [(Int, Scaled Type)]
-            bad_arg_tys = filter (\ (_, Scaled _ arg_ty) -> typeLevity_maybe arg_ty == Nothing)
+            bad_arg_tys = filter (\ (_, Scaled _ arg_ty) -> not (typeHasFixedRuntimeRep arg_ty))
                         $ zip [0..] arg_tys'
         ; massertPpr (null bad_arg_tys) $
             vcat [ text "tcPatSynPat: pattern arguments do not have a fixed RuntimeRep"


=====================================
compiler/GHC/Tc/Instance/FunDeps.hs
=====================================
@@ -527,7 +527,7 @@ also know `t2` and the other way.
 closeWrtFunDeps is used
  - when checking the coverage condition for an instance declaration
  - when determining which tyvars are unquantifiable during generalization, in
-   GHC.Tc.Solver.decideMonoTyVars.
+   GHC.Tc.Solver.decidePromotedTyVars.
 
 Note [Equality superclasses]
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~


=====================================
compiler/GHC/Tc/Utils/TcMType.hs
=====================================
@@ -1717,7 +1717,7 @@ we leave it alone.
 
 Note that not *every* variable with a higher level will get
 generalised, either due to the monomorphism restriction or other
-quirks. See, for example, the code in GHC.Tc.Solver.decideMonoTyVars
+quirks. See, for example, the code in GHC.Tc.Solver.decidePromotedTyVars
 and in GHC.Tc.Gen.HsType.kindGeneralizeSome, both of which exclude
 certain otherwise-eligible variables from being generalised.
 


=====================================
compiler/GHC/Tc/Utils/TcType.hs
=====================================
@@ -2001,8 +2001,8 @@ being the )
 -}
 
 tcSplitIOType_maybe :: Type -> Maybe (TyCon, Type)
--- (tcSplitIOType_maybe t) returns Just (IO,t',co)
---              if co : t ~ IO t'
+-- (tcSplitIOType_maybe t) returns Just (IO,t')
+--              if t = IO t'
 --              returns Nothing otherwise
 tcSplitIOType_maybe ty
   = case tcSplitTyConApp_maybe ty of


=====================================
compiler/GHC/Tc/Zonk/Type.hs
=====================================
@@ -1194,7 +1194,7 @@ zonk_cmd_top (HsCmdTop (CmdTopTc stack_tys ty ids) cmd)
        new_ty <- zonkTcTypeToTypeX ty
        new_ids <- mapSndM zonkExpr ids
 
-       massert (isLiftedTypeKind (typeKind new_stack_tys))
+       massert (definitelyLiftedType new_stack_tys)
          -- desugarer assumes that this is not representation-polymorphic...
          -- but indeed it should always be lifted due to the typing
          -- rules for arrows


=====================================
libraries/base/GHC/Exts.hs
=====================================



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a7349217fb9a992ad1c0e0d6ce1ab78e29dbe144

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a7349217fb9a992ad1c0e0d6ce1ab78e29dbe144
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20230722/4f50f358/attachment-0001.html>


More information about the ghc-commits mailing list