Allow Haddock comments in type synonyms
authorDavid Waern <david.waern@gmail.com>
Tue, 31 Mar 2009 21:23:06 +0000 (21:23 +0000)
committerDavid Waern <david.waern@gmail.com>
Tue, 31 Mar 2009 21:23:06 +0000 (21:23 +0000)
commitc0778bd3da61e80948e5813255ee82cdfebe0fdf
treeb5a303214f961b39f67fc1d4d56cead6b69ec9f2
parent79b22beb4d2eca1877d99d55838ba6ce69658405
Allow Haddock comments in type synonyms

We now use `ctypedoc` instead of `ctype` for type synonyms. `ctypedoc` was
previously only used for top-level type signatures. This change means that type
synonyms now can contain comments, just like top-level type signatures.

Note:

* I've modified `ctypedoc` so it allows implicit parameters and equational
constraints, just like ctype.

* Since `ctypedoc` allows nested foralls, we now allow that in type synonyms.

* I have inlined some productions into gentypedoc so that there is now a
non-doc version of every production with a 'doc' suffix. (Stylistic change
only, which should make the code easier to follow).

* It would have been nice to simplify the grammar by unifying `ctype` and
ctypedoc` into one production, allowing comments on types everywhere (and
rejecting them after parsing, where necessary).  This is however not possible
since it leads to ambiguity. The reason is the support for comments on record
fields:

> data R = R { field :: Int -- ^ comment on the field }

If we allow comments on types here, it's not clear if the comment applies
to 'field' or to 'Int'. So we must use `ctype` to describe the type.
compiler/parser/Parser.y.pp