[Git][ghc/ghc][wip/marge_bot_batch_merge_job] Add utility pprTrace_ function
Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC Commits: 5e924580 by sheaf at 2026-04-05T12:05:13-04:00 Add utility pprTrace_ function This function is useful for quick debugging, as it can be added to a where clause to pretty-print debugging information: fooBar x y | cond = body1 | otherwise = body2 where !_ = pprTrace_ "fooBar" $ vcat [ text "x:" <+> ppr x , text "y:" <+> ppr y , text "cond:" <+> ppr cond ] - - - - - 1 changed file: - compiler/GHC/Utils/Trace.hs Changes: ===================================== compiler/GHC/Utils/Trace.hs ===================================== @@ -1,6 +1,7 @@ -- | Tracing utilities module GHC.Utils.Trace ( pprTrace + , pprTrace_ , pprTraceM , pprTraceDebug , pprTraceIt @@ -43,6 +44,22 @@ pprTrace str doc x | unsafeHasNoDebugOutput = x | otherwise = pprDebugAndThen traceSDocContext trace (text str) doc x +-- | A version of 'pprTrace' that is useful for quick debugging: +-- +-- @ +-- fooBar x y +-- | cond = body1 +-- | otherwise = body2 +-- where +-- !_ = pprTrace_ "fooBar" $ +-- vcat [ text "x:" <+> ppr x +-- , text "y:" <+> ppr y +-- , text "cond:" <+> ppr cond +-- ] +-- @ +pprTrace_ :: String -> SDoc -> () +pprTrace_ str doc = pprTrace str doc () + pprTraceM :: Applicative f => String -> SDoc -> f () pprTraceM str doc = pprTrace str doc (pure ()) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5e924580d77c483967fd2d3d4591ce1c... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5e924580d77c483967fd2d3d4591ce1c... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Marge Bot (@marge-bot)