Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Document how to format long Haddock comments on fields

  • Loading branch information...
commit 74d065c73334d2dc1bfe6f5d8eadfa8ff09471c1 1 parent 4741eef
@tibbe authored
Showing with 21 additions and 3 deletions.
  1. +21 −3 haskell-style.md
View
24 haskell-style.md
@@ -180,7 +180,7 @@ punctuation.
Comment every top level function (particularly exported functions),
and provide a type signature; use Haddock syntax in the comments.
-Comment every exported data type. Some examples:
+Comment every exported data type. Function example:
```haskell
-- | Send a message on a socket. The socket must be in a connected
@@ -189,7 +189,14 @@ Comment every exported data type. Some examples:
send :: Socket -- ^ Connected socket
-> ByteString -- ^ Data to send
-> IO Int -- ^ Bytes sent
+```
+
+For functions the documentation should give enough information to
+apply the function without looking at the function's definition.
+
+Record example:
+```haskell
-- | Bla bla bla.
data Person = Person
{ age :: Int -- ^ Age
@@ -197,8 +204,19 @@ data Person = Person
}
```
-For functions the documentation should give enough information to
-apply the function without looking at the function's definition.
+For fields that require longer comments format them like so:
+
+```haskell
+data Record = Record
+ { -- | This is a very very very long comment that is split over
+ -- multiple lines.
+ field1 :: Text
+
+ -- | This is a second very very very long comment that is split
+ -- over multiple lines.
+ , field2 :: Int
+ }
+```
### End-of-Line Comments
Please sign in to comment.
Something went wrong with that request. Please try again.