@@ -85,9 +85,6 @@ isDocumented = any (isHaddock . unLoc)
8585 isHaddock _ = False
8686
8787-- | Group relevant declarations together.
88−--
89−-- Add a declaration to a group iff it is relevant to either the first or
90−-- the preceding declaration in the group.
9188groupDecls :: [LHsDecl GhcPs] -> [NonEmpty (LHsDecl GhcPs)]
9289groupDecls [] = []
9390groupDecls (l@(L _ DocNext) : xs) =
@@ -100,7 +97,8 @@ groupDecls (header : xs) =
10097 let (grp, rest) = flip span (zip (header : xs) xs) $ \(previous, current) ->
10198 let relevantToHdr = groupedDecls header current
10299 relevantToPrev = groupedDecls previous current
103− in relevantToHdr || relevantToPrev
100+ isDeclSeries = declSeries previous current
101+ in isDeclSeries || relevantToHdr || relevantToPrev
104102 in (header :| map snd grp) : groupDecls (map snd rest)
105103
106104p_hsDecl :: FamilyStyle -> HsDecl GhcPs -> R ()
@@ -197,6 +195,18 @@ groupedDecls (L l_x x') (L l_y y') =
197195 (_, DocPrev) -> True
198196 _ -> False
199197
198+-- | Detect declaration series that should not have blanks between them.
199+declSeries ::
200+ LHsDecl GhcPs ->
201+ LHsDecl GhcPs ->
202+ Bool
203+declSeries (L _ x) (L _ y) =
204+ case (x, y) of
205+ ( SigD NoExtField (TypeSig NoExtField _ _),
206+ SigD NoExtField (TypeSig NoExtField _ _)
207+ ) -> True
208+ _ -> False
209+
200210intersects :: Ord a => [a] -> [a] -> Bool
201211intersects a b = go (sort a) (sort b)
202212 where