Cabal package feature request [was: Streams 0.1e released]

Bulat Ziganshin bulat.ziganshin at
Thu Jun 8 12:38:48 EDT 2006

Hello Robert,

Thursday, June 8, 2006, 7:44:48 PM, you wrote:

>> if i correctly understand, this will not work on unix systems, while
>> without Win32 package program can't be compiled on my windows box.
>> what i can do here? only provide two separate cabal files - one for
>> unix, one for windows and give to user text instructions about
>> manual renaming of appropriate file?

> This brings up a feature I have sometimes wanted from Cabal.  I'd  
> like to be able to say the following: "Cabal, find and use package X  
> if it exists.  Furthermore, when CPPing source code, set a #define  
> HAS_PACKAGE_X so I can do conditional compilation based on the (non-) 
> avaliablility of package X".  Is this possible?  Difficult?  It seems
> like a nice way to handle a number of problems, including platform- 
> dependencies (as here) and optional features with external dependencies.

afair, there is already ticket for conditional enabling of some parts
of cabal file. but your idea is better. something like this:

required-lib: ArrayRef >= 0.1
optional-lib: FPS 0.7-0.9

and these preprocessor symbols should be defined to the actual
installed version of library. compiler dependencies can be tracked in
the same way:

required-lib: GHC 6.6

this can also be used to pass to the sources version of Hugs and any
other tools (drift, for example) that are used in compilation. cabal
file itself can be also processed two times - first to determine
required libs/tools, second to enable/disable sections according to
installed versions of these libs:

#ifdef HAS_GHC
optional-lib: FPS 0.7-0.9
#  ifdef HAS_FPS
#    if HAS_FPS==7
Exposed-modules: FastIO7.hs
#    else
Exposed-modules: FastIO.hs
#    endif
#  endif

Best regards,
 Bulat                            mailto:Bulat.Ziganshin at

More information about the Libraries mailing list