diff options
author | Sylvain Henry <sylvain@haskus.fr> | 2021-03-11 17:41:51 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-04-29 17:29:44 -0400 |
commit | 1d03d8bef962e6789db44e8b6f2cfd9e34f3f5ad (patch) | |
tree | d77ec6ba70bc70e87e954ecb2f56cfa39d12159e /compiler/GHC/Rename | |
parent | c2541c49f162f1d03b0ae55f47b9c76cc96df76f (diff) | |
download | haskell-1d03d8bef962e6789db44e8b6f2cfd9e34f3f5ad.tar.gz |
Replace (ptext .. sLit) with `text`
1. `text` is as efficient as `ptext . sLit` thanks to the rewrite rules
2. `text` is visually nicer than `ptext . sLit`
3. `ptext . sLit` encourages using one `ptext` for several `sLit` as in:
ptext $ case xy of
... -> sLit ...
... -> sLit ...
which may allocate SDoc's TextBeside constructors at runtime instead
of sharing them into CAFs.
Diffstat (limited to 'compiler/GHC/Rename')
-rw-r--r-- | compiler/GHC/Rename/Env.hs | 4 | ||||
-rw-r--r-- | compiler/GHC/Rename/Expr.hs | 2 | ||||
-rw-r--r-- | compiler/GHC/Rename/HsType.hs | 9 | ||||
-rw-r--r-- | compiler/GHC/Rename/Names.hs | 11 | ||||
-rw-r--r-- | compiler/GHC/Rename/Unbound.hs | 2 | ||||
-rw-r--r-- | compiler/GHC/Rename/Utils.hs | 4 |
6 files changed, 15 insertions, 17 deletions
diff --git a/compiler/GHC/Rename/Env.hs b/compiler/GHC/Rename/Env.hs index 67b3d0d8c0..d204e6ed0e 100644 --- a/compiler/GHC/Rename/Env.hs +++ b/compiler/GHC/Rename/Env.hs @@ -1531,7 +1531,7 @@ warnIfDeprecated gre@(GRE { gre_imp = iss }) occ = greOccName gre name = greMangledName gre name_mod = ASSERT2( isExternalName name, ppr name ) nameModule name - doc = text "The name" <+> quotes (ppr occ) <+> ptext (sLit "is mentioned explicitly") + doc = text "The name" <+> quotes (ppr occ) <+> text "is mentioned explicitly" mk_msg imp_spec txt = sep [ sep [ text "In the use of" @@ -1845,7 +1845,7 @@ lookupBindGroupOcc ctxt what rdr_name , nest 2 $ text "lacks an accompanying binding"] $$ nest 2 msg)) - local_msg = parens $ text "The" <+> what <+> ptext (sLit "must be given where") + local_msg = parens $ text "The" <+> what <+> text "must be given where" <+> quotes (ppr rdr_name) <+> text "is declared" -- Identify all similar names and produce a message listing them diff --git a/compiler/GHC/Rename/Expr.hs b/compiler/GHC/Rename/Expr.hs index bbf52be2f8..0ddd207148 100644 --- a/compiler/GHC/Rename/Expr.hs +++ b/compiler/GHC/Rename/Expr.hs @@ -2360,7 +2360,7 @@ checkStmt ctxt (L _ stmt) IsValid -> return () NotValid extra -> addErr (msg $$ extra) } where - msg = sep [ text "Unexpected" <+> pprStmtCat stmt <+> ptext (sLit "statement") + msg = sep [ text "Unexpected" <+> pprStmtCat stmt <+> text "statement" , text "in" <+> pprAStmtContext ctxt ] pprStmtCat :: Stmt (GhcPass a) body -> SDoc diff --git a/compiler/GHC/Rename/HsType.hs b/compiler/GHC/Rename/HsType.hs index f92100ffe2..e9ee8bb31b 100644 --- a/compiler/GHC/Rename/HsType.hs +++ b/compiler/GHC/Rename/HsType.hs @@ -68,7 +68,6 @@ import GHC.Types.Fixity ( compareFixity, negateFixity import GHC.Types.Basic ( TypeOrKind(..) ) import GHC.Utils.Outputable import GHC.Utils.Panic -import GHC.Data.FastString import GHC.Data.Maybe import qualified GHC.LanguageExtensions as LangExt @@ -831,7 +830,7 @@ rnHsTyOp env overall_ty (L loc op) -------------- notAllowed :: SDoc -> SDoc notAllowed doc - = text "Wildcard" <+> quotes doc <+> ptext (sLit "not allowed") + = text "Wildcard" <+> quotes doc <+> text "not allowed" checkWildCard :: RnTyKiEnv -> Maybe SDoc -> RnM () checkWildCard env (Just doc) @@ -1593,7 +1592,7 @@ precParseErr op1@(n1,_) op2@(n2,_) = return () -- Avoid error cascade | otherwise = addErr $ hang (text "Precedence parsing error") - 4 (hsep [text "cannot mix", ppr_opfix op1, ptext (sLit "and"), + 4 (hsep [text "cannot mix", ppr_opfix op1, text "and", ppr_opfix op2, text "in the same infix expression"]) @@ -1602,7 +1601,7 @@ sectionPrecErr op@(n1,_) arg_op@(n2,_) section | is_unbound n1 || is_unbound n2 = return () -- Avoid error cascade | otherwise - = addErr $ vcat [text "The operator" <+> ppr_opfix op <+> ptext (sLit "of a section"), + = addErr $ vcat [text "The operator" <+> ppr_opfix op <+> text "of a section", nest 4 (sep [text "must have lower precedence than that of the operand,", nest 2 (text "namely" <+> ppr_opfix arg_op)]), nest 4 (text "in the section:" <+> quotes (ppr section))] @@ -1655,7 +1654,7 @@ warnUnusedForAll doc (L loc tv) used_names opTyErr :: Outputable a => RdrName -> a -> SDoc opTyErr op overall_ty - = hang (text "Illegal operator" <+> quotes (ppr op) <+> ptext (sLit "in type") <+> quotes (ppr overall_ty)) + = hang (text "Illegal operator" <+> quotes (ppr op) <+> text "in type" <+> quotes (ppr overall_ty)) 2 (text "Use TypeOperators to allow operators in types") {- diff --git a/compiler/GHC/Rename/Names.hs b/compiler/GHC/Rename/Names.hs index 32d9bd0da8..2abc65e001 100644 --- a/compiler/GHC/Rename/Names.hs +++ b/compiler/GHC/Rename/Names.hs @@ -356,8 +356,7 @@ rnImportDecl this_mod (warnRedundantSourceImport imp_mod_name) when (mod_safe && not (safeImportsOn dflags)) $ addErr (text "safe import can't be used as Safe Haskell isn't on!" - $+$ ptext (sLit $ "please enable Safe Haskell through either " - ++ "Safe, Trustworthy or Unsafe")) + $+$ text ("please enable Safe Haskell through either Safe, Trustworthy or Unsafe")) let qual_mod_name = fmap unLoc as_mod `orElse` imp_mod_name @@ -2012,7 +2011,7 @@ dodgyImportWarn item dodgyMsg :: (Outputable a, Outputable b) => SDoc -> a -> b -> SDoc dodgyMsg kind tc ie - = sep [ text "The" <+> kind <+> ptext (sLit "item") + = sep [ text "The" <+> kind <+> text "item" -- <+> quotes (ppr (IEThingAll (noLoc (IEName $ noLoc tc)))) <+> quotes (ppr ie) <+> text "suggests that", @@ -2047,15 +2046,15 @@ addDupDeclErr gres@(gre : _) missingImportListWarn :: ModuleName -> SDoc missingImportListWarn mod - = text "The module" <+> quotes (ppr mod) <+> ptext (sLit "does not have an explicit import list") + = text "The module" <+> quotes (ppr mod) <+> text "does not have an explicit import list" missingImportListItem :: IE GhcPs -> SDoc missingImportListItem ie - = text "The import item" <+> quotes (ppr ie) <+> ptext (sLit "does not have an explicit import list") + = text "The import item" <+> quotes (ppr ie) <+> text "does not have an explicit import list" moduleWarn :: ModuleName -> WarningTxt -> SDoc moduleWarn mod (WarningTxt _ txt) - = sep [ text "Module" <+> quotes (ppr mod) <> ptext (sLit ":"), + = sep [ text "Module" <+> quotes (ppr mod) <> colon, nest 2 (vcat (map (ppr . sl_fs . unLoc) txt)) ] moduleWarn mod (DeprecatedTxt _ txt) = sep [ text "Module" <+> quotes (ppr mod) diff --git a/compiler/GHC/Rename/Unbound.hs b/compiler/GHC/Rename/Unbound.hs index 9ebd15e5f6..ab651b93a7 100644 --- a/compiler/GHC/Rename/Unbound.hs +++ b/compiler/GHC/Rename/Unbound.hs @@ -417,7 +417,7 @@ there are 2 cases, where we hide the last "no module is imported" line: exactNameErr :: Name -> SDoc exactNameErr name = - hang (text "The exact Name" <+> quotes (ppr name) <+> ptext (sLit "is not in scope")) + hang (text "The exact Name" <+> quotes (ppr name) <+> text "is not in scope") 2 (vcat [ text "Probable cause: you used a unique Template Haskell name (NameU), " , text "perhaps via newName, but did not bind it" , text "If that's it, then -ddump-splices might be useful" ]) diff --git a/compiler/GHC/Rename/Utils.hs b/compiler/GHC/Rename/Utils.hs index e5d27fa234..e87721edaf 100644 --- a/compiler/GHC/Rename/Utils.hs +++ b/compiler/GHC/Rename/Utils.hs @@ -451,7 +451,7 @@ warnUnusedGRE gre@(GRE { gre_lcl = lcl, gre_imp = is }) where span = importSpecLoc spec pp_mod = quotes (ppr (importSpecModule spec)) - msg = text "Imported from" <+> pp_mod <+> ptext (sLit "but not used") + msg = text "Imported from" <+> pp_mod <+> text "but not used" -- | Make a map from selector names to field labels and parent tycon -- names, to be used when reporting unused record fields. @@ -618,7 +618,7 @@ checkTupSize tup_size | tup_size <= mAX_TUPLE_SIZE = return () | otherwise - = addErr (sep [text "A" <+> int tup_size <> ptext (sLit "-tuple is too large for GHC"), + = addErr (sep [text "A" <+> int tup_size <> text "-tuple is too large for GHC", nest 2 (parens (text "max size is" <+> int mAX_TUPLE_SIZE)), nest 2 (text "Workaround: use nested tuples or define a data type")]) |