state of the cabal (preprocessors)

Simon Marlow simonmar at
Tue Oct 26 04:36:28 EDT 2004

To hopefully wind up this discussion, I'd like to make three proposals:

1. That if a compiler understands an in-file pragma specifying options,
it should take the form {-# OPTIONS_<compiler> ... #-}.

2. We introduce a new pragma to specify the language extensions in force
for the current source file.  I suggest: {-# LANGUAGE <ext1>,...,<extn>
#-} where <ext> is taken from the list of extensions understood by Cabal
in the 'extensions' field of a package description (eg.
OverlappingInstances, RecursiveDo, etc.).

3. We add CPP to the list of extensions in Cabal, so you can say {-#
LANGUAGE CPP #-} to get C preprocessing in the current file, or add CPP
to the list of extensions in the package description to get CPP on every
file.  That doesn't preclude also using a .cpp extension, but it means
you don't have to.

Hmm, I've just realised some problems with this.  Hugs probably won't be
implementing {-# LANGUAGE #-} any time soon (I imagine?) so it wouldn't
be portable.  Also old compilers don't implement it, so we have a
difficult migration path.

Perhaps for the time being we just do 1 & 3, and use the package-wide
list of extensions for portability.


More information about the Libraries mailing list