Skip to content

Commit

Permalink
Document how to format long Haddock comments on fields
Browse files Browse the repository at this point in the history
  • Loading branch information
tibbe committed Apr 6, 2012
1 parent 4741eef commit 74d065c
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions haskell-style.md
Expand Up @@ -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
Expand All @@ -189,16 +189,34 @@ 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
, name :: String -- ^ First name
}
```

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

Expand Down

0 comments on commit 74d065c

Please sign in to comment.