X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fcompiler%2Ftypes%2FClass.lhs;h=3385adc2b31336c139763b321a4e486092936d74;hb=4a6671660d388418a19a2cbda407e494e4ff5a3b;hp=b3e47e415383d45756f8d3b123dcfdcfa32ca3fd;hpb=77a8c0dbd5c5ad90fe483cb9ddc2b6ef36d3f4d8;p=ghc-hetmet.git diff --git a/ghc/compiler/types/Class.lhs b/ghc/compiler/types/Class.lhs index b3e47e4..3385adc 100644 --- a/ghc/compiler/types/Class.lhs +++ b/ghc/compiler/types/Class.lhs @@ -5,24 +5,24 @@ \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 ) import BasicTypes ( Arity ) import Unique ( Unique, Uniquable(..) ) import Outputable -import Util \end{code} %************************************************************************ @@ -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,16 +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, -- Selector function; contains unfolding - Id, -- Default methods - Bool) -- True <=> an explicit default method was - -- supplied in the class decl +type ClassOpItem = (Id, DefMeth) + -- Selector function; contains unfolding + -- Default-method info + +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. @@ -69,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 @@ -100,7 +101,7 @@ classArity clas = length (classTyVars clas) -- Could memoise this classSelIds (Class {classSCSels = sc_sels, classOpStuff = op_stuff}) - = sc_sels ++ [op_sel | (op_sel, _, _) <- op_stuff] + = sc_sels ++ [op_sel | (op_sel, _) <- op_stuff] classTvsFds c = (classTyVars c, classFunDeps c) @@ -148,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}