Skip to content

Commit dac9ae6

Browse files
committed
Fix rendering of single-line haddocks
In short: `null xs /= null (catMaybes xs)`, but we were using the former as a conditional to decide how to render the output, while we should have been using the latter conditional.
1 parent dbab462 commit dac9ae6

File tree

1 file changed

+5
-4
lines changed
  • hs-bindgen/src-internal/HsBindgen/Backend/HsModule

1 file changed

+5
-4
lines changed

hs-bindgen/src-internal/HsBindgen/Backend/HsModule/Render.hs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@ instance Pretty CommentKind where
152152
PartOfDeclarationComment c -> ("{- ^", "-}", c)
153153
THComment c -> ("", "", c)
154154
indentation = length commentStart - 1
155-
fromCCtxDoc = [ (\n -> "__C declaration:__ @"
155+
fromCCtxDoc = catMaybes [
156+
(\n -> "__C declaration:__ @"
156157
>< textToCtxDoc n
157158
>< "@") <$> commentOrigin
158159
, (\p -> "__defined at:__ @"
@@ -177,7 +178,7 @@ instance Pretty CommentKind where
177178
[] | Nothing <- commentTitle
178179
, not (null fromCCtxDoc) ->
179180
string commentStart
180-
<+> vsep (catMaybes fromCCtxDoc)
181+
<+> vsep fromCCtxDoc
181182
$$ string commentEnd
182183
| Just _ <- commentTitle
183184
, null fromCCtxDoc ->
@@ -188,13 +189,13 @@ instance Pretty CommentKind where
188189
, not (null fromCCtxDoc) ->
189190
string commentStart
190191
<+> firstContent
191-
$+$ vsep (catMaybes fromCCtxDoc)
192+
$+$ vsep fromCCtxDoc
192193
$$ string commentEnd
193194
| otherwise -> empty
194195

195196
_ -> vsep (string commentStart <+> firstContent
196197
: map (nest indentation . pretty) commentChildren)
197-
$+$ vcat [ vsep (catMaybes fromCCtxDoc)
198+
$+$ vcat [ vsep fromCCtxDoc
198199
, string commentEnd
199200
]
200201

0 commit comments

Comments
 (0)