diff options
author | simonpj@microsoft.com <unknown> | 2010-12-13 17:15:11 +0000 |
---|---|---|
committer | simonpj@microsoft.com <unknown> | 2010-12-13 17:15:11 +0000 |
commit | a3bab0506498db41853543558c52a4fda0d183af (patch) | |
tree | a46b0e888b4aeb6a6b2dadcd99b0796437aec0d9 /compiler/simplCore/Simplify.lhs | |
parent | 62f76a3cbced691b60f511fb83547a5d62653252 (diff) | |
download | haskell-a3bab0506498db41853543558c52a4fda0d183af.tar.gz |
Fix recursive superclasses (again). Fixes Trac #4809.
This patch finally deals with the super-delicate question of
superclases in possibly-recursive dictionaries. The key idea
is the DFun Superclass Invariant (see TcInstDcls):
In the body of a DFun, every superclass argument to the
returned dictionary is
either * one of the arguments of the DFun,
or * constant, bound at top level
To establish the invariant, we add new "silent" superclass
argument(s) to each dfun, so that the dfun does not do superclass
selection internally. There's a bit of hoo-ha to make sure that
we don't print those silent arguments in error messages; a knock
on effect was a change in interface-file format.
A second change is that instead of the complex and fragile
"self dictionary binding" in TcInstDcls and TcClassDcl,
using the same mechanism for existential pattern bindings.
See Note [Subtle interaction of recursion and overlap] in TcInstDcls
and Note [Binding when looking up instances] in InstEnv.
Main notes are here:
* Note [Silent Superclass Arguments] in TcInstDcls,
including the DFun Superclass Invariant
Main code changes are:
* The code for MkId.mkDictFunId and mkDictFunTy
* DFunUnfoldings get a little more complicated;
their arguments are a new type DFunArg (in CoreSyn)
* No "self" argument in tcInstanceMethod
* No special tcSimplifySuperClasss
* No "dependents" argument to EvDFunApp
IMPORTANT
It turns out that it's quite tricky to generate the right
DFunUnfolding for a specialised dfun, when you use SPECIALISE
INSTANCE. For now I've just commented it out (in DsBinds) but
that'll lose some optimisation, and I need to get back to
this.
Diffstat (limited to 'compiler/simplCore/Simplify.lhs')
-rw-r--r-- | compiler/simplCore/Simplify.lhs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/compiler/simplCore/Simplify.lhs b/compiler/simplCore/Simplify.lhs index 59c8ae4413..72227034bb 100644 --- a/compiler/simplCore/Simplify.lhs +++ b/compiler/simplCore/Simplify.lhs @@ -702,7 +702,7 @@ simplUnfolding :: SimplEnv-> TopLevelFlag simplUnfolding env _ _ _ _ (DFunUnfolding ar con ops) = return (DFunUnfolding ar con ops') where - ops' = map (substExpr (text "simplUnfolding") env) ops + ops' = map (fmap (substExpr (text "simplUnfolding") env)) ops simplUnfolding env top_lvl id _ _ (CoreUnfolding { uf_tmpl = expr, uf_arity = arity |