Incorrect Outputable instance for InstDecl
The pretty-printer produces trash output for instance declarations. This is how the Outputable instance is defined in compiler/hsSyn/HsDecls.lhs:
instance (OutputableBndr name) => Outputable (InstDecl name) where
ppr (InstDecl inst_ty binds uprags ats)
= vcat [hsep [ptext SLIT("instance"), ppr inst_ty, ptext SLIT("where")],
nest 4 (ppr ats),
nest 4 (ppr uprags),
nest 4 (pprLHsBinds binds) ]
Notice that 'ats' and 'uprags' are lists, so they are being printed as such, i.e., with braces and commas. This produces output that looks like this:
instance Monad Maybe where
[]
[]
return = Just
fail _ = Nothing
...
The correct (I think) definition is this:
instance (OutputableBndr name) => Outputable (InstDecl name) where
ppr (InstDecl inst_ty binds uprags ats)
= vcat ([hsep [ptext SLIT("instance"), ppr inst_ty, ptext SLIT("where")]] ++
[ nest 4 (ppr at) | at <- ats ] ++
[ nest 4 (ppr uprag) | uprag <- uprags ] ++
[ nest 4 (pprLHsBinds binds) ])
Trac metadata
Trac field | Value |
---|---|
Version | 6.9 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | df@dfranke.us |
Operating system | Multiple |
Architecture | Multiple |