Skip to content
  • Simon Peyton Jones's avatar
    Clean up Coercible handling, and interaction of data families with newtypes · 0aaf812e
    Simon Peyton Jones authored
    This patch fixes Trac #9580, in which the Coercible machinery succeeded
    even though the relevant data constructor was not in scope.
    
    As usual I got dragged into a raft of refactoring changes,
    all for the better.
    
    * Delete TcEvidence.coercionToTcCoercion (now unused)
    
    * Move instNewTyConTF_maybe, instNewTyCon_maybe to FamInst,
      and rename them to tcInstNewTyConTF_maybe, tcInstNewTyCon
      (They both return TcCoercions.)
    
    * tcInstNewTyConTF_maybe also gets more convenient type,
      which improves TcInteract.getCoercibleInst
    
    * Define FamInst.tcLookupDataFamInst, and use it in TcDeriv,
      (as well as in tcInstNewTyConTF_maybe)
    
    * Improve error report for Coercible errors, when data familes
      are involved  Another use of tcLookupDataFamInst
    
    * In TcExpr.tcTagToEnum, use tcLookupDataFamInst to replace
      local hacky code
    
    * Fix Coercion.instNewTyCon_maybe and Type.newTyConInstRhs to deal
      with eta-reduced newtypes, using
      (new) Type.unwrapNewTyConEtad_maybe and (new) Type.applyTysX
    
    Some small refactoring of TcSMonad.matchFam.
    0aaf812e