diff options
Diffstat (limited to 'compiler/GHC/Utils/Outputable.hs')
-rw-r--r-- | compiler/GHC/Utils/Outputable.hs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/compiler/GHC/Utils/Outputable.hs b/compiler/GHC/Utils/Outputable.hs index 7d33007ead..7d0436f2f2 100644 --- a/compiler/GHC/Utils/Outputable.hs +++ b/compiler/GHC/Utils/Outputable.hs @@ -57,6 +57,7 @@ module GHC.Utils.Outputable ( showSDocUnsafe, showPprUnsafe, renderWithContext, + pprDebugAndThen, pprInfixVar, pprPrefixVar, pprHsChar, pprHsString, pprHsBytes, @@ -607,6 +608,13 @@ showPprUnsafe :: Outputable a => a -> String showPprUnsafe a = renderWithContext defaultSDocContext (ppr a) +pprDebugAndThen :: SDocContext -> (String -> a) -> SDoc -> SDoc -> a +pprDebugAndThen ctx cont heading pretty_msg + = cont (renderWithContext ctx doc) + where + doc = withPprStyle defaultDumpStyle (sep [heading, nest 2 pretty_msg]) + + isEmpty :: SDocContext -> SDoc -> Bool isEmpty ctx sdoc = Pretty.isEmpty $ runSDoc sdoc (ctx {sdocPprDebug = True}) |