[project @ 2003-12-30 14:05:46 by simonpj]
[ghc-hetmet.git] / ghc / compiler / types / Class.lhs
index 3553763..3385adc 100644 (file)
@@ -5,18 +5,18 @@
 
 \begin{code}
 module Class (
-       Class, ClassOpItem, ClassPred, ClassContext, FunDep,
+       Class, ClassOpItem, FunDep,
        DefMeth (..),
 
        mkClass, classTyVars, classArity,
        classKey, className, classSelIds, classTyCon,
-       classBigSig, classExtraBigSig, classTvsFds
+       classBigSig, classExtraBigSig, classTvsFds, classSCTheta
     ) where
 
 #include "HsVersions.h"
 
 import {-# SOURCE #-} TyCon    ( TyCon )
-import {-# SOURCE #-} TypeRep  ( Type )
+import {-# SOURCE #-} TypeRep  ( PredType )
 
 import Var             ( Id, TyVar )
 import Name            ( NamedThing(..), Name )
@@ -42,7 +42,7 @@ data Class
        classTyVars  :: [TyVar],                -- The class type variables
        classFunDeps :: [FunDep TyVar],         -- The functional dependencies
 
-       classSCTheta :: [(Class,[Type])],       -- Immediate superclasses, and the
+       classSCTheta :: [PredType],             -- Immediate superclasses, and the
        classSCSels  :: [Id],                   -- corresponding selector functions to
                                                -- extract them from a dictionary of this
                                                -- class
@@ -52,20 +52,17 @@ data Class
        classTyCon :: TyCon             -- The data type constructor for dictionaries
   }                                    -- of this class
 
-type ClassPred           = (Class, [Type])
-type ClassContext = [ClassPred]
-
 type FunDep a    = ([a],[a])   --  e.g. class C a b c |  a b -> c, a c -> b  where ...
                                --  Here fun-deps are [([a,b],[c]), ([a,c],[b])]
 
-type ClassOpItem = (Id, DefMeth Id)
+type ClassOpItem = (Id, DefMeth)
        -- Selector function; contains unfolding
        -- Default-method info
 
-data DefMeth id = NoDefMeth            -- No default method
-               | DefMeth id            -- A polymorphic default method (named id)
-               | GenDefMeth            -- A generic default method
-                deriving Eq  
+data DefMeth = NoDefMeth               -- No default method
+            | DefMeth                  -- A polymorphic default method
+            | GenDefMeth               -- A generic default method
+             deriving Eq  
 \end{code}
 
 The @mkClass@ function fills in the indirect superclasses.
@@ -73,7 +70,7 @@ The @mkClass@ function fills in the indirect superclasses.
 \begin{code}
 mkClass :: Name -> [TyVar]
        -> [([TyVar], [TyVar])]
-       -> [(Class,[Type])] -> [Id]
+       -> [PredType] -> [Id]
        -> [ClassOpItem]
        -> TyCon
        -> Class
@@ -152,6 +149,11 @@ instance Outputable Class where
 
 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 NoDefMeth   =  empty   -- No default method
 \end{code}