X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2FhsSyn%2FHsDecls.lhs;h=09d8d0a560ae92433061552d2bab9b7072d2e2f1;hb=91f37e6a9be2c17642f5beb0a4bdddef2cb6fb37;hp=049f5972091ec48d75cfd7ace4956d7b39b90390;hpb=ab22f4e6456820c1b5169d75f5975a94e61f54ce;p=ghc-hetmet.git diff --git a/compiler/hsSyn/HsDecls.lhs b/compiler/hsSyn/HsDecls.lhs index 049f597..09d8d0a 100644 --- a/compiler/hsSyn/HsDecls.lhs +++ b/compiler/hsSyn/HsDecls.lhs @@ -344,11 +344,6 @@ Interface file code: \begin{code} --- TyClDecls are precisely the kind of declarations that can --- appear in interface files; or (internally) in GHC's interface --- for a module. That's why (despite the misnomer) IfaceSig and ForeignType --- are both in TyClDecl - -- Representation of indexed types -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- Kind signatures of indexed types come in two flavours: @@ -386,12 +381,21 @@ data TyClDecl name | TyData { tcdND :: NewOrData, tcdCtxt :: LHsContext name, -- Context tcdLName :: Located name, -- Type constructor + tcdTyVars :: [LHsTyVarBndr name], -- Type variables + tcdTyPats :: Maybe [LHsType name], -- Type patterns - tcdKindSig:: Maybe Kind, -- Optional kind sig; - -- (only for the - -- 'where' form and - -- indexed type sigs) + -- Just [t1..tn] for data instance T t1..tn = ... + -- in this case tcdTyVars = fv( tcdTyPats ) + -- Nothing for everything else + + tcdKindSig:: Maybe Kind, -- Optional kind sig + -- (Just k) for a + -- (a) GADT-style 'data', or 'data instance' decl + -- with explicit kind sig + -- (b) 'data family' decl, whether or not + -- there is an explicit kind sig + -- (this is how we distinguish a data family decl) tcdCons :: [LConDecl name], -- Data constructors -- For data T a = T1 | T2 a the LConDecls all have ResTyH98 @@ -405,6 +409,12 @@ data TyClDecl name -- Typically the foralls and ty args are empty, but they -- are non-empty for the newtype-deriving case } + -- data family: tcdPats = Nothing, tcdCons = [], tcdKindSig = Just k + -- + -- data instance: tcdPats = Just tys + -- + -- data: tcdPats = Nothing, + -- tcdCons is non-empty *or* tcdKindSig = Nothing | TyFunction {tcdLName :: Located name, -- type constructor tcdTyVars :: [LHsTyVarBndr name], -- type variables @@ -415,8 +425,9 @@ data TyClDecl name | TySynonym { tcdLName :: Located name, -- type constructor tcdTyVars :: [LHsTyVarBndr name], -- type variables tcdTyPats :: Maybe [LHsType name], -- Type patterns - -- 'Nothing' => vanilla - -- type synonym + -- See comments for tcdTyPats in TyData + -- 'Nothing' => vanilla type synonym + tcdSynRhs :: LHsType name -- synonym expansion } @@ -745,12 +756,11 @@ instDeclATs (InstDecl _ _ _ ats) = ats \begin{code} type LDerivDecl name = Located (DerivDecl name) -data DerivDecl name - = DerivDecl (LHsType name) (Located name) +data DerivDecl name = DerivDecl (LHsType name) instance (OutputableBndr name) => Outputable (DerivDecl name) where - ppr (DerivDecl ty n) - = hsep [ptext SLIT("deriving"), ppr ty, ptext SLIT("for"), ppr n] + ppr (DerivDecl ty) + = hsep [ptext SLIT("derived instance"), ppr ty] \end{code} %************************************************************************