Support constructor Haddocks in more places

Authored by harpocrates on Jan 12 2018, 3:45 PM.

Description

Support constructor Haddocks in more places

This adds support for adding Haddocks on individual non-record fields
of regular (and GADT) constructors. The following now parses just fine
with -haddock enabled:

data Foo

= Baz             -- ^ doc on the `Baz` constructor
    Int           -- ^ doc on the `Int` field of `Baz`
    String        -- ^ doc on the `String` field of `Baz`

| Int             -- ^ doc on the `Int` field of the `:*` constructor
    :*            -- ^ doc on the `:*` constructor
  String          -- ^ doc on the `String` field of the `:*`

constructor

| Boa             -- ^ doc on the `Boa` record constructor
    { y :: () }

The change is backwards compatible: if there is only one doc and it
occurs
on the last field, it is lifted to apply to the whole constructor (as
before).

Reviewers: bgamari, alanz

Subscribers: rwbarton, thomie, mpickering, carter

Differential Revision: https://phabricator.haskell.org/D4292