diff options
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/GHC/Iface/Syntax.hs | 6 | ||||
-rw-r--r-- | compiler/GHC/Iface/Type.hs | 10 |
2 files changed, 10 insertions, 6 deletions
diff --git a/compiler/GHC/Iface/Syntax.hs b/compiler/GHC/Iface/Syntax.hs index 2e7a39bc97..a633f59fbc 100644 --- a/compiler/GHC/Iface/Syntax.hs +++ b/compiler/GHC/Iface/Syntax.hs @@ -44,7 +44,8 @@ module GHC.Iface.Syntax ( import GHC.Prelude -import GHC.Builtin.Names ( unrestrictedFunTyConKey, liftedTypeKindTyConKey ) +import GHC.Builtin.Names ( unrestrictedFunTyConKey, liftedTypeKindTyConKey, + constraintKindTyConKey ) import GHC.Types.Unique ( hasKey ) import GHC.Iface.Type import GHC.Iface.Recomp.Binary @@ -988,7 +989,8 @@ pprIfaceDecl ss (IfaceSynonym { ifName = tc -- See Note [Printing type abbreviations] in GHC.Iface.Type ppr_tau | tc `hasKey` liftedTypeKindTyConKey || - tc `hasKey` unrestrictedFunTyConKey + tc `hasKey` unrestrictedFunTyConKey || + tc `hasKey` constraintKindTyConKey = updSDocContext (\ctx -> ctx { sdocPrintTypeAbbreviations = False }) $ ppr tau | otherwise = ppr tau diff --git a/compiler/GHC/Iface/Type.hs b/compiler/GHC/Iface/Type.hs index a7bdf04a4b..04b34849f8 100644 --- a/compiler/GHC/Iface/Type.hs +++ b/compiler/GHC/Iface/Type.hs @@ -846,7 +846,7 @@ Note [Printing type abbreviations] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Normally, we pretty-print `TYPE 'LiftedRep` as `Type` (or `*`) - `CONSTRAINT 'LiftedRep` as `Constraint` (or `*`) + `CONSTRAINT 'LiftedRep` as `Constraint` `FUN 'Many` as `(->)`. This way, error messages don't refer to representation polymorphism or linearity if it is not necessary. Normally we'd would represent @@ -856,14 +856,16 @@ command we specifically expand synonyms (see GHC.Tc.Module.tcRnExpr). So here in the pretty-printing we effectively collapse back Type and Constraint to their synonym forms. A bit confusing! -However, when printing the definition of Type or (->) with :info, +However, when printing the definition of Type, Constraint or (->) with :info, this would give confusing output: `type (->) = (->)` (#18594). Solution: detect when we are in :info and disable displaying the synonym with the SDoc option sdocPrintTypeAbbreviations. +If you are creating a similar synonym, make sure it is listed in pprIfaceDecl, +see reference to this Note. If there will be a need, in the future we could expose it as a flag --fprint-type-abbreviations or even two separate flags controlling -TYPE 'LiftedRep and FUN 'Many. +-fprint-type-abbreviations or even three separate flags controlling +TYPE 'LiftedRep, CONSTRAINT 'LiftedRep and FUN 'Many. -} -- | Do we want to suppress kind annotations on binders? |