Skip to content

Decoupling L.H.S.Decls from GHC.Types.ForeignCall

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

This MR addresses issue #26700 .

Basic data-types from GHC.Types.ForeignCall and which do not require extensibility via the "Trees that Grow" (TTG) methodology are moved to Language.Haskell.Syntax.Decls, soon to be moved to Language.Haskell.Syntax.Decls.ForeignCall.

Simple data-type migration

The migrated data types without modification:

  • Saftey
  • Header
  • CExportSpec

Data-type TTG extension points

There are three data-types which do modified to add a TTG extension point:

  1. CCallTarget: TTG extension with Unit

    This extension is complete. The Maybe Unit and SourceText have been moved to an extension point and instantiated as:

    • GhcPs: SourceText
    • GhcRn: (SourceText, Unit)
    • GhcTc: (SourceText, Unit) The Maybe wrapper around Unit is removed because we can now definitively add the Unit value for the specific passes where it exists.
  2. CType: TTG extension with two SourceString data-types used for exact printing. These are the same for all GHC passes.

  3. Header: TTG extension for the SourceString used for exact printing.

Code clarity improvements

Additionally, some code clarity improvements were made to reduce occurrences of "Boolean blindness:"

  • Replaced Bool parameter in dsCFExport and dsJsFExport of with the new data-type:

    data ExportLinking                                                                                                             
      = ExportIsDynamic
      | ExportIsStatic
  • Replaced the Bool in CCallTarget with the new data-type:

    data `ForeignKind
      = ForeignValue    -- ^ Binds to a value, a zero-arity function.
      | ForeignFunction -- ^ Binds to a function with arity /of at least one/.
  • Replaced the Maybe Unit in CCallTarget GhcRn and CCallTarget GhcRn with the new data-type:

    data CCallStaticTargetUnit
      = TargetIsInThisUnit  -- ^ In this current 'Unit'.
      | TargetIsInThat Unit -- ^ In that other   'Unit'.
Edited by recursion-ninja

Merge request reports

Loading