Refactor (again) the handling of default methods
[ghc-hetmet.git] / compiler / types / Class.lhs
index e7bda63..27ec5c1 100644 (file)
@@ -17,6 +17,8 @@ module Class (
        classBigSig, classExtraBigSig, classTvsFds, classSCTheta
     ) where
 
+#include "Typeable.h"
+
 import {-# SOURCE #-} TyCon    ( TyCon )
 import {-# SOURCE #-} TypeRep  ( PredType )
 
@@ -24,8 +26,11 @@ import Var
 import Name
 import BasicTypes
 import Unique
+import Util
 import Outputable
 import FastString
+
+import qualified Data.Data as Data
 \end{code}
 
 %************************************************************************
@@ -66,7 +71,7 @@ type ClassOpItem = (Id, DefMeth)
        -- Default-method info
 
 data DefMeth = NoDefMeth               -- No default method
-            | DefMeth                  -- A polymorphic default method
+            | DefMeth Name             -- A polymorphic default method
             | GenDefMeth               -- A generic default method
              deriving Eq  
 \end{code}
@@ -168,8 +173,8 @@ instance Show Class where
     showsPrec p c = showsPrecSDoc p (ppr c)
 
 instance Outputable DefMeth where
-    ppr DefMeth     =  text "{- has default method -}"
-    ppr GenDefMeth  =  text "{- has generic method -}"
+    ppr (DefMeth n) =  ptext (sLit "Default method") <+> ppr n
+    ppr GenDefMeth  =  ptext (sLit "Generic default method")
     ppr NoDefMeth   =  empty   -- No default method
 
 pprFundeps :: Outputable a => [FunDep a] -> SDoc
@@ -178,5 +183,14 @@ pprFundeps fds = hsep (ptext (sLit "|") : punctuate comma (map pprFunDep fds))
 
 pprFunDep :: Outputable a => FunDep a -> SDoc
 pprFunDep (us, vs) = hsep [interppSP us, ptext (sLit "->"), interppSP vs]
+
+instance Data.Typeable Class where
+    typeOf _ = Data.mkTyConApp (Data.mkTyCon "Class") []
+
+instance Data.Data Class where
+    -- don't traverse?
+    toConstr _   = abstractConstr "Class"
+    gunfold _ _  = error "gunfold"
+    dataTypeOf _ = mkNoRepType "Class"
 \end{code}