Hi Matthijs,
This is a shameless plug for EMGM, a library for generic programming that we've been working on at Utrecht.
| However, there are two issues bothering me still. The first is that theThere's absolutely no reason why
| Core types (in particular CoreExpr) are not instances of Show. They are
| instances of Outputable, which allows them to be pretty printed.
| However, this pretty printing is good to view the structure of the
| expression that the CoreExpr represents, but doesn't show the structure
| of the CoreExpr itself. For example, tuple construction is printed
| simply as (a, b), while the actual core expression is a nested
| application of two types, and a and b to the GHC.Tuple.(,) function
| (or datacon?). Also, the exact constructors used are not quite clear,
CoreExpr
CoreBind
Type
should not be an instance of Show. It'd take you 10 mins to make it so, with the aid of 'standalone deriving' (described in the GHC user manual).
There *is* a reason why TyCon and Class are not:
a TyCon
enumerates its DataCons
whose type mentions the TyCon
In short, the data structures are, by design, cyclic. Printing one of these would take a long time.
But I bet you could get a long way with the three above, plus just printing the *name* of a TyCon or Class or Id. Something like:
instance Show TyCon where
show tc = showSDoc (ppr tc)