From bbfb051c6e52f08cbdcd6e8a37245b714c385fa3 Mon Sep 17 00:00:00 2001
From: Ben Gamari <ben@smart-cactus.org>
Date: Wed, 14 Feb 2024 10:47:44 -0500
Subject: [PATCH] Allow docstrings after exports

Here we extend the parser and AST to preserve docstrings following
export items. We then extend Haddock to parse `@since` annotations in
such docstrings, allowing changes in export structure to be properly
documented.
---
 compiler/GHC/Parser/PostProcess/Haddock.hs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/compiler/GHC/Parser/PostProcess/Haddock.hs b/compiler/GHC/Parser/PostProcess/Haddock.hs
index 2ca6813c1aae..62fe91a4a974 100644
--- a/compiler/GHC/Parser/PostProcess/Haddock.hs
+++ b/compiler/GHC/Parser/PostProcess/Haddock.hs
@@ -1327,7 +1327,7 @@ mkDocIE (L l_comment hdk_comment) =
     HdkCommentSection n doc -> Just $ L l (IEGroup noExtField n $ L span $ lexHsDocString doc)
     HdkCommentNamed s _doc -> Just $ L l (IEDocNamed noExtField s)
     HdkCommentNext doc -> Just $ L l (IEDoc noExtField $ L span $ lexHsDocString doc)
-    _ -> Nothing
+    HdkCommentPrev doc -> Just $ L l (IEDoc noExtField $ L span $ lexHsDocString doc)
   where l = noAnnSrcSpan span
         span = mkSrcSpanPs l_comment
 
-- 
GitLab