summaryrefslogtreecommitdiff
path: root/compiler/iface/MkIface.hs
diff options
context:
space:
mode:
authorRichard Eisenberg <eir@cis.upenn.edu>2016-02-04 10:42:56 -0500
committerRichard Eisenberg <eir@cis.upenn.edu>2016-02-24 13:31:30 -0500
commitd8c64e86361f6766ebe26a262bb229fb8301a42a (patch)
tree94d68ebcb1cc6e9eabff08d3cd1d7e61dd99c01e /compiler/iface/MkIface.hs
parentce36115b369510c51f402073174d82d0d1244589 (diff)
downloadhaskell-d8c64e86361f6766ebe26a262bb229fb8301a42a.tar.gz
Address #11471 by putting RuntimeRep in kinds.wip/runtime-rep
See Note [TYPE] in TysPrim. There are still some outstanding pieces in #11471 though, so this doesn't actually nail the bug. This commit also contains a few performance improvements: * Short-cut equality checking of nullary type syns * Compare types before kinds in eqType * INLINE coreViewOneStarKind * Store tycon binders separately from kinds. This resulted in a ~10% performance improvement in compiling the Cabal package. No change in functionality other than performance. (This affects the interface file format, though.) This commit updates the haddock submodule.
Diffstat (limited to 'compiler/iface/MkIface.hs')
-rw-r--r--compiler/iface/MkIface.hs35
1 files changed, 18 insertions, 17 deletions
diff --git a/compiler/iface/MkIface.hs b/compiler/iface/MkIface.hs
index 8548eb3031..4bd5c3611f 100644
--- a/compiler/iface/MkIface.hs
+++ b/compiler/iface/MkIface.hs
@@ -76,7 +76,6 @@ import DataCon
import PatSyn
import Type
import TcType
-import TysPrim ( alphaTyVars )
import InstEnv
import FamInstEnv
import TcRnMonad
@@ -1377,28 +1376,28 @@ tyConToIfaceDecl env tycon
| Just syn_rhs <- synTyConRhs_maybe tycon
= ( tc_env1
, IfaceSynonym { ifName = getOccName tycon,
- ifTyVars = if_tc_tyvars,
ifRoles = tyConRoles tycon,
ifSynRhs = if_syn_type syn_rhs,
- ifSynKind = if_kind
+ ifBinders = if_binders,
+ ifResKind = if_res_kind
})
| Just fam_flav <- famTyConFlav_maybe tycon
= ( tc_env1
, IfaceFamily { ifName = getOccName tycon,
- ifTyVars = if_tc_tyvars,
ifResVar = if_res_var,
ifFamFlav = to_if_fam_flav fam_flav,
- ifFamKind = if_kind,
+ ifBinders = if_binders,
+ ifResKind = if_res_kind,
ifFamInj = familyTyConInjectivityInfo tycon
})
| isAlgTyCon tycon
= ( tc_env1
, IfaceData { ifName = getOccName tycon,
- ifKind = if_kind,
+ ifBinders = if_binders,
+ ifResKind = if_res_kind,
ifCType = tyConCType tycon,
- ifTyVars = if_tc_tyvars,
ifRoles = tyConRoles tycon,
ifCtxt = tidyToIfaceContext tc_env1 (tyConStupidTheta tycon),
ifCons = ifaceConDecls (algTyConRhs tycon) (algTcFields tycon),
@@ -1410,12 +1409,10 @@ tyConToIfaceDecl env tycon
-- For pretty printing purposes only.
= ( env
, IfaceData { ifName = getOccName tycon,
- ifKind =
- -- These don't have `tyConTyVars`, so we use an empty
- -- environment here, instead of `tc_env1` defined below.
- tidyToIfaceType emptyTidyEnv (tyConKind tycon),
+ ifBinders = if_degenerate_binders,
+ ifResKind = if_degenerate_res_kind,
+ -- These don't have `tyConTyVars`, hence "degenerate"
ifCType = Nothing,
- ifTyVars = funAndPrimTyVars,
ifRoles = tyConRoles tycon,
ifCtxt = [],
ifCons = IfDataTyCon [] False [],
@@ -1427,12 +1424,16 @@ tyConToIfaceDecl env tycon
-- is one of these TyCons (FunTyCon, PrimTyCon, PromotedDataCon) will cause
-- an error.
(tc_env1, tc_tyvars) = tidyTyClTyCoVarBndrs env (tyConTyVars tycon)
- if_tc_tyvars = toIfaceTvBndrs tc_tyvars
- if_kind = tidyToIfaceType tc_env1 (tyConKind tycon)
+ if_binders = zipIfaceBinders tc_tyvars (tyConBinders tycon)
+ if_res_kind = tidyToIfaceType tc_env1 (tyConResKind tycon)
if_syn_type ty = tidyToIfaceType tc_env1 ty
if_res_var = getFS `fmap` tyConFamilyResVar_maybe tycon
- funAndPrimTyVars = toIfaceTvBndrs $ take (tyConArity tycon) alphaTyVars
+ -- use these when you don't have tyConTyVars
+ (degenerate_binders, degenerate_res_kind)
+ = splitPiTys (tidyType env (tyConKind tycon))
+ if_degenerate_binders = toDegenerateBinders degenerate_binders
+ if_degenerate_res_kind = toIfaceType degenerate_res_kind
parent = case tyConFamInstSig_maybe tycon of
Just (tc, ty, ax) -> IfDataInstance (coAxiomName ax)
@@ -1522,9 +1523,8 @@ classToIfaceDecl env clas
= ( env1
, IfaceClass { ifCtxt = tidyToIfaceContext env1 sc_theta,
ifName = getOccName tycon,
- ifTyVars = toIfaceTvBndrs clas_tyvars',
ifRoles = tyConRoles (classTyCon clas),
- ifKind = tidyToIfaceType env1 (tyConKind tycon),
+ ifBinders = binders,
ifFDs = map toIfaceFD clas_fds,
ifATs = map toIfaceAT clas_ats,
ifSigs = map toIfaceClassOp op_stuff,
@@ -1536,6 +1536,7 @@ classToIfaceDecl env clas
tycon = classTyCon clas
(env1, clas_tyvars') = tidyTyCoVarBndrs env clas_tyvars
+ binders = zipIfaceBinders clas_tyvars' (tyConBinders tycon)
toIfaceAT :: ClassATItem -> IfaceAT
toIfaceAT (ATI tc def)