Introduce field selectors and simple smart constructors in template-haskell
For a long time template-haskell
has been a significant source of user-visible churn across GHC releases. In particular, the language features tend to add and change fields of various AST elements, breaking users who work with the AST. The severity of the problem is revealed by examining the patches in ghc/head.hackage> (e.g. by grepping for MIN_VERSION_template_haskell
): A significant amount of "trivial" patching is necessary simply to accommodating field additions due to language features that few TH users will use.
I suspect that things would be significantly easier if:
- AST types consistently provided field selectors, ensuring that users matching on constructors don't need to care about fields that happen to show up in the future
- each constructor provided a "simple" smart constructor providing only Haskell 2010 fields.
An extension to the second suggestion would be to provide a dedicated module, Language.Haskell.TH.Syntax.H2010
, which provides a complete set of pattern synonyms over the TH AST, reflecting only Haskell 2010 syntax.