-
Notifications
You must be signed in to change notification settings - Fork 29
Description
Currently, happstack has
Flag template_haskell
Description: Template Haskell is available on this system
Default: True
Manual: True
...
Library:
if (flag(template_haskell) && !(arch(arm)))
Build-Depends: template-haskell
cpp-options: -DTEMPLATE_HASKELL
...
Extensions: TemplateHaskell
There's a couple of problems here (with cabal-1.24 & GHC 8.0)
If the TH-flag is set to false (or arch=arm), this package still won't build when GHC doesn't support TH, because then extensions: TemplateHaskell will still be in effect, and GHC will fail complaining it doesn't support TH.
And with cabal-1.24, the solver will already exclude packages during solving where extensions: TemplateHaskell when GHC doesn't support that extension.
Moreover, arch(arm) is not the only platform lacking TH support. However, since cabal knows when your environment supports TH, you should let cabal decide.
Consequently, I suggest the following definitions instead:
Use an automatic flag for declaring TH support, and make sure this flag doesn't have any other pressure applied other than other-extensions: TemplateHaskell or default-extensions: TemplateHaskell, i.e.
Flag template_haskell
Description: Template Haskell is available on this system
Default: True
Manual: False
Library:
-- the TH library is available even in environments lacking -XTemplateHaskell support
-- placing this outside the conditional allows adding upper bounds after-the-fact on hackage w/o adding solver-pressure to the flag
Build-Depends: template-haskell
if flag(template_haskell)
cpp-options: -DTEMPLATE_HASKELL
-- other-extensions doesn't enable the extension; this only declares which LANGUAGE pragmas may be used
other-extensions: TemplateHaskell
this will cause cabal (starting with 1.24) to set the template_haskell flag depending on whether the compiler supports TH.