state of the cabal (preprocessors)

Simon Marlow simonmar at microsoft.com
Thu Oct 21 05:56:50 EDT 2004


On 20 October 2004 15:07, Henrik Nilsson wrote:

> [Aside: Is there a general agreement that the OPTION pragma should
> be understood by all Haskell systems, whereas system-specific
> options are given by pragmas like OPTIONS-GHC, OPTIONS-NHC, etc.
> or something along those lines?]

I'm happy to switch to using {-# OPTIONS_GHC #-} (or something) if
there's consensus.  Consider that a vote in favour on behalf of the GHC
camp.

> But what about interpreters? Would it be
> the build-system's responsibility (be it Cabal's simple build system
> or a make based system called from Cabal or whatever) to look for
> options pragmas in the source and run CPP if neccessary on those
> files? 

Yes, but that's pretty easy.  Slightly more difficult that just
inspecting the extension, but still easy.  GHC's version of the code is
here:

http://cvs.haskell.org/cgi-bin/cvsweb.cgi/~checkout~/fptools/ghc/compile
r/main/DriverUtil.hs?rev=1.45;content-type=text%2Fplain

(getOptionsFromSource function).

> If so, at least for make-based systems, a scheme based on file
> extensions is probably easier to handle?
>
> If not, then it would seem that non-preprocessed sources do get
> installed, and that Hugs would have to look for the option pragma
> on a per file bases and run CPP if necessary before loading the
> source? Perfectly OK, except that I still think it is a good idea to
> preprocess only once.
 
For make-based systems, you're probably using a compiler in which case
you just delegate CPP to the compiler.

The tricky cases are

  - make-based build system for Hugs. (pretty rare, I'd guess)
  - CPP'ing source for feeding to Haddock

For both of these cases, the make-based build system could just defer to
Cabal once it has done whatever setup is required.
 
> Finally, does not the option pragma solution imply that CPP-ing always
> is the last preprocessing step?
>
> This might be a reasonable assumption, but at least Malcolm raised
> concerns about building such an assumption into the tools.

When it is Haskell preprocessing, yes.  Preprocessing Happy (or other)
sources with CPP is still possible using the .cpp extension convention -
I'm only proposing we drop the .cpp when it follows .hs or .lhs.

Cheers,
	Simon


More information about the Libraries mailing list