[Haskell-cafe] Conditional compilation for different versions of
GHC?
Michael Snoyman
michael at snoyman.com
Sat Nov 27 19:56:04 CET 2010
No, the user doesn't need to do anything. By splitting up the "base"
range into pre-7 and post-7, cabal automatically applies the ghc7 flag
(and thus adds the GHC7 CPP declaration) as appropriate.
Michael
On Sat, Nov 27, 2010 at 7:59 PM, Jinjing Wang <nfjinjing at gmail.com> wrote:
> 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