Support constructor Haddocks in more places
authorAlec Theriault <alec.theriault@gmail.com>
Fri, 12 Jan 2018 21:45:48 +0000 (16:45 -0500)
committerBen Gamari <ben@smart-cactus.org>
Fri, 12 Jan 2018 21:45:51 +0000 (16:45 -0500)
commite20046a0c4a552c5037797cf720fb34877bc2d21
treeae4e5a12d4fa6dabbc4d535b458f297dd812e332
parentb2f10d8981bebe44f1ab39e417818dfa2d50639d
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
26 files changed:
compiler/parser/Parser.y
compiler/parser/RdrHsSyn.hs
testsuite/tests/ghc-api/annotations/T10255.stdout
testsuite/tests/ghc-api/annotations/T10268.stdout
testsuite/tests/ghc-api/annotations/T10278.stdout
testsuite/tests/ghc-api/annotations/T10312.stdout
testsuite/tests/ghc-api/annotations/T10354.stdout
testsuite/tests/ghc-api/annotations/T10399.stdout
testsuite/tests/ghc-api/annotations/T10598.stdout
testsuite/tests/ghc-api/annotations/T11018.stdout
testsuite/tests/ghc-api/annotations/T12417.stdout
testsuite/tests/ghc-api/annotations/boolFormula.stdout
testsuite/tests/ghc-api/annotations/exampleTest.stdout
testsuite/tests/ghc-api/annotations/listcomps.stdout
testsuite/tests/ghc-api/annotations/parseTree.stdout
testsuite/tests/haddock/should_compile_flag_haddock/all.T
testsuite/tests/haddock/should_compile_flag_haddock/haddockA035.hs [new file with mode: 0644]
testsuite/tests/haddock/should_compile_flag_haddock/haddockA035.stderr [new file with mode: 0644]
testsuite/tests/haddock/should_compile_flag_haddock/haddockA036.hs [new file with mode: 0644]
testsuite/tests/haddock/should_compile_flag_haddock/haddockA036.stderr [new file with mode: 0644]
testsuite/tests/haddock/should_compile_flag_haddock/haddockA037.hs [new file with mode: 0644]
testsuite/tests/haddock/should_compile_flag_haddock/haddockA037.stderr [new file with mode: 0644]
testsuite/tests/haddock/should_compile_noflag_haddock/all.T
testsuite/tests/haddock/should_compile_noflag_haddock/haddockC035.hs [new file with mode: 0644]
testsuite/tests/haddock/should_compile_noflag_haddock/haddockC036.hs [new file with mode: 0644]
testsuite/tests/haddock/should_compile_noflag_haddock/haddockC037.hs [new file with mode: 0644]