summaryrefslogtreecommitdiff
path: root/compiler/GHC/Parser/PostProcess/Haddock.hs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/GHC/Parser/PostProcess/Haddock.hs')
-rw-r--r--compiler/GHC/Parser/PostProcess/Haddock.hs28
1 files changed, 17 insertions, 11 deletions
diff --git a/compiler/GHC/Parser/PostProcess/Haddock.hs b/compiler/GHC/Parser/PostProcess/Haddock.hs
index 271d9db30f..2ce0dd5274 100644
--- a/compiler/GHC/Parser/PostProcess/Haddock.hs
+++ b/compiler/GHC/Parser/PostProcess/Haddock.hs
@@ -696,22 +696,14 @@ instance HasHaddock (LocatedA (ConDecl GhcPs)) where
addHaddock (L l_con_decl con_decl) =
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
+ ConDeclGADT { con_g_ext, con_names, con_bndrs, con_mb_cxt, con_body } -> do
-- discardHasInnerDocs is ok because we don't need this info for GADTs.
con_doc' <- discardHasInnerDocs $ getConDoc (getLocA (head con_names))
- con_g_args' <-
- case con_g_args of
- PrefixConGADT ts -> PrefixConGADT <$> addHaddock ts
- RecConGADT (L l_rec flds) arr -> do
- -- discardHasInnerDocs is ok because we don't need this info for GADTs.
- flds' <- traverse (discardHasInnerDocs . addHaddockConDeclField) flds
- pure $ RecConGADT (L l_rec flds') arr
- con_res_ty' <- addHaddock con_res_ty
+ con_body' <- addHaddock con_body
pure $ L l_con_decl $
ConDeclGADT { con_g_ext, con_names, con_bndrs, con_mb_cxt,
con_doc = lexLHsDocString <$> con_doc',
- con_g_args = con_g_args',
- con_res_ty = con_res_ty' }
+ con_body = con_body' }
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
@@ -738,6 +730,20 @@ instance HasHaddock (LocatedA (ConDecl GhcPs)) where
con_doc = lexLHsDocString <$> con_doc',
con_args = RecCon (L l_rec flds') }
+instance HasHaddock (ConGadtSigBody GhcPs) where
+ addHaddock (PrefixConGADT body) = PrefixConGADT <$> addHaddock body
+ addHaddock (RecConGADT (L l_rec flds) arr res_ty) = do
+ -- discardHasInnerDocs is ok because we don't need this info for GADTs.
+ flds' <- traverse (discardHasInnerDocs . addHaddockConDeclField) flds
+ res_ty' <- addHaddock res_ty
+ pure $ RecConGADT (L l_rec flds') arr res_ty'
+
+instance HasHaddock (PrefixConGadtSigBody GhcPs) where
+ addHaddock (PCGSAnonArg arg_ty body) =
+ PCGSAnonArg <$> addHaddock arg_ty <*> addHaddock body
+ addHaddock (PCGSRes res_ty) =
+ PCGSRes <$> addHaddock res_ty
+
-- Keep track of documentation comments on the data constructor or any of its
-- fields.
--