state of the cabal (preprocessors)

Simon Marlow simonmar at microsoft.com
Wed Oct 27 05:48:07 EDT 2004


On 26 October 2004 18:00, Henrik Nilsson wrote:

> However, at least superficially, it would seem simpler (and more
> flexible, since normal comments would not interfere) to simply
> require that all OPTIONS/LANGUAGE pragmas must occur before the
> keyword "module".
> 
> But maybe that is hard to implement, or undesirable for some other
> reason?

Well, it's more tricky because you have to ignore comments, and
therefore understand nested comments, but that's not too hard.  A little
Alex or parsec parser should do the trick, being careful not to read the
entire file.

I think Cabal could provide the functionality in a library:

  getOptionsFromSource
     :: FilePath
     -> IO (
            [Extension],                  -- LANGUAGE pragma, if any
            [(CompilerFlavour,[String])]  -- OPTIONS_FOO pragmas
           )

Cheers,
	Simon


More information about the Libraries mailing list