RE: state of the cabal (preprocessors)

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

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.
Careful - not all Haskell modules contain the keyword "module". Perhaps the scan should be up to the first non-comment, non-blank token? --KW 8-)
participants (2)
-
Keith Wansbrough
-
Simon Marlow