Cabal HackORama -- how to handle par and pseq on stable platforms

I am writing a Cabal file for an application that uses par and pseq. I want to support both modern distributions of GHC and the version that comes with Ubuntu Hardy Heron, a Long Term Support version of Ubuntu that will be retired in April 2011. It provides GHC 6.8.2 with Cabal 1.2.3.0 and no parallel package. You might be interested in my solution to supporting both releases. I did the obvious in my Cabal file. A defined a flag as follows: -- Disable with -f-par option during configuration. Flag Par Description: Enable use of the parallel construct par Default: True The description of the executable includes: if flag(par) Cpp-Options: -DHAVE_PAR GHC-Options: -threaded Build-Depends: parallel The C preprocessor is used to toggle between a parallel version of map and the usual one. #if defined HAVE_PAR parMap :: (a -> b) -> [a] -> [b] parMap _ [] = [] parMap f (x:xs) = par y (pseq ys (y:ys)) where y = f x ys = parMap f xs #else parMap :: (a -> b) -> [a] -> [b] parMap = map #endif Here is what makes this cabal file sweet. Cabal 1,2,3.0 supports flags, but ignores the Default specification. It assumes the default value of every flag is False. Thus, for both modern versions of GHC and the one on Hardy Heron, no user supplied flags are required during configuration. John
participants (1)
-
John D. Ramsdell