Cabal: Conditional code and dependencies

Simon Marlow simonmar at
Thu Jul 21 06:19:02 EDT 2005

I haven't had time to think about the other points in your message yet,
but wanted to comment on this one:

On 21 July 2005 06:32, Brian Smith wrote:

> (3) It would be useful if Cabal/GHC/Hugs/etc. #defined symbols for
> installed packages. This would allow us to write:
> module My.Program.Compat.Lib(foo1, foo2,foo3)
> #if __PACKAGE_foo__ >= 110 -- Is package foo-1.1 or later available?
> import Foo(foo1,foo2,foo3)
> #else
> foo1 = ....
> foo2 = ....
> foo3 = ...
> #endif

Absolutely - this thought also crossed my mind recently.  We should
agree on a convention.  __PACKAGE_<name>__  seems reasonable, but what
about the version number?  We could adopt the same policy as
__GLASGOW_HASKELL__, namely major*100+minor, and discard any futher
dimensions in the version number (e.g. 1.1.1 and 1.1.2 both get
__PACKAGE_foo__==101).  This perhaps isn't as intuitive as it could be:
people tend to write 110 when they want 101.  So is there an
alternate/better scheme?


More information about the Libraries mailing list