• simonpj@microsoft.com's avatar
    Refactor, improve, and document the deriving mechanism · 25f84fa7
    simonpj@microsoft.com authored
    This patch does a fairly major clean-up of the code that implements 'deriving.
    
    * The big changes are in TcDeriv, which is dramatically cleaned up.
      In particular, there is a clear split into
    	a) inference of instance contexts for deriving clauses
    	b) generation of the derived code, given a context 
      Step (a) is skipped for standalone instance decls, which 
      have an explicitly provided context.
    
    * The handling of "taggery", which is cooperative between TcDeriv and
      TcGenDeriv, is cleaned up a lot
    
    * I have added documentation for standalone deriving (which was 
      previously wrong).
    
    * The Haskell report is vague on exactly when a deriving clause should
      succeed.  Prodded by Conal I have loosened the rules slightly, thereyb
      making drv015 work again, and documented the rules in the user manual.
    
    I believe this patch validates ok (once I've update the test suite)
    and can go into the 6.8 branch.
    25f84fa7
Type.lhs 51.5 KB