summaryrefslogtreecommitdiff
path: root/compiler/GHC/Iface/Syntax.hs
diff options
context:
space:
mode:
authorKrzysztof Gogolewski <krzysztof.gogolewski@tweag.io>2020-08-20 17:30:51 +0200
committerKrzysztof Gogolewski <krzysztof.gogolewski@tweag.io>2020-08-23 14:12:53 +0200
commit8b86509270227dbc61f0700c7d9261a4c7672361 (patch)
tree8f95fd86fa1c052f12aefa7a1038519910ffafeb /compiler/GHC/Iface/Syntax.hs
parent3f50154591ada9064351ccec4adfe6df53ca2439 (diff)
downloadhaskell-8b86509270227dbc61f0700c7d9261a4c7672361.tar.gz
Do not print synonyms in :i (->), :i Type (#18594)
This adds a new printing flag `sdocPrintTypeAbbreviations` that is used specifically to avoid ghci printing 'type (->) = (->)' and 'type Type = Type'.
Diffstat (limited to 'compiler/GHC/Iface/Syntax.hs')
-rw-r--r--compiler/GHC/Iface/Syntax.hs10
1 files changed, 9 insertions, 1 deletions
diff --git a/compiler/GHC/Iface/Syntax.hs b/compiler/GHC/Iface/Syntax.hs
index 842bb2815a..bd576b26cf 100644
--- a/compiler/GHC/Iface/Syntax.hs
+++ b/compiler/GHC/Iface/Syntax.hs
@@ -45,6 +45,8 @@ module GHC.Iface.Syntax (
import GHC.Prelude
+import GHC.Builtin.Names ( unrestrictedFunTyConKey, liftedTypeKindTyConKey )
+import GHC.Types.Unique ( hasKey )
import GHC.Iface.Type
import GHC.Iface.Recomp.Binary
import GHC.Core( IsOrphan, isOrphan )
@@ -947,13 +949,19 @@ pprIfaceDecl ss (IfaceSynonym { ifName = tc
, ifResKind = res_kind})
= vcat [ pprStandaloneKindSig name_doc (mkIfaceTyConKind binders res_kind)
, hang (text "type" <+> pprIfaceDeclHead suppress_bndr_sig [] ss tc binders <+> equals)
- 2 (sep [ pprIfaceForAll tvs, pprIfaceContextArr theta, ppr tau
+ 2 (sep [ pprIfaceForAll tvs, pprIfaceContextArr theta, ppr_tau
, ppUnless (isIfaceLiftedTypeKind res_kind) (dcolon <+> ppr res_kind) ])
]
where
(tvs, theta, tau) = splitIfaceSigmaTy mono_ty
name_doc = pprPrefixIfDeclBndr (ss_how_much ss) (occName tc)
+ -- See Note [Printing type abbreviations] in GHC.Iface.Type
+ ppr_tau | tc `hasKey` liftedTypeKindTyConKey ||
+ tc `hasKey` unrestrictedFunTyConKey
+ = updSDocContext (\ctx -> ctx { sdocPrintTypeAbbreviations = False }) $ ppr tau
+ | otherwise = ppr tau
+
-- See Note [Suppressing binder signatures] in GHC.Iface.Type
suppress_bndr_sig = SuppressBndrSig True