Jens Petersen
Jens Petersen

Reputation: 191

Is it possible to turn off a Cabal flag for older ghc?

In my project's .cabal file I have a flag to control where to use https. However http-client doesn't build well with much older ghc versions... Is there a way to change the default for the flag for older ghc?

I can't see one or any other workaround (other than ignoring the flag).

Upvotes: 3

Views: 99

Answers (1)

Daniel Wagner
Daniel Wagner

Reputation: 152707

I haven't tested, but I would guess something like this works.

flag foo
    if impl(ghc > 7.10)
         default: True
    else
         default: False

Even if not, you can at least make the error appear early by making each stanza unbuildable in bad configurations, e.g.

executable foo
    if (impl(ghc > 7.10) && !foo) || (impl(ghc <= 7.10) && foo)
        buildable: False

Upvotes: 1

Related Questions