You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
While we're at it, I'd have a few more suggestions :-)
I suspect that happstack-server doesn't support any GHC version before 7.0; in that case I'd suggest to use Cabal-Version: >= 1.10
Then I see that the code makes seems to make use of {-# LANGUAGE #-} anyway; and the obsolete exceptions: ... declaration is the deprecated name for default-exceptions: ..., in fact if you update the cabal-version field, cabal will tell you:
Warning: For packages using cabal-version: >= 1.10 the extensions field is deprecated. The new default-extensions field lists extensions that are used in all modules in the component, while the other-extensions field lists extensions that are used in some modules, e.g. via the {-# LANGUAGE #-} pragma.
So I'd recommend to try to make more use of other-extensions if you use {-# LANGUAGE #-} anyway. Fwiw, I'm working extending the cabal tooling to help maintain the other-extensions list.
PS: I'll try to build happstack-server on a TH-less GHC to see if there's anything else to take care of
Activity
attempt to improve template_haskell flag as described here, #28
stepcut commentedon Jun 10, 2016
Does this patch,
ede159b
Correctly implement your suggestions?
hvr commentedon Jun 10, 2016
@stepcut yes, looks good!
While we're at it, I'd have a few more suggestions :-)
I suspect that
happstack-serverdoesn't support any GHC version before 7.0; in that case I'd suggest to useCabal-Version: >= 1.10Then I see that the code makes seems to make use of
{-# LANGUAGE #-}anyway; and the obsoleteexceptions: ...declaration is the deprecated name fordefault-exceptions: ..., in fact if you update thecabal-versionfield, cabal will tell you:So I'd recommend to try to make more use of
other-extensionsif you use{-# LANGUAGE #-}anyway. Fwiw, I'm working extending the cabal tooling to help maintain theother-extensionslist.PS: I'll try to build
happstack-serveron a TH-less GHC to see if there's anything else to take care of