summaryrefslogtreecommitdiff
path: root/compiler/GHC/Core/TyCon.hs
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2021-11-15 23:22:06 -0500
committerBen Gamari <ben@smart-cactus.org>2021-11-16 08:55:07 -0500
commitfc4d8f1e72cf6aaa7d1bacafa201e3553a63d93a (patch)
tree672569f812aae2ccf20c5251fd20524139dcdce7 /compiler/GHC/Core/TyCon.hs
parentcc635da167fdec2dead0603b0026cb841f0aa645 (diff)
downloadhaskell-wip/T20541.tar.gz
Increase type sharingwip/T20541
Fixes #20541 by making mkTyConApp do more sharing of types. In particular, replace * BoxedRep Lifted ==> LiftedRep * BoxedRep Unlifted ==> UnliftedRep * TupleRep '[] ==> ZeroBitRep * TYPE ZeroBitRep ==> ZeroBitType In each case, the thing on the right is a type synonym for the thing on the left, declared in ghc-prim:GHC.Types. See Note [Using synonyms to compress types] in GHC.Core.Type. The synonyms for ZeroBitRep and ZeroBitType are new, but absolutely in the same spirit as the other ones. (These synonyms are mainly for internal use, though the programmer can use them too.) I also renamed GHC.Core.Ty.Rep.isVoidTy to isZeroBitTy, to be compatible with the "zero-bit" nomenclature above. See discussion on !6806. There is a tricky wrinkle: see GHC.Core.Types Note [Care using synonyms to compress types] Compiler allocation decreases by up to 0.8%.
Diffstat (limited to 'compiler/GHC/Core/TyCon.hs')
-rw-r--r--compiler/GHC/Core/TyCon.hs24
1 files changed, 12 insertions, 12 deletions
diff --git a/compiler/GHC/Core/TyCon.hs b/compiler/GHC/Core/TyCon.hs
index fd5b3df534..24807945cc 100644
--- a/compiler/GHC/Core/TyCon.hs
+++ b/compiler/GHC/Core/TyCon.hs
@@ -138,7 +138,7 @@ import GHC.Prelude
import GHC.Platform
import {-# SOURCE #-} GHC.Core.TyCo.Rep
- ( Kind, Type, PredType, mkForAllTy, mkFunTyMany, mkTyConTy_ )
+ ( Kind, Type, PredType, mkForAllTy, mkFunTyMany, mkNakedTyConTy )
import {-# SOURCE #-} GHC.Core.TyCo.Ppr
( pprType )
import {-# SOURCE #-} GHC.Builtin.Types
@@ -1819,7 +1819,7 @@ So we compromise, and move their Kind calculation to the call site.
-}
-- | Given the name of the function type constructor and it's kind, create the
--- corresponding 'TyCon'. It is recommended to use 'GHC.Core.TyCo.Rep.funTyCon' if you want
+-- corresponding 'TyCon'. It is recommended to use 'GHC.Builtin.Types.funTyCon' if you want
-- this functionality
mkFunTyCon :: Name -> [TyConBinder] -> Name -> TyCon
mkFunTyCon name binders rep_nm
@@ -1831,7 +1831,7 @@ mkFunTyCon name binders rep_nm
tyConResKind = liftedTypeKind,
tyConKind = mkTyConKind binders liftedTypeKind,
tyConArity = length binders,
- tyConNullaryTy = mkTyConTy_ tc,
+ tyConNullaryTy = mkNakedTyConTy tc,
tcRepName = rep_nm
}
in tc
@@ -1858,7 +1858,7 @@ mkAlgTyCon name binders res_kind roles cType stupid rhs parent gadt_syn
tyConResKind = res_kind,
tyConKind = mkTyConKind binders res_kind,
tyConArity = length binders,
- tyConNullaryTy = mkTyConTy_ tc,
+ tyConNullaryTy = mkNakedTyConTy tc,
tyConTyVars = binderVars binders,
tcRoles = roles,
tyConCType = cType,
@@ -1897,7 +1897,7 @@ mkTupleTyCon name binders res_kind arity con sort parent
tyConResKind = res_kind,
tyConKind = mkTyConKind binders res_kind,
tyConArity = arity,
- tyConNullaryTy = mkTyConTy_ tc,
+ tyConNullaryTy = mkNakedTyConTy tc,
tcRoles = replicate arity Representational,
tyConCType = Nothing,
algTcGadtSyntax = False,
@@ -1927,7 +1927,7 @@ mkSumTyCon name binders res_kind arity tyvars cons parent
tyConResKind = res_kind,
tyConKind = mkTyConKind binders res_kind,
tyConArity = arity,
- tyConNullaryTy = mkTyConTy_ tc,
+ tyConNullaryTy = mkNakedTyConTy tc,
tcRoles = replicate arity Representational,
tyConCType = Nothing,
algTcGadtSyntax = False,
@@ -1962,7 +1962,7 @@ mkTcTyCon name binders res_kind scoped_tvs poly flav
, tyConResKind = res_kind
, tyConKind = mkTyConKind binders res_kind
, tyConArity = length binders
- , tyConNullaryTy = mkTyConTy_ tc
+ , tyConNullaryTy = mkNakedTyConTy tc
, tcTyConScopedTyVars = scoped_tvs
, tcTyConIsPoly = poly
, tcTyConFlavour = flav }
@@ -2013,7 +2013,7 @@ mkPrimTyCon' name binders res_kind roles is_unlifted rep_nm
tyConResKind = res_kind,
tyConKind = mkTyConKind binders res_kind,
tyConArity = length roles,
- tyConNullaryTy = mkTyConTy_ tc,
+ tyConNullaryTy = mkNakedTyConTy tc,
tcRoles = roles,
isUnlifted = is_unlifted,
primRepName = rep_nm
@@ -2032,7 +2032,7 @@ mkSynonymTyCon name binders res_kind roles rhs is_tau is_fam_free is_forgetful
tyConResKind = res_kind,
tyConKind = mkTyConKind binders res_kind,
tyConArity = length binders,
- tyConNullaryTy = mkTyConTy_ tc,
+ tyConNullaryTy = mkNakedTyConTy tc,
tyConTyVars = binderVars binders,
tcRoles = roles,
synTcRhs = rhs,
@@ -2055,7 +2055,7 @@ mkFamilyTyCon name binders res_kind resVar flav parent inj
, tyConResKind = res_kind
, tyConKind = mkTyConKind binders res_kind
, tyConArity = length binders
- , tyConNullaryTy = mkTyConTy_ tc
+ , tyConNullaryTy = mkNakedTyConTy tc
, tyConTyVars = binderVars binders
, famTcResVar = resVar
, famTcFlav = flav
@@ -2078,7 +2078,7 @@ mkPromotedDataCon con name rep_name binders res_kind roles rep_info
tyConUnique = nameUnique name,
tyConName = name,
tyConArity = length roles,
- tyConNullaryTy = mkTyConTy_ tc,
+ tyConNullaryTy = mkNakedTyConTy tc,
tcRoles = roles,
tyConBinders = binders,
tyConResKind = res_kind,
@@ -2468,7 +2468,7 @@ setTcTyConKind :: TyCon -> Kind -> TyCon
-- kind, so we don't need to update any other fields.
-- See Note [The Purely Kinded Invariant] in GHC.Tc.Gen.HsType
setTcTyConKind tc@(TcTyCon {}) kind = let tc' = tc { tyConKind = kind
- , tyConNullaryTy = mkTyConTy_ tc'
+ , tyConNullaryTy = mkNakedTyConTy tc'
-- see Note [Sharing nullary TyCons]
}
in tc'