[commit: ghc] master: Improve pretty-printing of type variables (27ba070)

git at git.haskell.org git at git.haskell.org
Tue Nov 4 10:37:55 UTC 2014


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

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

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

commit 27ba070c56fa6c583a34dc9eaede0083530f1dbe
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


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

27ba070c56fa6c583a34dc9eaede0083530f1dbe
 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