MIN_VERSION_foo() macro vs. CABAL-flag directed API-adaption
wren ng thornton
wren at freegeek.org
Thu Sep 20 00:52:37 CEST 2012
On 9/19/12 6:49 PM, wren ng thornton wrote:
> On 9/18/12 6:41 AM, Herbert Valerio Riedel wrote:
>> When I noticed the recently released HTTP-4000.2.5 package used a
>> CABAL-flag based approach for what I expected the use of a macro
>> MIN_VERSION_network(2,4,0) to be more appropriate (see ), I wasn't
>> totally sure whether there was any down-side with the
>> MIN_VERSION_-approach. So my question is:
>> Is it always desirable to prefer the MIN_VERSION_ approach over a
>> CABAL-flag approach for supporting multiple API versions of a
>> dependent package (if both ways are possible)? And if not, when
>> should I prefer which approach?
> If CPP is required, then I think it's preferable to use Cabal's
> MIN_VERSION macros; since, (1) Cabal can figure out the exact
> incantations for you, rather than foisting it upon users, and (2) it
> makes things more consistent across the Haskell ecosystem.
> However, the MIN_VERSION macros don't always work. In particular, they
> don't play nice with the hsc2hs preprocessor (and possibly other
> preprocessors as well). So in these cases one must resort to other hackery.
Oh, also, it's standard practice to use flags for dealing with the
vagaries of what's in Base at any given moment. Though this is more for
enabling Cabal conditionals, rather than for CPP stuff.
More information about the Libraries