[GHC] #10820: Provide a way to detect what extensions are enabled via TH
#10820: Provide a way to detect what extensions are enabled via TH -------------------------------------+------------------------------------- Reporter: spinda | Owner: Type: feature | Status: new request | Priority: normal | Milestone: Component: Template | Version: 7.10.2 Haskell | Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Revisions: | -------------------------------------+------------------------------------- This would be helpful for providing users with intuitive error messages if generated code relies on an extension that the user may not have enabled. Sample specification, to get things started: {{{ enabledExts :: Q [Extension] isExtEnabled :: Extension -> Q Bool data Extension = LiberalTypeSynonyms | RankNTypes | ... -- mirroring ExtensionFlag in DynFlags }}} See #10819 for an example case where this could be of use. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10820> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#10820: Provide a way to detect what extensions are enabled via TH -------------------------------------+------------------------------------- Reporter: spinda | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Template Haskell | Version: 7.10.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Description changed by spinda: Old description:
This would be helpful for providing users with intuitive error messages if generated code relies on an extension that the user may not have enabled.
Sample specification, to get things started:
{{{ enabledExts :: Q [Extension] isExtEnabled :: Extension -> Q Bool data Extension = LiberalTypeSynonyms | RankNTypes | ... -- mirroring ExtensionFlag in DynFlags }}}
See #10819 for an example case where this could be of use.
New description: This would be helpful for providing users with intuitive/explanatory error messages if generated code relies on an extension that the user may not have enabled. Sample specification, to get things started: {{{ enabledExts :: Q [Extension] isExtEnabled :: Extension -> Q Bool data Extension = LiberalTypeSynonyms | RankNTypes | ... -- mirroring ExtensionFlag in DynFlags }}} See #10819 for an example case where this could be of use. -- -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10820#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#10820: Provide a way to detect what extensions are enabled via TH -------------------------------------+------------------------------------- Reporter: spinda | Owner: Type: feature request | Status: new Priority: normal | Milestone: 7.12.1 Component: Template Haskell | Version: 7.10.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by goldfire): * milestone: => 7.12.1 Comment: I've wanted this, too. It should be able to happen by 7.12. But, what data type to use for the extensions? Would it work to have `template-haskell` depend on `Cabal` to pull the extension type from there? My guess: no. Would it work to have `template-haskell` depend on `ghc` and pull the type from `DynFlags`? My guess: yes. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10820#comment:2> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#10820: Provide a way to detect what extensions are enabled via TH -------------------------------------+------------------------------------- Reporter: spinda | Owner: Type: feature request | Status: new Priority: normal | Milestone: 7.12.1 Component: Template Haskell | Version: 7.10.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by spinda): Would it work to have template-haskell depend on ghc and pull the type from DynFlags? My guess: yes. Wouldn't this create a mutually recursive package dependency, as {{{ghc}}} already depends on {{{template-haskell}}}? (see [https://github.com/ghc/ghc/blob/b4ed13000cf0cbbb5916727dad018d91c10f1fd8/com... ghc.cabal.in] and [https://github.com/ghc/ghc/blob/master/compiler/typecheck/TcSplice.hs#L105 TcSplice]) -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10820#comment:3> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#10820: Provide a way to detect what extensions are enabled via TH -------------------------------------+------------------------------------- Reporter: spinda | Owner: Type: feature request | Status: new Priority: normal | Milestone: 7.12.1 Component: Template Haskell | Version: 7.10.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by goldfire): Bah. Of course you're right. And I don't think it's a great idea to depend on `Cabal` because that package can be upgraded independently of GHC. Correct me if this wouldn't cause pain. I guess we could have Yet Another List Of Extensions. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10820#comment:4> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#10820: Provide a way to detect what extensions are enabled via TH -------------------------------------+------------------------------------- Reporter: spinda | Owner: spinda Type: feature request | Status: new Priority: normal | Milestone: 7.12.1 Component: Template Haskell | Version: 7.10.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | th/T18020.hs Blocked By: | Blocking: Related Tickets: | Differential Revisions: Phab:D1200 -------------------------------------+------------------------------------- Changes (by spinda): * owner: => spinda * testcase: => th/T18020.hs * differential: => Phab:D1200 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10820#comment:5> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#10820: Provide a way to detect what extensions are enabled via TH -------------------------------------+------------------------------------- Reporter: spinda | Owner: spinda Type: feature request | Status: new Priority: normal | Milestone: 8.0.1 Component: Template Haskell | Version: 7.10.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: th/T18020.hs Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1200 -------------------------------------+------------------------------------- Comment (by Ben Gamari <ben@…>): In [changeset:"c1e25536d67fba33ad6ddae5556115340d99000a/ghc" c1e2553/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="c1e25536d67fba33ad6ddae5556115340d99000a" Expose enabled language extensions to TH This exposes `template-haskell` functions for querying the language extensions which are enabled when compiling a module, - an `isExtEnabled` function to check whether an extension is enabled - an `extsEnabled` function to obtain a full list of enabled extensions To avoid code duplication this adds a `GHC.LanguageExtensions` module to `ghc-boot` and moves `DynFlags.ExtensionFlag` into it. A happy consequence of this is that the ungainly `DynFlags` lost around 500 lines. Moreover, flags corresponding to language extensions are now clearly distinguished from other flags due to the `LangExt.*` prefix. Updates haddock submodule. This fixes #10820. Test Plan: validate Reviewers: austin, spinda, hvr, goldfire, alanz Reviewed By: goldfire Subscribers: mpickering, RyanGlScott, hvr, simonpj, thomie Differential Revision: https://phabricator.haskell.org/D1200 GHC Trac Issues: #10820 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10820#comment:7> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#10820: Provide a way to detect what extensions are enabled via TH -------------------------------------+------------------------------------- Reporter: spinda | Owner: spinda Type: feature request | Status: closed Priority: normal | Milestone: 8.0.1 Component: Template Haskell | Version: 7.10.2 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: th/T18020.hs Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1200 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: new => closed * resolution: => fixed -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10820#comment:8> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#10820: Provide a way to detect what extensions are enabled via TH -------------------------------------+------------------------------------- Reporter: spinda | Owner: spinda Type: feature request | Status: closed Priority: normal | Milestone: 8.0.1 Component: Template Haskell | Version: 7.10.2 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: th/T18020.hs Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D1200 Wiki Page: | -------------------------------------+------------------------------------- Description changed by bgamari: Old description:
This would be helpful for providing users with intuitive/explanatory error messages if generated code relies on an extension that the user may not have enabled.
Sample specification, to get things started:
{{{ enabledExts :: Q [Extension] isExtEnabled :: Extension -> Q Bool data Extension = LiberalTypeSynonyms | RankNTypes | ... -- mirroring ExtensionFlag in DynFlags }}}
See #10819 for an example case where this could be of use.
New description: This would be helpful for providing users with intuitive/explanatory error messages if generated code relies on an extension that the user may not have enabled. Sample specification, to get things started: {{{#!hs enabledExts :: Q [Extension] isExtEnabled :: Extension -> Q Bool data Extension = LiberalTypeSynonyms | RankNTypes | ... -- mirroring ExtensionFlag in DynFlags }}} See #10819 for an example case where this could be of use. -- -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10820#comment:9> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (1)
-
GHC