[GHC] #9858: Typeable instances should be kind-aware

GHC ghc-devs at haskell.org
Wed Apr 15 02:04:12 UTC 2015


#9858: Typeable instances should be kind-aware
-------------------------------------+-------------------------------------
        Reporter:  dreixel           |                   Owner:
            Type:  bug               |                  Status:  merge
        Priority:  highest           |               Milestone:  7.10.2
       Component:  Compiler          |                 Version:  7.9
      Resolution:                    |                Keywords:
Operating System:  Unknown/Multiple  |            Architecture:
 Type of failure:  None/Unknown      |  Unknown/Multiple
      Blocked By:                    |               Test Case:
 Related Tickets:                    |  typecheck/should_fail/T9858a,
                                     |  should_run/T9858b
                                     |                Blocking:
                                     |  Differential Revisions:  Phab:D652
-------------------------------------+-------------------------------------

Comment (by oerjan):

 Shachaf and I experimented a bit, and the fix does *not* prohibit
 `Typeable` for unapplied type constructors.  Together with the polykinded
 instance for type application, this can be used to construct, albeit
 awkwardly, `Typeable` instances for actual constraints. Example:

 {{{
 shachaf> λ> let foo :: forall a b. (Typeable a, Typeable b) => Proxy a
          -> Proxy b -> Proxy (a b) -> TypeRep; foo _ _ _ = typeRep
          (Proxy :: Proxy (a b)) in foo (Proxy :: Proxy Ord) (Proxy ::
          Proxy Int) (Proxy :: Proxy (Ord Int))
 shachaf> Ord Int
 }}}

 It is also possible to tease out constraint tuple constructors with type
 equalities (OK I'm not sure this was actually tested with HEAD, but I
 suspect it will work there):

 {{{
 shachaf> > let x :: forall (a :: Constraint -> Constraint -> Constraint)
          b c. (a b c ~ (Ord Int, Show Int)) => TypeRep; x = typeRep
          (Proxy :: Proxy a) in x
 lambdabot>  (,)
 }}}

 So my theory is that the only thing this fix *strictly* prohibits is
 `Typeable` for types involving nullary constraint constructors, including
 `()`.  Luckily we don't see a way to get an exploit without `()`, for now.

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


More information about the ghc-tickets mailing list