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

GHC ghc-devs at haskell.org
Thu Jul 5 09:52:16 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 Simon Peyton Jones <simonpj@…>):

 In [changeset:"45f44e2c9d5db2f25c52abb402f197c20579400f/ghc" 45f44e2/ghc]:
 {{{
 #!CommitTicketReference repository="ghc"
 revision="45f44e2c9d5db2f25c52abb402f197c20579400f"
 Refactor validity checking for constraints

 There are several changes here.

 * TcInteract has gotten too big, so I moved all the class-instance
   matching out of TcInteract into a new module ClsInst. It parallels
   the FamInst module.

   The main export of ClsInst is matchGlobalInst.
   This now works in TcM not TcS.

 * A big reason to make matchGlobalInst work in TcM is that we can
   then use it from TcValidity.checkSimplifiableClassConstraint.
   That extends checkSimplifiableClassConstraint to work uniformly
   for built-in instances, which means that we now get a warning
   if we have givens (Typeable x, KnownNat n); see Trac #15322.

 * This change also made me refactor LookupInstResult, in particular
   by adding the InstanceWhat field.  I also changed the name of the
   type to ClsInstResult.

   Then instead of matchGlobalInst reporting a staging error (which is
   inappropriate for the call from TcValidity), we can do so in
   TcInteract.checkInstanceOK.

 * In TcValidity, we now check quantified constraints for termination.
   For example, this signature should be rejected:
      f :: (forall a. Eq (m a) => Eq (m a)) => blah
   as discussed in Trac #15316.   The main change here is that
   TcValidity.check_pred_help now uses classifyPredType, and has a
   case for ForAllPred which it didn't before.

   This had knock-on refactoring effects in TcValidity.
 }}}

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


More information about the ghc-tickets mailing list