diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2013-01-01 23:09:32 +0000 |
---|---|---|
committer | Simon Peyton Jones <simonpj@microsoft.com> | 2013-01-01 23:09:32 +0000 |
commit | 5efe9b1146bd474a6f408093ef36c262b15b4ab2 (patch) | |
tree | 8d38ec5ec0e7209ae6baf687a324866258a00760 /compiler/iface | |
parent | 18003c9ec8e2f5a6ae82565c1e1ba35fada72021 (diff) | |
download | haskell-5efe9b1146bd474a6f408093ef36c262b15b4ab2.tar.gz |
Refactor the invariants for ClsInsts
We now have the invariant for a ClsInst that the is_tvs field
is always completely fresh type variables. See
Note [Template tyvars are fresh] in InstEnv.
(Previously we frehened them when extending the instance environment,
but that seems messier because it was an invariant only when the
ClsInst was in an InstEnv. Moreover, there was an invariant that
thet tyvars of the DFunid in the ClsInst had to match, and I have
removed that invariant altogether; there is no need for it.)
Other changes I made at the same time:
* Make is_tvs into a *list*, in the right order for the dfun type
arguments. This removes the wierd need for the dfun to have the
same tyvars as the ClsInst template, an invariant I have always
hated. The cost is that we need to make it a VarSet when matching.
We could cache an is_tv_set instead.
* Add a cached is_cls field to the ClsInst, to save fishing
the Class out of the DFun. (Renamed is_cls to is_cls_nm.)
* Make tcSplitDFunTy return the dfun args, not just the *number*
of dfun args
* Make InstEnv.instanceHead return just the *head* of the
instance declaration. Add instanceSig to return the whole
thing.
Diffstat (limited to 'compiler/iface')
-rw-r--r-- | compiler/iface/MkIface.lhs | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/compiler/iface/MkIface.lhs b/compiler/iface/MkIface.lhs index 53e1a63693..fed30f19e1 100644 --- a/compiler/iface/MkIface.lhs +++ b/compiler/iface/MkIface.lhs @@ -1604,8 +1604,9 @@ getFS x = occNameFS (getOccName x) -------------------------- instanceToIfaceInst :: ClsInst -> IfaceClsInst -instanceToIfaceInst (ClsInst { is_dfun = dfun_id, is_flag = oflag, - is_cls = cls_name, is_tcs = mb_tcs }) +instanceToIfaceInst (ClsInst { is_dfun = dfun_id, is_flag = oflag + , is_cls_nm = cls_name, is_cls = cls + , is_tys = tys, is_tcs = mb_tcs }) = ASSERT( cls_name == className cls ) IfaceClsInst { ifDFun = dfun_name, ifOFlag = oflag, @@ -1621,8 +1622,6 @@ instanceToIfaceInst (ClsInst { is_dfun = dfun_id, is_flag = oflag, is_local name = nameIsLocalOrFrom mod name -- Compute orphanhood. See Note [Orphans] in IfaceSyn - (_, _, cls, tys) = tcSplitDFunTy (idType dfun_id) - -- Slightly awkward: we need the Class to get the fundeps (tvs, fds) = classTvsFds cls arg_names = [filterNameSet is_local (orphNamesOfType ty) | ty <- tys] |