[Git][ghc/ghc][wip/T26330] Improve pretty printer for HsExpr
Simon Peyton Jones pushed to branch wip/T26330 at Glasgow Haskell Compiler / GHC Commits: 306e4416 by Simon Peyton Jones at 2025-09-18T23:25:07+01:00 Improve pretty printer for HsExpr Given a very deeply-nested application, it just kept printing deeper and deeper. This small change makes it cut off. Test is in #26330, but we also get a dramatic decrease in compile time for perf/compiler/InstanceMatching: InstanceMatching 4,086,884,584 1,181,767,232 -71.1% GOOD Why? Because before we got a GIGANTIC error message that took ages to pretty-print; now we get this much more civilised message (I have removed some whitespace.) Match.hs:1007:1: error: • No instance for ‘Show (F001 a)’ arising from a use of ‘showsPrec’ • In the second argument of ‘showString’, namely ‘(showsPrec 11 b1 (GHC.Internal.Show.showSpace (showsPrec 11 b2 (GHC.Internal.Show.showSpace (showsPrec 11 b3 (GHC.Internal.Show.showSpace (showsPrec 11 b4 (GHC.Internal.Show.showSpace (showsPrec 11 b5 (GHC.Internal.Show.showSpace (showsPrec 11 b6 (GHC.Internal.Show.showSpace (showsPrec ...)))))))))))))’ ----------------------- The main payload is * At the start of `pprExpr` * In the defn of `pprApp` A little bit of refactoring: * It turned out that we were setting the default cut-off depth to a fixed value in two places, so changing one didn't change the other. See defaultSDocDepth and defaultSDocCols * I refactored `pprDeeperList` a bit so I could understand it better. Because the depth calculation has changed, there are lots of small error message wibbles. Metric Decrease: InstanceMatching - - - - - 39 changed files: - compiler/GHC/Driver/DynFlags.hs - compiler/GHC/Hs/Expr.hs - compiler/GHC/Runtime/Heap/Inspect.hs - compiler/GHC/Utils/Outputable.hs - testsuite/tests/arrows/gadt/T17423.stderr - testsuite/tests/indexed-types/should_compile/PushedInAsGivens.stderr - testsuite/tests/indexed-types/should_fail/T26176.stderr - testsuite/tests/indexed-types/should_fail/T2693.stderr - testsuite/tests/indexed-types/should_fail/T4093b.stderr - testsuite/tests/indexed-types/should_fail/T8518.stderr - testsuite/tests/indexed-types/should_fail/T9662.stderr - testsuite/tests/linear/should_fail/Linear17.stderr - testsuite/tests/linear/should_fail/LinearLet7.stderr - testsuite/tests/parser/should_fail/RecordDotSyntaxFail10.stderr - testsuite/tests/parser/should_fail/RecordDotSyntaxFail11.stderr - testsuite/tests/parser/should_fail/RecordDotSyntaxFail13.stderr - testsuite/tests/parser/should_fail/RecordDotSyntaxFail8.stderr - testsuite/tests/partial-sigs/should_compile/T21719.stderr - testsuite/tests/polykinds/T13393.stderr - testsuite/tests/rep-poly/T12709.stderr - testsuite/tests/simplCore/should_compile/simpl017.stderr - testsuite/tests/th/T10945.stderr - testsuite/tests/th/TH_StaticPointers02.stderr - testsuite/tests/typecheck/should_compile/T11339.stderr - testsuite/tests/typecheck/should_fail/DoExpansion3.stderr - testsuite/tests/typecheck/should_fail/T12177.stderr - testsuite/tests/typecheck/should_fail/T22707.stderr - testsuite/tests/typecheck/should_fail/T24064.stderr - + testsuite/tests/typecheck/should_fail/T26330.hs - + testsuite/tests/typecheck/should_fail/T26330.stderr - testsuite/tests/typecheck/should_fail/T8142.stderr - testsuite/tests/typecheck/should_fail/T8603.stderr - testsuite/tests/typecheck/should_fail/all.T - testsuite/tests/typecheck/should_fail/tcfail128.stderr - testsuite/tests/typecheck/should_fail/tcfail153.stderr - testsuite/tests/typecheck/should_fail/tcfail168.stderr - testsuite/tests/typecheck/should_fail/tcfail177.stderr - testsuite/tests/typecheck/should_fail/tcfail185.stderr - testsuite/tests/typecheck/should_run/Typeable1.stderr The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/306e441628e3c9c7a866beeb1b3c688b... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/306e441628e3c9c7a866beeb1b3c688b... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Simon Peyton Jones (@simonpj)