[commit: ghc] master: Improve pretty printing of IfaceAT in interface files (a4494ac)

git at git.haskell.org git at git.haskell.org
Wed Nov 6 08:31:59 UTC 2013


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/a4494acd07a0b2120623812e57b180b96830a577/ghc

>---------------------------------------------------------------

commit a4494acd07a0b2120623812e57b180b96830a577
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date:   Tue Nov 5 14:55:44 2013 +0000

    Improve pretty printing of IfaceAT in interface files


>---------------------------------------------------------------

a4494acd07a0b2120623812e57b180b96830a577
 compiler/iface/IfaceSyn.lhs |   11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/compiler/iface/IfaceSyn.lhs b/compiler/iface/IfaceSyn.lhs
index 9088c2e..f693999 100644
--- a/compiler/iface/IfaceSyn.lhs
+++ b/compiler/iface/IfaceSyn.lhs
@@ -260,9 +260,9 @@ instance Binary IfaceClassOp where
         occ <- return $! mkOccNameFS varName n
         return (IfaceClassOp occ def ty)
 
-data IfaceAT = IfaceAT IfaceDecl [IfaceAxBranch]
-        -- Nothing => no default associated type instance
-        -- Just ds => default associated type instance from these templates
+data IfaceAT = IfaceAT
+                  IfaceDecl        -- The associated type declaration
+                  [IfaceAxBranch]  -- Default associated type instances, if any
 
 instance Binary IfaceAT where
     put_ bh (IfaceAT dec defs) = do
@@ -1082,7 +1082,10 @@ instance Outputable IfaceClassOp where
    ppr (IfaceClassOp n dm ty) = ppr n <+> ppr dm <+> dcolon <+> ppr ty
 
 instance Outputable IfaceAT where
-   ppr (IfaceAT d defs) = hang (ppr d) 2 (vcat (map ppr defs))
+   ppr (IfaceAT d defs) 
+      = vcat [ ppr d
+             , ppUnless (null defs) $ nest 2 $
+               ptext (sLit "Defaults:") <+> vcat (map ppr defs) ]
 
 pprIfaceDeclHead :: IfaceContext -> OccName -> [IfaceTvBndr] -> SDoc
 pprIfaceDeclHead context thing tyvars



More information about the ghc-commits mailing list