summaryrefslogtreecommitdiff
path: root/ghc
diff options
context:
space:
mode:
authorVladislav Zavialov <vlad.z.4096@gmail.com>2022-11-18 12:53:00 +0300
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-11-25 04:39:04 -0500
commit13d627bbd0bc3dd30d672de341aa7f471be0aa2c (patch)
tree3464a8c6dca4b9bb47db356352d964279eca94fe /ghc
parent1f1b99b86ab2b005604aea08b0614279a8ad1244 (diff)
downloadhaskell-13d627bbd0bc3dd30d672de341aa7f471be0aa2c.tar.gz
Print unticked promoted data constructors (#20531)
Before this patch, GHC unconditionally printed ticks before promoted data constructors: ghci> type T = True -- unticked (user-written) ghci> :kind! T T :: Bool = 'True -- ticked (compiler output) After this patch, GHC prints ticks only when necessary: ghci> type F = False -- unticked (user-written) ghci> :kind! F F :: Bool = False -- unticked (compiler output) ghci> data False -- introduce ambiguity ghci> :kind! F F :: Bool = 'False -- ticked by necessity (compiler output) The old behavior can be enabled by -fprint-redundant-promotion-ticks. Summary of changes: * Rename PrintUnqualified to NamePprCtx * Add QueryPromotionTick to it * Consult the GlobalRdrEnv to decide whether to print a tick (see mkPromTick) * Introduce -fprint-redundant-promotion-ticks Co-authored-by: Artyom Kuznetsov <hi@wzrd.ht>
Diffstat (limited to 'ghc')
-rw-r--r--ghc/GHCi/UI.hs4
-rw-r--r--ghc/GHCi/UI/Monad.hs14
2 files changed, 9 insertions, 9 deletions
diff --git a/ghc/GHCi/UI.hs b/ghc/GHCi/UI.hs
index 9327ac6da7..a2d16080f8 100644
--- a/ghc/GHCi/UI.hs
+++ b/ghc/GHCi/UI.hs
@@ -302,8 +302,8 @@ showSDocForUser' :: GHC.GhcMonad m => SDoc -> m String
showSDocForUser' doc = do
dflags <- getDynFlags
unit_state <- hsc_units <$> GHC.getSession
- unqual <- GHC.getPrintUnqual
- pure $ showSDocForUser dflags unit_state unqual doc
+ name_ppr_ctx <- GHC.getNamePprCtx
+ pure $ showSDocForUser dflags unit_state name_ppr_ctx doc
showSDocForUserQualify :: GHC.GhcMonad m => SDoc -> m String
showSDocForUserQualify doc = do
diff --git a/ghc/GHCi/UI/Monad.hs b/ghc/GHCi/UI/Monad.hs
index 3e6b834e11..fdd083c47b 100644
--- a/ghc/GHCi/UI/Monad.hs
+++ b/ghc/GHCi/UI/Monad.hs
@@ -364,21 +364,21 @@ printForUserNeverQualify doc = do
printForUserModInfo :: GhcMonad m => GHC.ModuleInfo -> SDoc -> m ()
printForUserModInfo info doc = do
dflags <- GHC.getInteractiveDynFlags
- mUnqual <- GHC.mkPrintUnqualifiedForModule info
- unqual <- maybe GHC.getPrintUnqual return mUnqual
- liftIO $ Ppr.printForUser dflags stdout unqual AllTheWay doc
+ m_name_ppr_ctx <- GHC.mkNamePprCtxForModule info
+ name_ppr_ctx <- maybe GHC.getNamePprCtx return m_name_ppr_ctx
+ liftIO $ Ppr.printForUser dflags stdout name_ppr_ctx AllTheWay doc
printForUser :: GhcMonad m => SDoc -> m ()
printForUser doc = do
- unqual <- GHC.getPrintUnqual
+ name_ppr_ctx <- GHC.getNamePprCtx
dflags <- GHC.getInteractiveDynFlags
- liftIO $ Ppr.printForUser dflags stdout unqual AllTheWay doc
+ liftIO $ Ppr.printForUser dflags stdout name_ppr_ctx AllTheWay doc
printForUserPartWay :: GhcMonad m => SDoc -> m ()
printForUserPartWay doc = do
- unqual <- GHC.getPrintUnqual
+ name_ppr_ctx <- GHC.getNamePprCtx
dflags <- GHC.getInteractiveDynFlags
- liftIO $ Ppr.printForUser dflags stdout unqual DefaultDepth doc
+ liftIO $ Ppr.printForUser dflags stdout name_ppr_ctx DefaultDepth doc
-- | Run a single Haskell expression
runStmt