[GHC] #15551: TH-reified type classes have redundant tyvars/class constraints on each method
#15551: TH-reified type classes have redundant tyvars/class constraints on each method -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.8.1 Component: Template | Version: 8.4.3 Haskell | Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- If you try to reify a type class in Template Haskell, as in the following example: {{{#!hs {-# LANGUAGE TemplateHaskell #-} module Bug where import Language.Haskell.TH class C a where method :: a $(pure []) main :: IO () main = putStrLn $(reify ''C >>= stringE . pprint) }}} You'll discover something strange: {{{ $ /opt/ghc/8.4.3/bin/runghc Bug.hs class Bug.C (a_0 :: *) where Bug.method :: forall (a_0 :: *) . Bug.C a_0 => a_0 }}} Notice how `method` has a completely redundant `forall (a_0 :: *) . Bug.C a_0 =>`! I find this very strange, and would have expected to simply see `Bug.method :: a_0` instead. Currently, I have to work around this oddity by manually stripping off the `forall (a_0 :: *) . Bug.C a_0 =>` myself, but it would be nice if I didn't have to do so. Does this proposal sound reasonable? -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15551> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#15551: TH-reified type classes have redundant tyvars/class constraints on each method -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: (none) Type: bug | Status: patch Priority: normal | Milestone: 8.8.1 Component: Template Haskell | Version: 8.4.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D5088 Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * status: new => patch * differential: => Phab:D5088 Comment: I decided to be bold and just fix this. See Phab:D5088. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15551#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#15551: TH-reified type classes have redundant tyvars/class constraints on each method -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: (none) Type: bug | Status: patch Priority: normal | Milestone: 8.8.1 Component: Template Haskell | Version: 8.4.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D5088 Wiki Page: | -------------------------------------+------------------------------------- Comment (by Krzysztof Gogolewski <krz.gogolewski@…>): In [changeset:"6e765aebbe0a565f2476b522a49faf8edb9a93ee/ghc" 6e765ae/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="6e765aebbe0a565f2476b522a49faf8edb9a93ee" Don't reify redundant class method tyvars/contexts Summary: Currently, reifying classes produces class methods with redundant tyvars and class contexts in their type signatures, such as in the following: ```lang=haskell class C a where method :: forall a. C a => a ``` Fixing this is very straightforward: just apply `tcSplitMethodTy` to the type of each class method to lop off the redundant parts. It's possible that this could break some TH code in the wild that assumes the existence of these tyvars and class contexts, so I'll advertise this change in the release notes just to be safe. Test Plan: make test TEST="TH_reifyDecl1 T9064 T10891 T14888" Reviewers: goldfire, bgamari, simonpj Reviewed By: simonpj Subscribers: simonpj, rwbarton, carter GHC Trac Issues: #15551 Differential Revision: https://phabricator.haskell.org/D5088 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15551#comment:2> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#15551: TH-reified type classes have redundant tyvars/class constraints on each method -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: (none) Type: bug | Status: merge Priority: normal | Milestone: 8.6.1 Component: Template Haskell | Version: 8.4.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D5088 Wiki Page: | -------------------------------------+------------------------------------- Changes (by monoidal): * status: patch => merge * milestone: 8.8.1 => 8.6.1 Comment: If it's not too late, this can be merged to 8.6. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15551#comment:3> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#15551: TH-reified type classes have redundant tyvars/class constraints on each method -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: 8.8.1 Component: Template Haskell | Version: 8.4.3 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D5088 Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * status: merge => closed * resolution: => fixed * milestone: 8.6.1 => 8.8.1 Comment: I'm going to request that this //not// be merged to GHC 8.6.1, since it has the potential to break code which assumes the existence of these redundant tyvars/class constraints when reified. (I'll update the Migration Guide for 8.8 to address this.) -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15551#comment:4> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#15551: TH-reified type classes have redundant tyvars/class constraints on each method -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: 8.8.1 Component: Template Haskell | Version: 8.4.3 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D5088 Wiki Page: | -------------------------------------+------------------------------------- Comment (by monoidal): I'm sorry, I updated the wrong ticket. I agree. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15551#comment:5> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (1)
-
GHC