Skip to content
  • Simon Peyton Jones's avatar
    Fix Trac #2334: validity checking for type families · 1c05d4fb
    Simon Peyton Jones authored
    When we deal with a family-instance declaration (TcTyClsDecls.tcFamInstDecl)
    we must check the TyCon for validity; for example, that a newtype has exactly
    one field.  That is done all-at-once for normal declarations, and had been
    forgotten altogether for families.
    
    I also refactored the interface to tcFamInstDecl1 slightly.
    
    
    A slightly separate matter: if there's an error in family instances
    (e.g. overlap) we get a confusing error message cascade if we attempt to
    deal with 'deriving' clauses too; this patch bales out earlier in that case.
    
    
    Another slightly separate matter: standalone deriving for family 
    instances can legitimately have more specific types, just like normal
    data decls. For example
       
       data instance F [a] = ...
       deriving instance (Eq a, Eq b) => Eq (F [(a,b)])
    
    So tcLookupFamInstExact can a bit more forgiving than it was.
     
    1c05d4fb