In addition to the very useful flags defined by the GHC (OS, architecture, etc.), other flags and macros are defined when using bondage.
Check package version
This uses crypto-api , which checks the version of the tagged package being used:
#if MIN_VERSION_tagged(0,2,0) import Data.Proxy #endif
Custom CPP Defines Based on Cabal Flags
You can define CPP characters depending on cabal flags. Here's a (optionally complicated) example from pureMD5 (from a .cabal file):
if arch(i386) || arch(x86_64) cpp-options: -DFastWordExtract
Inside the .hs module .hs you can use #ifdef , for example:
#ifdef FastWordExtract getNthWord nb = inlinePerformIO (unsafeUseAsCString b (flip peekElemOff n . castPtr)) #else ... other code ... #endif
For more information, you can see the Cabal user guide. This page contains conditional compilation information that you are probably looking for.
Thomas M. DuBuisson Jun 15 '11 at 17:50 2011-06-15 17:50
source share