Extensions and Cabal

Lennart Kolmodin kolmodin at dtek.chalmers.se
Sat Mar 24 08:03:21 EDT 2007

Hash: SHA1

Ian Lynagh wrote:

> * The same set of extensions is used for every module. For example, if
>   you want to allow overlapping instances in one particular place[1]
>   then you must allow them everywhere.

You explicitly have to add potentially dangerous extensions when you
need them, that would be a gain, the downside being that you actually
have to write them...

> * If you want to load one of the modules in ghci, say, then you need to
>   tell it what flags to use.

It's more or less this that raised this question at all. Big gain if you
didn't have to.

> Thus I propose that the .cabal file actually specifies what extensions
> the modules are /allowed/ to use, but does not actually enable them.
> They would then be enabled by LANGUAGE pragmas in the modules as
> necessary. So, if the .cabal file says "Extensions: E, F" then the
> modules will be compiled with
>     --no-extension-flags --allowed-extension=E,F
> and if a module has "{-# LANGUAGE E #-}" then only extension E would be
> enabled for that module. If a module has "{-# LANGUAGE E,G #-}" then
> compilation would fail as extension G is not permitted.
> Any comments? Criticisms? Flames?

Yes! It's a compiler independent way of adding extensions, yet the
control of what can be used is maintained by Cabal.

There will be a phase when many cabal projects has to be adapted, but it
might just be worth it.

I like it a lot, thanks Ian!

  Lennart Kolmodin
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org


More information about the cabal-devel mailing list