[GHC] #8822: Allow -- ^ Haddock syntax on record constructors
GHC
ghc-devs at haskell.org
Mon Oct 16 00:24:35 UTC 2017
#8822: Allow -- ^ Haddock syntax on record constructors
-------------------------------------+-------------------------------------
Reporter: Fuuzetsu | Owner: (none)
Type: feature request | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 7.9
(Parser) |
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: #9770, #12050 | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by harpocrates):
I have a patch that implements both the initial idea and the the
suggestion in comment:4. I'll link to it shortly. The only unpleasantness
here is that we probably want to maintain backwards compatibility.
For that, I decided to lift doc comments on the last field of the
constructor to the constructor, provided there are no other doc comments
either on the constructor or any of the other fields. This ensures that
existing docs will all still parse the same way.
{{{
data Foo
= Bar Int String -- ^ doc on `Bar` constructor
| Baz -- ^ doc on the `Baz` constructor
Int -- ^ doc on the `Int` field of `Baz`
String -- ^ doc on the `String` field of `Baz`
| Int :+ String -- ^ doc on the `:+` constructor
| Int -- ^ doc on the `Int` field of the `:*` constructor
:* -- ^ doc on the `:*` constructor
String -- ^ doc on the `String` field of the `:*`
constructor
| Boo { x :: () } -- ^ doc on the `Boo` record constructor
| Boa -- ^ doc on the `Boa` record constructor
{ y :: () }
}}}
The patch also adds support for doc comments on GADT constructor
arguments.
{{{
data Foo where
Foo :: Int -- ^ `Int` field of `Foo`
-> String -- ^ `String` field of `Foo`
-> Foo
}}}
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8822#comment:5>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list