[commit: ghc] wip/rae: Don't tidy vars when dumping a type (86e1984)

git at git.haskell.org git at git.haskell.org
Tue Jul 18 18:36:41 UTC 2017


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

On branch  : wip/rae
Link       : http://ghc.haskell.org/trac/ghc/changeset/86e1984241765e377270bc88886e0a427081c56c/ghc

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

commit 86e1984241765e377270bc88886e0a427081c56c
Author: Richard Eisenberg <rae at cs.brynmawr.edu>
Date:   Fri Apr 7 11:13:32 2017 -0400

    Don't tidy vars when dumping a type
    
    This makes variables print more consistenty in, say,
    -ddump-tc-trace.


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

86e1984241765e377270bc88886e0a427081c56c
 compiler/types/TyCoRep.hs | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/compiler/types/TyCoRep.hs b/compiler/types/TyCoRep.hs
index e6afece..a93d13e 100644
--- a/compiler/types/TyCoRep.hs
+++ b/compiler/types/TyCoRep.hs
@@ -137,8 +137,8 @@ import {-# SOURCE #-} DataCon( dataConFullSig
                              , dataConUnivTyVarBinders, dataConExTyVarBinders
                              , DataCon, filterEqSpec )
 import {-# SOURCE #-} Type( isPredTy, isCoercionTy, mkAppTy, mkCastTy
-                          , tyCoVarsOfTypesWellScoped
                           , tyCoVarsOfTypeWellScoped
+                          , tyCoVarsOfTypesWellScoped
                           , coreView, typeKind )
    -- Transitively pulls in a LOT of stuff, better to break the loop
 
@@ -2435,7 +2435,7 @@ pprType       = pprPrecType TopPrec
 pprParendType = pprPrecType TyConPrec
 
 pprPrecType :: TyPrec -> Type -> SDoc
-pprPrecType prec ty = pprPrecIfaceType prec (tidyToIfaceType ty)
+pprPrecType prec ty = getPprStyle $ \sty -> pprPrecIfaceType prec (tidyToIfaceTypeSty ty sty)
 
 pprTyLit :: TyLit -> SDoc
 pprTyLit = pprIfaceTyLit . toIfaceTyLit
@@ -2444,6 +2444,12 @@ pprKind, pprParendKind :: Kind -> SDoc
 pprKind       = pprType
 pprParendKind = pprParendType
 
+tidyToIfaceTypeSty :: Type -> PprStyle -> IfaceType
+tidyToIfaceTypeSty ty sty
+  | userStyle sty = tidyToIfaceType ty
+  | otherwise     = toIfaceTypeX (tyCoVarsOfType ty) ty
+     -- in latter case, don't tidy, as we'll be printing uniques.
+
 tidyToIfaceType :: Type -> IfaceType
 -- It's vital to tidy before converting to an IfaceType
 -- or nested binders will become indistinguishable!



More information about the ghc-commits mailing list