[GHC] #14190: Typeable imposes seemingly redundant constraints on polykinded instances

GHC ghc-devs at haskell.org
Thu Sep 7 14:34:37 UTC 2017


#14190: Typeable imposes seemingly redundant constraints on polykinded instances
-------------------------------------+-------------------------------------
        Reporter:  dfeuer            |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:  8.4.1
       Component:  Compiler (Type    |              Version:  8.2.1
  checker)                           |             Keywords:
      Resolution:                    |  TypeableReflection
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by RyanGlScott):

 Sorry, I think I woefully misunderstood the point you were making. You're
 not arguing that we shouldn't require `k` to be a `Typeable` instance, but
 rather than if you have `Typeable (a :: k)`, then that //implies//
 `Typeable k`. I must admit I wasn't aware of the `weGotThis` trick you
 showed off above. Here's a version that doesn't depend on the
 `constraints` library:

 {{{#!hs
 {-# LANGUAGE AllowAmbiguousTypes #-}
 {-# LANGUAGE ScopedTypeVariables #-}
 {-# LANGUAGE TypeApplications #-}
 {-# LANGUAGE TypeInType #-}

 import Type.Reflection

 hm :: forall k (a :: k). Typeable a => TypeRep k
 hm = withTypeable (typeRepKind (typeRep @a)) (typeRep @k)
 }}}

 In light of this, your suggestion to make `Typeable k` a superclass of
 `Typeable (a :: k)` makes much more sense. In fact, there was some
 [https://github.com/ghc-proposals/ghc-
 proposals/pull/16#issuecomment-255645119 discussion] about this on the
 corresponding GHC proposal, but it didn't seem to make it into
 [http://git.haskell.org/ghc.git/blob/055d73c6576bed2affaf96ef6a6b89aeb2cd2e9f:/libraries/base/Data/Typeable/Internal.hs#l458
 GHC's implementation] of it.

 Ben, do you know what became of this idea?

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14190#comment:4>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list