ttg: Remove dependency on `GHC.Types.Basic (InlinePragma)` from `Language.Haskell.Syntax.Binds`
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:
-
We have to split the module
GHC.Types.Basic
intoGHC.Types.Basic
andGHC.Types.InlinePragma
. This is necessary because without this split we get cyclic dependencies as soon as we try to both a) moveInlinePragma
and friends into theHaskell.Language.Syntax.Binds
and b) importHaskell.Language.Syntax.Binds
from theGHC.*
namespace. -
We have to parameterize
InlineSpec
,InlinePragma
andActivation
in order to get rid of the hard-codedSourceText
field in these types. We do this by redefiningInlinePragma
asHsInlinePragma a
and adding a type synonymtype InlinePragma = HsInlinePragma SourceText
. (Similarly for the other types.) -
We move the definition of these types into
Haskell.Language.Syntax.Binds
. -
We get rid of a remaining use of
SourceText
inHaskell.Language.Syntax.Binds
by introducing the type familyXHsInlinePragma
. 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.