Show instances for GHC internals
Ömer Sinan Ağacan
omeragacan at gmail.com
Mon Oct 19 21:18:41 UTC 2015
Currently the only way to debug and inspect GHC internals is by adding some
carefully placed print statements. (I'd love to be proven wrong on this, cost
of debugging this way is huge, given how long it's taking to rebuild GHC)
We have Outputable instances for most data types, and `Outputable.pprTrace`
etc. helps with debugging/inspecting pure functions this way.
However, Outputable instances are hiding some details and they're sometimes not
useful for debugging and inspecting internals. This is why I implemented
CoreDump package(http://hackage.haskell.org/package/CoreDump), Outputable
instance of CoreSyn is simply not useful for some things. Similarly, just today
I had to add a show function for `HscTypes.TargetId` because `Outputable`
instance was hiding `Maybe Phase` field.
Since the only way to debug or inspect GHC internals(except maybe the RTS) is
by printing things, I think we should provide Show instances for.. basically
everything. Otherwise I just can't see a way of debugging things and inspecting
internals, tracing code etc. for learning purposes.
I was wondering what would be the cost of adding Show instances. Would that
mean significantly increased compile times? Or significantly bigger GHC
binaries? If that's the case, could we enable Show instances with some
arguments so that we can enable/disable it by modifying mk/build.mk?
More information about the ghc-devs