Show-ing GHC internal data structures

Simon Marlow simonmarhaskell at gmail.com
Tue Mar 21 06:45:40 EST 2006


David William Simmons-Duffin wrote:
> I'm working with a friend on a project that involves hacking at the GHC
> internals.  We'd like to be able to print some of the large data
> structures involved -- specifically a TcGblEnv.  TcGblEnv is a record with
> a number of fields of different types, and it would be silly to go through
> the source adding "deriving Show" to the end of each type definition.
> 
> It seems like Show instances for internal data structures would be useful
> for the GHC developers (for debugging purposes -- perhaps they were left
> out of the GHC distribution to keep the compiled code small?), and we were
> wondering if anyone had the relevant instance declarations lying around.

The TcGblEnv is Very Large Indeed.  It probably includes almost 
everything in the heap :-)  I suggest you selectively print out the bits 
you're interested in, there is plenty of pretty-printing machinery in 
GHC for displaying the contents of internal stuff.

Also, in GHC we generally don't use Show.  There is a class Outputable 
(utils/Outputable.lhs) which many datatypes are instances of, and it 
provides for pretty-printing data in several different "styles": debug, 
user, code, etc.

Cheers,
	Simon


More information about the Glasgow-haskell-users mailing list