[GHC] #11046: lookupTypeName does not support type operators
#11046: lookupTypeName does not support type operators -------------------------------------+------------------------------------- Reporter: oerjan | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Template | Version: 7.10.2 Haskell | Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: GHC rejects Unknown/Multiple | valid program Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- The following non-working code (minus a missing import) was [http://stackoverflow.com/questions/33465109/template-haskell-how-to- lookup-type-operator-name posted on stackoverflow]: `IssueTH.hs`: {{{#!hs {-# LANGUAGE TemplateHaskell #-} module IssueTH where import Language.Haskell.TH f :: Q [Dec] f = do Just n <- lookupTypeName "GHC.TypeLits.*" return [] }}} `Issue.hs`: {{{#!hs {-# LANGUAGE TemplateHaskell #-} module Issue where import IssueTH import GHC.TypeLits $f }}} `ghc Issue.hs` fails with message: `Pattern match failure in do expression at IssueTH.hs:7:5-10` This gives no error if `*` is replaced by an alphanumeric type like `Nat`. Similar tests seem to fail whenever attempting to look up a type operator with `lookupTypeName`. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11046> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11046: lookupTypeName does not support type operators -------------------------------------+------------------------------------- Reporter: oerjan | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Template Haskell | Version: 7.10.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: GHC rejects | Unknown/Multiple valid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by oerjan): On a hunch I did a further test: `lookupTypeName` ''does'' work with a type operator if it starts with `:`. A bit more flexible test file: {{{#!hs {-# LANGUAGE TemplateHaskell #-} module IssueTH where import Language.Haskell.TH f :: String -> Q [Dec] f n = do Just n <- lookupTypeName n return [] }}} And then in GHCi: {{{ *IssueTH> :set -XTypeOperators *IssueTH> :set -XTemplateHaskell *IssueTH> data a :& b = A *IssueTH> data a & b = B *IssueTH> data Dummy; $(f ":&") *IssueTH> data Dummy; $(f "&") <interactive>:7:15: Pattern match failure in do expression at IssueTH.hs:9:5-10 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11046#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11046: lookupTypeName does not support type operators not starting with : -------------------------------------+------------------------------------- Reporter: oerjan | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Template Haskell | Version: 7.10.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: GHC rejects | Unknown/Multiple valid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11046#comment:2> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11046: lookupTypeName does not support type operators not starting with : -------------------------------------+------------------------------------- Reporter: oerjan | Owner: Type: bug | Status: new Priority: high | Milestone: 8.0.1 Component: Template Haskell | Version: 7.10.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: GHC rejects | Unknown/Multiple valid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by vagarenko): * cc: vagarenko (added) * priority: normal => high * milestone: => 8.0.1 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11046#comment:3> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11046: lookupTypeName does not support type operators not starting with : -------------------------------------+------------------------------------- Reporter: oerjan | Owner: Type: bug | Status: new Priority: high | Milestone: 8.0.1 Component: Template Haskell | Version: 7.10.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: GHC rejects | Unknown/Multiple valid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by thomie): Relevant commit 85926ae6c63a62e4f23423f220588875c8f1ab45: {{{ Author: Iavor S. Diatchki <iavor.diatchki@gmail.com> Date: Sun Jan 8 16:33:51 2012 -0800 Change -XTypeOperators to treat all type-operators as type- constructors. Previously, only type operators starting with ":" were type constructors, and writing "+" in a type resulted in a type variable. Now, type variables are always ordinary identifiers, and all operators are treated as constructors. One can still write type variables in infix form though, for example, "a `fun` b" is a type expression with 3 type variables: "a", "fun", and "b". Writing (+) in an import/export list always refers to the value (+) and not the type. To refer to the type one can write either "type (+)", or provide an explicit suobrdinate list (e.g., "(+)()"). For clarity, one can also combine the two, for example "type (+)(A,B,C)" is also accepted and means the same thing as "(+)(A,B,C)" (i.e., export the type (+), with the constructors A,B,and C). }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11046#comment:4> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11046: lookupTypeName does not support type operators not starting with : -------------------------------------+------------------------------------- Reporter: oerjan | Owner: Type: bug | Status: new Priority: high | Milestone: 8.0.1 Component: Template Haskell | Version: 7.10.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: GHC rejects | Test Case: valid program | testsuite/tests/th/TH_lookupName.hs Blocked By: | Blocking: Related Tickets: #10583 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by thomie): * testcase: => testsuite/tests/th/TH_lookupName.hs * related: => #10583 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11046#comment:5> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11046: lookupTypeName does not support type operators not starting with : -------------------------------------+------------------------------------- Reporter: oerjan | Owner: albertus Type: bug | Status: new Priority: high | Milestone: 8.0.1 Component: Template Haskell | Version: 7.10.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: GHC rejects | Test Case: valid program | testsuite/tests/th/TH_lookupName.hs, | testsuite/tests/th/T11046.hs Blocked By: | Blocking: Related Tickets: #10583 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by albertus): * owner: => albertus * testcase: testsuite/tests/th/TH_lookupName.hs => testsuite/tests/th/TH_lookupName.hs, testsuite/tests/th/T11046.hs -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11046#comment:6> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11046: lookupTypeName does not support type operators not starting with : -------------------------------------+------------------------------------- Reporter: oerjan | Owner: albertus Type: bug | Status: new Priority: high | Milestone: 8.0.1 Component: Template Haskell | Version: 7.10.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: GHC rejects | Test Case: valid program | testsuite/tests/th/TH_lookupName.hs, | testsuite/tests/th/T11046.hs Blocked By: | Blocking: Related Tickets: #10583 | Differential Rev(s): Phab:D1451 Wiki Page: | -------------------------------------+------------------------------------- Changes (by thomie): * differential: => Phab:D1451 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11046#comment:7> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11046: lookupTypeName does not support type operators not starting with : -------------------------------------+------------------------------------- Reporter: oerjan | Owner: albertus Type: bug | Status: new Priority: high | Milestone: 8.2.1 Component: Template Haskell | Version: 7.10.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: GHC rejects | Test Case: valid program | testsuite/tests/th/TH_lookupName.hs, | testsuite/tests/th/T11046.hs Blocked By: | Blocking: Related Tickets: #10583 | Differential Rev(s): Phab:D1451 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * milestone: 8.0.1 => 8.2.1 Comment: This won't be fixed for 8.0. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11046#comment:8> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11046: lookupTypeName does not support type operators not starting with : -------------------------------------+------------------------------------- Reporter: oerjan | Owner: albertus Type: bug | Status: new Priority: high | Milestone: 8.4.1 Component: Template Haskell | Version: 7.10.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: GHC rejects | Test Case: valid program | testsuite/tests/th/TH_lookupName.hs, | testsuite/tests/th/T11046.hs Blocked By: | Blocking: Related Tickets: #10583 | Differential Rev(s): Phab:D1451 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * milestone: 8.2.1 => 8.4.1 Comment: It doesn't look like this will be fixed for 8.2 either. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11046#comment:9> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11046: lookupTypeName does not support type operators not starting with : -------------------------------------+------------------------------------- Reporter: oerjan | Owner: albertus Type: bug | Status: new Priority: high | Milestone: 8.4.1 Component: Template Haskell | Version: 7.10.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: GHC rejects | Test Case: valid program | testsuite/tests/th/TH_lookupName.hs, | testsuite/tests/th/T11046.hs Blocked By: | Blocking: Related Tickets: #10583 | Differential Rev(s): Phab:D1451 Wiki Page: | -------------------------------------+------------------------------------- Comment (by Ben Gamari <ben@…>): In [changeset:"559357384e300355b62edb3d60dcc3fadb942a50/ghc" 5593573/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="559357384e300355b62edb3d60dcc3fadb942a50" Fixes bug #11046 For some time now, type-level operators such as '+' have been treated as type constructors, rahter than type variables. This pathc fixes TH's `lookupName` function to account for this behavior. Reviewers: bgamari, austin, goldfire, RyanGlScott Reviewed By: RyanGlScott Subscribers: Phyx, thomie Differential Revision: https://phabricator.haskell.org/D3025 GHC Trac Issues: #11046 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11046#comment:10> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11046: lookupTypeName does not support type operators not starting with : -------------------------------------+------------------------------------- Reporter: oerjan | Owner: albertus Type: bug | Status: closed Priority: high | Milestone: 8.4.1 Component: Template Haskell | Version: 7.10.2 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: GHC rejects | Test Case: valid program | testsuite/tests/th/TH_lookupName.hs, | testsuite/tests/th/T11046.hs Blocked By: | Blocking: Related Tickets: #10583 | Differential Rev(s): Phab:D1451 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: new => closed * resolution: => fixed -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11046#comment:11> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11046: lookupTypeName does not support type operators not starting with : -------------------------------------+------------------------------------- Reporter: oerjan | Owner: albertus Type: bug | Status: closed Priority: high | Milestone: 8.2.1 Component: Template Haskell | Version: 7.10.2 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: GHC rejects | Test Case: valid program | testsuite/tests/th/TH_lookupName.hs, | testsuite/tests/th/T11046.hs Blocked By: | Blocking: Related Tickets: #10583 | Differential Rev(s): Phab:D1451 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * milestone: 8.4.1 => 8.2.1 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11046#comment:12> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (1)
-
GHC