2

I'm using flymake(-ghc) on emacs (prelude setup, before anybody wonders, no extra configuration) for a yesod project which has some #if's here and there by default. All good apart from the fact that flymake shows this error:

/path/to/Import.hs:18:2:
    lexical error at character 'i'

and the line is precisely

#if __GLASGOW_HASKELL__ >= 704

so, exactly the same behaviour as ghci:

Prelude> #if something

<interactive>:2:2: lexical error at character 'i'

is there anything I'm missing here?

bonus: auto-complete doesn't work either (emacs, prelude, default setup etc.): it works for other things (e.g. R).

marco
  • 806
  • 1
  • 7
  • 17
  • turns out flymake complains (for a reason) for many *other* language extensions directives which are missing in the "yesod init"-generated files. – marco Mar 30 '14 at 00:37

1 Answers1

3

I presume this flymake-ghc thing does not enable the C preprocessor while checking. To fix it, add the following to the top of affected Haskell files::

{-# LANGUAGE CPP #-}

This pragma enables the preprocessor for the containing file.

Generally, that's actually the preferred way to enable Haskell language options and extensions, because this way they are confined to files that actually require them.

  • that did it, thanks! apparently that's not the only configuration difference, but at least this problem went away. – marco Mar 29 '14 at 14:18