MIN_VERSION_foo() macro vs. CABAL-flag directed API-adaption

wren ng thornton wren at freegeek.org
Thu Sep 20 00:49:00 CEST 2012


On 9/18/12 6:41 AM, Herbert Valerio Riedel wrote:
> Hello,
>
> When I noticed the recently released HTTP-4000.2.5[1] package used a
> CABAL-flag based approach[2] for what I expected the use of a macro
> MIN_VERSION_network(2,4,0) to be more appropriate (see [3]), 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.

-- 
Live well,
~wren



More information about the Libraries mailing list