[GHC] #15551: TH-reified type classes have redundant tyvars/class constraints on each method

GHC ghc-devs at haskell.org
Tue Aug 21 14:40:04 UTC 2018


#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


More information about the ghc-tickets mailing list