Skip to content
  • Vladislav Zavialov's avatar
    Merge doc and non-doc type grammar · dd7b3378
    Vladislav Zavialov authored
    Before this patch, we maintained two different grammars for types, one that
    accepted Haddock comments and one that did not:
    
      -- No documentation
      type
        : btype            { ... }
        | btype '->' ctype { ... }
    
      -- Documentation
      typedoc
        : btype                       { ... }
        | btype docprev               { ... }
        | docnext btype               { ... }
        | btype '->'     ctypedoc     { ... }
        | btype docprev '->' ctypedoc { ... }
        | docnext btype '->' ctypedoc { ... }
    
    See the (now deleted)  Note [ctype and ctypedoc]
        and (also deleted) Note [Constr variatons of non-terminals]
    
    This led to a fair share of duplication, with many rules having
    a parallel no-documentation rule:
    
         Documentation  | No documentation
        ----------------+------------------
         typedoc        | type
         ctypedoc       | ctype
         ktypedoc       | ktype
         sigtypedoc     | sigtype
         constr_ftype   | ftype
         constr_btype   | btype
         constr_context | context
    
    With this patch, we always parse the comments, and then either
    reject or accept them in a later validation step.
    dd7b3378