summaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2012-10-01 11:24:10 +0100
committerSimon Peyton Jones <simonpj@microsoft.com>2012-10-01 11:24:10 +0100
commit935fa10a2d9ec0bd4b0f69b3a73b62d382b19caa (patch)
tree0d73df06f5a6911ce66b3250bbd22772547ba068 /compiler
parent6e3e64aeda1add215ffccca87931a60e4f8b53e5 (diff)
downloadhaskell-935fa10a2d9ec0bd4b0f69b3a73b62d382b19caa.tar.gz
Comments about silent superclasses
Diffstat (limited to 'compiler')
-rw-r--r--compiler/basicTypes/IdInfo.lhs2
-rw-r--r--compiler/typecheck/TcInstDcls.lhs12
-rw-r--r--compiler/types/InstEnv.lhs5
3 files changed, 14 insertions, 5 deletions
diff --git a/compiler/basicTypes/IdInfo.lhs b/compiler/basicTypes/IdInfo.lhs
index 93762abba9..1d777895e4 100644
--- a/compiler/basicTypes/IdInfo.lhs
+++ b/compiler/basicTypes/IdInfo.lhs
@@ -142,7 +142,7 @@ data IdDetails
-- instance C a => C [a]
-- has is_silent = 1, because the dfun
-- has type dfun :: (D a, C a) => C [a]
- -- See the DFun Superclass Invariant in TcInstDcls
+ -- See Note [Silent superclass arguments] in TcInstDcls
--
-- Bool = True <=> the class has only one method, so may be
-- implemented with a newtype, so it might be bad
diff --git a/compiler/typecheck/TcInstDcls.lhs b/compiler/typecheck/TcInstDcls.lhs
index 2e62cd78a8..b4a27b5376 100644
--- a/compiler/typecheck/TcInstDcls.lhs
+++ b/compiler/typecheck/TcInstDcls.lhs
@@ -947,7 +947,7 @@ immediate superclasses of the dictionary we are trying to
construct. In our example:
dfun :: forall a. C [a] -> D [a] -> D [a]
dfun = \(dc::C [a]) (dd::D [a]) -> DOrd dc ...
-Notice teh extra (dc :: C [a]) argument compared to the previous version.
+Notice the extra (dc :: C [a]) argument compared to the previous version.
This gives us:
@@ -967,9 +967,13 @@ dictionary constructor). No superclass is hidden inside a dfun
application.
The extra arguments required to satisfy the DFun Superclass Invariant
-always come first, and are called the "silent" arguments. DFun types
-are built (only) by MkId.mkDictFunId, so that is where we decide
-what silent arguments are to be added.
+always come first, and are called the "silent" arguments. You can
+find out how many silent arguments there are using Id.dfunNSilent;
+and then you can just drop that number of arguments to see the ones
+that were in the original instance declaration.
+
+DFun types are built (only) by MkId.mkDictFunId, so that is where we
+decide what silent arguments are to be added.
In our example, if we had [Wanted] dw :: D [a] we would get via the instance:
dw := dfun d1 d2
diff --git a/compiler/types/InstEnv.lhs b/compiler/types/InstEnv.lhs
index 388846b8ee..f99b0a1bdd 100644
--- a/compiler/types/InstEnv.lhs
+++ b/compiler/types/InstEnv.lhs
@@ -61,6 +61,10 @@ data ClsInst
-- forall is_tvs. (...) => is_cls is_tys
, is_dfun :: DFunId -- See Note [Haddock assumptions]
+ -- See Note [Silent superclass arguments] in TcInstDcls
+ -- for how to map the DFun's type back to the source
+ -- language instance decl
+
, is_flag :: OverlapFlag -- See detailed comments with
-- the decl of BasicTypes.OverlapFlag
}
@@ -159,6 +163,7 @@ pprInstanceHdr (ClsInst { is_flag = flag, is_dfun = dfun })
let theta_to_print
| debugStyle sty = theta
| otherwise = drop (dfunNSilent dfun) theta
+ -- See Note [Silent superclass arguments] in TcInstDcls
in ptext (sLit "instance") <+> ppr flag
<+> sep [pprThetaArrowTy theta_to_print, ppr res_ty]
where