Hi,<br><br>I'm bringing up an old thread, because it's very relevant to my problem.<br><br><div class="gmail_quote">On Tue, Nov 18, 2008 at 22:30, Duncan Coutts<span dir="ltr"></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d">On Tue, 2008-11-18 at 01:48 -0800, Jason Dusek wrote:<br>
> I'd like to be able to do something like:<br>
><br>
> if (template-haskell < 2.3)<br>
> cpp-options: -D TH_THE_YOUNGER<br>
> else<br>
> cpp-options: -D TH_THE_ELDER<br>
><br>
> I guess this kind of thing is not possible at present?<br>
<br>
</div>It is possible, in two different ways.<br>
<br>
The easiest way is that if you're using Cabal-1.6 then it provides cpp<br>
macros to test the version number of packages you're using.<br>
<br>
#if MIN_VERSION_template_haskell(2,3,0)<br>
...<br>
#elseif<br>
...<br>
#endif<br>
<br>
The alternative that works back to Cabal-1.2 is to use:<br>
<br>
flag newer-th<br>
<br>
...<br>
if flag(newer-th)<br>
build-depends: template-haskell >= 2.3<br>
cpp-options: -D TH_THE_ELDER<br>
else<br>
build-depends: template-haskell < 2.3<br>
<div class="Ih2E3d"> cpp-options: -D TH_THE_YOUNGER<br></div></blockquote></div><br>Either I'm doing something wrong or this doesn't work for cabal-install and GHC 6.8.3. I used the "flag newer-th" approach in EMGM:<br>
<br> <a href="https://svn.cs.uu.nl:12443/viewvc/dgp-haskell/EMGM/tags/emgm-0.2/emgm.cabal?view=markup">https://svn.cs.uu.nl:12443/viewvc/dgp-haskell/EMGM/tags/emgm-0.2/emgm.cabal?view=markup</a><br><br><span style="font-family: courier new,monospace;">[...]</span><br style="font-family: courier new,monospace;">
<br><span style="font-family: courier new,monospace;">flag th23</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> description: Define a CPP flag that enables conditional compilation<br>
for template-haskell package version 2.3 and newer.</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">Library</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> [...]</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> build-depends: base >= 3.0 && < 4.0,</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> template-haskell < 2.4</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> -- Include deriveRep for Loc. This was introduced with</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> -- template-haskell-2.3, included with GHC 6.10.</span><span style="font-family: courier new,monospace;"><br> if flag(th23)</span><span style="font-family: courier new,monospace;"><br>
build-depends: template-haskell >= 2.3</span><span style="font-family: courier new,monospace;"><br> cpp-options: -DTH_LOC_DERIVEREP</span><span style="font-family: courier new,monospace;"><br> else</span><span style="font-family: courier new,monospace;"><br>
build-depends: template-haskell < 2.3</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> [...]</span><br style="font-family: courier new,monospace;">
<br>When I run <span style="font-family: courier new,monospace;">cabal install emgm</span> (with GHC 6.8.3 and either Cabal 1.2 or 1.6), it tries (and fails) to install template-haskell-2.3. That's exactly what I don't want. Any suggestions?<br>
<br>Thanks,<br>Sean<br>