forward language extension flags to pgmF custom preprocessor
Motivation
This proposal would give more complete information to the -pgmF
custom preprocessor about the source it is consuming. This idea occurred to me while prototyping a preprocessor that needs to know the language extensions, but it moreover seems natural when considered in the abstract: the preprocessor consumes Haskell source, so it should be informed how to do so/what constructs to expect.
Proposal
When passed -pgmF foo -F
, GHC invokes foo
as part of the compilation pipeline. The foo
program should expect three arguments: 1 the original the source file name, 2 the file path to the result of upstream preprocessing (eg Cpp), and 3 the file path where foo
should write its result. The foo
program will receive additional arguments beyond those three only if they are passed to GHC using optF
.
This Issue proposes an additional fourth argument, extending the default three. This new argument would be the path to a file that contains (at least) the language extensions that were provided to the GHC invocation. There may be other such flags to include in this fourth argument, but the language extensions are the only obvious ones. It should contain all flags that alter/enable meanings of syntactic forms in source intended for consumption by GHC.
We'd only need to control the presence of this fourth argument for the sake of backwards compatibility.