[Haskell-cafe] Conditional compilation for different versions of
GHC?
Jinjing Wang
nfjinjing at gmail.com
Sat Nov 27 18:59:16 CET 2010
Thanks Michael,
So the user should use `cabal install --flags -ghc7 package-name` to
install the package, if I'm not mistaken?
Will it work if the package is installed as a dependency? Will the
flag environment be passed down from the root package?
Is there a way to detect GHC version automatically?
: )
Best,
On Sun, Nov 28, 2010 at 1:32 AM, Michael Snoyman <michael at snoyman.com> wrote:
> On Sat, Nov 27, 2010 at 6:59 PM, Jinjing Wang <nfjinjing at gmail.com> wrote:
>> Dear list,
>>
>> >From ghc 7.0.1 release notes:
>>
>>> The Language.Haskell.TH.Quote.QuasiQuoter type has two new fields: quoteType and quoteDec.
>>
>> Some of my code needs to be conditionally compiled to support both
>> version 6 and 7, what is the recommended way to do it?
>>
>> ref:
>>
>> * http://new-www.haskell.org/ghc/docs/7.0.1/html/users_guide/release-7-0-1.html
>
> Hi Jinjing,
>
> I've done this in Yesod. I'm not sure if it's the best way, but
> basically I've added a ghc7 flag to the cabal file, and a block for
> the library that reads:
>
> if flag(ghc7)
> build-depends: base >= 4.3 && < 5
> cpp-options: -DGHC7
> else
> build-depends: base >= 4 && < 4.3
>
> Then whenever I want to quasi-quote in the code, I write:
>
> #if GHC7
> [quasiquoter|
> #else
> [$quasiquoter|
> #endif
>
> Michael
>
--
jinjing
More information about the Haskell-Cafe
mailing list