Skip to content

Strange Outputable instance structure

GHC's Outputable instances for HsSyn look like

instance (p ~ GhcPass pass, OutputableBndrId p) => Outputable (Pat p) where
    ppr = pprPat

But if we write

instance (OutputableBndrId (GhcPass p)) => Outputable (Pat (GhcPass p)) where
    ppr = pprPat

the instance is simpler, and (Richard and I checked) everything still works. Moreover, it is now possible to write instances for an index other than GhcPass, which is not possible today.

Let's do it.

Moreover, perhaps OutputableBndrId can take a GhcPass, so we'd get

instance (OutputableBndrId p) => Outputable (Pat (GhcPass p)) where
    ppr = pprPat

The entire pretty printer is GHC-specific, so we lose nothing by these changes.

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