• Simon Peyton Jones's avatar
    Refactor default methods (Trac #11105) · 924f8517
    Simon Peyton Jones authored
    This patch does some signficant refactoring to the treatment
    of default methods in class declarations, and more generally
    to the type checking of type/class decls.
    
    Highlights:
    
    * When the class has a generic-default method, such as
         class C a where
           op :: a -> a -> Bool
           default op :: Ord a => a -> a -> a
      the ClassOpItem records the type of the generic-default,
      in this case the type (Ord a => a -> a -> a)
    
    * I killed off Class.DefMeth in favour of the very-similar
      BasicTypes.DefMethSpec.  However it turned out to be better
      to use a Maybe, thus
          Maybe (DefMethSpec Type)
      with Nothing meaning "no default method".
    
    * In TcTyClsDecls.tcTyClGroup, we used to accumulate a [TyThing],
      but I found a way to make it much simpler, accumulating only
      a [TyCon].  Much less wrapping and unwrapping.
    
    * On the way I also fixed Trac #10896 in a better way. Instead
      of killing off all ambiguity checks whenever there are any type
      errors (the fix in commit 8e8b9ed9), I instead recover in
      TcTyClsDecls.checkValidTyCl.
    
    There was a lot of associated simplification all round
    924f8517
TcIface.hs 64.3 KB