Skip to content
  • David Waern's avatar
    Allow Haddock comments in type synonyms · c0778bd3
    David Waern authored
    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.
    c0778bd3