Skip to content
  • Simon Peyton Jones's avatar
    Refactor validity checking for constraints · 45f44e2c
    Simon Peyton Jones authored
    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...
    45f44e2c