summaryrefslogtreecommitdiff
path: root/compiler/types/TyCoRep.hs
diff options
context:
space:
mode:
authorRichard Eisenberg <rae@cs.brynmawr.edu>2017-06-06 11:01:14 -0400
committerRichard Eisenberg <rae@cs.brynmawr.edu>2017-07-27 07:49:06 -0400
commit79cfb1999474ad15dd955a10c846c8ea87e612c2 (patch)
treeae3ad8ca8517115049bdc2c971396021508c09a1 /compiler/types/TyCoRep.hs
parentbb2a446ae488522489c4ce03081439659820174c (diff)
downloadhaskell-79cfb1999474ad15dd955a10c846c8ea87e612c2.tar.gz
Remove old coercion pretty-printer
Now, all coercions are printed from IfaceType, just like types. This also changes the rendering of TransCo to use ; instead of a prefix operator.
Diffstat (limited to 'compiler/types/TyCoRep.hs')
-rw-r--r--compiler/types/TyCoRep.hs35
1 files changed, 28 insertions, 7 deletions
diff --git a/compiler/types/TyCoRep.hs b/compiler/types/TyCoRep.hs
index 9b82ab80f9..ca3a4ad32b 100644
--- a/compiler/types/TyCoRep.hs
+++ b/compiler/types/TyCoRep.hs
@@ -62,10 +62,12 @@ module TyCoRep (
pprTyVar, pprTyVars,
pprThetaArrowTy, pprClassPred,
pprKind, pprParendKind, pprTyLit,
- TyPrec(..), maybeParen, pprTcAppCo,
+ TyPrec(..), maybeParen,
pprPrefixApp, pprArrowChain,
pprDataCons, ppSuggestExplicitKinds,
+ pprCo, pprParendCo,
+
-- * Free variables
tyCoVarsOfType, tyCoVarsOfTypeDSet, tyCoVarsOfTypes, tyCoVarsOfTypesDSet,
tyCoFVsBndr, tyCoFVsOfType, tyCoVarsOfTypeList,
@@ -139,13 +141,14 @@ import {-# SOURCE #-} DataCon( dataConFullSig
import {-# SOURCE #-} Type( isPredTy, isCoercionTy, mkAppTy, mkCastTy
, tyCoVarsOfTypeWellScoped
, tyCoVarsOfTypesWellScoped
+ , toposortTyVars
, coreView, typeKind )
-- Transitively pulls in a LOT of stuff, better to break the loop
import {-# SOURCE #-} Coercion
import {-# SOURCE #-} ConLike ( ConLike(..), conLikeName )
import {-# SOURCE #-} ToIface( toIfaceTypeX, toIfaceTyLit, toIfaceForAllBndr
- , toIfaceTyCon, toIfaceTcArgs, toIfaceCoercion )
+ , toIfaceTyCon, toIfaceTcArgs, toIfaceCoercionX )
-- friends:
import IfaceType
@@ -2473,6 +2476,29 @@ tidyToIfaceType ty = toIfaceTypeX (mkVarSet free_tcvs) (tidyType env ty)
free_tcvs = tyCoVarsOfTypeWellScoped ty
------------
+pprCo, pprParendCo :: Coercion -> SDoc
+pprCo co = getPprStyle $ \ sty -> pprIfaceCoercion (tidyToIfaceCoSty co sty)
+pprParendCo co = getPprStyle $ \ sty -> pprParendIfaceCoercion (tidyToIfaceCoSty co sty)
+
+tidyToIfaceCoSty :: Coercion -> PprStyle -> IfaceCoercion
+tidyToIfaceCoSty co sty
+ | userStyle sty = tidyToIfaceCo co
+ | otherwise = toIfaceCoercionX (tyCoVarsOfCo co) co
+ -- in latter case, don't tidy, as we'll be printing uniques.
+
+tidyToIfaceCo :: Coercion -> IfaceCoercion
+-- It's vital to tidy before converting to an IfaceType
+-- or nested binders will become indistinguishable!
+--
+-- Also for the free type variables, tell toIfaceCoercionX to
+-- leave them as IfaceFreeCoVar. This is super-important
+-- for debug printing.
+tidyToIfaceCo co = toIfaceCoercionX (mkVarSet free_tcvs) (tidyCo env co)
+ where
+ env = tidyFreeTyCoVars emptyTidyEnv free_tcvs
+ free_tcvs = toposortTyVars $ tyCoVarsOfCoList co
+
+------------
pprClassPred :: Class -> [Type] -> SDoc
pprClassPred clas tys = pprTypeApp (classTyCon clas) tys
@@ -2596,11 +2622,6 @@ pprTypeApp tc tys
(toIfaceTcArgs tc tys)
-- TODO: toIfaceTcArgs seems rather wasteful here
-pprTcAppCo :: TyPrec -> (TyPrec -> Coercion -> SDoc)
- -> TyCon -> [Coercion] -> SDoc
-pprTcAppCo p _pp tc cos
- = pprIfaceCoTcApp p (toIfaceTyCon tc) (map toIfaceCoercion cos)
-
------------------
pprPrefixApp :: TyPrec -> SDoc -> [SDoc] -> SDoc