[commit: ghc] wip/new-flatten-skolems-Oct14: Improve pretty-printing of type variables (c8d8f92)

git at git.haskell.org git at git.haskell.org
Thu Oct 30 12:53:59 UTC 2014


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

On branch  : wip/new-flatten-skolems-Oct14
Link       : http://ghc.haskell.org/trac/ghc/changeset/c8d8f92a74387e2e11223bad5d1a9cd0abd05fb9/ghc

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

commit c8d8f92a74387e2e11223bad5d1a9cd0abd05fb9
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date:   Wed Oct 29 15:15:38 2014 +0000

    Improve pretty-printing of type variables
    
    In particular, print a bit of debug info in debug-style and dump-style
    Otherwise distinct type variables look the same


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

c8d8f92a74387e2e11223bad5d1a9cd0abd05fb9
 compiler/basicTypes/Var.lhs | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/compiler/basicTypes/Var.lhs b/compiler/basicTypes/Var.lhs
index f7e5f67..62253c8 100644
--- a/compiler/basicTypes/Var.lhs
+++ b/compiler/basicTypes/Var.lhs
@@ -206,16 +206,16 @@ After CoreTidy, top-level LocalIds are turned into GlobalIds
 
 \begin{code}
 instance Outputable Var where
-  ppr var = ppr (varName var) <+> ifPprDebug (brackets (ppr_debug var))
--- Printing the type on every occurrence is too much!
---            <+> if (not (gopt Opt_SuppressVarKinds dflags))
---                then ifPprDebug (text "::" <+> ppr (tyVarKind var) <+> text ")")
---                else empty
-
-ppr_debug :: Var -> SDoc
-ppr_debug (TyVar {})                           = ptext (sLit "tv")
-ppr_debug (TcTyVar {tc_tv_details = d})        = pprTcTyVarDetails d
-ppr_debug (Id { idScope = s, id_details = d }) = ppr_id_scope s <> pprIdDetails d
+  ppr var = ppr (varName var) <> getPprStyle (ppr_debug var)
+
+ppr_debug :: Var -> PprStyle -> SDoc
+ppr_debug (TyVar {}) sty 
+  | debugStyle sty = brackets (ptext (sLit "tv"))
+ppr_debug (TcTyVar {tc_tv_details = d}) sty
+  | dumpStyle sty || debugStyle sty = brackets (pprTcTyVarDetails d)
+ppr_debug (Id { idScope = s, id_details = d }) sty
+  | debugStyle sty = brackets (ppr_id_scope s <> pprIdDetails d)
+ppr_debug _ _ = empty
 
 ppr_id_scope :: IdScope -> SDoc
 ppr_id_scope GlobalId              = ptext (sLit "gid")



More information about the ghc-commits mailing list