Decoupling L.H.S.Decls from GHC.Types.ForeignCall
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:
SafteyHeaderCExportSpec
Data-type TTG extension points
There are three data-types which do modified to add a TTG extension point:
-
CCallTarget: TTG extension withUnitThis extension is complete. The
Maybe UnitandSourceTexthave been moved to an extension point and instantiated as:-
GhcPs:SourceText -
GhcRn: (SourceText,Unit) -
GhcTc: (SourceText,Unit) TheMaybewrapper aroundUnitis removed because we can now definitively add theUnitvalue for the specific passes where it exists.
-
-
CType: TTG extension with twoSourceStringdata-types used for exact printing. These are the same for all GHC passes. -
Header: TTG extension for theSourceStringused for exact printing.
Code clarity improvements
Additionally, some code clarity improvements were made to reduce occurrences of "Boolean blindness:"
-
Replaced
Boolparameter indsCFExportanddsJsFExportof with the new data-type:data ExportLinking = ExportIsDynamic | ExportIsStatic -
Replaced the
BoolinCCallTargetwith 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 UnitinCCallTarget GhcRnandCCallTarget GhcRnwith the new data-type:data CCallStaticTargetUnit = TargetIsInThisUnit -- ^ In this current 'Unit'. | TargetIsInThat Unit -- ^ In that other 'Unit'.