[GHC] #15322: `KnownNat` does not imply `Typeable` any more when used with plugin

GHC ghc-devs at haskell.org
Tue Jul 3 09:16:10 UTC 2018


#15322: `KnownNat` does not imply `Typeable` any more when used with plugin
-------------------------------------+-------------------------------------
        Reporter:  chshersh          |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:  8.6.1
       Component:  Compiler          |              Version:  8.4.3
      Resolution:                    |             Keywords:
                                     |  typeable,knownnat
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  GHC rejects       |  Unknown/Multiple
  valid program                      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:  #10348            |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by simonpj):

 OK, now I understand. I'll add this comment to `TcInteract`:
 {{{
 Note [Typeable for Nat and Symbol]
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 We have special Typeable instances for Nat and Symbol.  Roughly we
 have this instance, implemented here by doTyLit:
       instance KnownNat n => Typeable (n :: Nat) where
          typeRep = tyepNatTypeRep @n
 where
    Data.Typeable.Internals.typeNatTypeRep :: KnownNat a => TypeRep a

 Ultimately typeNatTypeRep uses 'natSing' from KnownNat to get a
 runtime value 'n'; it turns it into a string with 'show' and uses
 that to whiz up a TypeRep TyCon for 'n', with mkTypeLitTyCon.
 See #10348.

 Because of this rule it's inadvisable (see #15322) to have a constraint
     f :: (Typeable (n :: Nat)) => blah
 in a function signature; it gives rise to overlap problems just as
 if you'd written
     f :: Eq [a] => blah
 }}}
 Note the "inadvisable" part, which is what this ticket is about.  It just
 wasn't at all clear to me, and hence perhaps not to others.

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


More information about the ghc-tickets mailing list