Remove the distinction between data and newtype families
[ghc-hetmet.git] / compiler / hsSyn / HsDecls.lhs
index 2b97668..37ab35a 100644 (file)
@@ -18,7 +18,7 @@ module HsDecls (
        ForeignDecl(..), LForeignDecl, ForeignImport(..), ForeignExport(..),
        CImportSpec(..), FoType(..),
        ConDecl(..), ResType(..), LConDecl,     
-       DocDecl(..), LDocDecl, docDeclDoc, DocEntity(..),
+       DocDecl(..), LDocDecl, docDeclDoc,
        DeprecDecl(..),  LDeprecDecl,
        HsGroup(..),  emptyRdrGroup, emptyRnGroup, appendGroups,
        tcdName, tyClDeclNames, tyClDeclTyVars,
@@ -111,9 +111,7 @@ data HsGroup id
        hs_depds  :: [LDeprecDecl id],
        hs_ruleds :: [LRuleDecl id],
 
-       hs_docs   :: [DocEntity id]
-                -- Used to remember the module structure,
-                -- which is needed to produce Haddock documentation
+       hs_docs   :: [LDocDecl id]
   }
 
 emptyGroup, emptyRdrGroup, emptyRnGroup :: HsGroup a
@@ -360,7 +358,7 @@ Interface file code:
 --
 --   * If it is 'Just pats', we have the definition of an indexed type.  Then,
 --     'pats' are type patterns for the type-indexes of the type constructor
---     and 'tcdVars' are the variables in those patterns.  Hence, the arity of
+--     and 'tcdTyVars' are the variables in those patterns.  Hence, the arity of
 --     the indexed type (ie, the number of indexes) is 'length tcdTyPats' and
 --     *not* 'length tcdVars'.
 --
@@ -375,12 +373,16 @@ data TyClDecl name
                tcdFoType   :: FoType
     }
 
+       -- type/data/newtype family T :: *->*
   | TyFamily {  tcdFlavour:: FamilyFlavour,            -- type, new, or data
                tcdLName  :: Located name,              -- type constructor
                tcdTyVars :: [LHsTyVarBndr name],       -- type variables
                tcdKind   :: Maybe Kind                 -- result kind
     }
 
+       -- Declares a data type or newtype, giving its construcors
+       --      data/newtype T a = <constrs>
+       --      data/newtype instance T [a] = <constrs>
   | TyData {   tcdND     :: NewOrData,
                tcdCtxt   :: LHsContext name,           -- Context
                tcdLName  :: Located name,              -- Type constructor
@@ -408,9 +410,6 @@ data TyClDecl name
                        -- Typically the foralls and ty args are empty, but they
                        -- are non-empty for the newtype-deriving case
     }
-       -- data instance: tcdPats = Just tys
-       --
-       -- data:          tcdPats = Nothing, 
 
   | TySynonym {        tcdLName  :: Located name,              -- type constructor
                tcdTyVars :: [LHsTyVarBndr name],       -- type variables
@@ -431,7 +430,7 @@ data TyClDecl name
                                                        --   only 'TyData',
                                                        --   'TyFunction',
                                                        --   and 'TySynonym'
-               tcdDocs    :: [DocEntity name]          -- Haddock docs
+               tcdDocs    :: [LDocDecl name]           -- Haddock docs
     }
 
 data NewOrData
@@ -441,7 +440,7 @@ data NewOrData
 
 data FamilyFlavour
   = TypeFamily                 -- "type family ..."
-  | DataFamily NewOrData       -- "newtype family ..." or "data family ..."
+  | DataFamily                 -- "data family ..."
 \end{code}
 
 Simple classifiers
@@ -537,9 +536,8 @@ instance OutputableBndr name
       = pp_flavour <+> pp_decl_head [] ltycon tyvars Nothing <+> pp_kind
         where
          pp_flavour = case flavour of
-                        TypeFamily          -> ptext SLIT("type family")
-                        DataFamily NewType  -> ptext SLIT("newtype family")
-                        DataFamily DataType -> ptext SLIT("data family")
+                        TypeFamily -> ptext SLIT("type family")
+                        DataFamily -> ptext SLIT("data family")
 
           pp_kind = case mb_kind of
                      Nothing   -> empty
@@ -935,11 +933,6 @@ instance OutputableBndr name => Outputable (RuleBndr name) where
 
 \begin{code}
 
--- source code entities, for representing the module structure
-data DocEntity name
-  = DeclEntity name
-  | DocEntity (DocDecl name)
 type LDocDecl name = Located (DocDecl name)
 
 data DocDecl name