Simon Peyton Jones pushed to branch wip/T26330 at Glasgow Haskell Compiler / GHC Commits: fc907ec7 by Simon Peyton Jones at 2025-09-19T13:13:25+01:00 Use Outputable.ellipsis rather than text "..." - - - - - 13 changed files: - compiler/GHC/Core/Opt/Simplify/Env.hs - compiler/GHC/Core/Ppr.hs - compiler/GHC/HsToCore/Errors/Ppr.hs - compiler/GHC/HsToCore/Pmc/Ppr.hs - compiler/GHC/HsToCore/Pmc/Types.hs - compiler/GHC/Iface/Syntax.hs - compiler/GHC/Llvm/Ppr.hs - compiler/GHC/Llvm/Types.hs - compiler/GHC/Runtime/Loader.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Types/Hint/Ppr.hs - compiler/GHC/Utils/Outputable.hs - compiler/GHC/Utils/Ppr.hs Changes: ===================================== compiler/GHC/Core/Opt/Simplify/Env.hs ===================================== @@ -309,7 +309,7 @@ data SimplPhase instance Outputable SimplPhase where ppr (SimplPhase p) = ppr p - ppr (SimplPhaseRange s e) = brackets $ ppr s <> text "..." <> ppr e + ppr (SimplPhaseRange s e) = brackets $ ppr s <> ellipsis <> ppr e -- | Is this activation active in this simplifier phase? -- ===================================== compiler/GHC/Core/Ppr.hs ===================================== @@ -175,7 +175,7 @@ pprOptCo co = sdocOption sdocSuppressCoercions $ \case False -> parens $ sep [ppr co, dcolon <+> co_type] where co_type = sdocOption sdocSuppressCoercionTypes $ \case - True -> text "..." + True -> ellipsis False -> ppr (coercionType co) ppr_id_occ :: (SDoc -> SDoc) -> Id -> SDoc ===================================== compiler/GHC/HsToCore/Errors/Ppr.hs ===================================== @@ -246,7 +246,7 @@ instance Diagnostic DsMessage where <+> text "may fail for the following constructors:") 2 (hsep $ punctuate comma $ - map ppr (take maxCons cons) ++ [ text "..." | lengthExceeds cons maxCons ]) + map ppr (take maxCons cons) ++ [ ellipsis | lengthExceeds cons maxCons ]) diagnosticReason = \case DsUnknownMessage m -> diagnosticReason m @@ -338,7 +338,7 @@ badMonadBind elt_ty -- Print a single clause (for redundant/with-inaccessible-rhs) pprEqn :: HsMatchContextRn -> SDoc -> String -> SDoc pprEqn ctx q txt = pprContext True ctx (text txt) $ \f -> - f (q <+> matchSeparator ctx <+> text "...") + f (q <+> matchSeparator ctx <+> ellipsis) pprContext :: Bool -> HsMatchContextRn -> SDoc -> ((SDoc -> SDoc) -> SDoc) -> SDoc pprContext singular kind msg rest_of_msg_fun @@ -357,5 +357,5 @@ pprContext singular kind msg rest_of_msg_fun dots :: Int -> [a] -> SDoc dots maxPatterns qs - | qs `lengthExceeds` maxPatterns = text "..." + | qs `lengthExceeds` maxPatterns = ellipsis | otherwise = empty ===================================== compiler/GHC/HsToCore/Pmc/Ppr.hs ===================================== @@ -62,7 +62,7 @@ pprRefutableShapes (var, alts) = var <+> text "is not one of" <+> format_alts alts where format_alts = braces . fsep . punctuate comma . shorten . map ppr_alt - shorten (a:b:c:_:_) = a:b:c:[text "..."] + shorten (a:b:c:_:_) = a:b:c:[ellipsis] shorten xs = xs ppr_alt (PmAltConLike cl) = ppr cl ppr_alt (PmAltLit lit) = ppr lit ===================================== compiler/GHC/HsToCore/Pmc/Types.hs ===================================== @@ -217,7 +217,7 @@ instance Outputable p => Outputable (PmGRHS p) where instance Outputable p => Outputable (PmPatBind p) where ppr (PmPatBind PmGRHS { pg_grds = grds, pg_rhs = bind }) = - ppr bind <+> ppr grds <+> text "=" <+> text "..." + ppr bind <+> ppr grds <+> text "=" <+> ellipsis instance Outputable PmEmptyCase where ppr (PmEmptyCase { pe_var = var }) = ===================================== compiler/GHC/Iface/Syntax.hs ===================================== @@ -941,7 +941,7 @@ ppr_trim xs where go (Just doc) (_, so_far) = (False, doc : so_far) go Nothing (True, so_far) = (True, so_far) - go Nothing (False, so_far) = (True, text "..." : so_far) + go Nothing (False, so_far) = (True, ellipsis : so_far) isIfaceDataInstance :: IfaceTyConParent -> Bool isIfaceDataInstance IfNoParent = False ===================================== compiler/GHC/Llvm/Ppr.hs ===================================== @@ -199,10 +199,7 @@ ppLlvmFunctionDecls decs = vcat $ map ppLlvmFunctionDecl decs -- the function. ppLlvmFunctionDecl :: IsDoc doc => LlvmFunctionDecl -> doc ppLlvmFunctionDecl (LlvmFunctionDecl n l c r varg p a) - = let varg' = case varg of - VarArgs | null p -> text "..." - | otherwise -> text ", ..." - _otherwise -> text "" + = let varg' = ppVarArgsEllipsis varg p align = case a of Just a' -> text " align" <+> int a' Nothing -> empty ===================================== compiler/GHC/Llvm/Types.hs ===================================== @@ -100,15 +100,17 @@ ppLlvmTypeShort t = case t of LMVector l t -> "v" ++ show l ++ ppLlvmTypeShort t _ -> pprPanic "ppLlvmTypeShort" (ppLlvmType t) +ppVarArgsEllipsis :: IsLine doc => LlvmParameterListType -> [LlvmParameter] -> doc +ppVarArgsEllipsis list_type args + = case list_type of + FixedArgs -> text "" + VarArgs | null args -> text "..." -- Can't use ellipsis, comma here, + | otherwise -> text ", ..." -- because they aren't methods of IsLine + ppParams :: IsLine doc => LlvmParameterListType -> [LlvmParameter] -> doc ppParams varg p - = let varg' = case varg of - VarArgs | null args -> text "..." - | otherwise -> text ", ..." - _otherwise -> text "" - -- by default we don't print param attributes - args = map fst p - in ppCommaJoin ppLlvmType args <> varg' + = ppCommaJoin ppLlvmType (map fst p) <> ppVarArgsEllipsis varg p + {-# SPECIALIZE ppParams :: LlvmParameterListType -> [LlvmParameter] -> SDoc #-} {-# SPECIALIZE ppParams :: LlvmParameterListType -> [LlvmParameter] -> HLine #-} -- see Note [SPECIALIZE to HDoc] in GHC.Utils.Outputable ===================================== compiler/GHC/Runtime/Loader.hs ===================================== @@ -317,7 +317,7 @@ getHValueSafely interp hsc_env val_name expected_type = do lessUnsafeCoerce :: Logger -> String -> a -> IO b lessUnsafeCoerce logger context what = do debugTraceMsg logger 3 $ - (text "Coercing a value in") <+> (text context) <> (text "...") + (text "Coercing a value in") <+> text context <> ellipsis output <- evaluate (unsafeCoerce what) debugTraceMsg logger 3 (text "Successfully evaluated coercion") return output ===================================== compiler/GHC/Tc/Errors/Ppr.hs ===================================== @@ -1399,7 +1399,7 @@ instance Diagnostic TcRnMessage where EmptyCaseForall tvb -> vcat [ text "Empty list of alternatives in" <+> pp_ctxt , hang (text "checked against a forall-type:") - 2 (pprForAll [tvb] <+> text "...") + 2 (pprForAll [tvb] <+> ellipsis) ] where pp_ctxt = case ctxt of @@ -1591,7 +1591,7 @@ instance Diagnostic TcRnMessage where <+> text "may fail for the following constructors:") 2 (hsep $ punctuate comma $ - map ppr (take maxCons cons) ++ [ text "..." | lengthExceeds cons maxCons ]) + map ppr (take maxCons cons) ++ [ ellipsis | lengthExceeds cons maxCons ]) TcRnBadFieldAnnotation n con reason -> mkSimpleDecorated $ hang (pprBadFieldAnnotationReason reason) 2 (text "on the" <+> speakNth n @@ -3759,7 +3759,7 @@ derivErrDiagnosticMessage cls cls_tys mb_strat newtype_deriving pprHerald = \cas DerivErrNotWellKinded tc cls_kind _ -> sep [ hang (text "Cannot derive well-kinded instance of form" <+> quotes (pprClassPred cls cls_tys - <+> parens (ppr tc <+> text "..."))) + <+> parens (ppr tc <+> ellipsis))) 2 empty , nest 2 (text "Class" <+> quotes (ppr cls) <+> text "expects an argument of kind" @@ -6819,7 +6819,7 @@ pprInvalidAssocDefault = \case ppr_eqn :: SDoc ppr_eqn = quotes (text "type" <+> ppr (mkTyConApp fam_tc pat_tys) - <+> equals <+> text "...") + <+> equals <+> ellipsis) suggestion :: SDoc suggestion = text "The arguments to" <+> quotes (ppr fam_tc) ===================================== compiler/GHC/Types/Hint/Ppr.hs ===================================== @@ -227,7 +227,7 @@ instance Outputable GhcHint where <+> text "pattern synonym, e.g.") 2 (hang (text "pattern" <+> pp_name <+> pp_args <+> larrow <+> ppr pat <+> text "where") - 2 (pp_name <+> pp_args <+> equals <+> text "...")) + 2 (pp_name <+> pp_args <+> equals <+> ellipsis)) where pp_name = ppr name pp_args = hsep (map ppr args) ===================================== compiler/GHC/Utils/Outputable.hs ===================================== @@ -46,7 +46,7 @@ module GHC.Utils.Outputable ( arrow, lollipop, larrow, darrow, arrowt, larrowt, arrowtt, larrowtt, lambda, lparen, rparen, lbrack, rbrack, lbrace, rbrace, underscore, - blankLine, forAllLit, bullet, + blankLine, forAllLit, bullet, ellipsis, ($+$), cat, fcat, hang, hangNotEmpty, punctuate, punctuateFinal, @@ -521,7 +521,7 @@ withPprStyle sty d = SDoc $ \ctxt -> runSDoc d ctxt{sdocStyle=sty} pprDeeper :: SDoc -> SDoc pprDeeper d = SDoc $ \ctx -> case sdocStyle ctx of PprUser q depth c -> - let deeper 0 = Pretty.text "..." + let deeper 0 = Pretty.ellipsis deeper n = runSDoc d ctx{sdocStyle = PprUser q (PartWay (n-1)) c} in case depth of DefaultDepth -> deeper (sdocDefaultDepth ctx) @@ -551,7 +551,7 @@ pprDeeperList f ds trim :: Int -> [SDoc] -> [SDoc] trim _ [] = [] -trim 0 _ = [text "..."] +trim 0 _ = [ellipsis] trim n (d:ds) = d : trim (n-1) ds pprSetDepth :: Depth -> SDoc -> SDoc @@ -773,7 +773,7 @@ quotes d = sdocOption sdocCanUseUnicode $ \case | otherwise -> Pretty.quotes pp_d blankLine, dcolon, arrow, lollipop, larrow, darrow, arrowt, larrowt, arrowtt, - larrowtt, lambda :: SDoc + larrowtt, lambda, ellipsis :: SDoc blankLine = docToSDoc Pretty.emptyText dcolon = unicodeSyntax (char '∷') (text "::") @@ -786,6 +786,7 @@ larrowt = unicodeSyntax (char '⤙') (text "-<") arrowtt = unicodeSyntax (char '⤜') (text ">>-") larrowtt = unicodeSyntax (char '⤛') (text "-<<") lambda = unicodeSyntax (char 'λ') (char '\\') +ellipsis = docToSDoc Pretty.ellipsis semi, comma, colon, equals, space, underscore, dot, vbar :: IsLine doc => doc lparen, rparen, lbrack, rbrack, lbrace, rbrace :: IsLine doc => doc ===================================== compiler/GHC/Utils/Ppr.hs ===================================== @@ -74,7 +74,7 @@ module GHC.Utils.Ppr ( int, integer, float, double, rational, hex, -- ** Simple derived documents - semi, comma, colon, space, equals, + semi, comma, colon, space, equals, ellipsis, lparen, rparen, lbrack, rbrack, lbrace, rbrace, -- ** Wrapping documents in delimiters @@ -424,6 +424,7 @@ lbrack :: Doc -- ^ A '[' character rbrack :: Doc -- ^ A ']' character lbrace :: Doc -- ^ A '{' character rbrace :: Doc -- ^ A '}' character +ellipsis :: Doc -- ^ A '...' ellipsis semi = char ';' comma = char ',' colon = char ':' @@ -435,6 +436,7 @@ lbrack = char '[' rbrack = char ']' lbrace = char '{' rbrace = char '}' +ellipsis = text "..." spaceText, nlText :: TextDetails spaceText = Chr ' ' View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/fc907ec7df0766b0e84c4ea41e73b469... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/fc907ec7df0766b0e84c4ea41e73b469... You're receiving this email because of your account on gitlab.haskell.org.