diff options
author | Alan Zimmerman <alan.zimm@gmail.com> | 2015-01-19 08:15:18 -0600 |
---|---|---|
committer | Austin Seipp <austin@well-typed.com> | 2015-01-19 08:15:18 -0600 |
commit | 851ed7211fb18fea938be84c99b6389f6762b30d (patch) | |
tree | 0f24080f6c04578860b00e1b6e9c55a8f4f4cbaa /compiler/hsSyn/HsDecls.hs | |
parent | 960e3c92eace7f9b584cfc6f6eb69a37cd3d88f8 (diff) | |
download | haskell-851ed7211fb18fea938be84c99b6389f6762b30d.tar.gz |
API Annotations documentation update, parsing issue, add example test
Summary:
Add a reference note to each AnnKeywordId haddock comment so GHC
developers will have an idea why they are there.
Add a new test to ghc-api/annotations to serve as a template for other
GHC developers when they need to update the parser. It provides output
which checks that each SrcSpan that an annotation is attached to
actually appears in the `ParsedSource`, and lists the individual
annotations. The idea is that a developer writes a version of this
which parses a sample file using whatever syntax is changed in
Parser.y, and can then check that all the annotations come through.
Depends on D538
Test Plan: ./validate
Reviewers: simonpj, hvr, austin
Reviewed By: austin
Subscribers: thomie, jstolarek
Differential Revision: https://phabricator.haskell.org/D620
Diffstat (limited to 'compiler/hsSyn/HsDecls.hs')
-rw-r--r-- | compiler/hsSyn/HsDecls.hs | 51 |
1 files changed, 49 insertions, 2 deletions
diff --git a/compiler/hsSyn/HsDecls.hs b/compiler/hsSyn/HsDecls.hs index 6fcfa6724d..9f78a2b8b2 100644 --- a/compiler/hsSyn/HsDecls.hs +++ b/compiler/hsSyn/HsDecls.hs @@ -124,6 +124,8 @@ type LHsDecl id = Located (HsDecl id) -- - 'ApiAnnotation.AnnKeywordId' : 'ApiAnnotation.AnnSemi' -- +-- For details on above see note [Api annotations] in ApiAnnotation + -- | A Haskell Declaration data HsDecl id = TyClD (TyClDecl id) -- ^ A type or class declaration. @@ -468,12 +470,15 @@ data TyClDecl name -- 'ApiAnnotation.AnnOpen','ApiAnnotation.AnnDcolon', -- 'ApiAnnotation.AnnClose' + -- For details on above see note [Api annotations] in ApiAnnotation FamDecl { tcdFam :: FamilyDecl name } | -- | @type@ declaration -- -- - 'ApiAnnotation.AnnKeywordId' : 'ApiAnnotation.AnnType', -- 'ApiAnnotation.AnnEqual', + + -- For details on above see note [Api annotations] in ApiAnnotation SynDecl { tcdLName :: Located name -- ^ Type constructor , tcdTyVars :: LHsTyVarBndrs name -- ^ Type variables; for an associated type -- these include outer binders @@ -486,6 +491,8 @@ data TyClDecl name -- 'ApiAnnotation.AnnFamily', -- 'ApiAnnotation.AnnNewType', -- 'ApiAnnotation.AnnNewType','ApiAnnotation.AnnWhere' + + -- For details on above see note [Api annotations] in ApiAnnotation DataDecl { tcdLName :: Located name -- ^ Type constructor , tcdTyVars :: LHsTyVarBndrs name -- ^ Type variables; for an assoicated type -- these include outer binders @@ -516,6 +523,8 @@ data TyClDecl name -- 'ApiAnnotation.AnnComma' -- 'ApiAnnotation.AnnRarrow' + -- For details on above see note [Api annotations] in ApiAnnotation + deriving (Typeable) deriving instance (DataId id) => Data (TyClDecl id) @@ -818,6 +827,8 @@ data HsDataDefn name -- The payload of a data type defn -- - 'ApiAnnotation.AnnKeywordId' : -- 'ApiAnnotation.AnnDeriving', -- 'ApiAnnotation.AnnOpen','ApiAnnotation.AnnClose' + + -- For details on above see note [Api annotations] in ApiAnnotation } deriving( Typeable ) deriving instance (DataId id) => Data (HsDataDefn id) @@ -831,6 +842,8 @@ type LConDecl name = Located (ConDecl name) -- ^ May have 'ApiAnnotation.AnnKeywordId' : 'ApiAnnotation.AnnSemi' when -- in a GADT constructor list + -- For details on above see note [Api annotations] in ApiAnnotation + -- | -- -- @ @@ -852,6 +865,8 @@ type LConDecl name = Located (ConDecl name) -- 'ApiAnnotation.AnnEqual','ApiAnnotation.AnnVbar', -- 'ApiAnnotation.AnnDarrow','ApiAnnotation.AnnDarrow', -- 'ApiAnnotation.AnnForall','ApiAnnotation.AnnDot' + +-- For details on above see note [Api annotations] in ApiAnnotation data ConDecl name = ConDecl { con_names :: [Located name] @@ -1025,6 +1040,9 @@ It is parameterised over its tfe_pats field: type LTyFamInstEqn name = Located (TyFamInstEqn name) -- ^ May have 'ApiAnnotation.AnnKeywordId' : 'ApiAnnotation.AnnSemi' -- when in a list + +-- For details on above see note [Api annotations] in ApiAnnotation + type LTyFamDefltEqn name = Located (TyFamDefltEqn name) type HsTyPats name = HsWithBndrs name [LHsType name] @@ -1044,6 +1062,8 @@ data TyFamEqn name pats , tfe_rhs :: LHsType name } -- ^ -- - 'ApiAnnotation.AnnKeywordId' : 'ApiAnnotation.AnnEqual' + + -- For details on above see note [Api annotations] in ApiAnnotation deriving( Typeable ) deriving instance (DataId name, Data pats) => Data (TyFamEqn name pats) @@ -1055,6 +1075,8 @@ data TyFamInstDecl name -- ^ -- - 'ApiAnnotation.AnnKeywordId' : 'ApiAnnotation.AnnType', -- 'ApiAnnotation.AnnInstance', + + -- For details on above see note [Api annotations] in ApiAnnotation deriving( Typeable ) deriving instance (DataId name) => Data (TyFamInstDecl name) @@ -1073,6 +1095,8 @@ data DataFamInstDecl name -- 'ApiAnnotation.AnnNewType','ApiAnnotation.AnnInstance', -- 'ApiAnnotation.AnnWhere','ApiAnnotation.AnnOpen', -- 'ApiAnnotation.AnnClose' + + -- For details on above see note [Api annotations] in ApiAnnotation deriving( Typeable ) deriving instance (DataId name) => Data (DataFamInstDecl name) @@ -1093,12 +1117,14 @@ data ClsInstDecl name -- ^ - 'ApiAnnotation.AnnKeywordId' : 'ApiAnnotation.AnnOpen', -- 'ApiAnnotation.AnnClose', + -- For details on above see note [Api annotations] in ApiAnnotation } -- ^ -- - 'ApiAnnotation.AnnKeywordId' : 'ApiAnnotation.AnnInstance', -- 'ApiAnnotation.AnnWhere', -- 'ApiAnnotation.AnnOpen','ApiAnnotation.AnnClose', - -- + + -- For details on above see note [Api annotations] in ApiAnnotation deriving (Typeable) deriving instance (DataId id) => Data (ClsInstDecl id) @@ -1238,7 +1264,9 @@ data DerivDecl name = DerivDecl -- ^ - 'ApiAnnotation.AnnKeywordId' : 'ApiAnnotation.AnnOpen', -- 'ApiAnnotation.AnnClose', -- 'ApiAnnotation.AnnDeriving', - -- 'ApiAnnotation.AnnInstance', + -- 'ApiAnnotation.AnnInstance' + + -- For details on above see note [Api annotations] in ApiAnnotation } deriving (Typeable) deriving instance (DataId name) => Data (DerivDecl name) @@ -1266,6 +1294,7 @@ data DefaultDecl name -- ^ - 'ApiAnnotation.AnnKeywordId's : 'ApiAnnotation.AnnDefault', -- 'ApiAnnotation.AnnOpen','ApiAnnotation.AnnClose' + -- For details on above see note [Api annotations] in ApiAnnotation deriving (Typeable) deriving instance (DataId name) => Data (DefaultDecl name) @@ -1304,6 +1333,8 @@ data ForeignDecl name -- - 'ApiAnnotation.AnnKeywordId' : 'ApiAnnotation.AnnForeign', -- 'ApiAnnotation.AnnImport','ApiAnnotation.AnnExport', -- 'ApiAnnotation.AnnDcolon' + + -- For details on above see note [Api annotations] in ApiAnnotation deriving (Typeable) deriving instance (DataId name) => Data (ForeignDecl name) {- @@ -1433,6 +1464,8 @@ data RuleDecl name -- 'ApiAnnotation.AnnClose', -- 'ApiAnnotation.AnnForall','ApiAnnotation.AnnDot', -- 'ApiAnnotation.AnnEqual', + + -- For details on above see note [Api annotations] in ApiAnnotation deriving (Typeable) deriving instance (DataId name) => Data (RuleDecl name) @@ -1446,6 +1479,8 @@ data RuleBndr name -- ^ -- - 'ApiAnnotation.AnnKeywordId' : 'ApiAnnotation.AnnOpen', -- 'ApiAnnotation.AnnDcolon','ApiAnnotation.AnnClose' + + -- For details on above see note [Api annotations] in ApiAnnotation deriving (Typeable) deriving instance (DataId name) => Data (RuleBndr name) @@ -1495,11 +1530,15 @@ data VectDecl name (LHsExpr name) -- ^ - 'ApiAnnotation.AnnKeywordId' : 'ApiAnnotation.AnnOpen', -- 'ApiAnnotation.AnnEqual','ApiAnnotation.AnnClose' + + -- For details on above see note [Api annotations] in ApiAnnotation | HsNoVect SourceText -- Note [Pragma source text] in BasicTypes (Located name) -- ^ - 'ApiAnnotation.AnnKeywordId' : 'ApiAnnotation.AnnOpen', -- 'ApiAnnotation.AnnClose' + + -- For details on above see note [Api annotations] in ApiAnnotation | HsVectTypeIn -- pre type-checking SourceText -- Note [Pragma source text] in BasicTypes Bool -- 'TRUE' => SCALAR declaration @@ -1508,6 +1547,8 @@ data VectDecl name -- ^ - 'ApiAnnotation.AnnKeywordId' : 'ApiAnnotation.AnnOpen', -- 'ApiAnnotation.AnnType','ApiAnnotation.AnnClose', -- 'ApiAnnotation.AnnEqual' + + -- For details on above see note [Api annotations] in ApiAnnotation | HsVectTypeOut -- post type-checking Bool -- 'TRUE' => SCALAR declaration TyCon @@ -1517,6 +1558,8 @@ data VectDecl name (Located name) -- ^ - 'ApiAnnotation.AnnKeywordId' : 'ApiAnnotation.AnnOpen', -- 'ApiAnnotation.AnnClass','ApiAnnotation.AnnClose', + + -- For details on above see note [Api annotations] in ApiAnnotation | HsVectClassOut -- post type-checking Class | HsVectInstIn -- pre type-checking (always SCALAR) !!!FIXME: should be superfluous now @@ -1651,6 +1694,8 @@ data AnnDecl name = HsAnnotation -- 'ApiAnnotation.AnnType' -- 'ApiAnnotation.AnnModule' -- 'ApiAnnotation.AnnClose' + + -- For details on above see note [Api annotations] in ApiAnnotation deriving (Typeable) deriving instance (DataId name) => Data (AnnDecl name) @@ -1694,6 +1739,8 @@ data RoleAnnotDecl name [Located (Maybe Role)] -- optional annotations -- ^ - 'ApiAnnotation.AnnKeywordId' : 'ApiAnnotation.AnnType', -- 'ApiAnnotation.AnnRole' + + -- For details on above see note [Api annotations] in ApiAnnotation deriving (Data, Typeable) instance OutputableBndr name => Outputable (RoleAnnotDecl name) where |