Skip to content

Move tracing functions into GHC.Prelude

It's annoying that GHC.Utils.Trace is not re-exported from GHC.Prelude (say), for these reasons:

  1. New GHC devs reportedly don't know of pprTrace because it's hidden in some obscure, nested module (not to say that it's not an accurate module name).
  2. I have to import GHC.Utils.Trace anytime I want it
  3. ... and have to remove the import once I'm done tracing and commented out the trace calls, when it becomes a redundant import. That's why in the past I've resorted to hacks like https://gitlab.haskell.org/ghc/ghc/-/blob/64923cf295ea914db458547432237a5ed1eff571/compiler/GHC/Core/Opt/DmdAnal.hs#L47.

I'm aware that importing GHC.Utils.Trace from GHC.Prelude probably incurs a circular dependency and that we absolutely must be able to inline pprTrace, so we can't break the circle by doing a source import from GHC.Utils.Trace in GHC.Prelude. So maybe that is the reason why we haven't done it already. Breaking the circle the other way around might be too tedious...

Anyway, maybe someone else can think of a good way forward.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information