[commit: ghc] ghc-8.0: Improve pretty-printing of UnivCo (91c3424)

git at git.haskell.org git at git.haskell.org
Fri Jan 22 12:19:42 UTC 2016


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

On branch  : ghc-8.0
Link       : http://ghc.haskell.org/trac/ghc/changeset/91c342479bcb3e1cdab0b5bddef925d607f6d203/ghc

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

commit 91c342479bcb3e1cdab0b5bddef925d607f6d203
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date:   Wed Jan 20 14:10:08 2016 +0000

    Improve pretty-printing of UnivCo
    
    We really need to know the UnivCoProvenance to make sense
    of UnivCos in debug output
    
    (cherry picked from commit b3ee37ce2b4ebde0f0e5574e2e50b2177bddf361)


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

91c342479bcb3e1cdab0b5bddef925d607f6d203
 compiler/types/Coercion.hs | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/compiler/types/Coercion.hs b/compiler/types/Coercion.hs
index 42405d6..6835f02 100644
--- a/compiler/types/Coercion.hs
+++ b/compiler/types/Coercion.hs
@@ -233,12 +233,18 @@ ppr_co p (InstCo co arg) = maybeParen p TyConPrec $
 ppr_co p (UnivCo UnsafeCoerceProv r ty1 ty2)
   = pprPrefixApp p (text "UnsafeCo" <+> ppr r)
                    [pprParendType ty1, pprParendType ty2]
-ppr_co _ (UnivCo p r t1 t2)= angleBrackets ( ppr t1 <> comma <+> ppr t2 ) <> ppr_role r <> ppr_prov
+ppr_co _ (UnivCo p r t1 t2)
+  = char 'U'
+    <> parens (ppr_prov <> comma <+> ppr t1 <> comma <+> ppr t2)
+    <> ppr_role r
   where
     ppr_prov = case p of
-      HoleProv h          -> ppr h
-      PhantomProv kind_co -> braces (ppr kind_co)
-      _                   -> empty
+      HoleProv h          -> text "hole:"   <> ppr h
+      PhantomProv kind_co -> text "phant:"  <> ppr kind_co
+      ProofIrrelProv co   -> text "irrel:"  <> ppr co
+      PluginProv s        -> text "plugin:" <> text s
+      UnsafeCoerceProv    -> text "unsafe"
+
 ppr_co p (SymCo co)          = pprPrefixApp p (text "Sym") [pprParendCo co]
 ppr_co p (NthCo n co)        = pprPrefixApp p (text "Nth:" <> int n) [pprParendCo co]
 ppr_co p (LRCo sel co)       = pprPrefixApp p (ppr sel) [pprParendCo co]



More information about the ghc-commits mailing list