[GHC] #9734: Provide macro __GLASGOW_HASKELL_TH__
#9734: Provide macro __GLASGOW_HASKELL_TH__ -------------------------------------+------------------------------------- Reporter: nomeata | Owner: Type: feature request | Status: new Priority: normal | Milestone: 7.10.1 Component: Compiler | Version: 7.8.3 Keywords: | Operating System: Architecture: Unknown/Multiple | Unknown/Multiple Difficulty: Unknown | Type of failure: Blocked By: | None/Unknown Related Tickets: | Test Case: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- The Debian packaging added a few hacks to create a CPP macro that can be used to distinguish compilers with Template Haskell support from those that don’t have that support. We need this to compiler some code on non- TH architectures. It works, but we found that we cannot upstream such patches, which is a shame. I propose that among the GHC-defined macros listed at https://www.haskell.org/ghc/docs/latest/html/users_guide/options- phases.html#c-pre-processor there is also `__GLASGOW_HASKELL_TH__=YES`, which is available if the compiler supports splices, or ``__GLASGOW_HASKELL_TH__=NO` if not. (I propose a two-valued comparison so that library authors can decide themselves what the default should be if this symbol is not defined, some might want to use TH on older compilers, some not.) I hope this can be part of 7.10. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9734> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#9734: Provide macro __GLASGOW_HASKELL_TH__ -------------------------------------+------------------------------------- Reporter: nomeata | Owner: Type: feature | Status: new request | Milestone: 7.10.1 Priority: normal | Version: 7.8.3 Component: Compiler | Keywords: Resolution: | Architecture: Unknown/Multiple Operating System: | Difficulty: Unknown Unknown/Multiple | Blocked By: Type of failure: | Related Tickets: None/Unknown | Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Description changed by nomeata: Old description:
The Debian packaging added a few hacks to create a CPP macro that can be used to distinguish compilers with Template Haskell support from those that don’t have that support. We need this to compiler some code on non- TH architectures.
It works, but we found that we cannot upstream such patches, which is a shame.
I propose that among the GHC-defined macros listed at https://www.haskell.org/ghc/docs/latest/html/users_guide/options- phases.html#c-pre-processor there is also `__GLASGOW_HASKELL_TH__=YES`, which is available if the compiler supports splices, or ``__GLASGOW_HASKELL_TH__=NO` if not.
(I propose a two-valued comparison so that library authors can decide themselves what the default should be if this symbol is not defined, some might want to use TH on older compilers, some not.)
I hope this can be part of 7.10.
New description: The Debian packaging added a few hacks to create a CPP macro that can be used to distinguish compilers with Template Haskell support from those that don’t have that support. We need this to compiler some code on non- TH architectures. It works, but we found that we cannot upstream such patches, which is a shame. I propose that among the GHC-defined macros listed at https://www.haskell.org/ghc/docs/latest/html/users_guide/options- phases.html#c-pre-processor there is also `__GLASGOW_HASKELL_TH__=YES`, which is available if the compiler supports splices, or `__GLASGOW_HASKELL_TH__=NO` if not. (I propose a two-valued comparison so that library authors can decide themselves what the default should be if this symbol is not defined, some might want to use TH on older compilers, some not.) I hope this can be part of 7.10. -- -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9734#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#9734: Provide macro __GLASGOW_HASKELL_TH__ -------------------------------------+------------------------------------- Reporter: nomeata | Owner: Type: feature | Status: patch request | Milestone: 7.10.1 Priority: normal | Version: 7.8.3 Component: Compiler | Keywords: Resolution: | Architecture: Unknown/Multiple Operating System: | Difficulty: Unknown Unknown/Multiple | Blocked By: Type of failure: | Related Tickets: None/Unknown | Test Case: | Blocking: | Differential Revisions: Phab:D386 | -------------------------------------+------------------------------------- Changes (by nomeata): * status: new => patch * differential: => Phab:D386 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9734#comment:2> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#9734: Provide macro __GLASGOW_HASKELL_TH__ -------------------------------------+------------------------------------- Reporter: nomeata | Owner: Type: feature | Status: patch request | Milestone: 7.10.1 Priority: normal | Version: 7.8.3 Component: Compiler | Keywords: Resolution: | Architecture: Unknown/Multiple Operating System: | Difficulty: Unknown Unknown/Multiple | Blocked By: Type of failure: | Related Tickets: None/Unknown | Test Case: | Blocking: | Differential Revisions: Phab:D386 | -------------------------------------+------------------------------------- Comment (by Austin Seipp <austin@…>): In [changeset:"c211f8e55b8dd1d43854ce3c4554ffbafb0009f9/ghc"]: {{{ #!CommitTicketReference repository="ghc" revision="c211f8e55b8dd1d43854ce3c4554ffbafb0009f9" Add __GLASGOW_HASKELL_TH__=YES/NO to CPP definitions Test Plan: None really. Reviewers: austin Reviewed By: austin Subscribers: thomie, carter, simonmar Differential Revision: https://phabricator.haskell.org/D386 GHC Trac Issues: #9734 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9734#comment:3> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#9734: Provide macro __GLASGOW_HASKELL_TH__ -------------------------------------+------------------------------------- Reporter: nomeata | Owner: Type: feature | Status: closed request | Milestone: 7.10.1 Priority: normal | Version: 7.8.3 Component: Compiler | Keywords: Resolution: fixed | Architecture: Unknown/Multiple Operating System: | Difficulty: Unknown Unknown/Multiple | Blocked By: Type of failure: | Related Tickets: None/Unknown | Test Case: | Blocking: | Differential Revisions: Phab:D386 | -------------------------------------+------------------------------------- Changes (by nomeata): * status: patch => closed * resolution: => fixed Comment: Thanks! -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9734#comment:4> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#9734: Provide macro __GLASGOW_HASKELL_TH__ -------------------------------------+------------------------------------- Reporter: nomeata | Owner: Type: feature request | Status: closed Priority: normal | Milestone: 7.10.1 Component: Compiler | Version: 7.8.3 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #11322 | Differential Rev(s): Phab:D386 Wiki Page: | -------------------------------------+------------------------------------- Changes (by hvr): * related: => #11322 Comment: Turns out, using `YES`/`NO` as values for CPP constants is not a good idea... :-/ -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9734#comment:5> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#9734: Provide macro __GLASGOW_HASKELL_TH__ -------------------------------------+------------------------------------- Reporter: nomeata | Owner: Type: feature request | Status: closed Priority: normal | Milestone: 7.10.1 Component: Compiler | Version: 7.8.3 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #11322 | Differential Rev(s): Phab:D386 Wiki Page: | -------------------------------------+------------------------------------- Comment (by Herbert Valerio Riedel <hvr@…>): In [changeset:"eae40e16a0933fe3b6cb0ee4dc9cdbe3d21e44ce/ghc" eae40e1/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="eae40e16a0933fe3b6cb0ee4dc9cdbe3d21e44ce" Use 0/1 instead of YES/NO as `__GLASGOW_HASKELL_TH__` macro value Using `YES`/`NO` causes all sorts of problems as CPP doesn't work on symbolic tokens but rather on scalar values. A use like #if __GLASGOW_HASKELL_TH__==YES {-# LANGUAGE TemplateHaskell #-} #endif doesn't do what one may naively expect, and neither does #if __GLASGOW_HASKELL_TH__ {-# LANGUAGE TemplateHaskell #-} #endif *unless* `YES` happens to evaluate to a non-zero scalar. `__GLASGOW_HASKELL_TH__ was originally introduced via D396 / #9734. Fixes #11322 Reviewed By: austin Differential Revision: https://phabricator.haskell.org/D1723 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9734#comment:6> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (1)
-
GHC