patch applied (ghc): Make the LiberateCase transformation understand associated types

Simon Peyton Jones <[email protected]> Thu, 11 Jan 2007 01:17:55 -0800
Newsgroups gmane.comp.lang.haskell.cvs.all
Message-ID <20070111091755.GA29561__47259.3780061745$1168507097$gmane$org@cvs.haskell.org>
Thu Jan 11 01:15:33 PST 2007  [email protected]
  * Make the LiberateCase transformation understand associated types
  
  Consider this FC program:
  	data family AT a :: *
  	data instance AT Int = T1 Int Int
  
  	f :: AT Int -> Int
  	f t = case t of DEFAULT -> <body>
  
  We'd like to replace the DEFAULT by a use of T1, so that if 
  we scrutinise t inside <body> we share the evaluation:
  
  	f t = case (t `cast` co) of T1 x y -> <body>
  
  I decided to do this as part of the liberate-case transformation,
  which is already trying to avoid redundant evals.  
  
  The new transformation requires knowledge of the family instance
  environment, so I had to extend ModGuts to carry the fam_inst_env,
  and put that envt into the liberate-case environment. 
  
  Otherwise it's all pretty straightforward.
  

    M ./compiler/deSugar/Desugar.lhs -34 +36
    M ./compiler/main/HscTypes.lhs -1 +5
    M ./compiler/simplCore/LiberateCase.lhs -73 +160
    M ./compiler/simplCore/SimplCore.lhs -1 +3
    M ./compiler/typecheck/TcRnDriver.lhs +1