Skip to content

Commit 114d57b

Browse files
authored
Merge pull request #418 from haskellfoundation/GHC-05641
Add message for GHC-05641
2 parents 0bb2d8e + 6d7372c commit 114d57b

File tree

4 files changed

+38
-0
lines changed

4 files changed

+38
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
title: Multiple Haddock comments
3+
summary: Multiple Haddock comments for a single entity are not allowed
4+
severity: warning
5+
flag: -Winvalid-haddock
6+
introduced: 9.6.1
7+
---
8+
9+
Haddock provides multiple ways of adding documentation strings to entities such as types, constructors or functions. If more than one way is used to document an entity, all but the first documentation comment are ignored, and this warning is emitted.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module MultiConstructorComments where
2+
3+
data Maybe a =
4+
-- | The Nothing constructor signals the absence of a value.
5+
-- You can use the Nothing constructor where you would use `null` in other languages.
6+
Nothing
7+
| Just a
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module MultiConstructorComments where
2+
3+
data Maybe a =
4+
-- | The Nothing constructor signals the absence of a value.
5+
Nothing
6+
-- ^ You can use the Nothing constructor where you would use `null` in other languages.
7+
| Just a
8+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
title: The Nothing constructor is documented with two separate Haddock comments
3+
---
4+
5+
In this example, the `Nothing` constructor was documented twice, once using a `-- |` style comment and once using a `-- ^` style comment. But only one form of comment is allowed per documented entity. In order to fix this warning, only use one form of documentation comment.
6+
7+
```
8+
messages/GHC-05641/multi-constructor-comments/before/Multi-constructor-comments.hs:6:7: warning: [GHC-05641] [-Winvalid-haddock]
9+
Multiple Haddock comments for a single entity are not allowed.
10+
The extraneous comment will be ignored.
11+
|
12+
6 | -- ^ You can use the Nothing constructor where you would use `null`in other languages.
13+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
14+
```

0 commit comments

Comments
 (0)