Skip to content

ttg: Remove dependency on `GHC.Types.Basic (InlinePragma)` from `Language.Haskell.Syntax.Binds`

BinderDavid requested to merge BinderDavid/ghc:wip/split-out-inlinepragma into master

Part of the #21592 effort.

This PR is about making the types which represent the {-# INLINE ...#-}, {-# OPAQUE ... -#} etc pragmas a part of the AST in the Language.Haskell.* namespace. Previously, they lived in the GHC.Types.Basic module.

These pragmas are represented jointly by a handful of data types: InlinePragma InlineSpec, RuleMatchInfo and Activation. The problem is that these types are also used ubiquitously in the compiler to represent inlining information, and not just for parts of the AST.

Here are the four steps which correspond to the four Commits in this MR:

  1. We have to split the module GHC.Types.Basic into GHC.Types.Basic and GHC.Types.InlinePragma. This is necessary because without this split we get cyclic dependencies as soon as we try to both a) move InlinePragma and friends into the Haskell.Language.Syntax.Binds and b) import Haskell.Language.Syntax.Binds from the GHC.* namespace.

  2. We have to parameterize InlineSpec, InlinePragma and Activation in order to get rid of the hard-coded SourceText field in these types. We do this by redefining InlinePragma as HsInlinePragma a and adding a type synonym type InlinePragma = HsInlinePragma SourceText. (Similarly for the other types.)

  3. We move the definition of these types into Haskell.Language.Syntax.Binds.

  4. We get rid of a remaining use of SourceText in Haskell.Language.Syntax.Binds by introducing the type family XHsInlinePragma. This extension point does not follow the "pure TTG philosophy", but it kind of does its job. I am open to suggestions to find a nicer solution for this.

Edited by BinderDavid

Merge request reports