Fix Trac #2856: make deriving work for type families
[ghc-hetmet.git] / compiler / typecheck / TcEnv.lhs
index 9afe28f..8c37e08 100644 (file)
@@ -57,6 +57,7 @@ import TcType
 -- import TcSuspension
 import qualified Type
 import Id
+import Coercion
 import Var
 import VarSet
 import VarEnv
@@ -642,8 +643,12 @@ data InstBindings a
                                -- specialised instances
 
   | NewTypeDerived              -- Used for deriving instances of newtypes, where the
-                               -- witness dictionary is identical to the argument 
+       CoercionI               -- witness dictionary is identical to the argument 
                                -- dictionary.  Hence no bindings, no pragmas.
+               -- The coercion maps from newtype to the representation type
+               -- (mentioning type variables bound by the forall'd iSpec variables)
+               -- E.g.   newtype instance N [a] = N1 (Tree a)
+               --        co : N [a] ~ Tree a
 
 pprInstInfo :: InstInfo a -> SDoc
 pprInstInfo info = vcat [ptext (sLit "InstInfo:") <+> ppr (idType (iDFunId info))]
@@ -651,8 +656,8 @@ pprInstInfo info = vcat [ptext (sLit "InstInfo:") <+> ppr (idType (iDFunId info)
 pprInstInfoDetails :: OutputableBndr a => InstInfo a -> SDoc
 pprInstInfoDetails info = pprInstInfo info $$ nest 2 (details (iBinds info))
   where
-    details (VanillaInst b _) = pprLHsBinds b
-    details NewTypeDerived    = text "Derived from the representation type"
+    details (VanillaInst b _)  = pprLHsBinds b
+    details (NewTypeDerived _) = text "Derived from the representation type"
 
 simpleInstInfoClsTy :: InstInfo a -> (Class, Type)
 simpleInstInfoClsTy info = case instanceHead (iSpec info) of