[Git][ghc/ghc][master] Haddock comments on infix constructors (#24221)

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Thu Feb 8 05:37:23 UTC 2024



Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC


Commits:
e8fb2451 by Vladislav Zavialov at 2024-02-08T00:36:36-05:00
Haddock comments on infix constructors (#24221)

Rewrite the `HasHaddock` instance for `ConDecl GhcPs` to account for
infix constructors.

This change fixes a Haddock regression (introduced in 19e80b9af252)
that affected leading comments on infix data constructor declarations:

	-- | Docs for infix constructor
	| Int :* Bool

The comment should be associated with the data constructor (:*), not
with its left-hand side Int.

- - - - -


5 changed files:

- compiler/GHC/Parser/PostProcess/Haddock.hs
- compiler/GHC/Utils/Misc.hs
- + testsuite/tests/haddock/should_compile_flag_haddock/T24221.hs
- + testsuite/tests/haddock/should_compile_flag_haddock/T24221.stderr
- testsuite/tests/haddock/should_compile_flag_haddock/all.T


Changes:

=====================================
compiler/GHC/Parser/PostProcess/Haddock.hs
=====================================
@@ -53,27 +53,23 @@ import GHC.Prelude hiding (head, init, last, mod, tail)
 import GHC.Hs
 
 import GHC.Types.SrcLoc
-import GHC.Utils.Panic
 import GHC.Data.Bag
 
 import Data.Semigroup
 import Data.Foldable
 import Data.Traversable
-import Data.Maybe
-import Data.List.NonEmpty (nonEmpty)
 import qualified Data.List.NonEmpty as NE
+import Control.Applicative
 import Control.Monad
 import Control.Monad.Trans.State.Strict
 import Control.Monad.Trans.Reader
-import Control.Monad.Trans.Writer
 import Data.Functor.Identity
-import qualified Data.Monoid
 
 import {-# SOURCE #-} GHC.Parser (parseIdentifier)
 import GHC.Parser.Lexer
 import GHC.Parser.HaddockLex
 import GHC.Parser.Errors.Types
-import GHC.Utils.Misc (mergeListsBy, filterOut, mapLastM, (<&&>))
+import GHC.Utils.Misc (mergeListsBy, filterOut, (<&&>))
 import qualified GHC.Data.Strict as Strict
 
 {- Note [Adding Haddock comments to the syntax tree]
@@ -699,14 +695,12 @@ instance HasHaddock (LocatedA (ConDecl GhcPs)) where
     extendHdkA (locA l_con_decl) $
     case con_decl of
       ConDeclGADT { con_g_ext, con_names, con_bndrs, con_mb_cxt, con_g_args, con_res_ty } -> do
-        -- discardHasInnerDocs is ok because we don't need this info for GADTs.
-        con_doc' <- discardHasInnerDocs $ getConDoc (getLocA (NE.head con_names))
+        con_doc' <- getConDoc (getLocA (NE.head con_names))
         con_g_args' <-
           case con_g_args of
             PrefixConGADT x ts -> PrefixConGADT x <$> addHaddock ts
             RecConGADT arr (L l_rec flds) -> do
-              -- discardHasInnerDocs is ok because we don't need this info for GADTs.
-              flds' <- traverse (discardHasInnerDocs . addHaddockConDeclField) flds
+              flds' <- traverse addHaddockConDeclField flds
               pure $ RecConGADT arr (L l_rec flds')
         con_res_ty' <- addHaddock con_res_ty
         pure $ L l_con_decl $
@@ -715,185 +709,99 @@ instance HasHaddock (LocatedA (ConDecl GhcPs)) where
                         con_g_args = con_g_args',
                         con_res_ty = con_res_ty' }
       ConDeclH98 { con_ext, con_name, con_forall, con_ex_tvs, con_mb_cxt, con_args } ->
-        addConTrailingDoc (srcSpanEnd $ locA l_con_decl) $
-        case con_args of
-          PrefixCon _ ts -> do
-            con_doc' <- getConDoc (getLocA con_name)
-            ts' <- traverse addHaddockConDeclFieldTy ts
-            pure $ L l_con_decl $
-              ConDeclH98 { con_ext, con_name, con_forall, con_ex_tvs, con_mb_cxt,
-                           con_doc = lexLHsDocString <$> con_doc',
-                           con_args = PrefixCon noTypeArgs ts' }
-          InfixCon t1 t2 -> do
-            t1' <- addHaddockConDeclFieldTy t1
-            con_doc' <- getConDoc (getLocA con_name)
-            t2' <- addHaddockConDeclFieldTy t2
-            pure $ L l_con_decl $
-              ConDeclH98 { con_ext, con_name, con_forall, con_ex_tvs, con_mb_cxt,
-                           con_doc = lexLHsDocString <$> con_doc',
-                           con_args = InfixCon t1' t2' }
-          RecCon (L l_rec flds) -> do
-            con_doc' <- getConDoc (getLocA con_name)
-            flds' <- traverse addHaddockConDeclField flds
-            pure $ L l_con_decl $
-              ConDeclH98 { con_ext, con_name, con_forall, con_ex_tvs, con_mb_cxt,
-                           con_doc = lexLHsDocString <$> con_doc',
-                           con_args = RecCon (L l_rec flds') }
-
--- Keep track of documentation comments on the data constructor or any of its
--- fields.
---
--- See Note [Trailing comment on constructor declaration]
-type ConHdkA = WriterT HasInnerDocs HdkA
-
--- Does the data constructor declaration have any inner (non-trailing)
--- documentation comments?
---
--- Example when HasInnerDocs is True:
---
---   data X =
---      MkX       -- ^ inner comment
---        Field1  -- ^ inner comment
---        Field2  -- ^ inner comment
---        Field3  -- ^ trailing comment
---
--- Example when HasInnerDocs is False:
---
---   data Y = MkY Field1 Field2 Field3  -- ^ trailing comment
---
--- See Note [Trailing comment on constructor declaration]
-newtype HasInnerDocs = HasInnerDocs Bool
-  deriving (Semigroup, Monoid) via Data.Monoid.Any
-
--- Run ConHdkA by discarding the HasInnerDocs info when we have no use for it.
---
--- We only do this when processing data declarations that use GADT syntax,
--- because only the H98 syntax declarations have special treatment for the
--- trailing documentation comment.
---
--- See Note [Trailing comment on constructor declaration]
-discardHasInnerDocs :: ConHdkA a -> HdkA a
-discardHasInnerDocs = fmap fst . runWriterT
+        let
+          -- See Note [Leading and trailing comments on H98 constructors]
+          getTrailingLeading :: HdkM (LocatedA (ConDecl GhcPs))
+          getTrailingLeading = do
+            con_doc' <- getPrevNextDoc (locA l_con_decl)
+            return $ L l_con_decl $
+              ConDeclH98 { con_ext, con_name, con_forall, con_ex_tvs, con_mb_cxt, con_args
+                         , con_doc = lexLHsDocString <$> con_doc' }
+
+          -- See Note [Leading and trailing comments on H98 constructors]
+          getMixed :: HdkA (LocatedA (ConDecl GhcPs))
+          getMixed =
+            case con_args of
+              PrefixCon _ ts -> do
+                con_doc' <- getConDoc (getLocA con_name)
+                ts' <- traverse addHaddockConDeclFieldTy ts
+                pure $ L l_con_decl $
+                  ConDeclH98 { con_ext, con_name, con_forall, con_ex_tvs, con_mb_cxt,
+                               con_doc = lexLHsDocString <$> con_doc',
+                               con_args = PrefixCon noTypeArgs ts' }
+              InfixCon t1 t2 -> do
+                t1' <- addHaddockConDeclFieldTy t1
+                con_doc' <- getConDoc (getLocA con_name)
+                t2' <- addHaddockConDeclFieldTy t2
+                pure $ L l_con_decl $
+                  ConDeclH98 { con_ext, con_name, con_forall, con_ex_tvs, con_mb_cxt,
+                               con_doc = lexLHsDocString <$> con_doc',
+                               con_args = InfixCon t1' t2' }
+              RecCon (L l_rec flds) -> do
+                con_doc' <- getConDoc (getLocA con_name)
+                flds' <- traverse addHaddockConDeclField flds
+                pure $ L l_con_decl $
+                  ConDeclH98 { con_ext, con_name, con_forall, con_ex_tvs, con_mb_cxt,
+                               con_doc = lexLHsDocString <$> con_doc',
+                               con_args = RecCon (L l_rec flds') }
+        in
+          hoistHdkA
+            (\m -> do { a <- onlyTrailingOrLeading (locA l_con_decl)
+                      ; if a then getTrailingLeading else m })
+            getMixed
+
+-- See Note [Leading and trailing comments on H98 constructors]
+onlyTrailingOrLeading :: SrcSpan -> HdkM Bool
+onlyTrailingOrLeading l = peekHdkM $ do
+  leading <-
+    inLocRange (locRangeTo (getBufPos (srcSpanStart l))) $
+    takeHdkComments mkDocNext
+  inner <-
+    inLocRange (locRangeIn (getBufSpan l)) $
+    takeHdkComments (\x -> mkDocNext x <|> mkDocPrev x)
+  trailing <-
+    inLocRange (locRangeFrom (getBufPos (srcSpanEnd l))) $
+    takeHdkComments mkDocPrev
+  return $ case (leading, inner, trailing) of
+    (_:_, [], []) -> True  -- leading comment only
+    ([], [], _:_) -> True  -- trailing comment only
+    _             -> False
 
 -- Get the documentation comment associated with the data constructor in a
 -- data/newtype declaration.
 getConDoc
   :: SrcSpan  -- Location of the data constructor
-  -> ConHdkA (Maybe (Located HsDocString))
-getConDoc l =
-  WriterT $ extendHdkA l $ liftHdkA $ do
-    mDoc <- getPrevNextDoc l
-    return (mDoc, HasInnerDocs (isJust mDoc))
+  -> HdkA (Maybe (Located HsDocString))
+getConDoc l = extendHdkA l $ liftHdkA $ getPrevNextDoc l
 
 -- Add documentation comment to a data constructor field.
 -- Used for PrefixCon and InfixCon.
 addHaddockConDeclFieldTy
   :: HsScaled GhcPs (LHsType GhcPs)
-  -> ConHdkA (HsScaled GhcPs (LHsType GhcPs))
+  -> HdkA (HsScaled GhcPs (LHsType GhcPs))
 addHaddockConDeclFieldTy (HsScaled mult (L l t)) =
-  WriterT $ extendHdkA (locA l) $ liftHdkA $ do
+  extendHdkA (locA l) $ liftHdkA $ do
     mDoc <- getPrevNextDoc (locA l)
-    return (HsScaled mult (mkLHsDocTy (L l t) mDoc),
-            HasInnerDocs (isJust mDoc))
+    return (HsScaled mult (mkLHsDocTy (L l t) mDoc))
 
 -- Add documentation comment to a data constructor field.
 -- Used for RecCon.
 addHaddockConDeclField
   :: LConDeclField GhcPs
-  -> ConHdkA (LConDeclField GhcPs)
+  -> HdkA (LConDeclField GhcPs)
 addHaddockConDeclField (L l_fld fld) =
-  WriterT $ extendHdkA (locA l_fld) $ liftHdkA $ do
+  extendHdkA (locA l_fld) $ liftHdkA $ do
     cd_fld_doc <- fmap lexLHsDocString <$> getPrevNextDoc (locA l_fld)
-    return (L l_fld (fld { cd_fld_doc }),
-            HasInnerDocs (isJust cd_fld_doc))
-
--- 1. Process a H98-syntax data constructor declaration in a context with no
---    access to the trailing documentation comment (by running the provided
---    ConHdkA computation).
---
--- 2. Then grab the trailing comment (if it exists) and attach it where
---    appropriate: either to the data constructor itself or to its last field,
---    depending on HasInnerDocs.
---
--- See Note [Trailing comment on constructor declaration]
-addConTrailingDoc
-  :: SrcLoc  -- The end of a data constructor declaration.
-             -- Any docprev comment past this point is considered trailing.
-  -> ConHdkA (LConDecl GhcPs)
-  -> HdkA (LConDecl GhcPs)
-addConTrailingDoc l_sep =
-    hoistHdkA add_trailing_doc . runWriterT
-  where
-    add_trailing_doc
-      :: HdkM (LConDecl GhcPs, HasInnerDocs)
-      -> HdkM (LConDecl GhcPs)
-    add_trailing_doc m = do
-      (L l con_decl, HasInnerDocs has_inner_docs) <-
-        inLocRange (locRangeTo (getBufPos l_sep)) m
-          -- inLocRange delimits the context so that the inner computation
-          -- will not consume the trailing documentation comment.
-      case con_decl of
-        ConDeclH98{} -> do
-          trailingDocs <-
-            inLocRange (locRangeFrom (getBufPos l_sep)) $
-            takeHdkComments mkDocPrev
-          if null trailingDocs
-          then return (L l con_decl)
-          else do
-            if has_inner_docs then do
-              let mk_doc_ty ::       HsScaled GhcPs (LHsType GhcPs)
-                            -> HdkM (HsScaled GhcPs (LHsType GhcPs))
-                  mk_doc_ty x@(HsScaled _ (L _ HsDocTy{})) =
-                    -- Happens in the following case:
-                    --
-                    --    data T =
-                    --      MkT
-                    --        -- | Comment on SomeField
-                    --        SomeField
-                    --        -- ^ Another comment on SomeField? (rejected)
-                    --
-                    -- See tests/.../haddockExtraDocs.hs
-                    x <$ reportExtraDocs trailingDocs
-                  mk_doc_ty (HsScaled mult (L l' t)) = do
-                    doc <- selectDocString trailingDocs
-                    return $ HsScaled mult (mkLHsDocTy (L l' t) doc)
-              let mk_doc_fld ::       LConDeclField GhcPs
-                             -> HdkM (LConDeclField GhcPs)
-                  mk_doc_fld x@(L _ (ConDeclField { cd_fld_doc = Just _ })) =
-                    -- Happens in the following case:
-                    --
-                    --    data T =
-                    --      MkT {
-                    --        -- | Comment on SomeField
-                    --        someField :: SomeField
-                    --      } -- ^ Another comment on SomeField? (rejected)
-                    --
-                    -- See tests/.../haddockExtraDocs.hs
-                    x <$ reportExtraDocs trailingDocs
-                  mk_doc_fld (L l' con_fld) = do
-                    doc <- selectDocString trailingDocs
-                    return $ L l' (con_fld { cd_fld_doc = fmap lexLHsDocString doc })
-              con_args' <- case con_args con_decl of
-                x@(PrefixCon _ ts) -> case nonEmpty ts of
-                    Nothing -> x <$ reportExtraDocs trailingDocs
-                    Just ts -> PrefixCon noTypeArgs . toList <$> mapLastM mk_doc_ty ts
-                x@(RecCon (L l_rec flds)) -> case nonEmpty flds of
-                    Nothing -> x <$ reportExtraDocs trailingDocs
-                    Just flds -> RecCon . L l_rec . toList <$> mapLastM mk_doc_fld flds
-                InfixCon t1 t2 -> InfixCon t1 <$> mk_doc_ty t2
-              return $ L l (con_decl{ con_args = con_args' })
-            else do
-              con_doc' <- selectDoc (con_doc con_decl `mcons` (map lexLHsDocString trailingDocs))
-              return $ L l (con_decl{ con_doc = con_doc' })
-        _ -> panic "addConTrailingDoc: non-H98 ConDecl"
-
-{- Note [Trailing comment on constructor declaration]
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+    return (L l_fld (fld { cd_fld_doc }))
+
+{- Note [Leading and trailing comments on H98 constructors]
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 The trailing comment after a constructor declaration is associated with the
-constructor itself when there are no other comments inside the declaration:
+constructor itself when it is the only comment:
 
    data T = MkT A B        -- ^ Comment on MkT
    data T = MkT { x :: A } -- ^ Comment on MkT
+   data T = A `MkT` B      -- ^ Comment on MkT
 
 When there are other comments, the trailing comment applies to the last field:
 
@@ -906,7 +814,58 @@ When there are other comments, the trailing comment applies to the last field:
          , b :: B   -- ^ Comment on b
          , c :: C } -- ^ Comment on c
 
-This makes the trailing comment context-sensitive. Example:
+   data T =
+       A      -- ^ Comment on A
+      `MkT`   -- ^ Comment on MkT
+       B      -- ^ Comment on B
+
+When it comes to the leading comment, there is no such ambiguity in /prefix/
+constructor declarations (plain or record syntax):
+
+   data T =
+    -- | Comment on MkT
+    MkT A B
+
+   data T =
+    -- | Comment on MkT
+    MkT
+      -- | Comment on A
+      A
+      -- | Comment on B
+      B
+
+   data T =
+    -- | Comment on MkT
+    MkT { x :: A }
+
+   data T =
+     -- | Comment on MkT
+     MkT {
+      -- | Comment on a
+      a :: A,
+      -- | Comment on b
+      b :: B,
+      -- | Comment on c
+      c :: C
+    }
+
+However, in /infix/ constructor declarations the leading comment is associated
+with the constructor itself if it is the only comment, and with the first
+field if there are other comments:
+
+   data T =
+    -- | Comment on MkT
+    A `MkT` B
+
+   data T =
+    -- | Comment on A
+    A
+    -- | Comment on MkT
+    `MkT`
+    -- | Comment on B
+    B
+
+This makes the leading and trailing comments context-sensitive. Example:
       data T =
         -- | comment 1
         MkT Int Bool -- ^ comment 2
@@ -920,17 +879,20 @@ GADTSyntax data constructors don't have any special treatment for the trailing c
 
 We implement this in two steps:
 
-  1. Process the data constructor declaration in a delimited context where the
-     trailing documentation comment is not visible. Delimiting the context is done
-     in addConTrailingDoc.
+  1. Gather information about available comments using `onlyTrailingOrLeading`.
+     It inspects available comments but does not consume them, and returns a
+     boolean that tells us what algorithm we should use
+        True  <=>  expect a single leading/trailing comment
+        False <=>  expect inner comments or more than one comment
 
-     When processing the declaration, track whether the constructor or any of
-     its fields have a documentation comment associated with them.
-     This is done using WriterT HasInnerDocs, see ConHdkA.
+  2. Collect the comments using the algorithm determined in the previous step
 
-  2. Depending on whether HasInnerDocs is True or False, attach the
-     trailing documentation comment to the data constructor itself
-     or to its last field.
+     a) `getTrailingLeading`:
+            a single leading/trailing comment is applied to the entire
+            constructor declaration as a whole; see the `con_doc` field
+     b) `getMixed`:
+            comments apply to individual parts of a constructor declaration,
+            including its field types
 -}
 
 instance HasHaddock a => HasHaddock (HsScaled GhcPs a) where
@@ -1266,6 +1228,13 @@ takeHdkComments f =
         Just item -> (item : items, other_hdk_comments)
         Nothing -> (items, hdk_comment : other_hdk_comments)
 
+-- Run a HdkM action and restore the original state.
+peekHdkM :: HdkM a -> HdkM a
+peekHdkM m =
+  HdkM $ \r s ->
+    case unHdkM m r s of
+      (a, _) -> (a, s)
+
 -- Get the docnext or docprev comment for an AST node at the given source span.
 getPrevNextDoc :: SrcSpan -> HdkM (Maybe (Located HsDocString))
 getPrevNextDoc l = do
@@ -1290,15 +1259,6 @@ selectDocString = select . filterOut (isEmptyDocString . unLoc)
       reportExtraDocs extra_docs
       return (Just doc)
 
-selectDoc :: forall a. [LHsDoc a] -> HdkM (Maybe (LHsDoc a))
-selectDoc = select . filterOut (isEmptyDocString . hsDocString . unLoc)
-  where
-    select [] = return Nothing
-    select [doc] = return (Just doc)
-    select (doc : extra_docs) = do
-      reportExtraDocs $ map (\(L l d) -> L l $ hsDocString d) extra_docs
-      return (Just doc)
-
 reportExtraDocs :: [Located HsDocString] -> HdkM ()
 reportExtraDocs =
   traverse_ (\extra_doc -> appendHdkWarning (HdkWarnExtraComment extra_doc))
@@ -1398,6 +1358,13 @@ locRangeTo :: Strict.Maybe BufPos -> LocRange
 locRangeTo (Strict.Just l) = mempty { loc_range_to = EndLoc l }
 locRangeTo Strict.Nothing = mempty
 
+-- The location range within the specified span.
+locRangeIn :: Strict.Maybe BufSpan -> LocRange
+locRangeIn (Strict.Just l) =
+  mempty { loc_range_from = StartLoc (bufSpanStart l)
+         , loc_range_to   = EndLoc (bufSpanEnd l) }
+locRangeIn Strict.Nothing = mempty
+
 -- Represents a predicate on BufPos:
 --
 --   LowerLocBound |   BufPos -> Bool
@@ -1526,10 +1493,6 @@ cmpBufSpanA (L la a) (L lb b) = cmpBufSpan (L (locA la) a) (L (locA lb) b)
 *                                                                      *
 ********************************************************************* -}
 
--- Cons an element to a list, if exists.
-mcons :: Maybe a -> [a] -> [a]
-mcons = maybe id (:)
-
 -- Map a function over a list of located items.
 mapLL :: (a -> b) -> [GenLocated l a] -> [GenLocated l b]
 mapLL f = map (fmap f)


=====================================
compiler/GHC/Utils/Misc.hs
=====================================
@@ -36,7 +36,6 @@ module GHC.Utils.Misc (
         holes,
 
         changeLast,
-        mapLastM,
 
         whenNonEmpty,
 
@@ -126,7 +125,6 @@ import GHC.Utils.Fingerprint
 import Data.Data
 import qualified Data.List as List
 import Data.List.NonEmpty  ( NonEmpty(..), last, nonEmpty )
-import qualified Data.List.NonEmpty as NE
 
 import GHC.Exts
 import GHC.Stack (HasCallStack)
@@ -522,11 +520,6 @@ expectNonEmptyPanic :: String -> a
 expectNonEmptyPanic msg = panic ("expectNonEmpty: " ++ msg)
 {-# NOINLINE expectNonEmptyPanic #-}
 
--- | Apply an effectful function to the last list element.
-mapLastM :: Functor f => (a -> f a) -> NonEmpty a -> f (NonEmpty a)
-mapLastM f (x:|[]) = NE.singleton <$> f x
-mapLastM f (x0:|x1:xs) = (x0 NE.<|) <$> mapLastM f (x1:|xs)
-
 whenNonEmpty :: Applicative m => [a] -> (NonEmpty a -> m ()) -> m ()
 whenNonEmpty []     _ = pure ()
 whenNonEmpty (x:xs) f = f (x :| xs)


=====================================
testsuite/tests/haddock/should_compile_flag_haddock/T24221.hs
=====================================
@@ -0,0 +1,43 @@
+module T24221 where
+
+data Foo0
+  -- | Docs for Foo1
+  = Foo1 Int
+  -- | Docs for Foo2
+  | Foo2 Int
+  -- | Docs for infix constructor
+  | Int :* Bool
+
+data Foo3 =
+  Int :+ Bool -- ^ Docs for infix constructor
+
+data Foo4 =
+  Int    -- ^ Docs for Int
+  :%     -- ^ Docs for infix constructor
+  Bool   -- ^ Docs for Bool
+
+data Foo5 =
+  -- | Docs for Int
+  Int
+  -- | Docs for infix constructor
+  :@
+  -- | Docs for Bool
+  Bool
+
+data Foo6 =
+  MkFoo6 { a6 :: Int   -- ^ Docs for a6
+         , b6 :: Int } -- ^ Docs for b6
+
+data Foo7 =
+  MkFoo7 -- ^ Docs for MkFoo7
+    { a7 :: Int    -- ^ Docs for a7
+    , b7 :: Int }  -- ^ Docs for b7
+
+data Foo8 =
+  -- | Docs for MkFoo8
+  MkFoo8 {
+    -- | Docs for a8
+    a8 :: Int,
+    -- | Docs for b8
+    b8 :: Int
+  }
\ No newline at end of file


=====================================
testsuite/tests/haddock/should_compile_flag_haddock/T24221.stderr
=====================================
@@ -0,0 +1,1466 @@
+
+==================== Parser AST ====================
+
+(L
+ { T24221.hs:1:1 }
+ (HsModule
+  (XModulePs
+   (EpAnn
+    (EpaSpan { T24221.hs:1:1 })
+    (AnnsModule
+     [(AddEpAnn AnnModule (EpaSpan { T24221.hs:1:1-6 }))
+     ,(AddEpAnn AnnWhere (EpaSpan { T24221.hs:1:15-19 }))]
+     []
+     (Just
+      ((,)
+       { T24221.hs:43:4 }
+       { T24221.hs:43:3 })))
+    (EpaCommentsBalanced
+     []
+     []))
+   (EpVirtualBraces
+    (1))
+   (Nothing)
+   (Nothing))
+  (Just
+   (L
+    (EpAnn
+     (EpaSpan { T24221.hs:1:8-13 })
+     (AnnListItem
+      [])
+     (EpaComments
+      []))
+    {ModuleName: T24221}))
+  (Nothing)
+  []
+  [(L
+    (EpAnn
+     (EpaSpan { T24221.hs:(3,1)-(9,15) })
+     (AnnListItem
+      [])
+     (EpaComments
+      []))
+    (TyClD
+     (NoExtField)
+     (DataDecl
+      (EpAnn
+       (EpaSpan { T24221.hs:(3,1)-(9,15) })
+       [(AddEpAnn AnnData (EpaSpan { T24221.hs:3:1-4 }))
+       ,(AddEpAnn AnnEqual (EpaSpan { T24221.hs:5:3 }))]
+       (EpaComments
+        []))
+      (L
+       (EpAnn
+        (EpaSpan { T24221.hs:3:6-9 })
+        (NameAnnTrailing
+         [])
+        (EpaComments
+         []))
+       (Unqual
+        {OccName: Foo0}))
+      (HsQTvs
+       (NoExtField)
+       [])
+      (Prefix)
+      (HsDataDefn
+       (NoExtField)
+       (Nothing)
+       (Nothing)
+       (Nothing)
+       (DataTypeCons
+        (False)
+        [(L
+          (EpAnn
+           (EpaSpan { T24221.hs:5:5-12 })
+           (AnnListItem
+            [(AddVbarAnn
+              (EpaSpan { T24221.hs:7:3 }))])
+           (EpaComments
+            []))
+          (ConDeclH98
+           (EpAnn
+            (EpaSpan { T24221.hs:5:5-12 })
+            []
+            (EpaComments
+             []))
+           (L
+            (EpAnn
+             (EpaSpan { T24221.hs:5:5-8 })
+             (NameAnnTrailing
+              [])
+             (EpaComments
+              []))
+            (Unqual
+             {OccName: Foo1}))
+           (False)
+           []
+           (Nothing)
+           (PrefixCon
+            []
+            [(HsScaled
+              (HsLinearArrow
+               (EpPct1
+                (NoEpTok)
+                (NoEpUniTok)))
+              (L
+               (EpAnn
+                (EpaSpan { T24221.hs:5:10-12 })
+                (AnnListItem
+                 [])
+                (EpaComments
+                 []))
+               (HsTyVar
+                (EpAnn
+                 (EpaSpan { T24221.hs:5:10-12 })
+                 []
+                 (EpaComments
+                  []))
+                (NotPromoted)
+                (L
+                 (EpAnn
+                  (EpaSpan { T24221.hs:5:10-12 })
+                  (NameAnnTrailing
+                   [])
+                  (EpaComments
+                   []))
+                 (Unqual
+                  {OccName: Int})))))])
+           (Just
+            (L
+             { T24221.hs:4:3-20 }
+             (WithHsDocIdentifiers
+              (MultiLineDocString
+               (HsDocStringNext)
+               (:|
+                (L
+                 { T24221.hs:4:7-20 }
+                 (HsDocStringChunk
+                  " Docs for Foo1"))
+                []))
+              [])))))
+        ,(L
+          (EpAnn
+           (EpaSpan { T24221.hs:7:5-12 })
+           (AnnListItem
+            [(AddVbarAnn
+              (EpaSpan { T24221.hs:9:3 }))])
+           (EpaComments
+            []))
+          (ConDeclH98
+           (EpAnn
+            (EpaSpan { T24221.hs:7:5-12 })
+            []
+            (EpaComments
+             []))
+           (L
+            (EpAnn
+             (EpaSpan { T24221.hs:7:5-8 })
+             (NameAnnTrailing
+              [])
+             (EpaComments
+              []))
+            (Unqual
+             {OccName: Foo2}))
+           (False)
+           []
+           (Nothing)
+           (PrefixCon
+            []
+            [(HsScaled
+              (HsLinearArrow
+               (EpPct1
+                (NoEpTok)
+                (NoEpUniTok)))
+              (L
+               (EpAnn
+                (EpaSpan { T24221.hs:7:10-12 })
+                (AnnListItem
+                 [])
+                (EpaComments
+                 []))
+               (HsTyVar
+                (EpAnn
+                 (EpaSpan { T24221.hs:7:10-12 })
+                 []
+                 (EpaComments
+                  []))
+                (NotPromoted)
+                (L
+                 (EpAnn
+                  (EpaSpan { T24221.hs:7:10-12 })
+                  (NameAnnTrailing
+                   [])
+                  (EpaComments
+                   []))
+                 (Unqual
+                  {OccName: Int})))))])
+           (Just
+            (L
+             { T24221.hs:6:3-20 }
+             (WithHsDocIdentifiers
+              (MultiLineDocString
+               (HsDocStringNext)
+               (:|
+                (L
+                 { T24221.hs:6:7-20 }
+                 (HsDocStringChunk
+                  " Docs for Foo2"))
+                []))
+              [])))))
+        ,(L
+          (EpAnn
+           (EpaSpan { T24221.hs:9:5-15 })
+           (AnnListItem
+            [])
+           (EpaComments
+            []))
+          (ConDeclH98
+           (EpAnn
+            (EpaSpan { T24221.hs:9:5-15 })
+            []
+            (EpaComments
+             []))
+           (L
+            (EpAnn
+             (EpaSpan { T24221.hs:9:9-10 })
+             (NameAnnTrailing
+              [])
+             (EpaComments
+              []))
+            (Unqual
+             {OccName: :*}))
+           (False)
+           []
+           (Nothing)
+           (InfixCon
+            (HsScaled
+             (HsLinearArrow
+              (EpPct1
+               (NoEpTok)
+               (NoEpUniTok)))
+             (L
+              (EpAnn
+               (EpaSpan { T24221.hs:9:5-7 })
+               (AnnListItem
+                [])
+               (EpaComments
+                []))
+              (HsTyVar
+               (EpAnn
+                (EpaSpan { T24221.hs:9:5-7 })
+                []
+                (EpaComments
+                 []))
+               (NotPromoted)
+               (L
+                (EpAnn
+                 (EpaSpan { T24221.hs:9:5-7 })
+                 (NameAnnTrailing
+                  [])
+                 (EpaComments
+                  []))
+                (Unqual
+                 {OccName: Int})))))
+            (HsScaled
+             (HsLinearArrow
+              (EpPct1
+               (NoEpTok)
+               (NoEpUniTok)))
+             (L
+              (EpAnn
+               (EpaSpan { T24221.hs:9:12-15 })
+               (AnnListItem
+                [])
+               (EpaComments
+                []))
+              (HsTyVar
+               (EpAnn
+                (EpaSpan { T24221.hs:9:12-15 })
+                []
+                (EpaComments
+                 []))
+               (NotPromoted)
+               (L
+                (EpAnn
+                 (EpaSpan { T24221.hs:9:12-15 })
+                 (NameAnnTrailing
+                  [])
+                 (EpaComments
+                  []))
+                (Unqual
+                 {OccName: Bool}))))))
+           (Just
+            (L
+             { T24221.hs:8:3-33 }
+             (WithHsDocIdentifiers
+              (MultiLineDocString
+               (HsDocStringNext)
+               (:|
+                (L
+                 { T24221.hs:8:7-33 }
+                 (HsDocStringChunk
+                  " Docs for infix constructor"))
+                []))
+              [])))))])
+       []))))
+  ,(L
+    (EpAnn
+     (EpaSpan { T24221.hs:(11,1)-(12,13) })
+     (AnnListItem
+      [])
+     (EpaComments
+      []))
+    (TyClD
+     (NoExtField)
+     (DataDecl
+      (EpAnn
+       (EpaSpan { T24221.hs:(11,1)-(12,13) })
+       [(AddEpAnn AnnData (EpaSpan { T24221.hs:11:1-4 }))
+       ,(AddEpAnn AnnEqual (EpaSpan { T24221.hs:11:11 }))]
+       (EpaComments
+        []))
+      (L
+       (EpAnn
+        (EpaSpan { T24221.hs:11:6-9 })
+        (NameAnnTrailing
+         [])
+        (EpaComments
+         []))
+       (Unqual
+        {OccName: Foo3}))
+      (HsQTvs
+       (NoExtField)
+       [])
+      (Prefix)
+      (HsDataDefn
+       (NoExtField)
+       (Nothing)
+       (Nothing)
+       (Nothing)
+       (DataTypeCons
+        (False)
+        [(L
+          (EpAnn
+           (EpaSpan { T24221.hs:12:3-13 })
+           (AnnListItem
+            [])
+           (EpaComments
+            []))
+          (ConDeclH98
+           (EpAnn
+            (EpaSpan { T24221.hs:12:3-13 })
+            []
+            (EpaComments
+             []))
+           (L
+            (EpAnn
+             (EpaSpan { T24221.hs:12:7-8 })
+             (NameAnnTrailing
+              [])
+             (EpaComments
+              []))
+            (Unqual
+             {OccName: :+}))
+           (False)
+           []
+           (Nothing)
+           (InfixCon
+            (HsScaled
+             (HsLinearArrow
+              (EpPct1
+               (NoEpTok)
+               (NoEpUniTok)))
+             (L
+              (EpAnn
+               (EpaSpan { T24221.hs:12:3-5 })
+               (AnnListItem
+                [])
+               (EpaComments
+                []))
+              (HsTyVar
+               (EpAnn
+                (EpaSpan { T24221.hs:12:3-5 })
+                []
+                (EpaComments
+                 []))
+               (NotPromoted)
+               (L
+                (EpAnn
+                 (EpaSpan { T24221.hs:12:3-5 })
+                 (NameAnnTrailing
+                  [])
+                 (EpaComments
+                  []))
+                (Unqual
+                 {OccName: Int})))))
+            (HsScaled
+             (HsLinearArrow
+              (EpPct1
+               (NoEpTok)
+               (NoEpUniTok)))
+             (L
+              (EpAnn
+               (EpaSpan { T24221.hs:12:10-13 })
+               (AnnListItem
+                [])
+               (EpaComments
+                []))
+              (HsTyVar
+               (EpAnn
+                (EpaSpan { T24221.hs:12:10-13 })
+                []
+                (EpaComments
+                 []))
+               (NotPromoted)
+               (L
+                (EpAnn
+                 (EpaSpan { T24221.hs:12:10-13 })
+                 (NameAnnTrailing
+                  [])
+                 (EpaComments
+                  []))
+                (Unqual
+                 {OccName: Bool}))))))
+           (Just
+            (L
+             { T24221.hs:12:15-45 }
+             (WithHsDocIdentifiers
+              (MultiLineDocString
+               (HsDocStringPrevious)
+               (:|
+                (L
+                 { T24221.hs:12:19-45 }
+                 (HsDocStringChunk
+                  " Docs for infix constructor"))
+                []))
+              [])))))])
+       []))))
+  ,(L
+    (EpAnn
+     (EpaSpan { T24221.hs:(14,1)-(17,6) })
+     (AnnListItem
+      [])
+     (EpaComments
+      []))
+    (TyClD
+     (NoExtField)
+     (DataDecl
+      (EpAnn
+       (EpaSpan { T24221.hs:(14,1)-(17,6) })
+       [(AddEpAnn AnnData (EpaSpan { T24221.hs:14:1-4 }))
+       ,(AddEpAnn AnnEqual (EpaSpan { T24221.hs:14:11 }))]
+       (EpaComments
+        []))
+      (L
+       (EpAnn
+        (EpaSpan { T24221.hs:14:6-9 })
+        (NameAnnTrailing
+         [])
+        (EpaComments
+         []))
+       (Unqual
+        {OccName: Foo4}))
+      (HsQTvs
+       (NoExtField)
+       [])
+      (Prefix)
+      (HsDataDefn
+       (NoExtField)
+       (Nothing)
+       (Nothing)
+       (Nothing)
+       (DataTypeCons
+        (False)
+        [(L
+          (EpAnn
+           (EpaSpan { T24221.hs:(15,3)-(17,6) })
+           (AnnListItem
+            [])
+           (EpaComments
+            []))
+          (ConDeclH98
+           (EpAnn
+            (EpaSpan { T24221.hs:(15,3)-(17,6) })
+            []
+            (EpaComments
+             []))
+           (L
+            (EpAnn
+             (EpaSpan { T24221.hs:16:3-4 })
+             (NameAnnTrailing
+              [])
+             (EpaComments
+              []))
+            (Unqual
+             {OccName: :%}))
+           (False)
+           []
+           (Nothing)
+           (InfixCon
+            (HsScaled
+             (HsLinearArrow
+              (EpPct1
+               (NoEpTok)
+               (NoEpUniTok)))
+             (L
+              (EpAnn
+               (EpaSpan { T24221.hs:15:3-5 })
+               (AnnListItem
+                [])
+               (EpaComments
+                []))
+              (HsDocTy
+               (EpAnn
+                (EpaDelta (SameLine 0) [])
+                []
+                (EpaComments
+                 []))
+               (L
+                (EpAnn
+                 (EpaSpan { T24221.hs:15:3-5 })
+                 (AnnListItem
+                  [])
+                 (EpaComments
+                  []))
+                (HsTyVar
+                 (EpAnn
+                  (EpaSpan { T24221.hs:15:3-5 })
+                  []
+                  (EpaComments
+                   []))
+                 (NotPromoted)
+                 (L
+                  (EpAnn
+                   (EpaSpan { T24221.hs:15:3-5 })
+                   (NameAnnTrailing
+                    [])
+                   (EpaComments
+                    []))
+                  (Unqual
+                   {OccName: Int}))))
+               (L
+                { T24221.hs:15:10-26 }
+                (WithHsDocIdentifiers
+                 (MultiLineDocString
+                  (HsDocStringPrevious)
+                  (:|
+                   (L
+                    { T24221.hs:15:14-26 }
+                    (HsDocStringChunk
+                     " Docs for Int"))
+                   []))
+                 [])))))
+            (HsScaled
+             (HsLinearArrow
+              (EpPct1
+               (NoEpTok)
+               (NoEpUniTok)))
+             (L
+              (EpAnn
+               (EpaSpan { T24221.hs:17:3-6 })
+               (AnnListItem
+                [])
+               (EpaComments
+                []))
+              (HsDocTy
+               (EpAnn
+                (EpaDelta (SameLine 0) [])
+                []
+                (EpaComments
+                 []))
+               (L
+                (EpAnn
+                 (EpaSpan { T24221.hs:17:3-6 })
+                 (AnnListItem
+                  [])
+                 (EpaComments
+                  []))
+                (HsTyVar
+                 (EpAnn
+                  (EpaSpan { T24221.hs:17:3-6 })
+                  []
+                  (EpaComments
+                   []))
+                 (NotPromoted)
+                 (L
+                  (EpAnn
+                   (EpaSpan { T24221.hs:17:3-6 })
+                   (NameAnnTrailing
+                    [])
+                   (EpaComments
+                    []))
+                  (Unqual
+                   {OccName: Bool}))))
+               (L
+                { T24221.hs:17:10-27 }
+                (WithHsDocIdentifiers
+                 (MultiLineDocString
+                  (HsDocStringPrevious)
+                  (:|
+                   (L
+                    { T24221.hs:17:14-27 }
+                    (HsDocStringChunk
+                     " Docs for Bool"))
+                   []))
+                 []))))))
+           (Just
+            (L
+             { T24221.hs:16:10-40 }
+             (WithHsDocIdentifiers
+              (MultiLineDocString
+               (HsDocStringPrevious)
+               (:|
+                (L
+                 { T24221.hs:16:14-40 }
+                 (HsDocStringChunk
+                  " Docs for infix constructor"))
+                []))
+              [])))))])
+       []))))
+  ,(L
+    (EpAnn
+     (EpaSpan { T24221.hs:(19,1)-(25,6) })
+     (AnnListItem
+      [])
+     (EpaComments
+      []))
+    (TyClD
+     (NoExtField)
+     (DataDecl
+      (EpAnn
+       (EpaSpan { T24221.hs:(19,1)-(25,6) })
+       [(AddEpAnn AnnData (EpaSpan { T24221.hs:19:1-4 }))
+       ,(AddEpAnn AnnEqual (EpaSpan { T24221.hs:19:11 }))]
+       (EpaComments
+        []))
+      (L
+       (EpAnn
+        (EpaSpan { T24221.hs:19:6-9 })
+        (NameAnnTrailing
+         [])
+        (EpaComments
+         []))
+       (Unqual
+        {OccName: Foo5}))
+      (HsQTvs
+       (NoExtField)
+       [])
+      (Prefix)
+      (HsDataDefn
+       (NoExtField)
+       (Nothing)
+       (Nothing)
+       (Nothing)
+       (DataTypeCons
+        (False)
+        [(L
+          (EpAnn
+           (EpaSpan { T24221.hs:(21,3)-(25,6) })
+           (AnnListItem
+            [])
+           (EpaComments
+            []))
+          (ConDeclH98
+           (EpAnn
+            (EpaSpan { T24221.hs:(21,3)-(25,6) })
+            []
+            (EpaComments
+             []))
+           (L
+            (EpAnn
+             (EpaSpan { T24221.hs:23:3-4 })
+             (NameAnnTrailing
+              [])
+             (EpaComments
+              []))
+            (Unqual
+             {OccName: :@}))
+           (False)
+           []
+           (Nothing)
+           (InfixCon
+            (HsScaled
+             (HsLinearArrow
+              (EpPct1
+               (NoEpTok)
+               (NoEpUniTok)))
+             (L
+              (EpAnn
+               (EpaSpan { T24221.hs:21:3-5 })
+               (AnnListItem
+                [])
+               (EpaComments
+                []))
+              (HsDocTy
+               (EpAnn
+                (EpaDelta (SameLine 0) [])
+                []
+                (EpaComments
+                 []))
+               (L
+                (EpAnn
+                 (EpaSpan { T24221.hs:21:3-5 })
+                 (AnnListItem
+                  [])
+                 (EpaComments
+                  []))
+                (HsTyVar
+                 (EpAnn
+                  (EpaSpan { T24221.hs:21:3-5 })
+                  []
+                  (EpaComments
+                   []))
+                 (NotPromoted)
+                 (L
+                  (EpAnn
+                   (EpaSpan { T24221.hs:21:3-5 })
+                   (NameAnnTrailing
+                    [])
+                   (EpaComments
+                    []))
+                  (Unqual
+                   {OccName: Int}))))
+               (L
+                { T24221.hs:20:3-19 }
+                (WithHsDocIdentifiers
+                 (MultiLineDocString
+                  (HsDocStringNext)
+                  (:|
+                   (L
+                    { T24221.hs:20:7-19 }
+                    (HsDocStringChunk
+                     " Docs for Int"))
+                   []))
+                 [])))))
+            (HsScaled
+             (HsLinearArrow
+              (EpPct1
+               (NoEpTok)
+               (NoEpUniTok)))
+             (L
+              (EpAnn
+               (EpaSpan { T24221.hs:25:3-6 })
+               (AnnListItem
+                [])
+               (EpaComments
+                []))
+              (HsDocTy
+               (EpAnn
+                (EpaDelta (SameLine 0) [])
+                []
+                (EpaComments
+                 []))
+               (L
+                (EpAnn
+                 (EpaSpan { T24221.hs:25:3-6 })
+                 (AnnListItem
+                  [])
+                 (EpaComments
+                  []))
+                (HsTyVar
+                 (EpAnn
+                  (EpaSpan { T24221.hs:25:3-6 })
+                  []
+                  (EpaComments
+                   []))
+                 (NotPromoted)
+                 (L
+                  (EpAnn
+                   (EpaSpan { T24221.hs:25:3-6 })
+                   (NameAnnTrailing
+                    [])
+                   (EpaComments
+                    []))
+                  (Unqual
+                   {OccName: Bool}))))
+               (L
+                { T24221.hs:24:3-20 }
+                (WithHsDocIdentifiers
+                 (MultiLineDocString
+                  (HsDocStringNext)
+                  (:|
+                   (L
+                    { T24221.hs:24:7-20 }
+                    (HsDocStringChunk
+                     " Docs for Bool"))
+                   []))
+                 []))))))
+           (Just
+            (L
+             { T24221.hs:22:3-33 }
+             (WithHsDocIdentifiers
+              (MultiLineDocString
+               (HsDocStringNext)
+               (:|
+                (L
+                 { T24221.hs:22:7-33 }
+                 (HsDocStringChunk
+                  " Docs for infix constructor"))
+                []))
+              [])))))])
+       []))))
+  ,(L
+    (EpAnn
+     (EpaSpan { T24221.hs:(27,1)-(29,22) })
+     (AnnListItem
+      [])
+     (EpaComments
+      []))
+    (TyClD
+     (NoExtField)
+     (DataDecl
+      (EpAnn
+       (EpaSpan { T24221.hs:(27,1)-(29,22) })
+       [(AddEpAnn AnnData (EpaSpan { T24221.hs:27:1-4 }))
+       ,(AddEpAnn AnnEqual (EpaSpan { T24221.hs:27:11 }))]
+       (EpaComments
+        []))
+      (L
+       (EpAnn
+        (EpaSpan { T24221.hs:27:6-9 })
+        (NameAnnTrailing
+         [])
+        (EpaComments
+         []))
+       (Unqual
+        {OccName: Foo6}))
+      (HsQTvs
+       (NoExtField)
+       [])
+      (Prefix)
+      (HsDataDefn
+       (NoExtField)
+       (Nothing)
+       (Nothing)
+       (Nothing)
+       (DataTypeCons
+        (False)
+        [(L
+          (EpAnn
+           (EpaSpan { T24221.hs:(28,3)-(29,22) })
+           (AnnListItem
+            [])
+           (EpaComments
+            []))
+          (ConDeclH98
+           (EpAnn
+            (EpaSpan { T24221.hs:(28,3)-(29,22) })
+            []
+            (EpaComments
+             []))
+           (L
+            (EpAnn
+             (EpaSpan { T24221.hs:28:3-8 })
+             (NameAnnTrailing
+              [])
+             (EpaComments
+              []))
+            (Unqual
+             {OccName: MkFoo6}))
+           (False)
+           []
+           (Nothing)
+           (RecCon
+            (L
+             (EpAnn
+              (EpaSpan { T24221.hs:(28,10)-(29,22) })
+              (AnnList
+               (Just
+                (EpaSpan { T24221.hs:28:12-20 }))
+               (Just
+                (AddEpAnn AnnOpenC (EpaSpan { T24221.hs:28:10 })))
+               (Just
+                (AddEpAnn AnnCloseC (EpaSpan { T24221.hs:29:22 })))
+               []
+               [])
+              (EpaComments
+               []))
+             [(L
+               (EpAnn
+                (EpaSpan { T24221.hs:28:12-20 })
+                (AnnListItem
+                 [(AddCommaAnn
+                   (EpaSpan { T24221.hs:29:10 }))])
+                (EpaComments
+                 []))
+               (ConDeclField
+                (EpAnn
+                 (EpaSpan { T24221.hs:28:12-20 })
+                 [(AddEpAnn AnnDcolon (EpaSpan { T24221.hs:28:15-16 }))]
+                 (EpaComments
+                  []))
+                [(L
+                  (EpAnn
+                   (EpaSpan { T24221.hs:28:12-13 })
+                   (AnnListItem
+                    [])
+                   (EpaComments
+                    []))
+                  (FieldOcc
+                   (NoExtField)
+                   (L
+                    (EpAnn
+                     (EpaSpan { T24221.hs:28:12-13 })
+                     (NameAnnTrailing
+                      [])
+                     (EpaComments
+                      []))
+                    (Unqual
+                     {OccName: a6}))))]
+                (L
+                 (EpAnn
+                  (EpaSpan { T24221.hs:28:18-20 })
+                  (AnnListItem
+                   [])
+                  (EpaComments
+                   []))
+                 (HsTyVar
+                  (EpAnn
+                   (EpaSpan { T24221.hs:28:18-20 })
+                   []
+                   (EpaComments
+                    []))
+                  (NotPromoted)
+                  (L
+                   (EpAnn
+                    (EpaSpan { T24221.hs:28:18-20 })
+                    (NameAnnTrailing
+                     [])
+                    (EpaComments
+                     []))
+                   (Unqual
+                    {OccName: Int}))))
+                (Just
+                 (L
+                  { T24221.hs:28:24-39 }
+                  (WithHsDocIdentifiers
+                   (MultiLineDocString
+                    (HsDocStringPrevious)
+                    (:|
+                     (L
+                      { T24221.hs:28:28-39 }
+                      (HsDocStringChunk
+                       " Docs for a6"))
+                     []))
+                   [])))))
+             ,(L
+               (EpAnn
+                (EpaSpan { T24221.hs:29:12-20 })
+                (AnnListItem
+                 [])
+                (EpaComments
+                 []))
+               (ConDeclField
+                (EpAnn
+                 (EpaSpan { T24221.hs:29:12-20 })
+                 [(AddEpAnn AnnDcolon (EpaSpan { T24221.hs:29:15-16 }))]
+                 (EpaComments
+                  []))
+                [(L
+                  (EpAnn
+                   (EpaSpan { T24221.hs:29:12-13 })
+                   (AnnListItem
+                    [])
+                   (EpaComments
+                    []))
+                  (FieldOcc
+                   (NoExtField)
+                   (L
+                    (EpAnn
+                     (EpaSpan { T24221.hs:29:12-13 })
+                     (NameAnnTrailing
+                      [])
+                     (EpaComments
+                      []))
+                    (Unqual
+                     {OccName: b6}))))]
+                (L
+                 (EpAnn
+                  (EpaSpan { T24221.hs:29:18-20 })
+                  (AnnListItem
+                   [])
+                  (EpaComments
+                   []))
+                 (HsTyVar
+                  (EpAnn
+                   (EpaSpan { T24221.hs:29:18-20 })
+                   []
+                   (EpaComments
+                    []))
+                  (NotPromoted)
+                  (L
+                   (EpAnn
+                    (EpaSpan { T24221.hs:29:18-20 })
+                    (NameAnnTrailing
+                     [])
+                    (EpaComments
+                     []))
+                   (Unqual
+                    {OccName: Int}))))
+                (Just
+                 (L
+                  { T24221.hs:29:24-39 }
+                  (WithHsDocIdentifiers
+                   (MultiLineDocString
+                    (HsDocStringPrevious)
+                    (:|
+                     (L
+                      { T24221.hs:29:28-39 }
+                      (HsDocStringChunk
+                       " Docs for b6"))
+                     []))
+                   [])))))]))
+           (Nothing)))])
+       []))))
+  ,(L
+    (EpAnn
+     (EpaSpan { T24221.hs:(31,1)-(34,17) })
+     (AnnListItem
+      [])
+     (EpaComments
+      []))
+    (TyClD
+     (NoExtField)
+     (DataDecl
+      (EpAnn
+       (EpaSpan { T24221.hs:(31,1)-(34,17) })
+       [(AddEpAnn AnnData (EpaSpan { T24221.hs:31:1-4 }))
+       ,(AddEpAnn AnnEqual (EpaSpan { T24221.hs:31:11 }))]
+       (EpaComments
+        []))
+      (L
+       (EpAnn
+        (EpaSpan { T24221.hs:31:6-9 })
+        (NameAnnTrailing
+         [])
+        (EpaComments
+         []))
+       (Unqual
+        {OccName: Foo7}))
+      (HsQTvs
+       (NoExtField)
+       [])
+      (Prefix)
+      (HsDataDefn
+       (NoExtField)
+       (Nothing)
+       (Nothing)
+       (Nothing)
+       (DataTypeCons
+        (False)
+        [(L
+          (EpAnn
+           (EpaSpan { T24221.hs:(32,3)-(34,17) })
+           (AnnListItem
+            [])
+           (EpaComments
+            []))
+          (ConDeclH98
+           (EpAnn
+            (EpaSpan { T24221.hs:(32,3)-(34,17) })
+            []
+            (EpaComments
+             []))
+           (L
+            (EpAnn
+             (EpaSpan { T24221.hs:32:3-8 })
+             (NameAnnTrailing
+              [])
+             (EpaComments
+              []))
+            (Unqual
+             {OccName: MkFoo7}))
+           (False)
+           []
+           (Nothing)
+           (RecCon
+            (L
+             (EpAnn
+              (EpaSpan { T24221.hs:(33,5)-(34,17) })
+              (AnnList
+               (Just
+                (EpaSpan { T24221.hs:33:7-15 }))
+               (Just
+                (AddEpAnn AnnOpenC (EpaSpan { T24221.hs:33:5 })))
+               (Just
+                (AddEpAnn AnnCloseC (EpaSpan { T24221.hs:34:17 })))
+               []
+               [])
+              (EpaComments
+               []))
+             [(L
+               (EpAnn
+                (EpaSpan { T24221.hs:33:7-15 })
+                (AnnListItem
+                 [(AddCommaAnn
+                   (EpaSpan { T24221.hs:34:5 }))])
+                (EpaComments
+                 []))
+               (ConDeclField
+                (EpAnn
+                 (EpaSpan { T24221.hs:33:7-15 })
+                 [(AddEpAnn AnnDcolon (EpaSpan { T24221.hs:33:10-11 }))]
+                 (EpaComments
+                  []))
+                [(L
+                  (EpAnn
+                   (EpaSpan { T24221.hs:33:7-8 })
+                   (AnnListItem
+                    [])
+                   (EpaComments
+                    []))
+                  (FieldOcc
+                   (NoExtField)
+                   (L
+                    (EpAnn
+                     (EpaSpan { T24221.hs:33:7-8 })
+                     (NameAnnTrailing
+                      [])
+                     (EpaComments
+                      []))
+                    (Unqual
+                     {OccName: a7}))))]
+                (L
+                 (EpAnn
+                  (EpaSpan { T24221.hs:33:13-15 })
+                  (AnnListItem
+                   [])
+                  (EpaComments
+                   []))
+                 (HsTyVar
+                  (EpAnn
+                   (EpaSpan { T24221.hs:33:13-15 })
+                   []
+                   (EpaComments
+                    []))
+                  (NotPromoted)
+                  (L
+                   (EpAnn
+                    (EpaSpan { T24221.hs:33:13-15 })
+                    (NameAnnTrailing
+                     [])
+                    (EpaComments
+                     []))
+                   (Unqual
+                    {OccName: Int}))))
+                (Just
+                 (L
+                  { T24221.hs:33:20-35 }
+                  (WithHsDocIdentifiers
+                   (MultiLineDocString
+                    (HsDocStringPrevious)
+                    (:|
+                     (L
+                      { T24221.hs:33:24-35 }
+                      (HsDocStringChunk
+                       " Docs for a7"))
+                     []))
+                   [])))))
+             ,(L
+               (EpAnn
+                (EpaSpan { T24221.hs:34:7-15 })
+                (AnnListItem
+                 [])
+                (EpaComments
+                 []))
+               (ConDeclField
+                (EpAnn
+                 (EpaSpan { T24221.hs:34:7-15 })
+                 [(AddEpAnn AnnDcolon (EpaSpan { T24221.hs:34:10-11 }))]
+                 (EpaComments
+                  []))
+                [(L
+                  (EpAnn
+                   (EpaSpan { T24221.hs:34:7-8 })
+                   (AnnListItem
+                    [])
+                   (EpaComments
+                    []))
+                  (FieldOcc
+                   (NoExtField)
+                   (L
+                    (EpAnn
+                     (EpaSpan { T24221.hs:34:7-8 })
+                     (NameAnnTrailing
+                      [])
+                     (EpaComments
+                      []))
+                    (Unqual
+                     {OccName: b7}))))]
+                (L
+                 (EpAnn
+                  (EpaSpan { T24221.hs:34:13-15 })
+                  (AnnListItem
+                   [])
+                  (EpaComments
+                   []))
+                 (HsTyVar
+                  (EpAnn
+                   (EpaSpan { T24221.hs:34:13-15 })
+                   []
+                   (EpaComments
+                    []))
+                  (NotPromoted)
+                  (L
+                   (EpAnn
+                    (EpaSpan { T24221.hs:34:13-15 })
+                    (NameAnnTrailing
+                     [])
+                    (EpaComments
+                     []))
+                   (Unqual
+                    {OccName: Int}))))
+                (Just
+                 (L
+                  { T24221.hs:34:20-35 }
+                  (WithHsDocIdentifiers
+                   (MultiLineDocString
+                    (HsDocStringPrevious)
+                    (:|
+                     (L
+                      { T24221.hs:34:24-35 }
+                      (HsDocStringChunk
+                       " Docs for b7"))
+                     []))
+                   [])))))]))
+           (Just
+            (L
+             { T24221.hs:32:10-29 }
+             (WithHsDocIdentifiers
+              (MultiLineDocString
+               (HsDocStringPrevious)
+               (:|
+                (L
+                 { T24221.hs:32:14-29 }
+                 (HsDocStringChunk
+                  " Docs for MkFoo7"))
+                []))
+              [])))))])
+       []))))
+  ,(L
+    (EpAnn
+     (EpaSpan { T24221.hs:(36,1)-(43,3) })
+     (AnnListItem
+      [])
+     (EpaComments
+      []))
+    (TyClD
+     (NoExtField)
+     (DataDecl
+      (EpAnn
+       (EpaSpan { T24221.hs:(36,1)-(43,3) })
+       [(AddEpAnn AnnData (EpaSpan { T24221.hs:36:1-4 }))
+       ,(AddEpAnn AnnEqual (EpaSpan { T24221.hs:36:11 }))]
+       (EpaComments
+        []))
+      (L
+       (EpAnn
+        (EpaSpan { T24221.hs:36:6-9 })
+        (NameAnnTrailing
+         [])
+        (EpaComments
+         []))
+       (Unqual
+        {OccName: Foo8}))
+      (HsQTvs
+       (NoExtField)
+       [])
+      (Prefix)
+      (HsDataDefn
+       (NoExtField)
+       (Nothing)
+       (Nothing)
+       (Nothing)
+       (DataTypeCons
+        (False)
+        [(L
+          (EpAnn
+           (EpaSpan { T24221.hs:(38,3)-(43,3) })
+           (AnnListItem
+            [])
+           (EpaComments
+            []))
+          (ConDeclH98
+           (EpAnn
+            (EpaSpan { T24221.hs:(38,3)-(43,3) })
+            []
+            (EpaComments
+             []))
+           (L
+            (EpAnn
+             (EpaSpan { T24221.hs:38:3-8 })
+             (NameAnnTrailing
+              [])
+             (EpaComments
+              []))
+            (Unqual
+             {OccName: MkFoo8}))
+           (False)
+           []
+           (Nothing)
+           (RecCon
+            (L
+             (EpAnn
+              (EpaSpan { T24221.hs:(38,10)-(43,3) })
+              (AnnList
+               (Just
+                (EpaSpan { T24221.hs:40:5-13 }))
+               (Just
+                (AddEpAnn AnnOpenC (EpaSpan { T24221.hs:38:10 })))
+               (Just
+                (AddEpAnn AnnCloseC (EpaSpan { T24221.hs:43:3 })))
+               []
+               [])
+              (EpaComments
+               []))
+             [(L
+               (EpAnn
+                (EpaSpan { T24221.hs:40:5-13 })
+                (AnnListItem
+                 [(AddCommaAnn
+                   (EpaSpan { T24221.hs:40:14 }))])
+                (EpaComments
+                 []))
+               (ConDeclField
+                (EpAnn
+                 (EpaSpan { T24221.hs:40:5-13 })
+                 [(AddEpAnn AnnDcolon (EpaSpan { T24221.hs:40:8-9 }))]
+                 (EpaComments
+                  []))
+                [(L
+                  (EpAnn
+                   (EpaSpan { T24221.hs:40:5-6 })
+                   (AnnListItem
+                    [])
+                   (EpaComments
+                    []))
+                  (FieldOcc
+                   (NoExtField)
+                   (L
+                    (EpAnn
+                     (EpaSpan { T24221.hs:40:5-6 })
+                     (NameAnnTrailing
+                      [])
+                     (EpaComments
+                      []))
+                    (Unqual
+                     {OccName: a8}))))]
+                (L
+                 (EpAnn
+                  (EpaSpan { T24221.hs:40:11-13 })
+                  (AnnListItem
+                   [])
+                  (EpaComments
+                   []))
+                 (HsTyVar
+                  (EpAnn
+                   (EpaSpan { T24221.hs:40:11-13 })
+                   []
+                   (EpaComments
+                    []))
+                  (NotPromoted)
+                  (L
+                   (EpAnn
+                    (EpaSpan { T24221.hs:40:11-13 })
+                    (NameAnnTrailing
+                     [])
+                    (EpaComments
+                     []))
+                   (Unqual
+                    {OccName: Int}))))
+                (Just
+                 (L
+                  { T24221.hs:39:5-20 }
+                  (WithHsDocIdentifiers
+                   (MultiLineDocString
+                    (HsDocStringNext)
+                    (:|
+                     (L
+                      { T24221.hs:39:9-20 }
+                      (HsDocStringChunk
+                       " Docs for a8"))
+                     []))
+                   [])))))
+             ,(L
+               (EpAnn
+                (EpaSpan { T24221.hs:42:5-13 })
+                (AnnListItem
+                 [])
+                (EpaComments
+                 []))
+               (ConDeclField
+                (EpAnn
+                 (EpaSpan { T24221.hs:42:5-13 })
+                 [(AddEpAnn AnnDcolon (EpaSpan { T24221.hs:42:8-9 }))]
+                 (EpaComments
+                  []))
+                [(L
+                  (EpAnn
+                   (EpaSpan { T24221.hs:42:5-6 })
+                   (AnnListItem
+                    [])
+                   (EpaComments
+                    []))
+                  (FieldOcc
+                   (NoExtField)
+                   (L
+                    (EpAnn
+                     (EpaSpan { T24221.hs:42:5-6 })
+                     (NameAnnTrailing
+                      [])
+                     (EpaComments
+                      []))
+                    (Unqual
+                     {OccName: b8}))))]
+                (L
+                 (EpAnn
+                  (EpaSpan { T24221.hs:42:11-13 })
+                  (AnnListItem
+                   [])
+                  (EpaComments
+                   []))
+                 (HsTyVar
+                  (EpAnn
+                   (EpaSpan { T24221.hs:42:11-13 })
+                   []
+                   (EpaComments
+                    []))
+                  (NotPromoted)
+                  (L
+                   (EpAnn
+                    (EpaSpan { T24221.hs:42:11-13 })
+                    (NameAnnTrailing
+                     [])
+                    (EpaComments
+                     []))
+                   (Unqual
+                    {OccName: Int}))))
+                (Just
+                 (L
+                  { T24221.hs:41:5-20 }
+                  (WithHsDocIdentifiers
+                   (MultiLineDocString
+                    (HsDocStringNext)
+                    (:|
+                     (L
+                      { T24221.hs:41:9-20 }
+                      (HsDocStringChunk
+                       " Docs for b8"))
+                     []))
+                   [])))))]))
+           (Just
+            (L
+             { T24221.hs:37:3-22 }
+             (WithHsDocIdentifiers
+              (MultiLineDocString
+               (HsDocStringNext)
+               (:|
+                (L
+                 { T24221.hs:37:7-22 }
+                 (HsDocStringChunk
+                  " Docs for MkFoo8"))
+                []))
+              [])))))])
+       []))))]))
+
+


=====================================
testsuite/tests/haddock/should_compile_flag_haddock/all.T
=====================================
@@ -64,3 +64,4 @@ test('haddockTySyn', normal, compile, ['-haddock -Winvalid-haddock -ddump-parsed
 test('T8944', normal, compile, ['-haddock -Winvalid-haddock -ddump-parsed'])
 test('T17652', normal, compile, ['-haddock -Winvalid-haddock -ddump-parsed'])
 test('haddockLinear', normal, compile, ['-haddock -Winvalid-haddock -ddump-parsed'])
+test('T24221', normal, compile, ['-haddock -Winvalid-haddock -ddump-parsed-ast'])



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e8fb2451ae07d3797afd4cdefa545afc7c5523b6

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e8fb2451ae07d3797afd4cdefa545afc7c5523b6
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20240208/10a3c48a/attachment-0001.html>


More information about the ghc-commits mailing list