Show instances for GHC internals

Ömer Sinan Ağacan omeragacan at gmail.com
Tue Oct 20 13:22:45 UTC 2015


> One difficulty is that many of the core type data types, e.g. TyThing,
> are (1) a large mutually recursive graph, and (2) have
> unsafeInterleaveIO thunks which would induce IO action.  So a naive
> Show instance would give infinite output and have lots of side effects.
> There are many data types which could usefully have Show added but
> also many which would be very difficult to.

Ah, yes, this is a very annoying problem. I discovered that when I first wrote
CoreDump: https://github.com/osa1/CoreDump/issues/2

I don't have solution to this yet.

2015-10-19 21:59 GMT-04:00 Edward Z. Yang <ezyang at mit.edu>:
> Excerpts from Ömer Sinan Ağacan's message of 2015-10-19 14:18:41 -0700:
>> 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?
>
> One difficulty is that many of the core type data types, e.g. TyThing,
> are (1) a large mutually recursive graph, and (2) have
> unsafeInterleaveIO thunks which would induce IO action.  So a naive
> Show instance would give infinite output and have lots of side effects.
> There are many data types which could usefully have Show added but
> also many which would be very difficult to.
>
> Edward


More information about the ghc-devs mailing list