[commit: ghc] master: Better pretty-printing for CHoleCan (11657c4)

git at git.haskell.org git at git.haskell.org
Thu Aug 24 13:40:08 UTC 2017


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

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

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

commit 11657c4bdda391d4f21289e3412589a3c520ca2a
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date:   Wed Aug 23 13:48:07 2017 +0100

    Better pretty-printing for CHoleCan
    
    Debug-only; no change in mainstream behaviour


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

11657c4bdda391d4f21289e3412589a3c520ca2a
 compiler/hsSyn/HsExpr.hs        | 3 ++-
 compiler/typecheck/TcRnTypes.hs | 6 +++++-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/compiler/hsSyn/HsExpr.hs b/compiler/hsSyn/HsExpr.hs
index 1bde776..aaebce5 100644
--- a/compiler/hsSyn/HsExpr.hs
+++ b/compiler/hsSyn/HsExpr.hs
@@ -196,7 +196,8 @@ data UnboundVar
   deriving Data
 
 instance Outputable UnboundVar where
-    ppr = ppr . unboundVarOcc
+    ppr (OutOfScope occ _) = text "OutOfScope" <> parens (ppr occ)
+    ppr (TrueExprHole occ) = text "ExprHole"   <> parens (ppr occ)
 
 unboundVarOcc :: UnboundVar -> OccName
 unboundVarOcc (OutOfScope occ _) = occ
diff --git a/compiler/typecheck/TcRnTypes.hs b/compiler/typecheck/TcRnTypes.hs
index 381710b..f735a93 100644
--- a/compiler/typecheck/TcRnTypes.hs
+++ b/compiler/typecheck/TcRnTypes.hs
@@ -1671,6 +1671,10 @@ data Hole = ExprHole UnboundVar
           | TypeHole OccName
             -- ^ A hole in a type (PartialTypeSignatures)
 
+instance Outputable Hole where
+  ppr (ExprHole ub)  = ppr ub
+  ppr (TypeHole occ) = text "TypeHole" <> parens (ppr occ)
+
 holeOcc :: Hole -> OccName
 holeOcc (ExprHole uv)  = unboundVarOcc uv
 holeOcc (TypeHole occ) = occ
@@ -1784,7 +1788,7 @@ instance Outputable Ct where
             | pend_sc   -> text "CDictCan(psc)"
             | otherwise -> text "CDictCan"
          CIrredEvCan {}   -> text "CIrredEvCan"
-         CHoleCan { cc_hole = hole } -> text "CHoleCan:" <+> ppr (holeOcc hole)
+         CHoleCan { cc_hole = hole } -> text "CHoleCan:" <+> ppr hole
 
 {-
 ************************************************************************



More information about the ghc-commits mailing list