Language extensions - backwards compatibility

Simon Marlow marlowsd at gmail.com
Fri Jan 29 04:46:18 EST 2010


On 28/01/10 23:38, Iain Alexander wrote:
> I'm looking for a way of specifying language extensions in a way which will
> work in all versions of GHC from 6.4 onwards.
>
> GHC 6.4 does not support the LANGUAGE pragma.  Specifying language options in
> the OPTIONS_GHC pragma starts to produce deprecation warnings in 6.10, and will
> presumably eventually fail altogether.
>
> Any sort of preprocessing at the beginning of a file appears to insert enough
> noise to inhibit recognition of file-header pragmas. (Cpphs doesn't appear to
> help here.) Attempting preprocessing inside a leading OPTIONS_GHC pragma fails
> because it apparently attempts to interpret the pragma *before* invoking the
> preprocessor.
>
> The only remaining option I can see is to have a completely separate version of
> the file for GHC 6.4.  Have I missed anything?

There are a little cluster of bugs to do with this, see

   http://hackage.haskell.org/trac/ghc/ticket/3457

We need to re-read the pragmas after preprocessing.  Ironically though, 
you will only be able to use this facility with a GHC that supports it, 
so we'll see a lot of source files like

{-# LANGUAGE ... #-}
#if __GLASGOW_HASKELL__ >= 614
{-# LANGUAGE .. more .. #-}
#endif

because GHC before 6.14 will stop at the first #if.  (that's assuming we 
implement this for 6.14, it hasn't been done yet)

Cheers,
	Simon


More information about the Glasgow-haskell-users mailing list