Support constructor Haddocks in more places
authorAlec Theriault <alec.theriault@gmail.com>
Fri, 12 Jan 2018 21:45:48 +0000 (16:45 -0500)
committerBen Gamari <ben@smart-cactus.org>
Fri, 12 Jan 2018 21:45:51 +0000 (16:45 -0500)
This adds support for adding Haddocks on individual non-record fields
of regular (and GADT) constructors. The following now parses just fine
with `-haddock` enabled:

data Foo
  = Baz             -- ^ doc on the `Baz` constructor
      Int           -- ^ doc on the `Int` field of `Baz`
      String        -- ^ doc on the `String` field of `Baz`

  | Int             -- ^ doc on the `Int` field of the `:*` constructor
      :*            -- ^ doc on the `:*` constructor
    String          -- ^ doc on the `String` field of the `:*`
constructor

  | Boa             -- ^ doc on the `Boa` record constructor
      { y :: () }

The change is backwards compatible: if there is only one doc and it
occurs
on the last field, it is lifted to apply to the whole constructor (as
before).

Reviewers: bgamari, alanz

Subscribers: rwbarton, thomie, mpickering, carter

Differential Revision: https://phabricator.haskell.org/D4292

26 files changed:
compiler/parser/Parser.y
compiler/parser/RdrHsSyn.hs
testsuite/tests/ghc-api/annotations/T10255.stdout
testsuite/tests/ghc-api/annotations/T10268.stdout
testsuite/tests/ghc-api/annotations/T10278.stdout
testsuite/tests/ghc-api/annotations/T10312.stdout
testsuite/tests/ghc-api/annotations/T10354.stdout
testsuite/tests/ghc-api/annotations/T10399.stdout
testsuite/tests/ghc-api/annotations/T10598.stdout
testsuite/tests/ghc-api/annotations/T11018.stdout
testsuite/tests/ghc-api/annotations/T12417.stdout
testsuite/tests/ghc-api/annotations/boolFormula.stdout
testsuite/tests/ghc-api/annotations/exampleTest.stdout
testsuite/tests/ghc-api/annotations/listcomps.stdout
testsuite/tests/ghc-api/annotations/parseTree.stdout
testsuite/tests/haddock/should_compile_flag_haddock/all.T
testsuite/tests/haddock/should_compile_flag_haddock/haddockA035.hs [new file with mode: 0644]
testsuite/tests/haddock/should_compile_flag_haddock/haddockA035.stderr [new file with mode: 0644]
testsuite/tests/haddock/should_compile_flag_haddock/haddockA036.hs [new file with mode: 0644]
testsuite/tests/haddock/should_compile_flag_haddock/haddockA036.stderr [new file with mode: 0644]
testsuite/tests/haddock/should_compile_flag_haddock/haddockA037.hs [new file with mode: 0644]
testsuite/tests/haddock/should_compile_flag_haddock/haddockA037.stderr [new file with mode: 0644]
testsuite/tests/haddock/should_compile_noflag_haddock/all.T
testsuite/tests/haddock/should_compile_noflag_haddock/haddockC035.hs [new file with mode: 0644]
testsuite/tests/haddock/should_compile_noflag_haddock/haddockC036.hs [new file with mode: 0644]
testsuite/tests/haddock/should_compile_noflag_haddock/haddockC037.hs [new file with mode: 0644]

index d40b62b..a3bc996 100644 (file)
@@ -48,7 +48,7 @@ import PackageConfig
 import OrdList
 import BooleanFormula   ( BooleanFormula(..), LBooleanFormula(..), mkTrue )
 import FastString
-import Maybes           ( orElse )
+import Maybes           ( isJust, orElse )
 import Outputable
 
 -- compiler/basicTypes
@@ -1807,9 +1807,10 @@ context_no_ops :: { LHsContext GhcPs }
 ~~~~~~~~~~~~~~~~~~~~~
 The type production for
 
-    btype `->` btype
+    btype `->`         ctypedoc
+    btype docprev `->` ctypedoc
 
-adds the AnnRarrow annotation twice, in different places.
+add the AnnRarrow annotation twice, in different places.
 
 This is because if the type is processed as usual, it belongs on the annotations
 for the type as a whole.
@@ -1821,17 +1822,18 @@ is connected to the first type too.
 
 type :: { LHsType GhcPs }
         : btype                        { $1 }
-        | btype '->' ctype             {% ams $1 [mu AnnRarrow $2] -- See note [GADT decl discards annotations]
-                                       >> ams (sLL $1 $> $ HsFunTy $1 $3)
+        | btype '->' ctype             {% ams (sLL $1 $> $ HsFunTy $1 $3)
                                               [mu AnnRarrow $2] }
 
 
 typedoc :: { LHsType GhcPs }
         : btype                          { $1 }
         | btype docprev                  { sLL $1 $> $ HsDocTy $1 $2 }
-        | btype '->'     ctypedoc        {% ams (sLL $1 $> $ HsFunTy $1 $3)
+        | btype '->'     ctypedoc        {% ams $1 [mu AnnRarrow $2] -- See note [GADT decl discards annotations]
+                                         >> ams (sLL $1 $> $ HsFunTy $1 $3)
                                                 [mu AnnRarrow $2] }
-        | btype docprev '->' ctypedoc    {% ams (sLL $1 $> $
+        | btype docprev '->' ctypedoc    {% ams $1 [mu AnnRarrow $3] -- See note [GADT decl discards annotations]
+                                         >> ams (sLL $1 $> $
                                                  HsFunTy (L (comb2 $1 $2) (HsDocTy $1 $2))
                                                          $4)
                                                 [mu AnnRarrow $3] }
@@ -1846,8 +1848,8 @@ btype :: { LHsType GhcPs }
 -- > data Foo = Int :+ Char :* Bool
 -- See also Note [Parsing data constructors is hard] in RdrHsSyn
 btype_no_ops :: { LHsType GhcPs }
-        : btype_no_ops atype            { sLL $1 $> $ HsAppTy $1 $2 }
-        | atype                         { $1 }
+        : btype_no_ops atype_docs       { sLL $1 $> $ HsAppTy $1 $2 }
+        | atype_docs                    { $1 }
 
 tyapps :: { Located [LHsAppType GhcPs] }   -- NB: This list is reversed
         : tyapp                         { sL1 $1 [$1] }
@@ -1863,6 +1865,10 @@ tyapp :: { LHsAppType GhcPs }
         | SIMPLEQUOTE varop             {% ams (sLL $1 $> $ HsAppInfix $2)
                                                [mj AnnSimpleQuote $1] }
 
+atype_docs :: { LHsType GhcPs }
+        : atype docprev                 { sLL $1 $> $ HsDocTy $1 $2 }
+        | atype                         { $1 }
+
 atype :: { LHsType GhcPs }
         : ntgtycon                       { sL1 $1 (HsTyVar NotPromoted $1) }      -- Not including unit tuples
         | tyvar                          { sL1 $1 (HsTyVar NotPromoted $1) }      -- (See Note [Unit tuples])
@@ -2063,7 +2069,7 @@ gadt_constr_with_doc
 gadt_constr :: { LConDecl GhcPs }
     -- see Note [Difference in parsing GADT and data constructors]
     -- Returns a list because of:   C,D :: ty
-        : con_list '::' sigtype
+        : con_list '::' sigtypedoc
                 {% ams (sLL $1 $> (mkGadtDecl (unLoc $1) $3))
                        [mu AnnDcolon $2] }
 
@@ -2090,33 +2096,38 @@ constrs1 :: { Located [LConDecl GhcPs] }
         | constr                                          { sL1 $1 [$1] }
 
 constr :: { LConDecl GhcPs }
-        : maybe_docnext forall context_no_ops '=>' constr_stuff maybe_docprev
-                {% ams (let (con,details) = unLoc $5 in
+        : maybe_docnext forall context_no_ops '=>' constr_stuff
+                {% ams (let (con,details,doc_prev) = unLoc $5 in
                   addConDoc (L (comb4 $2 $3 $4 $5) (mkConDeclH98 con
                                                        (snd $ unLoc $2)
                                                        (Just $3)
                                                        details))
-                            ($1 `mplus` $6))
+                            ($1 `mplus` doc_prev))
                         (mu AnnDarrow $4:(fst $ unLoc $2)) }
-        | maybe_docnext forall constr_stuff maybe_docprev
-                {% ams ( let (con,details) = unLoc $3 in
+        | maybe_docnext forall constr_stuff
+                {% ams ( let (con,details,doc_prev) = unLoc $3 in
                   addConDoc (L (comb2 $2 $3) (mkConDeclH98 con
                                                       (snd $ unLoc $2)
                                                       Nothing   -- No context
                                                       details))
-                            ($1 `mplus` $4))
+                            ($1 `mplus` doc_prev))
                        (fst $ unLoc $2) }
 
 forall :: { Located ([AddAnn], Maybe [LHsTyVarBndr GhcPs]) }
         : 'forall' tv_bndrs '.'       { sLL $1 $> ([mu AnnForall $1,mj AnnDot $3], Just $2) }
         | {- empty -}                 { noLoc ([], Nothing) }
 
-constr_stuff :: { Located (Located RdrName, HsConDeclDetails GhcPs) }
+constr_stuff :: { Located (Located RdrName, HsConDeclDetails GhcPs, Maybe LHsDocString) }
     -- See Note [Parsing data constructors is hard] in RdrHsSyn
         : btype_no_ops                         {% do { c <- splitCon $1
                                                      ; return $ sLL $1 $> c } }
-        | btype_no_ops conop btype_no_ops      {% do { ty <- splitTilde $1
-                                                     ; return $ sLL $1 $> ($2, InfixCon ty $3) } }
+        | btype_no_ops conop maybe_docprev btype_no_ops
+            {% do { lhs <- splitTilde $1
+                              ; (_, ds_l) <- checkInfixConstr lhs
+                  ; (rhs, ds_r) <- checkInfixConstr $4
+                  ; return $ if isJust (ds_l `mplus` $3)
+                               then sLL $1 $> ($2, InfixCon lhs $4, $3)
+                               else sLL $1 $> ($2, InfixCon lhs rhs, ds_r) } }
 
 fielddecls :: { [LConDeclField GhcPs] }
         : {- empty -}     { [] }
index 0f8e503..389e7ee 100644 (file)
@@ -44,6 +44,7 @@ module   RdrHsSyn (
         -- checking and constructing values
         checkPrecP,           -- Int -> P Int
         checkContext,         -- HsType -> P HsContext
+        checkInfixConstr,
         checkPattern,         -- HsExp -> P HsPat
         bang_RDR,
         checkPatterns,        -- SrcLoc -> [HsExp] -> P [HsPat]
@@ -454,7 +455,8 @@ So the plan is:
 
 * Parse the data constructor declration as a type (actually btype_no_ops)
 
-* Use 'splitCon' to rejig it into the data constructor and the args
+* Use 'splitCon' to rejig it into the data constructor, the args, and possibly
+  extract a docstring for the constructor
 
 * In doing so, we use 'tyConToDataCon' to convert the RdrName for
   the data con, which has been parsed as a tycon, back to a datacon.
@@ -466,23 +468,51 @@ So the plan is:
 -}
 
 splitCon :: LHsType GhcPs
-      -> P (Located RdrName, HsConDeclDetails GhcPs)
+      -> P ( Located RdrName         -- constructor name
+           , HsConDeclDetails GhcPs  -- constructor field information
+           , Maybe LHsDocString      -- docstring to go on the constructor
+           )
 -- See Note [Parsing data constructors is hard]
 -- This gets given a "type" that should look like
 --      C Int Bool
 -- or   C { x::Int, y::Bool }
 -- and returns the pieces
 splitCon ty
- = split ty []
+ = split apps' []
  where
    -- This is used somewhere where HsAppsTy is not used
-   split (L _ (HsAppTy t u)) ts       = split t (u : ts)
-   split (L l (HsTyVar _ (L _ tc)))  ts = do data_con <- tyConToDataCon l tc
-                                             return (data_con, mk_rest ts)
-   split (L l (HsTupleTy HsBoxedOrConstraintTuple ts)) []
-      = return (L l (getRdrName (tupleDataCon Boxed (length ts))), PrefixCon ts)
-   split (L l _) _ = parseErrorSDoc l (text "Cannot parse data constructor in a data/newtype declaration:" <+> ppr ty)
-
+   unrollApps (L _ (HsAppTy t u)) = u : unrollApps t
+   unrollApps t = [t]
+
+   apps = unrollApps ty
+   oneDoc = [ () | L _ (HsDocTy _ _) <- apps ] `lengthIs` 1
+
+   -- the trailing doc, if any, can be extracted first
+   (apps', trailing_doc)
+     = case apps of
+         L _ (HsDocTy t ds) : ts | oneDoc -> (t : ts, Just ds)
+         ts -> (ts, Nothing)
+
+   -- A comment on the constructor is handled a bit differently - it doesn't
+   -- remain an 'HsDocTy', but gets lifted out and returned as the third
+   -- element of the tuple.
+   split [ L _ (HsDocTy con con_doc) ] ts = do
+     (data_con, con_details, con_doc') <- split [con] ts
+     return (data_con, con_details, con_doc' `mplus` Just con_doc)
+   split [ L l (HsTyVar _ (L _ tc)) ] ts = do
+     data_con <- tyConToDataCon l tc
+     return (data_con, mk_rest ts, trailing_doc)
+   split [ L l (HsTupleTy HsBoxedOrConstraintTuple ts) ] []
+     = return ( L l (getRdrName (tupleDataCon Boxed (length ts)))
+              , PrefixCon ts
+              , trailing_doc
+              )
+   split [ L l _ ] _ = parseErrorSDoc l (text msg <+> ppr ty)
+     where msg = "Cannot parse data constructor in a data/newtype declaration:"
+   split (u : us) ts = split us (u : ts)
+   split _ _ = panic "RdrHsSyn:splitCon"
+
+   mk_rest [L _ (HsDocTy t@(L _ HsRecTy{}) _)] = mk_rest [t]
    mk_rest [L l (HsRecTy flds)] = RecCon (L l flds)
    mk_rest ts                   = PrefixCon ts
 
@@ -504,6 +534,22 @@ tyConToDataCon loc tc
           = text "Perhaps you intended to use ExistentialQuantification"
           | otherwise = empty
 
+-- | Split a type to extract the trailing doc string (if there is one) from a
+-- type produced by the 'btype_no_ops' production.
+splitDocTy :: LHsType GhcPs -> (LHsType GhcPs, Maybe LHsDocString)
+splitDocTy (L l (HsAppTy t1 t2)) = (L l (HsAppTy t1 t2'), ds)
+  where ~(t2', ds) = splitDocTy t2
+splitDocTy (L _ (HsDocTy ty ds)) = (ty, Just ds)
+splitDocTy ty = (ty, Nothing)
+
+-- | Given a type that is a field to an infix data constructor, try to split
+-- off a trailing docstring on the type, and check that there are no other
+-- docstrings.
+checkInfixConstr :: LHsType GhcPs -> P (LHsType GhcPs, Maybe LHsDocString)
+checkInfixConstr ty = checkNoDocs msg ty' *> pure (ty', doc_string)
+  where (ty', doc_string) = splitDocTy ty
+        msg = text "infix constructor field"
+
 mkPatSynMatchGroup :: Located RdrName
                    -> Located (OrdList (LHsDecl GhcPs))
                    -> P (MatchGroup GhcPs (LHsExpr GhcPs))
@@ -795,8 +841,21 @@ checkContext (L l orig_t)
          where anns' = if l == lp1 then anns
                                    else (anns ++ mkParensApiAnn lp1)
 
-  check _anns _
-    = return ([],L l [L l orig_t]) -- no need for anns, returning original
+  -- no need for anns, returning original
+  check _anns t = checkNoDocs msg t *> return ([],L l [L l orig_t])
+
+  msg = text "data constructor context"
+
+-- | Check recursively if there are any 'HsDocTy's in the given type.
+-- This only works on a subset of types produced by 'btype_no_ops'
+checkNoDocs :: SDoc -> LHsType GhcPs -> P ()
+checkNoDocs msg ty = go ty
+  where
+    go (L _ (HsAppTy t1 t2)) = go t1 *> go t2
+    go (L l (HsDocTy t ds)) = parseErrorSDoc l $ hsep
+                                [ text "Unexpected haddock", quotes (ppr ds)
+                                , text "on", msg, quotes (ppr t) ]
+    go _ = pure ()
 
 -- -------------------------------------------------------------------------
 -- Checking Patterns.
index 494136d..994c76f 100644 (file)
@@ -16,7 +16,6 @@
 ((Test10255.hs:6:6-26,AnnDcolon), [Test10255.hs:6:8-9]),
 ((Test10255.hs:6:11-26,AnnCloseP), [Test10255.hs:6:26]),
 ((Test10255.hs:6:11-26,AnnOpenP), [Test10255.hs:6:11]),
-((Test10255.hs:6:12-18,AnnRarrow), [Test10255.hs:6:20-21]),
 ((Test10255.hs:6:12-25,AnnRarrow), [Test10255.hs:6:20-21]),
 ((<no location info>,AnnEofPos), [Test10255.hs:8:1])
 ]
index 7833733..399393d 100644 (file)
@@ -12,6 +12,7 @@
 ((Test10268.hs:5:6-17,AnnThIdSplice), [Test10268.hs:5:6-17]),
 ((Test10268.hs:7:1-27,AnnDcolon), [Test10268.hs:7:6-7]),
 ((Test10268.hs:7:1-27,AnnSemi), [Test10268.hs:8:1]),
+((Test10268.hs:7:9,AnnRarrow), [Test10268.hs:7:11-12]),
 ((Test10268.hs:7:9-27,AnnRarrow), [Test10268.hs:7:11-12]),
 ((Test10268.hs:7:22-25,AnnCloseS), [Test10268.hs:7:25]),
 ((Test10268.hs:7:22-25,AnnOpenS), [Test10268.hs:7:23]),
index 4676757..dcaf80d 100644 (file)
@@ -12,7 +12,9 @@
 ((Test10278.hs:4:19-61,AnnForall), [Test10278.hs:4:19-24]),
 ((Test10278.hs:4:31-61,AnnDot), [Test10278.hs:4:42]),
 ((Test10278.hs:4:31-61,AnnForall), [Test10278.hs:4:31-36]),
+((Test10278.hs:4:44-46,AnnRarrow), [Test10278.hs:4:48-49]),
 ((Test10278.hs:4:44-61,AnnRarrow), [Test10278.hs:4:48-49]),
+((Test10278.hs:4:51-54,AnnRarrow), [Test10278.hs:4:56-57]),
 ((Test10278.hs:4:51-61,AnnRarrow), [Test10278.hs:4:56-57]),
 ((Test10278.hs:5:1-26,AnnEqual), [Test10278.hs:5:16]),
 ((Test10278.hs:5:1-26,AnnFunId), [Test10278.hs:5:1-14]),
 ((Test10278.hs:7:21-24,AnnComma), [Test10278.hs:7:25]),
 ((Test10278.hs:(8,19)-(10,58),AnnCloseP), [Test10278.hs:10:58]),
 ((Test10278.hs:(8,19)-(10,58),AnnOpenP), [Test10278.hs:8:19]),
+((Test10278.hs:(8,19)-(10,58),AnnRarrow), [Test10278.hs:11:23-24]),
 ((Test10278.hs:(8,19)-(11,33),AnnRarrow), [Test10278.hs:11:23-24]),
 ((Test10278.hs:(8,20)-(10,57),AnnDot), [Test10278.hs:8:30]),
 ((Test10278.hs:(8,20)-(10,57),AnnForall), [Test10278.hs:8:20-25]),
 ((Test10278.hs:(8,32)-(10,57),AnnDot), [Test10278.hs:8:43]),
 ((Test10278.hs:(8,32)-(10,57),AnnForall), [Test10278.hs:8:32-37]),
-((Test10278.hs:9:27-50,AnnRarrow), [Test10278.hs:10:31-32]),
 ((Test10278.hs:(9,27)-(10,57),AnnRarrow), [Test10278.hs:10:31-32]),
 ((Test10278.hs:9:38-50,AnnCloseP), [Test10278.hs:9:50]),
 ((Test10278.hs:9:38-50,AnnOpenP), [Test10278.hs:9:38]),
 ((Test10278.hs:10:45-57,AnnCloseP), [Test10278.hs:10:57]),
 ((Test10278.hs:10:45-57,AnnOpenP), [Test10278.hs:10:45]),
+((Test10278.hs:11:26,AnnRarrow), [Test10278.hs:11:28-29]),
 ((Test10278.hs:11:26-33,AnnRarrow), [Test10278.hs:11:28-29]),
 ((Test10278.hs:11:31-33,AnnCloseS), [Test10278.hs:11:33]),
 ((Test10278.hs:11:31-33,AnnOpenS), [Test10278.hs:11:31]),
index c8dff60..30879b3 100644 (file)
 ((Test10312.hs:57:13-44,AnnComma), [Test10312.hs:58:11]),
 ((Test10312.hs:61:1-40,AnnDcolon), [Test10312.hs:61:8-9]),
 ((Test10312.hs:61:1-40,AnnSemi), [Test10312.hs:62:1]),
+((Test10312.hs:61:11-13,AnnRarrow), [Test10312.hs:61:15-16]),
 ((Test10312.hs:61:11-40,AnnRarrow), [Test10312.hs:61:15-16]),
 ((Test10312.hs:61:18-28,AnnCloseS), [Test10312.hs:61:28]),
 ((Test10312.hs:61:18-28,AnnOpenS), [Test10312.hs:61:18]),
+((Test10312.hs:61:18-28,AnnRarrow), [Test10312.hs:61:30-31]),
 ((Test10312.hs:61:18-40,AnnRarrow), [Test10312.hs:61:30-31]),
 ((Test10312.hs:61:33-40,AnnCloseS), [Test10312.hs:61:40]),
 ((Test10312.hs:61:33-40,AnnOpenS), [Test10312.hs:61:33]),
 ((Test10312.hs:68:19-23,AnnDarrow), [Test10312.hs:68:25-26]),
 ((Test10312.hs:68:28-35,AnnCloseP), [Test10312.hs:68:35]),
 ((Test10312.hs:68:28-35,AnnOpenP), [Test10312.hs:68:28]),
+((Test10312.hs:68:28-35,AnnRarrow), [Test10312.hs:68:37-38]),
 ((Test10312.hs:68:28-51,AnnRarrow), [Test10312.hs:68:37-38]),
-((Test10312.hs:68:29,AnnRarrow), [Test10312.hs:68:31-32]),
 ((Test10312.hs:68:29-34,AnnRarrow), [Test10312.hs:68:31-32]),
 ((Test10312.hs:68:40-42,AnnCloseS), [Test10312.hs:68:42]),
 ((Test10312.hs:68:40-42,AnnOpenS), [Test10312.hs:68:40]),
+((Test10312.hs:68:40-42,AnnRarrow), [Test10312.hs:68:44-45]),
 ((Test10312.hs:68:40-51,AnnRarrow), [Test10312.hs:68:44-45]),
 ((Test10312.hs:68:47-51,AnnCloseS), [Test10312.hs:68:51]),
 ((Test10312.hs:68:47-51,AnnOpenS), [Test10312.hs:68:47]),
 ((Test10312.hs:71:1-50,AnnSemi), [Test10312.hs:72:1]),
 ((Test10312.hs:71:19-29,AnnCloseS), [Test10312.hs:71:29]),
 ((Test10312.hs:71:19-29,AnnOpenS), [Test10312.hs:71:19]),
+((Test10312.hs:71:19-29,AnnRarrow), [Test10312.hs:71:31-32]),
 ((Test10312.hs:71:19-50,AnnRarrow), [Test10312.hs:71:31-32]),
 ((Test10312.hs:71:34-50,AnnCloseS), [Test10312.hs:71:50]),
 ((Test10312.hs:71:34-50,AnnOpenS), [Test10312.hs:71:34]),
index d9094c9..2e07948 100644 (file)
@@ -14,7 +14,9 @@
 ((Test10354.hs:4:7-15,AnnCloseP), [Test10354.hs:4:15]),
 ((Test10354.hs:4:7-15,AnnOpenP), [Test10354.hs:4:7]),
 ((Test10354.hs:4:8-11,AnnComma), [Test10354.hs:4:12]),
+((Test10354.hs:4:21,AnnRarrow), [Test10354.hs:4:23-24]),
 ((Test10354.hs:4:21-34,AnnRarrow), [Test10354.hs:4:23-24]),
+((Test10354.hs:4:26,AnnRarrow), [Test10354.hs:4:28-29]),
 ((Test10354.hs:4:26-34,AnnRarrow), [Test10354.hs:4:28-29]),
 ((Test10354.hs:5:1-14,AnnEqual), [Test10354.hs:5:7]),
 ((Test10354.hs:5:1-14,AnnFunId), [Test10354.hs:5:1]),
@@ -26,6 +28,7 @@
 ((Test10354.hs:7:8-12,AnnDarrow), [Test10354.hs:7:14-15]),
 ((Test10354.hs:7:8-12,AnnOpenP), [Test10354.hs:7:8, Test10354.hs:7:8]),
 ((Test10354.hs:7:8-12,AnnUnit), [Test10354.hs:7:8-12]),
+((Test10354.hs:7:17,AnnRarrow), [Test10354.hs:7:18-19]),
 ((Test10354.hs:7:17-24,AnnRarrow), [Test10354.hs:7:18-19]),
 ((Test10354.hs:8:1-15,AnnEqual), [Test10354.hs:8:5]),
 ((Test10354.hs:8:1-15,AnnFunId), [Test10354.hs:8:1-3]),
@@ -33,6 +36,7 @@
 ((Test10354.hs:10:1-23,AnnDcolon), [Test10354.hs:10:5-6]),
 ((Test10354.hs:10:1-23,AnnSemi), [Test10354.hs:11:1]),
 ((Test10354.hs:10:8,AnnDarrow), [Test10354.hs:10:10-11]),
+((Test10354.hs:10:13,AnnRarrow), [Test10354.hs:10:15-16]),
 ((Test10354.hs:10:13-23,AnnRarrow), [Test10354.hs:10:15-16]),
 ((Test10354.hs:11:1-15,AnnEqual), [Test10354.hs:11:5]),
 ((Test10354.hs:11:1-15,AnnFunId), [Test10354.hs:11:1-3]),
index e290be4..76c0f7c 100644 (file)
 ((Test10399.hs:16:28-43,AnnDarrow), [Test10399.hs:16:45-46]),
 ((Test10399.hs:16:28-43,AnnOpenP), [Test10399.hs:16:28, Test10399.hs:16:28]),
 ((Test10399.hs:16:30-33,AnnComma), [Test10399.hs:16:34]),
-((Test10399.hs:16:48,AnnRarrow), [Test10399.hs:16:50-51]),
 ((Test10399.hs:(16,48)-(17,68),AnnRarrow), [Test10399.hs:16:50-51]),
-((Test10399.hs:16:53-66,AnnRarrow), [Test10399.hs:17:45-46]),
 ((Test10399.hs:(16,53)-(17,68),AnnRarrow), [Test10399.hs:17:45-46]),
-((Test10399.hs:17:48,AnnRarrow), [Test10399.hs:17:50-51]),
 ((Test10399.hs:17:48-68,AnnRarrow), [Test10399.hs:17:50-51]),
 ((Test10399.hs:17:66-68,AnnCloseS), [Test10399.hs:17:68]),
 ((Test10399.hs:17:66-68,AnnOpenS), [Test10399.hs:17:66]),
index 21029da..af1ac3b 100644 (file)
@@ -11,6 +11,7 @@
 ((Test10598.hs:(7,1)-(9,10),AnnWhere), [Test10598.hs:7:11-15]),
 ((Test10598.hs:8:3-21,AnnDcolon), [Test10598.hs:8:5-6]),
 ((Test10598.hs:8:3-21,AnnSemi), [Test10598.hs:9:3]),
+((Test10598.hs:8:8-14,AnnRarrow), [Test10598.hs:8:16-17]),
 ((Test10598.hs:8:8-21,AnnRarrow), [Test10598.hs:8:16-17]),
 ((Test10598.hs:9:3-10,AnnEqual), [Test10598.hs:9:7]),
 ((Test10598.hs:9:3-10,AnnFunId), [Test10598.hs:9:3]),
index 011867e..78b7640 100644 (file)
@@ -10,6 +10,7 @@
 ((Test11018.hs:6:1-36,AnnSemi), [Test11018.hs:7:1]),
 ((Test11018.hs:6:15-36,AnnDot), [Test11018.hs:6:24]),
 ((Test11018.hs:6:15-36,AnnForall), [Test11018.hs:6:15-20]),
+((Test11018.hs:6:26,AnnRarrow), [Test11018.hs:6:28-29]),
 ((Test11018.hs:6:26-36,AnnRarrow), [Test11018.hs:6:28-29]),
 ((Test11018.hs:(7,1)-(9,10),AnnEqual), [Test11018.hs:7:14]),
 ((Test11018.hs:(7,1)-(9,10),AnnFunId), [Test11018.hs:7:1-10]),
@@ -23,7 +24,6 @@
 ((Test11018.hs:12:21-32,AnnCloseP), [Test11018.hs:12:32]),
 ((Test11018.hs:12:21-32,AnnDcolonU), [Test11018.hs:12:24]),
 ((Test11018.hs:12:21-32,AnnOpenP), [Test11018.hs:12:21]),
-((Test11018.hs:12:26,AnnRarrow), [Test11018.hs:12:28-29]),
 ((Test11018.hs:12:26-31,AnnRarrow), [Test11018.hs:12:28-29]),
 ((Test11018.hs:(13,16)-(15,7),AnnCloseC), [Test11018.hs:15:7]),
 ((Test11018.hs:(13,16)-(15,7),AnnOpenC), [Test11018.hs:13:16]),
@@ -70,6 +70,7 @@
 ((Test11018.hs:23:1-49,AnnDcolon), [Test11018.hs:23:3-4]),
 ((Test11018.hs:23:1-49,AnnSemi), [Test11018.hs:24:1]),
 ((Test11018.hs:23:6-17,AnnDarrow), [Test11018.hs:23:19-20]),
+((Test11018.hs:23:22-24,AnnRarrow), [Test11018.hs:23:26-27]),
 ((Test11018.hs:23:22-49,AnnRarrow), [Test11018.hs:23:26-27]),
 ((Test11018.hs:23:31-45,AnnCloseP), [Test11018.hs:23:45]),
 ((Test11018.hs:23:31-45,AnnOpenP), [Test11018.hs:23:31]),
@@ -87,6 +88,7 @@
 ((Test11018.hs:26:1-50,AnnDcolon), [Test11018.hs:26:4-5]),
 ((Test11018.hs:26:1-50,AnnSemi), [Test11018.hs:27:1]),
 ((Test11018.hs:26:7-18,AnnDarrow), [Test11018.hs:26:20-21]),
+((Test11018.hs:26:23-25,AnnRarrow), [Test11018.hs:26:27-28]),
 ((Test11018.hs:26:23-50,AnnRarrow), [Test11018.hs:26:27-28]),
 ((Test11018.hs:26:32-46,AnnCloseP), [Test11018.hs:26:46]),
 ((Test11018.hs:26:32-46,AnnOpenP), [Test11018.hs:26:32]),
 ((Test11018.hs:31:1-26,AnnSemi), [Test11018.hs:32:1]),
 ((Test11018.hs:31:11-26,AnnDot), [Test11018.hs:31:15]),
 ((Test11018.hs:31:11-26,AnnForallU), [Test11018.hs:31:11]),
+((Test11018.hs:31:17,AnnRarrowU), [Test11018.hs:31:19]),
 ((Test11018.hs:31:17-26,AnnRarrowU), [Test11018.hs:31:19]),
 ((Test11018.hs:(32,1)-(34,10),AnnEqual), [Test11018.hs:32:11]),
 ((Test11018.hs:(32,1)-(34,10),AnnFunId), [Test11018.hs:32:1-7]),
 ((Test11018.hs:37:22-32,AnnCloseP), [Test11018.hs:37:32]),
 ((Test11018.hs:37:22-32,AnnDcolonU), [Test11018.hs:37:25]),
 ((Test11018.hs:37:22-32,AnnOpenP), [Test11018.hs:37:22]),
-((Test11018.hs:37:27,AnnRarrowU), [Test11018.hs:37:29]),
 ((Test11018.hs:37:27-31,AnnRarrowU), [Test11018.hs:37:29]),
 ((Test11018.hs:(38,17)-(40,7),AnnCloseC), [Test11018.hs:40:7]),
 ((Test11018.hs:(38,17)-(40,7),AnnOpenC), [Test11018.hs:38:17]),
 ((Test11018.hs:48:1-49,AnnDcolon), [Test11018.hs:48:4-5]),
 ((Test11018.hs:48:1-49,AnnSemi), [Test11018.hs:49:1]),
 ((Test11018.hs:48:7-18,AnnDarrowU), [Test11018.hs:48:20]),
+((Test11018.hs:48:22-24,AnnRarrow), [Test11018.hs:48:26-27]),
 ((Test11018.hs:48:22-49,AnnRarrow), [Test11018.hs:48:26-27]),
 ((Test11018.hs:48:31-45,AnnCloseP), [Test11018.hs:48:45]),
 ((Test11018.hs:48:31-45,AnnOpenP), [Test11018.hs:48:31]),
 ((Test11018.hs:51:1-50,AnnDcolon), [Test11018.hs:51:5-6]),
 ((Test11018.hs:51:1-50,AnnSemi), [Test11018.hs:52:1]),
 ((Test11018.hs:51:8-19,AnnDarrowU), [Test11018.hs:51:21]),
+((Test11018.hs:51:23-25,AnnRarrow), [Test11018.hs:51:27-28]),
 ((Test11018.hs:51:23-50,AnnRarrow), [Test11018.hs:51:27-28]),
 ((Test11018.hs:51:32-46,AnnCloseP), [Test11018.hs:51:46]),
 ((Test11018.hs:51:32-46,AnnOpenP), [Test11018.hs:51:32]),
index 3f61650..7e642de 100644 (file)
@@ -26,6 +26,7 @@
 ((Test12417.hs:12:16-31,AnnDarrow), [Test12417.hs:12:33-34]),
 ((Test12417.hs:12:16-31,AnnOpenP), [Test12417.hs:12:16, Test12417.hs:12:16]),
 ((Test12417.hs:12:17-22,AnnComma), [Test12417.hs:12:23]),
+((Test12417.hs:12:36-46,AnnRarrow), [Test12417.hs:12:48-49]),
 ((Test12417.hs:12:36-56,AnnRarrow), [Test12417.hs:12:48-49]),
 ((Test12417.hs:13:1-48,AnnEqual), [Test12417.hs:13:27]),
 ((Test12417.hs:13:1-48,AnnFunId), [Test12417.hs:13:1-11]),
@@ -54,6 +55,7 @@
 ((Test12417.hs:16:60-63,AnnVbar), [Test12417.hs:16:65]),
 ((Test12417.hs:18:1-26,AnnDcolon), [Test12417.hs:18:13-14]),
 ((Test12417.hs:18:1-26,AnnSemi), [Test12417.hs:19:1]),
+((Test12417.hs:18:16,AnnRarrow), [Test12417.hs:18:18-19]),
 ((Test12417.hs:18:16-26,AnnRarrow), [Test12417.hs:18:18-19]),
 ((Test12417.hs:19:1-52,AnnEqual), [Test12417.hs:19:33]),
 ((Test12417.hs:19:1-52,AnnFunId), [Test12417.hs:19:1-11]),
index c3caae1..d816f04 100644 (file)
 ((TestBoolFormula.hs:(3,1)-(19,9),AnnWhere), [TestBoolFormula.hs:3:17-21]),
 ((TestBoolFormula.hs:4:5-25,AnnDcolon), [TestBoolFormula.hs:4:9-10]),
 ((TestBoolFormula.hs:4:5-25,AnnSemi), [TestBoolFormula.hs:5:5]),
+((TestBoolFormula.hs:4:12,AnnRarrow), [TestBoolFormula.hs:4:14-15]),
 ((TestBoolFormula.hs:4:12-25,AnnRarrow), [TestBoolFormula.hs:4:14-15]),
+((TestBoolFormula.hs:4:17,AnnRarrow), [TestBoolFormula.hs:4:19-20]),
 ((TestBoolFormula.hs:4:17-25,AnnRarrow), [TestBoolFormula.hs:4:19-20]),
 ((TestBoolFormula.hs:5:5-19,AnnEqual), [TestBoolFormula.hs:5:9]),
 ((TestBoolFormula.hs:5:5-19,AnnFunId), [TestBoolFormula.hs:5:5-7]),
 ((TestBoolFormula.hs:5:5-19,AnnSemi), [TestBoolFormula.hs:6:5]),
 ((TestBoolFormula.hs:6:5-25,AnnDcolon), [TestBoolFormula.hs:6:9-10]),
 ((TestBoolFormula.hs:6:5-25,AnnSemi), [TestBoolFormula.hs:7:5]),
+((TestBoolFormula.hs:6:12,AnnRarrow), [TestBoolFormula.hs:6:14-15]),
 ((TestBoolFormula.hs:6:12-25,AnnRarrow), [TestBoolFormula.hs:6:14-15]),
+((TestBoolFormula.hs:6:17,AnnRarrow), [TestBoolFormula.hs:6:19-20]),
 ((TestBoolFormula.hs:6:17-25,AnnRarrow), [TestBoolFormula.hs:6:19-20]),
 ((TestBoolFormula.hs:7:5-19,AnnEqual), [TestBoolFormula.hs:7:9]),
 ((TestBoolFormula.hs:7:5-19,AnnFunId), [TestBoolFormula.hs:7:5-7]),
 ((TestBoolFormula.hs:7:5-19,AnnSemi), [TestBoolFormula.hs:8:5]),
 ((TestBoolFormula.hs:8:5-25,AnnDcolon), [TestBoolFormula.hs:8:9-10]),
 ((TestBoolFormula.hs:8:5-25,AnnSemi), [TestBoolFormula.hs:9:5]),
+((TestBoolFormula.hs:8:12,AnnRarrow), [TestBoolFormula.hs:8:14-15]),
 ((TestBoolFormula.hs:8:12-25,AnnRarrow), [TestBoolFormula.hs:8:14-15]),
+((TestBoolFormula.hs:8:17,AnnRarrow), [TestBoolFormula.hs:8:19-20]),
 ((TestBoolFormula.hs:8:17-25,AnnRarrow), [TestBoolFormula.hs:8:19-20]),
 ((TestBoolFormula.hs:9:5-19,AnnEqual), [TestBoolFormula.hs:9:9]),
 ((TestBoolFormula.hs:9:5-19,AnnFunId), [TestBoolFormula.hs:9:5-7]),
 ((TestBoolFormula.hs:9:5-19,AnnSemi), [TestBoolFormula.hs:10:5]),
 ((TestBoolFormula.hs:10:5-25,AnnDcolon), [TestBoolFormula.hs:10:9-10]),
 ((TestBoolFormula.hs:10:5-25,AnnSemi), [TestBoolFormula.hs:11:5]),
+((TestBoolFormula.hs:10:12,AnnRarrow), [TestBoolFormula.hs:10:14-15]),
 ((TestBoolFormula.hs:10:12-25,AnnRarrow), [TestBoolFormula.hs:10:14-15]),
+((TestBoolFormula.hs:10:17,AnnRarrow), [TestBoolFormula.hs:10:19-20]),
 ((TestBoolFormula.hs:10:17-25,AnnRarrow), [TestBoolFormula.hs:10:19-20]),
 ((TestBoolFormula.hs:11:5-19,AnnEqual), [TestBoolFormula.hs:11:9]),
 ((TestBoolFormula.hs:11:5-19,AnnFunId), [TestBoolFormula.hs:11:5-7]),
 ((TestBoolFormula.hs:11:5-19,AnnSemi), [TestBoolFormula.hs:12:5]),
 ((TestBoolFormula.hs:12:5-25,AnnDcolon), [TestBoolFormula.hs:12:9-10]),
 ((TestBoolFormula.hs:12:5-25,AnnSemi), [TestBoolFormula.hs:13:5]),
+((TestBoolFormula.hs:12:12,AnnRarrow), [TestBoolFormula.hs:12:14-15]),
 ((TestBoolFormula.hs:12:12-25,AnnRarrow), [TestBoolFormula.hs:12:14-15]),
+((TestBoolFormula.hs:12:17,AnnRarrow), [TestBoolFormula.hs:12:19-20]),
 ((TestBoolFormula.hs:12:17-25,AnnRarrow), [TestBoolFormula.hs:12:19-20]),
 ((TestBoolFormula.hs:13:5-19,AnnEqual), [TestBoolFormula.hs:13:9]),
 ((TestBoolFormula.hs:13:5-19,AnnFunId), [TestBoolFormula.hs:13:5-7]),
 ((TestBoolFormula.hs:13:5-19,AnnSemi), [TestBoolFormula.hs:14:5]),
 ((TestBoolFormula.hs:14:5-25,AnnDcolon), [TestBoolFormula.hs:14:9-10]),
 ((TestBoolFormula.hs:14:5-25,AnnSemi), [TestBoolFormula.hs:15:5]),
+((TestBoolFormula.hs:14:12,AnnRarrow), [TestBoolFormula.hs:14:14-15]),
 ((TestBoolFormula.hs:14:12-25,AnnRarrow), [TestBoolFormula.hs:14:14-15]),
+((TestBoolFormula.hs:14:17,AnnRarrow), [TestBoolFormula.hs:14:19-20]),
 ((TestBoolFormula.hs:14:17-25,AnnRarrow), [TestBoolFormula.hs:14:19-20]),
 ((TestBoolFormula.hs:15:5-19,AnnEqual), [TestBoolFormula.hs:15:9]),
 ((TestBoolFormula.hs:15:5-19,AnnFunId), [TestBoolFormula.hs:15:5-7]),
 ((TestBoolFormula.hs:(21,1)-(30,47),AnnWhere), [TestBoolFormula.hs:21:13-17]),
 ((TestBoolFormula.hs:22:5-25,AnnDcolon), [TestBoolFormula.hs:22:9-10]),
 ((TestBoolFormula.hs:22:5-25,AnnSemi), [TestBoolFormula.hs:23:5]),
+((TestBoolFormula.hs:22:12,AnnRarrow), [TestBoolFormula.hs:22:14-15]),
 ((TestBoolFormula.hs:22:12-25,AnnRarrow), [TestBoolFormula.hs:22:14-15]),
+((TestBoolFormula.hs:22:17,AnnRarrow), [TestBoolFormula.hs:22:19-20]),
 ((TestBoolFormula.hs:22:17-25,AnnRarrow), [TestBoolFormula.hs:22:19-20]),
 ((TestBoolFormula.hs:23:5-25,AnnDcolon), [TestBoolFormula.hs:23:9-10]),
 ((TestBoolFormula.hs:23:5-25,AnnSemi), [TestBoolFormula.hs:24:5]),
+((TestBoolFormula.hs:23:12,AnnRarrow), [TestBoolFormula.hs:23:14-15]),
 ((TestBoolFormula.hs:23:12-25,AnnRarrow), [TestBoolFormula.hs:23:14-15]),
+((TestBoolFormula.hs:23:17,AnnRarrow), [TestBoolFormula.hs:23:19-20]),
 ((TestBoolFormula.hs:23:17-25,AnnRarrow), [TestBoolFormula.hs:23:19-20]),
 ((TestBoolFormula.hs:24:5-25,AnnDcolon), [TestBoolFormula.hs:24:9-10]),
 ((TestBoolFormula.hs:24:5-25,AnnSemi), [TestBoolFormula.hs:25:5]),
+((TestBoolFormula.hs:24:12,AnnRarrow), [TestBoolFormula.hs:24:14-15]),
 ((TestBoolFormula.hs:24:12-25,AnnRarrow), [TestBoolFormula.hs:24:14-15]),
+((TestBoolFormula.hs:24:17,AnnRarrow), [TestBoolFormula.hs:24:19-20]),
 ((TestBoolFormula.hs:24:17-25,AnnRarrow), [TestBoolFormula.hs:24:19-20]),
 ((TestBoolFormula.hs:25:5-19,AnnEqual), [TestBoolFormula.hs:25:9]),
 ((TestBoolFormula.hs:25:5-19,AnnFunId), [TestBoolFormula.hs:25:5-7]),
 ((TestBoolFormula.hs:25:5-19,AnnSemi), [TestBoolFormula.hs:26:5]),
 ((TestBoolFormula.hs:26:5-25,AnnDcolon), [TestBoolFormula.hs:26:9-10]),
 ((TestBoolFormula.hs:26:5-25,AnnSemi), [TestBoolFormula.hs:27:5]),
+((TestBoolFormula.hs:26:12,AnnRarrow), [TestBoolFormula.hs:26:14-15]),
 ((TestBoolFormula.hs:26:12-25,AnnRarrow), [TestBoolFormula.hs:26:14-15]),
+((TestBoolFormula.hs:26:17,AnnRarrow), [TestBoolFormula.hs:26:19-20]),
 ((TestBoolFormula.hs:26:17-25,AnnRarrow), [TestBoolFormula.hs:26:19-20]),
 ((TestBoolFormula.hs:27:5-19,AnnEqual), [TestBoolFormula.hs:27:9]),
 ((TestBoolFormula.hs:27:5-19,AnnFunId), [TestBoolFormula.hs:27:5-7]),
 ((TestBoolFormula.hs:27:5-19,AnnSemi), [TestBoolFormula.hs:28:5]),
 ((TestBoolFormula.hs:28:5-26,AnnDcolon), [TestBoolFormula.hs:28:10-11]),
 ((TestBoolFormula.hs:28:5-26,AnnSemi), [TestBoolFormula.hs:29:5]),
+((TestBoolFormula.hs:28:13,AnnRarrow), [TestBoolFormula.hs:28:15-16]),
 ((TestBoolFormula.hs:28:13-26,AnnRarrow), [TestBoolFormula.hs:28:15-16]),
+((TestBoolFormula.hs:28:18,AnnRarrow), [TestBoolFormula.hs:28:20-21]),
 ((TestBoolFormula.hs:28:18-26,AnnRarrow), [TestBoolFormula.hs:28:20-21]),
 ((TestBoolFormula.hs:29:5-20,AnnEqual), [TestBoolFormula.hs:29:10]),
 ((TestBoolFormula.hs:29:5-20,AnnFunId), [TestBoolFormula.hs:29:5-8]),
index 2cdef95..3c7a5af 100644 (file)
@@ -64,7 +64,6 @@
 ((AnnotationTuple.hs:18:1-28,AnnDcolon), [AnnotationTuple.hs:18:20-21]),
 ((AnnotationTuple.hs:18:1-28,AnnFamily), [AnnotationTuple.hs:18:6-11]),
 ((AnnotationTuple.hs:18:1-28,AnnSemi), [AnnotationTuple.hs:19:1]),
-((AnnotationTuple.hs:18:23,AnnRarrow), [AnnotationTuple.hs:18:25-26]),
 ((AnnotationTuple.hs:18:23-28,AnnRarrow), [AnnotationTuple.hs:18:25-26]),
 ((AnnotationTuple.hs:(20,1)-(24,14),AnnFunId), [AnnotationTuple.hs:20:1-5]),
 ((AnnotationTuple.hs:(20,1)-(24,14),AnnSemi), [AnnotationTuple.hs:25:1]),
index 3965257..7b92474 100644 (file)
 
 (AK ListComprehensions.hs:24:11-15 AnnOpenS = [ListComprehensions.hs:24:11])
 
+(AK ListComprehensions.hs:24:11-15 AnnRarrow = [ListComprehensions.hs:24:17-18])
+
 (AK ListComprehensions.hs:24:11-27 AnnRarrow = [ListComprehensions.hs:24:17-18])
 
 (AK ListComprehensions.hs:24:20-27 AnnCloseS = [ListComprehensions.hs:24:27])
index 092ba97..e229ba6 100644 (file)
 
 (AK AnnotationTuple.hs:18:1-28 AnnSemi = [AnnotationTuple.hs:19:1])
 
-(AK AnnotationTuple.hs:18:23 AnnRarrow = [AnnotationTuple.hs:18:25-26])
-
 (AK AnnotationTuple.hs:18:23-28 AnnRarrow = [AnnotationTuple.hs:18:25-26])
 
 (AK AnnotationTuple.hs:(20,1)-(24,14) AnnFunId = [AnnotationTuple.hs:20:1-5])
index 7db4379..90d4a55 100644 (file)
@@ -39,6 +39,9 @@ test('haddockA029', normal, compile, ['-haddock -ddump-parsed'])
 test('haddockA030', normal, compile, ['-haddock -ddump-parsed'])
 test('haddockA031', normal, compile, ['-haddock -ddump-parsed -XExistentialQuantification'])
 test('haddockA032', normal, compile, ['-haddock -ddump-parsed'])
+test('haddockA035', normal, compile, ['-haddock -ddump-parsed'])
+test('haddockA036', normal, compile, ['-haddock -ddump-parsed'])
+test('haddockA037', normal, compile, ['-haddock -ddump-parsed'])
 
 # The tests below this line are not duplicated in
 # should_compile_noflag_haddock.
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA035.hs b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA035.hs
new file mode 100644 (file)
index 0000000..25ed2ac
--- /dev/null
@@ -0,0 +1,9 @@
+{-# LANGUAGE GADTs #-}
+
+module Hi where
+
+data Hi where
+    Hi :: () -- ^ This is a comment on the '()' field of 'Hi'
+       -> Int
+       -> String -- ^ This is a comment on the 'String' field of 'Hi'
+       -> Hi -- ^ This is a comment on the return type of 'Hi'
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA035.stderr b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA035.stderr
new file mode 100644 (file)
index 0000000..d0e5bbc
--- /dev/null
@@ -0,0 +1,9 @@
+
+==================== Parser ====================
+module Hi where
+data Hi
+  where
+      Hi :: ()  This is a comment on the '()' field of 'Hi'
+            -> Int
+               -> String  This is a comment on the 'String' field of 'Hi'
+                  -> Hi  This is a comment on the return type of 'Hi'
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA036.hs b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA036.hs
new file mode 100644 (file)
index 0000000..02dd1f9
--- /dev/null
@@ -0,0 +1,19 @@
+module ConstructorFields where
+
+data Foo
+  = Bar Int String  -- ^ doc on `Bar` constructor
+
+  | Baz             -- ^ doc on the `Baz` constructor
+      Int           -- ^ doc on the `Int` field of `Baz`
+      String        -- ^ doc on the `String` field of `Baz`
+
+  | Int :+ String   -- ^ doc on the `:+` constructor
+
+  | Int             -- ^ doc on the `Int` field of the `:*` constructor
+      :*            -- ^ doc on the `:*` constructor
+    String          -- ^ doc on the `String` field of the `:*` constructor
+
+  | Boo { x :: () } -- ^ doc on the `Boo` record constructor
+
+  | Boa             -- ^ doc on the `Boa` record constructor
+      { y :: () }
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA036.stderr b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA036.stderr
new file mode 100644 (file)
index 0000000..0d884ab
--- /dev/null
@@ -0,0 +1,12 @@
+
+==================== Parser ====================
+module ConstructorFields where
+data Foo
+  =  doc on `Bar` constructor Bar Int String |
+     doc on the `Baz` constructor
+    Baz Int  doc on the `Int` field of `Baz` String  doc on the `String` field of `Baz` |
+     doc on the `:+` constructor Int :+ String |
+     doc on the `:*` constructor
+    Int  doc on the `Int` field of the `:*` constructor :* String  doc on the `String` field of the `:*` constructor |
+     doc on the `Boo` record constructor Boo {x :: ()} |
+     doc on the `Boa` record constructor Boa {y :: ()}
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA037.hs b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA037.hs
new file mode 100644 (file)
index 0000000..4571e09
--- /dev/null
@@ -0,0 +1,10 @@
+module UnamedConstructorFields where
+
+data A = A
+data B = B
+data C = C
+
+-- Haddock on 'A' prevents the haddock on 'C' from being applied to 'MkFoo'
+data Foo = MkFoo A -- ^ 'A' has a comment
+                 B -- This doesn't
+                 C -- ^ 'C' has a comment
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA037.stderr b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA037.stderr
new file mode 100644 (file)
index 0000000..8e90efa
--- /dev/null
@@ -0,0 +1,7 @@
+
+==================== Parser ====================
+module UnamedConstructorFields where
+data A = A
+data B = B
+data C = C
+data Foo = MkFoo A  'A' has a comment B C  'C' has a comment
index c0d62ae..edb2bd0 100644 (file)
@@ -39,6 +39,9 @@ test('haddockC029', normal, compile, [''])
 test('haddockC030', normal, compile, [''])
 test('haddockC031', normal, compile, ['-XExistentialQuantification'])
 test('haddockC032', normal, compile, [''])
+test('haddockC035', normal, compile, [''])
+test('haddockC036', normal, compile, [''])
+test('haddockC037', normal, compile, [''])
 
 # The tests below this line are not duplicated in
 # should_compile_flag_haddock.
diff --git a/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC035.hs b/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC035.hs
new file mode 100644 (file)
index 0000000..25ed2ac
--- /dev/null
@@ -0,0 +1,9 @@
+{-# LANGUAGE GADTs #-}
+
+module Hi where
+
+data Hi where
+    Hi :: () -- ^ This is a comment on the '()' field of 'Hi'
+       -> Int
+       -> String -- ^ This is a comment on the 'String' field of 'Hi'
+       -> Hi -- ^ This is a comment on the return type of 'Hi'
diff --git a/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC036.hs b/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC036.hs
new file mode 100644 (file)
index 0000000..02dd1f9
--- /dev/null
@@ -0,0 +1,19 @@
+module ConstructorFields where
+
+data Foo
+  = Bar Int String  -- ^ doc on `Bar` constructor
+
+  | Baz             -- ^ doc on the `Baz` constructor
+      Int           -- ^ doc on the `Int` field of `Baz`
+      String        -- ^ doc on the `String` field of `Baz`
+
+  | Int :+ String   -- ^ doc on the `:+` constructor
+
+  | Int             -- ^ doc on the `Int` field of the `:*` constructor
+      :*            -- ^ doc on the `:*` constructor
+    String          -- ^ doc on the `String` field of the `:*` constructor
+
+  | Boo { x :: () } -- ^ doc on the `Boo` record constructor
+
+  | Boa             -- ^ doc on the `Boa` record constructor
+      { y :: () }
diff --git a/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC037.hs b/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC037.hs
new file mode 100644 (file)
index 0000000..4571e09
--- /dev/null
@@ -0,0 +1,10 @@
+module UnamedConstructorFields where
+
+data A = A
+data B = B
+data C = C
+
+-- Haddock on 'A' prevents the haddock on 'C' from being applied to 'MkFoo'
+data Foo = MkFoo A -- ^ 'A' has a comment
+                 B -- This doesn't
+                 C -- ^ 'C' has a comment