Skip to content

Decoupling Language.Haskell.Syntax.Binds from GHC.Types.Basic

recursion-ninja requested to merge wip/fix-26670 into master

This MR addresses issue #26670 (closed) by decoupling Language.Haskell.Syntax.Binds from GHC.Types.Basic.

This is achieved by transferring the InlinePragma data-type and its related sub-types from GHC.Types.Basic to a new module Language.Haskell.Syntax.Binds.InlinePragma.

Changes

  • A new module GHC.Types.Arity is added to export arity related type synonyms to the importing module without forming an module import loop. The arity type synonyms are transfered from GHC.Types.Basic.

  • Another new module GHC.Types.InlinePragma is added to define GHC-specific definitions related to InlinePragma and re-export definitions from Language.Haskell.Syntax.Binds.InlinePragma independently of the GHC.Types.Basic module. The GHC.Types.Basic module is a "dumping ground" of many types in GHC and consequently it has become a troublesome entanglement that causes module import loops. By paring off the InlinePragma definitions into their own module, we avoid several module import loops while simultaneously reducing the entangling nature of GHC.Types.Basic, since many data-types are now defined outside the that module.

  • Many GHC modules no longer depend on the "dumping ground" GHC.Types.Basic modules, and instead depend on either GHC.Types.Arity or GHC.Types.InlinePragma

  • The following data-types are moved from GHC.Types.Basic to Language.Haskell.Syntax.Binds.InlinePragma:

    • InlinePragma
    • InlineSpec
    • RuleMatchInfo
    • Activation
    • PhaseNum
  • The following data-types are moved from GHC.Types.Basic to GHC.Types.InlinePragma:

    • CompilerPhase
  • The following data-types are exported from GHC.Types.InlinePragma:

    • InlinePragma
    • InlineSpec
    • RuleMatchInfo
    • Activation
    • PhaseNum
    • CompilerPhase
  • The InlineSpec data-type has been simplified to no longer store a SourceText value. It was determined that the SourceText value of the InlineSpec was always identical to the SourceText value contain in the parent InlinePragma data-type. The removal of redundant storage simplifies the AST syntax and marginally reduces memory usage.

  • Added a new record InlinePragmaGhcTag to track the SourceText and Arity of the function during GhcRn and GhcTc passes.

  • The instances of Binary for these data-types are moved to GHC.Utils.Binary (no orphans):

    • InlineSpec
    • RuleMatchInfo
    • Activation
  • The instances of Binary for these data-types are moved to GHC.Types.InlinePragma (sadly orphans):

    • InlinePragma
    • CompilerPhase
  • The instances of Outputable for these data-types are moved to GHC.Utils.Outputable (no orphans):

    • InlinePragma
    • InlineSpec
    • RuleMatchInfo
    • Activation
  • The instances of Outputable for these data-types are moved to GHC.Types.InlinePragma (sadly orphans):

    • CompilerPhase

Note: The orphan Binary andOutputable instances exist due to cyclic imports, and cannot be migrated to GHC.Utils.{Binary,Outputable} until the dependency on GHC.Hs.Doc and GHC.Types.Basic are removed from several GHC modules.

Edited by recursion-ninja

Merge request reports

Loading